function toggleDivArray(index) {

    var visDivs = new Array();
    visDivs[0]=['sub_menu_1a'];
    visDivs[1]=['sub_menu_2a'];
    visDivs[2]=['sub_menu_3a'];
    
    var hideDivs = new Array();
    hideDivs[0]=['sub_menu_1b'];
    hideDivs[1]=['sub_menu_2b'];
    hideDivs[2]=['sub_menu_3b'];

    thisDiv = document.getElementById(visDivs[index]);
	thisDiv2 = document.getElementById(hideDivs[index]);
	
	for(i=0;i<hideDivs.length;i++) {
	   if (i==index) {
            thisDiv = document.getElementById(visDivs[i]);
        	thisDiv2 = document.getElementById(hideDivs[i]);
            thisDiv.style.display = "none";
            thisDiv2.style.display = "block";
		} else {
            thisDiv = document.getElementById(visDivs[i]);
        	thisDiv2 = document.getElementById(hideDivs[i]);
            thisDiv.style.display = "block";
            thisDiv2.style.display = "none";
		}
    }
}

/*****
* script voor de SWITCHING show/hide divs 
****/

function toggleDiv(divName, divName2) {
    thisDiv = document.getElementById(divName);
	thisDiv2 = document.getElementById(divName2);
	
	if (thisDiv) {
			if (thisDiv.style.display == "none") {
				thisDiv.style.display = "block";
			} else {
				thisDiv.style.display = "none";
			}
		}
		if (thisDiv2) {
			if (thisDiv2.style.display == "block") {
				thisDiv2.style.display = "none";
			} else {
				thisDiv2.style.display = "block";
			}
		}
    }
/*****
* script voor de show/hide divs 
****/
function toggleLayer(whichLayer) {
    if (document.getElementById)  {
        // this is the way the standards work
        var style2 = document.getElementById(whichLayer).style;
        style2.display = style2.display? "":"block";
    } else if (document.all) {
        // this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
        style2.display = style2.display? "":"block";
    }  else if (document.layers)  {
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style2.display = style2.display? "":"block";
    }
}
/*****************************************
VALIDATE FUNCTIONS
1 ***Subject filled ??********************/

function validateGuestBook(theform) {
	if ((theform.newName.value=="uw naam") || (theform.newMail.value=="uw email") || (theform.reactie.value=="uw bericht:") || (theform.reactie.value=="")){
		alert("Vult uw aub minstens uw naam, email en bericht in.");
		return false; 
	}  else { 
	   return true; 
	}
}
/*
function validateOrder(theform) {
	if ((theform.naam.value=="") || (theform.adres.value=="") || (theform.postcode.value=="") || (theform.plaats.value=="") || (theform.email.value=="")){
		alert("Vul aub uw naam, email en adresgegevens in.");
		return false; 
	}  else { 
	   return true; 
	}
}
*/
var default_border_color = '#000000';
function validateOrder(theform) {
    /* ---- PERSOONLIJKE GEGEVENS --- */
	var msg_naam=theform.naam;
	if(!default_check(msg_naam)) { return false; }
	var adres=theform.adres;
	if(!default_check(adres)) { return false; }
	var postcode=theform.postcode;
	if(!default_check(postcode)) { return false; }
	var plaats=theform.plaats;
	if(!default_check(plaats)) { return false; }
	var country=theform.country;
	if ((country.value==null)||(country.value=="")){
		alert('Choose a country');
		return false;
	}
	var msg_email=theform.email;
	if(!default_check(msg_email)) { return false; }
	if (echeck(msg_email.value)==false){
		msg_email.focus()
		return false;
	}
	
}
function default_check(input) {
	if ((input.value==null)||(input.value=="")){
    	input.style.borderColor="#ff0000";
		input.focus()
		return false;
	} else {
        input.style.borderColor=default_border_color;
        return true;
	}
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid e-mail adress")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid e-mail adress")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid e-mail adress")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid e-mail adress")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid e-mail adress")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid e-mail adress")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid e-mail adress")
		    return false
		 }
 		 return true					
}