$(document).ready(function(){

$("body").css ("display", "none");
$("body").fadeIn(2000);

$("#nav a").click(function(event) {
	event.preventDefault();
	LinkLocation = this.href;
	$("body").fadeOut(1000, redirectPage);
	});
$("#homelink").click(function(event) {
	event.preventDefault();
	LinkLocation = this.href;
	$("body").fadeOut(1000, redirectPage);
	});

function redirectPage() {
	window.location = LinkLocation;
}

$(document).pngFix();
$("#slides").easySlider();
$("a.iframe").fancybox({ 'frameWidth': 1000, 'frameHeight': 550, 'overlayShow':true, 'overlayOpacity': .6 });

// Contactform on click
	$("#contactlink").click(function() {
	
		if (document.getElementById('contactform').style.height == '230px') {
		
			$("#contactform").stop()
				.animate({
					height: '0px',
					opacity: '0'
				}, 500); 
			document.getElementById('formemail').value = '';
			document.getElementById('formbericht').value = '';

		} else {
		
			$("#contactconfirmation").stop()
				.animate({
					height: '0px',
					opacity: '0'
				}, 500); 
			$("#contactform").stop()
				.animate({
					height: '230px',
					opacity: '1'
				}, 500); 

		}
	});

// Page Flip on hover
	$("#pageflip").hover(function() {
		$("#pageflip img , .msg_block").stop()
			.animate({
				width: '207px', 
				height: '219px'
			}, 500); 
		} , function() {
		$("#pageflip img").stop() 
			.animate({
				width: '25px', 
				height: '26px'
			}, 220);
		$(".msg_block").stop() 
			.animate({
				width: '25px', 
				height: '25px'
			}, 200);
	});

	
});


// Eigen functies

function showHideLayer(el) {
	if ((document.getElementById(el).style.display == 'none') || (document.getElementById(el).style.display == '')) {
		document.getElementById(el).style.display = 'block';
	} else {
		document.getElementById(el).style.display = 'none';	
	}
}
function resetForm(el) {
	document.getElementById('formemail').value='';
	document.getElementById('formbericht').value='';
	document.getElementById('norobot').value='';
}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=args[i+1]; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' moet een geldig e-mailadres zijn.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' moet een getal zijn.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' moet een getal zijn tussen '+min+' en '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is verplicht.\n'; }
    } if (errors) alert('De volgende fouten zijn opgetreden:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

