var timerID = null;
var timerOn = false;
var timecount = 500;
var what = null;
var newbrowser = true;
var check = false;

var layerRef;
var styleSwitch;

function init(){
	if(document.layers){
		layerRef="document.layers";
		styleSwitch="";
		visibleVar="show";
		screenSize = window.innerWidth;
		what ="ns4";
	}else if(document.all){
		layerRef="document.all";
		styleSwitch=".style";
		visibleVar="visible";
		screenSize = document.body.clientWidth + 18;
		what ="ie";
	}else if(document.getElementById){
		layerRef="document.getElementByID";
		styleSwitch=".style";
		visibleVar="visible";
		what="moz";
	}else{
		what="none";
		newbrowser = false;
	}

	check = true;
}

function showLayer(layerName){
	if(check){
		if (what =="none"){
			return;
		}else if (what == "moz"){
			document.getElementById(layerName).style.visibility="visible";
		}else{
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
		}
	}else{
		return;
	}
}

function hideLayer(layerName){
	if(check){
		if (what =="none"){
			return;
		}else if (what == "moz"){
			document.getElementById(layerName).style.visibility="hidden";
		}else{
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
		}
	}else{
		return;
	}
}

function hideAll(){
	hideLayer('MENU_BLOK1');
	hideLayer('MENU_BLOK2');
	hideLayer('MENU_BLOK3');
	hideLayer('MENU_BLOK4');
	hideLayer('MENU_BLOK5');
}

function startTime(){
	if(timerOn == false){
		timerID=setTimeout( "hideAll()" , timecount);
		timerOn = true;
	}
}

function stopTime() {
	if(timerOn){
		clearTimeout(timerID);
		timerID = null;
		timerOn = false;
	}
}

function openImage(photoId,photoGroup){
	var winl = ((screen.width) / 2) - 350;
	var wint = ((screen.height) / 2) - 300;

	windowName = "pictureWindow";
	windowURL = "pictureWindow.asp?photoId=" + photoId + "&photoGroup=" + photoGroup;
	myWindow = window.open(windowURL, windowName,'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=700, height=600,top='+wint+',left='+winl+'');
	myWindow.focus();
}

function closeImage(){
	window.close();
}

function SubmitContact(){
	var filter  = /^[\w\.-]+@[\w\.-]+\.[a-zA-Z]{2,4}$/;
	if(document.contact.Naam.value == "" || document.contact.Adres.value == "" || document.contact.Postcode.value == "" || document.contact.Woonplaats.value == "" || document.contact.Telefoon.value == "" || !filter.test(document.contact.Email.value)){
		alert("U moet alle velden invullen.\nYou must fill in all fields.");
		return false;
	}
	return true;
}

function openImage(photoId,photoGroup){
	var winl = ((screen.width) / 2) - 350;
	var wint = ((screen.height) / 2) - 300;

	windowName = "pictureWindow";
	windowURL = "pictureWindow.asp?photoId=" + photoId + "&photoGroup=" + photoGroup;
	myWindow = window.open(windowURL, windowName,'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=700, height=600,top='+wint+',left='+winl+'');
	myWindow.focus();
}

function closeImage(){
	window.close();
}
