/**
 * Initialize $.CORE in case it's not present
 */
if(typeof $.CORE == "undefined") {
	$.CORE= Object;
};

/**
 * animate background image header
 */
$.CORE.animateHeader = {
	construct : function() {
		this.animateHeaderBackground();
	},
	
	animateHeaderBackground : function() {
		$(window).scroll(function(){
			var x = $(this).scrollTop();
			$('#headerHolder').css('background-position','0% '+parseInt(-x/10)+'px');
		});
	}
};


/**
 * dropdownmenu for ie
 */
 
$.CORE.dropdown = {
	construct : function() {
		$('#mainmenu li').hover(
			function () {
				$(this).addClass('Hover');
			}, 
			function () {
				$(this).removeClass('Hover');
			}
		);
		$('#mainmenu > li:last').addClass('last');
			
	}
};



/**
 * set up scrollables
 */

$.CORE.scrollables = {
	construct : function() {
		this.scrollProjects(); // projects op de homepage
		this.cycleBanners(); // projects op de homepage
	},
	cycleBanners : function() {
		
		var $preview = $('#bannerImages');
		var $previewImg = $($preview+'#images:first-child img');
		var $ph = $previewImg.height()-10;
		
		function firstResize() {
		$preview
		.animate({
			 height: $ph
			 }, 1000);
		}
		
		firstResize();
		
		$(".Index #bannerImages #images").cycle({
			fx:     'fade',
			speed:  1000,
			timeout: 0, 
			next:   '.next',
			prev:   '.prev',
			//before: resize,
			after:   onAfter
		});
		
		function onAfter(curr, next, opts, fwd) { 
			$ph = $(this).height()-10;
			resize();	
			
		}
		
		function resize() {
		$preview
		.animate({
			 height: $ph
			 }, 500);
		}
		
	},
	scrollProjects : function() {
		$("#projectScrollable")
		.scrollable({
			next:".next2", 
			prev:".prev2", 
			items:"#projects" 
			});
	}
};


/**
 * set up cufon
 */

$.CORE.cufon = {
	construct : function() {
		Cufon.replace('h1, h2,h3,h4,h5, #promoties a', {hover : true});
		Cufon.replace('.Button', {
				textShadow: '1px 1px rgba(255, 255, 255, 0.5)'
			});
		Cufon.replace('.introBox h2, .Title, #aside h3,', {
				textShadow: '-1px -1px rgba(0, 0, 0, 0.8)'
			});
		Cufon.replace('#tagline', { fontFamily: 'FuturaB'});
	}
};


/**
 * Forms
 */
 
$.CORE.forms = {
	construct : function() {
		this.execFormCheckerPlugin();
	},
	
	execFormCheckerPlugin : function() {
		var $formRef = $('form.formGenerated');
		if($formRef.length) {
        	$formRef.formChecker();
		}
	}
};

/**
 * Executes when the DOM has been fully loaded
 */
 
$(document).ready(function() {
	$.CORE.forms.construct();
	$.CORE.animateHeader.construct();
	$.CORE.scrollables.construct();
	$.CORE.cufon.construct();
	$.CORE.dropdown.construct();
	
	
	$('#a_email').focus(function(){
		if($(this).val() == 'e-mailadres'){
			$(this).val('');
		}
	});
	
});





