// JQUERY CUSTOM COMMANDS
jQuery(document).ready(function() {
	
	/* SUBMENU */
	jQuery('#subMenu > ul > li > a').addClass('level1');
	Cufon.replace('#subMenu a.level1', { hover: true });
	
	/* CONTACT TOGGLE */
	jQuery('.contactList .cAnswer').hide();
	jQuery('.contactList .cQuestion a').click(function() {
		jQuery(this).parents('.contactList').find(".cAnswer").slideUp(200); // Hide all answers
		jQuery(this).parents('.contactList').find('li').removeClass("active");
	    jQuery(this).parents('li').find(".cAnswer").slideDown(200); // Show current answer
		jQuery(this).parents('li').addClass("active");
		return false;		
	});
		//extra remove active
	jQuery("#contactBox").mouseleave(function() {			
		jQuery('.contactList').find(".cAnswer").slideUp(200); // Hide all answers
		jQuery('.contactList').find('li').removeClass("active");
	});	
	
	
	
	/* CLIENT LOGOS TOGGLE */
	jQuery('#clientLogos .midNext').hide();
	jQuery('#clientLogos .midFeatured a').hover(function() {		
	    jQuery(this).parents('#clientLogos').find(".midNext").slideDown(200); // Show current answer	
		jQuery(this).parents('li').addClass('hover');			
	}, function() {
	    jQuery(this).parents('li').removeClass('hover');
	});
		//extra remove active
	jQuery("#clientLogos").mouseleave(function() {			
		jQuery('#clientLogos').find(".midNext").slideUp(200); // Hide all answers		
	});	
	
	
	/* Left column more services choice */
	jQuery('.leftColumn .moreInfo ul.moreChoice li ul').hide();	
	jQuery('.leftColumn .moreInfo ul.moreChoice li a').hover(function() {		
	    jQuery(this).parents('.leftColumn .moreInfo ul.moreChoice li').find("ul").slideDown(200); // Show current answer		
		return false;		
	});
	
	//extra remove active
	jQuery(".leftColumn .moreInfo ul.moreChoice").mouseleave(function() {			
		jQuery('.leftColumn .moreInfo ul.moreChoice li').find("ul").slideUp(200); // Hide all answers		
	});	
	

			
	/* MENU HOVERS */
	jQuery('#topMenu li, #services li, .leftColumn .services li, .tabMenu li, .projectThumbs img, #clientLogos .midNext li').hover(function() { // IE6 does not support :hover on elements other than <a>
	    jQuery(this).addClass('hover');
	}, function() {
	    jQuery(this).removeClass('hover');
	});
	
	
			
	// INPUT FOCUS & BLUR
	jQuery('input.textfield, textarea.textarea, select.select').focus(function() {
	    jQuery(this).addClass("focus");
	});
	jQuery('input.textfield, textarea.textarea, select.select').blur(function() {
	    jQuery(this).removeClass("focus");
		jQuery(this).removeClass("error");
		jQuery(this).parents("li").find("div.error").empty();
	});
	
	// HIDE EMPTY ERROR FIELDS
	jQuery('ul.formfields div.error:empty').hide();
	
	
	
	
	// ACCOUNT INPUT LABELS as background
	// fill or empty name field onDefault
	if (jQuery(".inputName").val() == "") {
		jQuery(".inputName").css({ backgroundImage : "url(images/account_input_name.gif)" });
	} else {
		jQuery(".inputName").css({ backgroundImage : "url(images/account_input_empty.gif)" });
	};
	// fill or empty email field onDefault
	if (jQuery(".inputEmail").val() == "") {
		jQuery(".inputEmail").css({ backgroundImage : "url(images/account_input_email.gif)" });
	} else {
		jQuery(".inputEmail").css({ backgroundImage : "url(images/account_input_empty.gif)" });
	};	
	
	// fill or empty clientName field onDefault
	if (jQuery(".clientName").val() == "") {
		jQuery(".clientName").css({ backgroundImage : "url(images/account_client_name.gif)" });
	} else {
		jQuery(".clientName").css({ backgroundImage : "url(images/account_input_empty.gif)" });
	};	
	// fill or empty clientPassword field onDefault
	if (jQuery(".clientPassword").val() == "") {
		jQuery(".clientPassword").css({ backgroundImage : "url(images/account_client_password.gif)" });
	} else {
		jQuery(".clientPassword").css({ backgroundImage : "url(images/account_input_empty.gif)" });
	};		
		
	// empty fiels onClick
	jQuery(".inputName, .inputEmail, .clientName, .clientPassword").click(function() {
		jQuery(this).css({ backgroundImage : "url(images/account_input_empty.gif)" });
	});
	// empty fiels onFocus
	jQuery(".inputName, .inputEmail, .clientName, .clientPassword").focus(function() {
		jQuery(this).css({ backgroundImage : "url(images/account_input_empty.gif)" });
	});
	
		
	// refill namefield onBlur
	jQuery(".inputName").blur(function() {
		if (jQuery(".inputName").val() == "") {
			jQuery(".inputName").css({ backgroundImage : "url(images/account_input_name.gif)" });
		} else {
			jQuery(".inputName").css({ backgroundImage : "url(images/account_input_empty.gif)" });
		};
	});
	// refill emailfield onBlur
	jQuery(".inputEmail").blur(function() {
		if (jQuery(".inputEmail").val() == "") {
			jQuery(".inputEmail").css({ backgroundImage : "url(images/account_input_email.gif)" });
		} else {
			jQuery(".inputEmail").css({ backgroundImage : "url(images/account_input_empty.gif)" });
		};
	});	
	// refill passfield onBlur
	jQuery(".clientName").blur(function() {
		if (jQuery(".clientName").val() == "") {
			jQuery(".clientName").css({ backgroundImage : "url(images/account_client_name.gif)" });
		} else {
			jQuery(".clientName").css({ backgroundImage : "url(images/account_input_empty.gif)" });
		};
	});
	// refill passfield onBlur
	jQuery(".clientPassword").blur(function() {
		if (jQuery(".clientPassword").val() == "") {
			jQuery(".clientPassword").css({ backgroundImage : "url(images/account_client_password.gif)" });
		} else {
			jQuery(".clientPassword").css({ backgroundImage : "url(images/account_input_empty.gif)" });
		};
	});
	
	
	
   jQuery('input[type="text"]').focus(function() {   
       if (this.value == this.defaultValue){   
           this.value = '';   
       }   
       if(this.value != this.defaultValue){   
           this.select();   
       }   
   });   
   jQuery('input[type="text"]').blur(function() {   
       if (jQuery.trim(this.value) == ''){   
//	   		alert('Bauke');
			this.value = (this.defaultValue ? this.defaultValue : '');   
       }   
    });   
	

	
	// let the the grey box in the left-column grow longer
	mainContentMidSection = jQuery("#mainContent #midSection").height();	
	leftColumnTopMid = jQuery(".leftColumn .topMid").height();	
	
	newHeightMoreInfo = (mainContentMidSection - leftColumnTopMid)-115;
	
	// voor IE6
	if (jQuery.browser.msie && jQuery.browser.version == 6){ 	
	} 	else {
		jQuery(".leftColumn .moreInfo").css("height",newHeightMoreInfo);
	}
	
	//tab menu - contact
	//count master-tabs
	//make jquery triggers
	//set remove all active
	//set .this active
	var n = jQuery(".tabMenu li").length;
	var letter;
	height_body = jQuery("body").height();
	
	
	
	for (var i=1; i < (n+1); i++){		//n = 3 means: 2 master-tabs
		if (i==1)	   {	letter = 'A';	}
		else if (i==2) {	letter = 'B';	}
		else if (i==3) {	letter = 'C';	}
		else if (i==4) {	letter = 'D';	}
		else if (i==5) {	letter = 'E';	}  
		else if (i==6) {	letter = 'F';	} 
		
		//alert (["#masterTabcontent"+letter]);
		
		plaatsMasterButtons(letter);	
	} 
	
	function plaatsMasterButtons(letter) {
		jQuery([".showUnit"+letter]+ " a").click(function() {
			jQuery('li').removeClass('active'); // make tab inactive
			jQuery(this).parents("li").addClass("active"); // make this tab active
			jQuery('.unit').removeClass('active'); // hide other content			
			jQuery("#unit"+letter).addClass('active'); // show this content
			return false;
		});
	}


	var n2 = jQuery(".tabMenuArchive li").length;
	var letter2;
	height_body2 = jQuery("body").height();
	
	
	
	for (var i2=1; i2 < (n2+1); i2++){		//n = 3 means: 2 master-tabs
		if (i2==1)	   {	letter2 = 'A';	}
		else if (i2==2) {	letter2 = 'B';	}
		else if (i2==3) {	letter2 = 'C';	}
		else if (i2==4) {	letter2 = 'D';	}
		else if (i2==5) {	letter2 = 'E';	}  
		else if (i2==6) {	letter2 = 'F';	} 
		
		//alert (["#masterTabcontent"+letter]);
		
		plaatsMasterButtons(letter2);	
	} 
	
	
	
	// REMOVE DUPLICATE SOCIAL ICONS PLUGIN FROM FOOTER NEWSLETTER
	$('.newsLetter .simplesocial').parent().remove();
	
}); // end ready function

