/**
 * @project: Vondelmolen
 * @location: Wax Interactive - www.wax.be
 * @date: 07.03.2011
 * @author: Jan De Wilde
 * @description: Core logic
 */ 

if(typeof $.VONDELMOLEN == "undefined") {
	$.VONDELMOLEN = Object;
}

$.VONDELMOLEN.navigation = {
	construct : function() {
		//this.topNavigation();
	},
	
	topNavigation : function() {
        $('ul.sf-menu').superfish({ 
            delay : 200,
            speed : 0,
            autoArrows: false,
            dropShadows: false
        }); 
	}
};

$.VONDELMOLEN.banner = {
	construct : function() {
		this.cycle();
	},
	
	cycle : function() {
		$('#slideshow').cycle({
			delay: 2000, 
			speed: 500
		});
	}
};

$.VONDELMOLEN.recipes = {
	construct : function() {
		this.clickable();
		this.listImages();
	},
	
	clickable : function() {
		$('.recipe').bind('click',function(e) {
			window.location = $('h2 a',this).attr('href');
		});
	},
	
	listImages : function() {
		$('.recipe .img img').attr({
			width : null,
			height : null
		});
	}
};

$.VONDELMOLEN.forms = {
	construct : function() {
		this.formExists();
	},
	
	formExists : function() {
		$('form.formGenerated').each(function() {
			$(this).formChecker({
				nOkMessage : $('#errMsgContact').val()
			});
		});
	}
};

$.VONDELMOLEN.vacatures = {
	construct : function() {
		this.toggleVisible();
		this.showForm();
	},
	
	toggleVisible : function() {
		$('.vacature h2').bind('click',function() {
			if($(this).hasClass('active')) {
				return false;
			}
			$('.vacature h2').removeClass('active');
			$(this).addClass('active');
			$('.vacature .content:visible, #genForm3').slideUp('normal');
			$(this).next().slideDown('normal');
		});
	},
	
	showForm : function() {
		$('.solliciteer').bind('click',function() {
			$('.vacature h2').removeClass('active');
			var title = $(this).parent().prev().text();
			$('#vacature').val(title);
			$(this).parent().slideUp('normal');
			$('#genForm3').slideDown('normal');
		});
	}
};

$(document).ready(function(){
	$.VONDELMOLEN.navigation.construct();
	$.VONDELMOLEN.banner.construct();
	$.VONDELMOLEN.recipes.construct();
	$.VONDELMOLEN.forms.construct();
	$.VONDELMOLEN.vacatures.construct();
	
	$("#side-nav a").each(function(){
		var linkto = $(this).attr("href");
		if(linkto == "#"){
			$(this).addClass("nolink");
			$(this).attr("onclick", "return false;");
		}
		//alert(href);
	});
});
