var resizeTimer = null;
var totalImages = 0;
var currentImage = 1;

$(document).ready(
	function() {
		//currentImage = Math.floor(Math.random()*totalImages)+1;
		
		//$('#outer').vAlign();
		
		$(window).bind('resize', function() { 
		    if (resizeTimer) clearTimeout(resizeTimer); 
		    resizeTimer = setTimeout(doRefresh,1);
		});
		
		//if ( $("#sliderhome").length > 0 ) {
			//$("#img" + currentImage + "").fadeIn(1000);
			//$("#teaser").fadeIn(1000);
			//setTimeout(changeHome,5000);
		//}
		
		//if ( $("#slidercomp").length > 0 ) {
			//$("#img" + currentImage + "").fadeIn(1000);
			//$("#img" + currentImage + "teaser").fadeIn(1000);
			//$("#img" + currentImage + "thumb").attr("src","/sitemanager/images/" + arImage[currentImage] + "");
		//}
		
		//if ( $("#sliderpeop").length > 0 ) {
		//	$("#img" + currentImage + "").fadeIn(1000);
		//	$("#teaser" + currentImage + "").fadeIn(1000);
		//	$("#img" + currentImage + "thumb").attr("src","/sitemanager/images/" + arImage[currentImage] + "");
		//}
		
		if ( $("#contactform").length > 0 ) {
			$("#page1").fadeIn(150);
		}
		
		//if ( $("#sliderlogin").length > 0 ) {
		//	$("#img" + currentImage + "").fadeIn(1000);
		//}
		
		//if ( $("#slidercontact").length > 0 ) {
		//	$("#img" + currentImage + "").fadeIn(1000);
		//}
	}
)



function doRefresh() {
	 location.reload();
}



function changeHome(){
	$("#img" + currentImage + "").fadeOut(1000);
	id = currentImage + 1;
	if (id > totalImages){id = 1}
	$("#img" + id + "").fadeIn(1000);
	currentImage = id;
	setTimeout(changeHome,5000);
}



function compImg(id){
	if (currentImage != id){
		$("#img" + currentImage + "").fadeOut(1000);
		$("#img" + currentImage + "teaser").fadeOut(1000);
		$("#img" + id + "").fadeIn(1000);
		$("#img" + id + "teaser").fadeIn(1000);
		$("#img" + currentImage + "thumb").attr("src","/sitemanager/images/" + arDefImage[currentImage] + "");
		currentImage = id;
	}
}



function peopImg(id){
	if (currentImage != id){
		$("#img" + currentImage + "").fadeOut(1000);
		$("#teaser" + currentImage + "").fadeOut(1000);
		$("#img" + id + "").fadeIn(1000);
		$("#teaser" + id + "").fadeIn(1000);
		$("#img" + currentImage + "thumb").attr("src","/sitemanager/images/" + arDefImage[currentImage] + "");
		currentImage = id;
	}
}



function showPage(id){
	for (var i = 1; i <= 3; i++){
		if (i != id){$("#page" + i).fadeOut(150);}
	}
	$("#page" + id).fadeIn(150);
}



function changeImg(id,sImage){
	if (id != currentImage){
		$("#img" + id + "thumb").attr("src","/sitemanager/images/" + sImage + "");
	}
}



function checkForm(){
	frm = document.contactformulier;
	errorstr = "";
	
	$("#lbl1").css('color','#fff');
	$("#naam").css('background','#fff');
	$("#lbl2").css('color','#fff');
	$("#email").css('background','#fff');
	$("#lbl3").css('color','#fff');
	$("#bericht").css('background','#fff');
	
	if (frm.naam.value == ''){
		errorstr = 'error';
		$("#lbl1").css('color','#f3990d');
		$("#naam").css('background','#f3990d');
	}
	if (frm.email.value == ''){
		errorstr = 'error';
		$("#lbl2").css('color','#f3990d');
		$("#email").css('background','#f3990d');
	}
	if (frm.bericht.value == ''){
		errorstr = 'error';
		$("#lbl3").css('color','#f3990d');
		$("#bericht").css('background','#f3990d');
	}

	if(errorstr == ''){
		frm.submit();
	}
	else{
		showError();
	}
}



function hideError(){
	$("#contacterror").fadeOut(0);
	$("#contactfields").fadeIn(0);
}



function showError(){
	$("#contactfields").fadeOut(0);
	$("#contacterror").fadeIn(0);
}


