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) {

	var msg_naam=theform.newName;
	if(!default_check(msg_naam, 'uw naam:')) { return false; }
	
	var msg_email=theform.newMail;
	if(!default_check(msg_email, 'uw email:')) { return false; }
	if (echeck(msg_email.value)==false){
		msg_email.focus()
		return false;
	}
	var msg_text=theform.reactie;
	if(!default_check(msg_text, 'uw bericht:')) { return false; }

	var msg_checker=theform.checker;
	if(!default_check(msg_checker)) { return false; }

   return true; 
	
}

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;
	}
	
}
var default_border_color = '#000000';

function default_check(input, default_value) {
	if(default_value==undefined) {
		default_value=='';
	}
	if ((input.value==null) || (input.value=="") || input.value==default_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("Voer een geldig email adres in")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Voer een geldig email adres in")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Voer een geldig email adres in")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Voer een geldig email adres in")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Voer een geldig email adres in")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Voer een geldig email adres in")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Voer een geldig email adres in")
		    return false
		 }
 		 return true					
}
