$(document).ready(function() {
//Home Slider
	$('#slider').nivoSlider({
		effect:'random',
		slices: 15,
		animSpeed: 500,
		pauseTime: 4000,
		directionNav: true, //Next & Prev
		directionNavHide: false, //Only show on hover
		controlNav: false, //1,2,3...
		pauseOnHover: true, //Stop animation while hovering
		manualAdvance: false, //Force manual transitions
		beforeChange: function(){},
		afterChange: function(){}
	});
//Feestfolder Slider
	$('#feestfolderslider').nivoSlider({
		effect:'slideInLeft',
		slices: 2,
		prevText: 'Prev', // Prev directionNav text
        nextText: 'Next',
		animSpeed: 500,
		pauseTime: 4000,
		directionNav: true, //Next & Prev
		directionNavHide: false, //Only show on hover
		controlNav: false, //1,2,3...
		keyboardNav: true,
		pauseOnHover: true, //Stop animation while hovering
		manualAdvance: true, //Force manual transitions
		beforeChange: function(){},
		afterChange: function(){}
	});
//Gallery
	 $(function() {
        $('#news a.gogo').lightBox();
     });
//Winkel Images
	$('.j_winkel .block img').css("cursor","pointer");
	$('.j_winkel .block img').click(function() {
 		//
		var id_smallimg = $(this).attr("id");
		var id_bigimg = $('.main img').attr("id");
		//
		$(this).attr("src", "img/content/winkel/0"+id_bigimg+"-thumb.png");
		$(this).attr("id", id_bigimg);
		$('.main img').attr("src", "img/content/winkel/0"+id_smallimg+"-full.png");
		$('.main img').attr("id", id_smallimg)
		//
		var idimg = $(this).attr("id");
		//
	});
//Bakkerij Images
	$('.j_bakkerij .block img').css("cursor","pointer");
	$('.j_bakkerij .block img').click(function() {
 		//
		var id_smallimg = $(this).attr("id");
		var id_bigimg = $('.main img').attr("id");
		//
		$(this).attr("src", "img/content/bakkerij/00"+id_bigimg+"-thumb.png");
		$(this).attr("id", id_bigimg);
		$('.main img').attr("src", "img/content/bakkerij/00"+id_smallimg+"-full.png");
		$('.main img').attr("id", id_smallimg)
		//
		var idimg = $(this).attr("id");
		//
	});
//E-mail cover-up
	$('a.email').each(function(){
		e = this.rel.replace('/','@');
		this.href = 'mailto:' + e;
		$(this).text(e);
	});
//Contact Formulier
	$('#contact_button').click(function() {
		//-----------------------------------------------------------------------------------------
		//naam
		if($("#field_contact_naam").val()==""){
			alert('Geef een geldige naam in!');
			$("#field_contact_naam").focus();
			return false;
		}
		//telefoon
		if($("#field_contact_telefoon").val()==""){
			
		}
		//e-mail
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var address = $("#field_contact_email").val();
		if(reg.test(address) == false) {
			alert('Geef een geldig e-mailadres in!');
			$("#field_contact_email").focus();
			return false;
		}
		//tekst
		if($("#field_contact_tekst").val()==""){
			alert('Geef een opmerking of vraag in!');
			$("#field_contact_tekst").focus();
			return false;
		}
		//zend e-mail
		var str = $("#formulier_contact").serialize();
		$.ajax({
			type: "POST",  
			url: "php/mdl.contact.mail.php",   
			data: str,
			success: function(msg) {
				if(msg=="ok"){
					alert('Bericht verzonden!');
				}else{
					alert('Uw bericht kan niet worden verzonden, onze excuses voor het ongemak! (00x01)');
				}		
			},
		   error: function(msg) {  
				alert('Uw bericht kan niet worden verzonden, onze excuses voor het ongemak! (00x02)');
		   }   
		});
		//-----------------------------------------------------------------------------------------
	});
});
