theMainNav = new Array("homeButt", "expositieButt", "juryButt", "stichtingButt", "nachtvdbuitenreclButt");
theMainContent = new Array("homeHolder", "expositieHolder", "juryHolder", "stichtingHolder","nachtvdbuitenreclHolder","stemHolder", "stemForm", "stemBericht");
theCloud = new Array("w_homeHolder", "w_expositieHolder", "w_juryHolder", "w_stichtingHolder","w_nachtvdbuitenrecl","", "", "");

var picCount = 26;
var mouseAction = false;
var selectedPic = 0;


function stopmouseaction() {
	mouseAction = false;
}
function startmouseaction() {
	mouseAction = true;
}
///INIT ALL ELEMENTS FOR THE FIRST TIME//
function init(){
	  	mouseAction = true;     	
		for(i=0;i<theMainNav.length;i++){
			document.getElementById(theMainNav[i]).style.cursor="pointer";		
		}
		for(i=1;i<theMainContent.length;i++){
			document.getElementById(theMainContent[i]).style.visibility="hidden";		
		}
		for(p=1;p<picCount;p++){
			document.getElementById("pic"+p).style.cursor="pointer";	
		}
		// options = "toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, top=100, left=300, width=266, height=592"
		// window.open('home_popup.html', 'stem_nu', options)
		document.getElementById("homeHolder").style.visibility="visible";
		stopmouseaction()
		setTimeout("startmouseaction()",1000);
		
}

///INIT ALL ELEMENTS WHEN VOTE IS MADE///
function init2(vote_id){
		mouseAction = true;
		selectedPic = vote_id;
		showPic(vote_id);
		//lockPic(vote_id);
		mouseAction = false;
		for(i=0;i<theMainNav.length;i++){
			document.getElementById(theMainNav[i]).style.cursor="pointer";		
		}
		for(i=0;i<theMainContent.length;i++){
			document.getElementById(theMainContent[i]).style.visibility="hidden";		
		}
		for(p=1;p<picCount;p++){
			document.getElementById("pic"+p).style.cursor="default";	
		}
		document.getElementById("stemBericht").style.visibility="visible";
		document.getElementById("stemHolder").style.visibility = "hidden";
		document.getElementById("stemForm").style.visibility="hidden";
}

///SHOWS THE DIVS CONTAINING TEXT///
function showContent(id) {
		mouseAction = true;
		document.getElementById("activePic").src = "img/fake.gif";
		document.getElementById("activePic2").src = "img/fake.gif";
		for(i=0;i<theMainContent.length;i++){
			document.getElementById(theMainContent[i]).style.visibility = "hidden";
			if (theCloud[i] != "") {
				document.getElementById(theCloud[i]).style.visibility = "hidden";
			}
		}
		for(p=1;p<picCount;p++){
			document.getElementById("pic"+p).style.cursor="pointer";	
		}
		document.getElementById(theMainContent[id]).style.visibility = "visible";
		if (theCloud[id] != "") {
			document.getElementById(theCloud[id]).style.visibility = "visible";
		}
		else {
			document.getElementById("w_homeHolder").style.visibility = "visible";
		}
		document.getElementById("stemForm").style.visibility = "hidden";
		document.getElementById("stemBericht").style.visibility = "hidden";
}

///SHOW SELECTED PIC///
function showPic(picId){
	if (mouseAction) {
		for(i=0;i<theMainContent.length;i++){                                     
			document.getElementById(theMainContent[i]).style.visibility = "hidden";
		}
		
		if (picId < 26) {
			document.getElementById("activePic").src = "img/large/"+picId+".jpg";
			document.getElementById("activePic2").src = "img/fake.gif";
		}
		else {
			document.getElementById("activePic2").src = "img/large/"+picId+".jpg";
			document.getElementById("activePic").src = "img/fake.gif";
		}
		document.getElementById("mupiItem").value = picId;
		document.getElementById("stemForm").style.visibility = "hidden";
	}
		
}

///LOCKS THE GRID///
function lockPicExtra() {
	id = document.getElementById("mupiItem").value
	lockPic(id)
}

function lockPic(picId){
		if(mouseAction){
			selectedPic = picId;
			for(i=0;i<theMainContent.length;i++){                                     
				document.getElementById(theMainContent[i]).style.visibility = "hidden";
			}
			for(p=1;p<picCount;p++){
				document.getElementById("pic"+p).style.cursor = "default";
			}
			//document.getElementById("activePic").src = "img/large/"+picId+".jpg";
			document.getElementById("stemForm").style.visibility = "visible";
			document.getElementById("stemHolder").style.visibility = "visible";
			document.getElementById("mupiItem").value = selectedPic;
			mouseAction = false;
		}
		else {
			document.getElementById("stemForm").style.visibility = "hidden";
			document.getElementById("stemHolder").style.visibility = "hidden";
			mouseAction = true;
		}
		
}

///VALIDATES FORM FIELDS///
var testresults
function checkemail(form){
		var str=form.email.value
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		
		if (filter.test(str)){
			testresults=true
		}else{
			alert("Graag een correct emailadres invullen!")
			testresults=false
		}
	return (testresults)
}

function check(formulier){
		if(formulier.name.value.length <= 0){
			alert("Graag een naam invullen!");
			formulier.name.focus();
			return false;
		}
		if(formulier.email.value.length <= 0){
			alert("Graag een email adres invullen!");
			formulier.email.focus();
			return false;
		}
		if(formulier.telephone.value.length <= 0){
			alert("Graag een telefoon nummer invullen!");
			formulier.telephone.focus();
			return false;
		}
		if(formulier.leeftijd.value.length <= 0){
			alert("Graag een leeftijd invullen!");
			formulier.leeftijd.focus();
			return false;
		}
		if(document.getElementById("sexe_m").checked || document.getElementById("sexe_v").checked) {
			if(document.layers||document.getElementById||document.all){
				return checkemail(formulier);
			}else{
				return true;
			}
		}
		else {
			alert("Graag uw geslacht kiezen!");
			return false;
		}
}
function doPop(url){
	window.open(url, "buitenreclame","resizable=no,scrollbars=no,locationbar=no,menubar=no,status=no,width=230,height=357");
}
