// JavaScript Document

jQuery(document).ready(function() {
	
	// colorbox iframe for employee contact
	jQuery("a.cboxEmployee").colorbox({
		iframe: true,
		width: "600px",
		height: "470px"
	});
	
	// getting all e-mailaddresses to add pagetracking
	jQuery("a[href^=mailto:]").each(function() {
		jQuery(this).click(function() {
			if(typeof(pageTracker) != 'undefined') {
				pageTracker._trackPageview(jQuery(this).attr("href"));
			}
		});
	});
	
	jQuery("#slider1").css("display","block");
	jQuery("#slider1").AdwiseSlider();
	
	
	// Contactform validation
	jQuery("form#contactform").validate({
		rules: {
			initials: { required: true },
			surname: { required: true },
			email: { required: true, email: true },
			text: { required: true }
		},
		messages: {
			initials: " ",
			surname: " ",
			email: " ",
			text: " "
		},
		unhighlight: validateUnhighlight,
		errorPlacement: validateErrorPlacement
	});
	
	
});

Cufon.replace('#menuniv2 > a, h1, h2, div.title1, div.title2', {hover:true});



/**
 * Validate methods to place the errors in the TD behind the TD of the input field
 */
function validateUnhighlight(element, errorClass, validClass) {
	jQuery(element).removeClass(errorClass).addClass(validClass);
	jQuery(element).parent().next().addClass(validClass);
}

function validateErrorPlacement(error, element) {
	// group checks
	if(element.hasClass("group-check")) {
		element.parent("td").next("td").html('');
	}
	
	error.appendTo( element.parent("td").next("td") );
}

