


function home(){
	document.location='index.php';
}

function zoom(size) {
			document.location='/'+"?zoom="+size;
		}

	


function resetEmail(){
	if(document.headerform.email.value=='E-mail')
		document.headerform.email.value='';
}

function Aanmelden(){
	if(validateEmail(document.forms["headerform"].email.value)){
	   document.forms["headerform"].action='http://mailing.zinnebeeld.nl/mail/form.php?form=25';
	   document.forms["headerform"].method='post';
	   document.forms["headerform"].submit();
	}else{
		alert('Ongeldig E-mail adres');
	}
}

function validateEmail(email){
   var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
   if (! email.match(re)) {
	   return (false);
   }
   return(true);
}

function largeText(){
	document.body.style.fontSize="13px";
	document.body.style.lineHeight="16px";
}

function smallText(){
	document.body.style.fontSize="11px";
	document.body.style.lineHeight="14px";
}

function resetZoek(){
	if(document.headerform.query.value=='Vul zoekterm in')
		document.headerform.query.value='';
}

function Zoek(){
	if(document.headerform.query.value!='Vul zoekterm in')
		document.headerform.submit();
}

function loginenter(myfield,e){
	if(myfield.name=='email'){
		var keycode;
		if (window.event){ 
			keycode = window.event.keyCode;
		}else if (e){ 
			keycode = e.which;
		}else{
			return true;
		}
		if (keycode == 13){
		   Aanmelden();
		   return false;
		}else{
		   return true;
		}
	}else{
		var keycode;
		if (window.event){ 
			keycode = window.event.keyCode;
		}else if (e){ 
			keycode = e.which;
		}else{
			return true;
		}
		if (keycode == 13){
		   document.forms["headerform"].submit();
		   return false;
		}else{
		   return true;
		}
	}
}







$(document).ready(function() {

	var timer;
	var headers;
	$.getJSON('/services/getHeader.php?call=getHeaders&id_category='+id_category+'&format=json&d='+new Date().getTime(), 
		function(data) {
			headers=data;
			setupSlideshow(headers);
			var timer = setInterval('slideshow()',5000);	
		}
	);
	

});

function setupSlideshow(headers){
		var numRand = Math.floor(Math.random()*headers.length);
		var header=headers[numRand];
		$.each(headers, function(i,header){		
			if(header.id_category==0){

				if(header.type==0){			
					$('<div class="header" id="header_'+header.id+'"/>').appendTo("#images");
					$("#header_"+header.id).attr("z-index",5);
					$("<img class='img_0'/>").attr("src", '/images/header/crop/'+header.images[2].url).appendTo("#header_"+header.id).attr("z-index",5);
				}

				if(header.type==1){		

					$('<div class="header type_1" id="header_'+header.id+'"/>').appendTo("#images");
					$("#header_"+header.id).attr("z-index",5);
					$("<img class='img_0'/>").attr("src", '/images/header/crop/'+header.images[0].url).appendTo("#header_"+header.id).attr("z-index",5);
					$("<img class='img_2'/>").attr("src", '/images/header/crop/'+header.images[1].url).appendTo("#header_"+header.id).attr("z-index",6);
					$("#header_"+header.id).attr("z-index",5);
					
				}

				if(header.type==2){			
					$('<div class="header type_2" id="header_'+header.id+'"/>').appendTo("#images");
					$("#header_"+header.id).attr("z-index",5);
					$("<img class='img_2'/>").attr("src", '/images/header/crop/'+header.images[1].url).appendTo("#header_"+header.id).attr("z-index",5);
					$("<img class='img_3'/>").attr("src", '/images/header/crop/'+header.images[0].url).appendTo("#header_"+header.id).attr("z-index",6);
					$("#header_"+header.id).attr("z-index",5);
					
				}
			}else{
				if(header.type==0){			
					$('<div class="header" id="header_'+header.id+'"/>').appendTo("#images");
					$("#header_"+header.id).attr("z-index",5);
					$("<div class='header_label'><div class='label_text'>"+header.label+"</div></div>").attr("src", '/images/header/crop/'+header.images[0].url).appendTo("#header_"+header.id).attr("z-index",5).css('background-color',header.color);
					$("<img class='img_1'/>").attr("src", '/images/header/crop/'+header.images[2].url).appendTo("#header_"+header.id).attr("z-index",5);
					
				}

				if(header.type==1){			
					$('<div class="header type_1" id="header_'+header.id+'"/>').appendTo("#images");
					$("#header_"+header.id).attr("z-index",5);
					$("<img class='img_0'/>").attr("src", '/images/header/crop/'+header.images[2].url).appendTo("#header_"+header.id).attr("z-index",5);
					$("<img class='img_1'/>").attr("src", '/images/header/crop/'+header.images[1].url).appendTo("#header_"+header.id).attr("z-index",6);
					$("#header_"+header.id).attr("z-index",5);
					
				}
			}
		});		
		$('#images .header:first').show();
	}
	function slideshow(){
		if($('#images .header:visible').attr('id')==$('#images .header:last').attr('id')){
			$('#images .header:last').fadeOut(2000);
			$('#images .header:first').fadeIn(2000);
		}else{
			$('#images .header:visible').fadeOut(2000).next().fadeIn(2000);
		}
	}
