$(document).ready(function() {
						   
	/* PAGE DEPENDENT */
	switch(pagedata.name)
	{
		case 'contact':
			initContact();
			break;
	}
	
	/* SLIDESHOW */

	$(".paging").show();
	$(".paging a:first").addClass("active");
	
	var imageWidth = $(".window").width();
	var imageSum = $(".reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	$(".reel").css({'width' : imageReelWidth});
	
	rotate = function(){
	    var triggerID = $active.attr("rel") - 1;
	    var image_reelPosition = triggerID * imageWidth;
	
	    $(".paging a").removeClass('active');
	    $active.addClass('active');
	
	    $(".reel").animate({
	        left: -image_reelPosition
	    }, 500 );
	
	}; 
	
	rotateSwitch = function(){
	    play = setInterval(function(){
	        $active = $('.paging a.active').next();
	        if ( $active.length === 0) {
	            $active = $('.paging a:first');
	        }
	        rotate();
	    }, 7000);
	};
	
	rotateSwitch();
	
	$(".reel a").hover(function() {
	    clearInterval(play);
	}, function() {
	    rotateSwitch();
	});	
	
	$(".paging a").click(function() {
	    $active = $(this);
	    clearInterval(play);
	    rotate();
	    rotateSwitch();
	    return false;
	});
	
	/* PRELOAD IMAGES */
	
	preLoadImages = function() {
	  var cache = [];
	  var args_len = arguments.length;
	  for (var i = args_len; i--;) {
		var cacheImage = document.createElement('img');
		cacheImage.src = arguments[i];
		cache.push(cacheImage);
	  }
	}
	
	preLoadImages("/images/menu_active_bg_left.png", "/images/menu_active_bg_right.png");
	
});
	
initContact = function()
{
	/* AUTO LABELS FOR CONTACTFORM */
	
	$(".infield label").inFieldLabels({ fadeOpacity:0 });
	
	/* VALIDATIONS */
	/*$("#contform form").validate({
		focusInvalid: false,
		rules: {
			contactpersoon: "required",
			email: {
				required: true,
				email:true
			},
			vraag: "required"
		},
		messages: {
			contactpersoon: text.error_default,
			email: text.error_email,
			vraag: text.error_default
		}
	});*/

	/* SENDFUNCTION CONTACTFORM */
	
	$('#contform form').submit(function(){
		/*if($("#contform form").valid()){*/
			$('#contform').load('/'+active_language_code+'/info/contact/a/submit', $(this).serializeArray());
			
			return false;
		/*}*/
	})
}
