$(document).ready(function() {
			
		$('.emptyonclick').emptyonclick();
	
		if ($('#slideshow').size() > 0){
		    $('#slideshow').cycle({
		        fx:     'fade',
		        speed:  1200,
		        timeout: 4000,
				slideExpr: 'img'
		    });
	   }  
	    	    
	    	$('div#maps').html('<iframe width="880" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.nl/maps?f=q&amp;source=s_q&amp;hl=nl&amp;geocode=&amp;q=de+monnik+dranken&amp;sll=52.296013,6.909091&amp;sspn=0.006798,0.022101&amp;ie=UTF8&amp;hq=de+monnik+dranken&amp;hnear=&amp;ll=52.311417,6.913147&amp;spn=0.036732,0.169945&amp;z=13&amp;iwloc=A&amp;output=embed"></iframe>');


	$(".zebras div:even").addClass("prodzebrarow");
	$(".zebras").each(function() {
		$(this).children('div:last').addClass("prodzebralast");
	});
	
	
	
	$('.nextfields').each(function(){
		$(this).bind("keyup change", function(){
			val = $(this).val();
			if (val.length == 2){
				if (val >= 1 && val <= 31){
					$('#'+$(this).attr('rel')).focus();
				}
			}
			
		});
		
	});
	
	

/*
	$('#zoekterm[rel=onview]').bind('keydown', function(e){
		if (e.keyCode == 13){
			$('#searchbutton[rel=onview]').click();
		}
		
	});
*/
	
	
	
	
});

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function check_age(){
	var month = document.getElementById('maand').value;
	var day = document.getElementById('dag').value;
	var year = document.getElementById('jaar').value;
	var remember = document.getElementById('cookie_check');
	
	if(year >= 1900){
		if(checkdate(month, day, year)){
			var theirDate = new Date((parseInt(year) + parseInt(16)), parseInt(month)-1, parseInt(day));
			var today = new Date;
			if ( (today.getTime() - theirDate.getTime()) >= 0){
				if(remember.checked == true){
					createCookie('demonnik_agecheck',1,365);
					window.location = '/';
				}else{
					window.location = '/agecheck/save_session/' + today.getTime() + '/' + theirDate.getTime();
				}
			}
			else{
				alert('Helaas! Je moet 16 jaar zijn om deze website te bekijken.');
			}
		}else{
			alert('Je hebt geen geldige datum ingevoerd.');
		}
	}else{
		alert('Je hebt geen geldige datum ingevoerd');
	}
}

function checkdate (m, d, y) {
    // Returns true(1) if it is a valid date in gregorian calendar  
    // 
    // version: 1102.614
    // discuss at: http://phpjs.org/functions/checkdate    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Pyerre
    // +   improved by: Theriault
    // *     example 1: checkdate(12, 31, 2000);
    // *     returns 1: true    // *     example 2: checkdate(2, 29, 2001);
    // *     returns 2: false
    // *     example 3: checkdate(3, 31, 2008);
    // *     returns 3: true
    // *     example 4: checkdate(1, 390, 2000);    // *     returns 4: false
    return m > 0 && m < 13 && y > 0 && y < 32768 && d > 0 && d <= (new Date(y, m, 0)).getDate();
}

