// jQuery functies

$(document).ready(function() {
	$('#global_password_placeholder').focus(function() {
		$(this).hide();
		$('#global_password').val('').show().focus();
	});
	$('#global_password').blur(function() {
		if($.trim($(this).val()) == '') { 
			$(this).hide();
			$('#global_password_placeholder').show();
		}
	});
	
	$(".fancybox").fancybox({
		transitionIn	: 'elastic',
		transitionOut	: 'elastic',
		easingIn   	   	: 'easeOutBack',
		easingOut   	: 'easeInBack',
		speedIn			: 600, 
		speedOut		: 200,
		overlayColor	: '#000',
		width:776,
		height:442
		/*autoScale		: false*/
	});
});

//function to check the forms within the website.
function CheckForm(Form){
	var ErrorText = '';
	submitOK = true;
	var emailFilter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	/*var postcodeFilter = /^[1-9]{1}[0-9]{3}[A-Z]{2}$/i;
	var telefoonFilter = /^0[0-9]{9}$/i;*/
	
	$('input[type=text], select, textarea').css({'border-color': '#262626'});
	if (Form.Company != null && Form.Company.value.length==0){
		ErrorText = ErrorText + '- Your company name.\n';
		Form.Company.style.border = '1px solid #ff0000';
		submitOK = false;
	}
	if (Form.Name != null && Form.Name.value.length==0){
		ErrorText = ErrorText + '- Your name.\n';
		Form.Name.style.border = '1px solid #ff0000';
		submitOK = false;
	}
	if (Form.Email != null && !emailFilter.test(Form.Email.value)) {
		ErrorText = ErrorText + '- You need to enter a valid email address.\n';
		Form.Email.style.border = '1px solid #ff0000';
		submitOK = false;
	}
	if (Form.Business != null && Form.Business.value==0){
		ErrorText = ErrorText + '- You need to select your business.\n';
		Form.Business.style.border = '1px solid #ff0000';
		submitOK = false;
	}
	if (Form.Comment != null && Form.Comment.value==0){
		ErrorText = ErrorText + '- You need to give us your questions or comments.\n';
		Form.Comment.style.border = '1px solid #ff0000';
		submitOK = false;
	}
	//
	if (submitOK == false ){
		alert('The following fields are mandatory:\n' + ErrorText);
		return false;
	}else{
		Form.submit();
	}	
}
// All document ready functions with jQuery
$(function(){
	// Function to rotate the testimonials on the homepage
	/*if($("#testimonials").length >= 1){
		RotateNieuws();
	}*/
	// Switch naar lijst of screenshot styles
	$("a#SwitchPlain").click(function(e){
		e.preventDefault();
		$("a#SwitchAni").removeClass("aan");
		$(this).addClass("aan");
		$("#ps_slider").fadeOut("fast", function(){
            $("#plain_view").fadeIn("fast");
        });
	});
	$("a#SwitchAni").click(function(e){
		e.preventDefault();
		$("a#SwitchPlain").removeClass("aan");
		$(this).addClass("aan");
		$("#plain_view").fadeOut("fast", function(){
			$("#ps_slider").fadeIn("fast");
        });
	});
});
