// ********************* General Cookie handling *********************
// Cookie Functions - Second Helping (21-Jan-96)
// Written by: Bill Dortch, hIdaho Design <bdortch@netw.com>
// The following functions are released to the public domain.

var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}

function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
// This cookie is history
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

//dit hoort eigenlijk bij de abstractie....
function AddToBasket(item, amount) {
	var basket = "";
	var result = "";
	var found = false;
	var items = 0;
	var cookie_array;
	basket = basket + GetCookie('basket');
	cookie_array = basket.split(";");
  for (x=0; x < cookie_array.length; x++) {
		cookieParts_array = cookie_array[x].split("x")
		if (cookieParts_array[0] == item) {
			cookieParts_array[1] = cookieParts_array[1] + amount;
			found = true;
		}
		if(IsNumeric(cookieParts_array[0]) && IsNumeric(cookieParts_array[1])) {
			result = result + cookieParts_array[0] + 'x' + cookieParts_array[1] + ';';
			items = items + 1;
		}
	}
	if(!(found)) {
		result = result + item + 'x' + amount + ';';
	}
	SetCookie ('basket', result);
	alert('Dit item werd toegevoegd aan uw mandje\n' + items + ' items in uw mandje');
}


function fmtestfields() {
	// test de velden van het inschrijf-formulier
	if (document.forms[0].PC.value == "") {
		alert("Gelieve je postcode op te geven a.u.b.");
		document.forms[0].PC.focus();
	return (false);
	}
	if (document.forms[0].Gezinsleden.value == "") {
		alert("Gelieve het aantal gezinsleden op te geven a.u.b.");
		document.forms[0].Gezinsleden.focus();
	return (false);
	}	
	return (true);
}


function checkvals( formelm_ , type , min , max , omax , omin , req, alrt) {
    var formelm = formelm_.value;
    if (formelm.length == 0) { 
    	if(req) {
    	    alert(alrt + " : \nDit veld is verplicht in te vullen");
    	} else {
    	    return(true)
    	}
    } else {
    	if (type == 1) { // integer gewenst
            if(IsNumeric(formelm)) { 
            	formelm = PuntToComma(formelm);
            	formelm_.value = formelm;  // ze de waarde daar met een comma
            	if (parseFloat(formelm) >= parseFloat(min)) {
            	    if (parseFloat(formelm) <= parseFloat(max)) {
                    	return(true); // waarde zit tussen de twee in.
                    } else { 
                        if(omax) {
                    	    return(confirm(alrt + " : \nU vulde een erg hoge waarde in; klopt dit?"));
                    	} else {
                    	    alert(alrt + " : \nDe waarde " + formelm + " mag niet groter zijn dan " + max);
                    	    return(false);
                    	}
                    }
            	} else { 
            	    if(omin) {
            	        return(confirm(alrt + " : \nU vulde een erg lage waarde in; klopt dit?"));
            	    } else {
            	    	alert(alrt + " : \nDe waarde " + formelm + " mag niet kleiner zijn dan " + min); 
            	    }
            	}
            } else { 
            	alert(alrt + " : \nU dient een numerieke waarde in te geven. \nIn geval van decimale waarde: gebruik een komma ipv een punt\nIn geval duizendtallen: gebruik géén duizendtal-notaties, noch komma's nog punten.\n" + formelm + " voldoet niet aan deze voorwaarde");
            }
    	} 
    }
}



function maxtest(formelm_,type,min,max) {
    	var formelm = formelm_.value;
    if (type == 1) { // int
        
        if(IsNumeric(formelm)) { 
            formelm = PuntToComma(formelm);
            formelm_.value = formelm;
            if (parseFloat(formelm) >= parseFloat(min)) {
            	if (parseFloat(formelm) <= parseFloat(max)) {
                    return(true);
                } else { alert("De waarde " + formelm + " mag niet groter zijn dan " + max); }
            } else  { alert("De waarde " + formelm + " mag niet kleiner zijn dan " + min); }
        } else { alert("U moet hier een numerieke waarde ingeven. " + formelm + " is niet nummeriek"); }
    } else {
    	if (formelm.length > 0) { return(true); }
    	else { alert("U dient een waarde in te vullen!"); }
    }
}

function maxtest2(formelm_,type,min,max,alrt) {
    	var formelm = formelm_.value;
    if (type == 1) { // int
        if(IsNumeric(formelm)) { 
            formelm = PuntToComma(formelm);
            formelm_.value = formelm;
            if (parseFloat(formelm) > (parseFloat(min) - 1)) {
            	if (parseFloat(formelm) <= parseFloat(max)) {
                    return(true);
                } else { alert(alrt + " : \nDe waarde " + formelm + " mag niet groter zijn dan " + max); }
            } else  { alert(alrt + " : \nDe waarde " + formelm + " mag niet kleiner zijn dan " + min); }
        } else { alert(alrt + " : \nU moet hier een numerieke waarde ingeven. " + formelm + " is niet nummeriek. Gebruik een , ipv een ."); }
    } else {
    	if (formelm.length > 0) { return(true); }
    	else { alert(alrt + " : \nU dient een waarde in te vullen!"); }
    }
}

function maxtest3(formelm_,type,min,max,alrt) {  // not required
	var formelm = formelm_.value;
    if (type == 1) { // int
     	if(formelm.length < 1) { return(true); }  // not required
            formelm = PuntToComma(formelm);
            formelm_.value = formelm;
        if(IsNumeric(formelm)) { 
            if (parseFloat(formelm) > (parseFloat(min) - 1)) {
            	if (parseFloat(formelm) <= parseFloat(max)) {
                    return(true);
                } else { alert(alrt + " : \nDe waarde " + formelm + " mag niet groter zijn dan " + max); }
            } else  { alert(alrt + " : \nDe waarde " + formelm + " mag niet kleiner zijn dan " + min); }
        } else { alert(alrt + " : \nU dient een numerieke waarde in te geven. \nIn geval van decimale waarde: gebruik een komma ipv een punt\nIn geval duizendtallen: gebruik géén duizendtal-notaties, noch komma's nog punten.\n" + formelm + " voldoet niet aan deze voorwaarde"); }
    } else {
    	if (formelm.length > 0) { return(true); }
    	else { alert(alrt + " : \nU dient een waarde in te vullen!"); }
    }
}


function GetRBselection(group) {
    for ( var i=0; i<group.length; i++ ) {
        if ( group[i].checked == true ) { return( group[i].value ); }
    }
    return("");
}

function GetSBselection(slect) {
    return( slect.options[slect.selectedIndex].value );
}

function NotEmpty (radiobutn) {
	var strrb = GetRBselection(radiobutn);
	if (strrb.length > 0) { return(true); }
    	else { alert(" : u moet een keuze te maken."); }
}

function NotEmpty2(radiobutn,alrt) {
	var strrb = GetRBselection(radiobutn);
	if (strrb.length > 0) { return(true); }
    	else { alert(alrt + " : \nu moet een keuze te maken."); }
}

function NotEmptyStr (inputfield, errormsg) {
	if ( inputfield.value.length > 0)  { return(true); }
    	else { alert(errormsg + " : You have to fill out this field!"); }
}

function PuntToComma(str) {
	var stro1;
	var stro2;
	var pos;
	pos = str.indexOf(".");
	if(( pos > 0) && (str.length > 0)) {
		stro1 = str.substring(0,pos);
		stro2 = str.substring(pos+1,str.length);
		return(stro1 + "," + stro2);
	} else { return(str); }
}

function CommaToPunt(str) {
	var stro1;
	var stro2;
	var pos;
	pos = str.indexOf(",");
	if(( pos > 0) && (str.length > 0)) {
		stro1 = str.substring(0,pos);
		stro2 = str.substring(pos+1,str.length);
		return(stro1 + "." + stro2);
	} else { return(str); }
}
    	
function IsNumeric(var1)
   //  check for valid numeric strings	
   {
   var stringo = "";
   var strValidChars = "-0123456789,";
   var strChar;
   var blnResult = true;
	 stringo = stringo + var1;
	 
   //  test string consists of valid characters listed above
   for (i = 0; i < stringo.length && blnResult == true; i++)
      {
      strChar = stringo.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}


function IsInteger(var1)
   //  check for valid numeric strings	
   {
   var stringo = var1;
   var strValidChars = "-0123456789";
   var strChar;
   var blnResult = true;

   //  test string consists of valid characters listed above
   for (i = 0; i < stringo.length && blnResult == true; i++)
      {
      strChar = stringo.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

function CheckAges(l1, l2, l3, l4, l5, l6, l7, l8, l9, l10 ) {
	if(IsInteger(l1.value) && IsInteger(l2.value) && IsInteger(l3.value) && IsInteger(l4.value) && IsInteger(l5.value) && IsInteger(l6.value) && IsInteger(l7.value) && IsInteger(l8.value) && IsInteger(l9.value) && IsInteger(l10.value)) {
 		if ((l1.value > 17) || (l2.value > 17) || (l3.value > 17) || (l4.value > 17) || (l5.value > 17) || (l6.value > 17) || (l7.value > 17) || (l8.value > 17) || (l9.value > 17) || (l10.value > 17)) { 
  			return(true); 
 		} else { 
  			alert('Er moet minstens één gezinslid minstens 18 zijn.'); 
  			return(false); 
 		}
	} else {
		alert('Sorry, U mag geen kommagetallen gebruiken.\n Als u kind jonger is als 1 jaar, noteer dit dan als 0'); 
		return(false);
	}
}

function CheckSame(pw1, pw2, alrt) {
	if(pw1.value == pw2.value) {
		return(true);
	} else { alert(alrt); return(false); }
}


function openWindow(URL, windowName, windowProperties) {
newWindow=window.open(URL,windowName, windowProperties);
}

function close() {
parent.close;
}

function editKommentaar(aKommentaarveld, aKommentaarveld2, aOmschrijving) {
        if (aKommentaarveld.options[aKommentaarveld.selectedIndex].value == "andere") {
		comment = window.prompt('Vul in : ' + ' ' + aOmschrijving, aKommentaarveld.options[aKommentaarveld.selectedIndex].text) 
		if (comment != null) {
			addToTheList(comment, aKommentaarveld);
			aKommentaarveld2.value = comment; 
			//aKommentaarveld2.options[aKommentaarveld2.options.length].text = comment; 
			//aKommentaarveld2.selectedIndex = aKommentaarveld2.options.length;
		}
	}
	return false;   
}

function editkommentaar(aKommentaarveld, aKommentaarveld2, aOmschrijving) {
        if (aKommentaarveld.options[aKommentaarveld.selectedIndex].value == "andere") {
		comment = window.prompt('Vul in : ' + ' ' + aOmschrijving, aKommentaarveld2.options[aKommentaarveld.selectedIndex].text) 
		if (comment != null) {
			addToTheList(comment, aKommentaarveld);
			aKommentaarveld2.value = comment; 
		}
	}
	return false;   
}

/***********************************************************************************
fill_in_clock script by Jason Schanker (jcheetah@orion.webspan.net)                        
comes from "http://www.webspan.net/~herbs/jcheetah/web_design/javascript/time.html"                             
You may copy this source freely if credit is given to the author
************************************************************************************/
function fill_in_clock() 
{
        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var seconds = now.getSeconds();
        var today = now.getDay();
        var month = now.getMonth() + 1;
        var year = now.getYear() - 100; 
        var date = now.getDate();
        var datum   = date + "/" + month;
        if(seconds < 10) seconds = "0" + seconds;
        if(minutes < 10) minutes = "0" + minutes;
        if(hours < 10)   hours   = "0" + hours;
        if(date < 10)    date    = "0" + date;
        if(month < 10)   month   = "0" + month;
        if(year > 1900)  year    = year - 1900;
        if(year > 100)   year    = year - 100;
        if(year < 10)    year    = "0" + year;
        if (!(document.forms[0].rd_dag.value > 0)) {
	        document.forms[0].rd_dag.value = date;
        	document.forms[0].rd_maand.value = month;
        	document.forms[0].rd_jaar.value = year;
        	document.forms[0].rd_uur.value = hours;
        	document.forms[0].rd_minuten.value = minutes;
        }
}

function fill_in_day() 
{
        var now = new Date();
        var today = now.getDay();
        var month = now.getMonth() + 1;
        var year = now.getYear() - 100; 
        var date = now.getDate();
        var datum   = date + "/" + month;
        if(seconds < 10) seconds = "0" + seconds;
        if(minutes < 10) minutes = "0" + minutes;
        if(hours < 10)   hours   = "0" + hours;
        if(date < 10)    date    = "0" + date;
        if(month < 10)   month   = "0" + month;
        if(year > 1900)  year    = year - 1900;
        if(year > 100)   year    = year - 100;
        if(year < 10)    year    = "0" + year;
        if (!(document.forms[0].rd_dag.value > 0)) {
	        document.forms[0].rd_dag.value = date;
        	document.forms[0].rd_maand.value = month;
        	document.forms[0].rd_jaar.value = year;
        }
}


function addToTheList(srcStr, destList) {
	var currentLength = destList.length;
	var theStr = srcStr;
	var count = 0;
	
	for ( count=0; count<=currentLength && destList.options[count] != null; count++) {
		var localStr = destList.options[count].text.toLowerCase(); 
		if (theStr == localStr) {
			alert("This vallue is already present");
			destList.selectedIndex = count;
			return false;   
		}
	}
	destList.options[currentLength] = new Option(theStr,theStr);
	destList.selectedIndex = currentLength;
	return true;
} 

function isValidEmail(frmstr) {
   var str = frmstr.value;
   if((str.indexOf(".") > 2) && (str.indexOf("@") > 0)) {
   	return(true);
   } else {
   	alert(str + ' is not a valid email address');
   	return(false);
   }
}

function validate_form() {
	var myform = document.forms[0];
	if ( NotEmptyStr(myform.firstname , 'Firstname') && NotEmptyStr(myform.lastname , 'Lastname') && NotEmptyStr(myform.nick , 'Nickname') && isValidEmail(myform.email , 'Email') && CheckSame(myform.email, myform.email2, 'The conirm email is not the same as the original email.')) {
		myform.submit();
	}
}


function validate_profiel() {
	var myform = document.forms[0];
	if ( NotEmptyStr(myform.firstname , 'Firstname') && NotEmptyStr(myform.lastname , 'Lastname') && NotEmptyStr(myform.nick , 'Nickname') && isValidEmail(myform.email , 'Email')) {
		myform.submit();
	}
}


function getwidth(width1, height1, size1) {
	//window.onerror=null;
	var mymaxwidth = window.screen.availWidth;
	//var mymaxwidth = window.outerWidth;
	//var mymaxwidth = window.innerWidth;
	var mymaxheight = window.screen.availHeight;
	//var mymaxheight = window.outerHeight;
	//var mymaxheight = window.innerHeight;
	var wth;
	if (width1 < mymaxwidth * size1) { 
		wth = width1;
	} else {
		wth =  mymaxwidth * size1;
	}
	return (wth);
}
function getheight(width1, height1, size1) {
	window.onerror=null;
	var wth = getwidth(width1, height1, size1);
	var mymaxwidth = window.screen.availWidth;
	//var mymaxwidth = window.outerWidth;
	//var mymaxwidth = window.innerWidth;
	var mymaxheight = window.screen.availHeight;
	//var mymaxheight = window.outerHeight;
	//var mymaxheight = window.innerHeight;
	var hgt;
	if (width1 < mymaxwidth * size1) { 
		hgt = height1;
	} else {
		hgt = Math.round(height1 * wth / width1);
	}	
	return (hgt);
}


function popupfullscreen(){
	newwin = window.open('','NEWMR2K','width=800,height=600,left=80,top=80,toolbar=no,menubar=no,statusbar=yes,scrollbars=yes,fullscreen=yes');
}


/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="default.asp">Home</a><br>'
menu1[1]='<a href="missie.asp">Missie en Visie</a><br>'
menu1[2]='<a href="medewerkers.asp">Medewerkers</a><br>'
menu1[3]='<a href="links.asp">Links</a><br>'
menu1[4]='<a href="projecten.asp">Projectoverzicht</a><br>'
menu1[5]='<a href="kader.asp">Theoretisch kader</a><br>'

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="voetafdruk.asp">Ecolife en de Ecologische voetafdruk</a><br>'
menu2[1]='<b>Voetafdruk projecten:</b><br>'
menu2[2]=' &nbsp;&nbsp;&nbsp;&nbsp; <a href="voetproject.asp">Overzicht voorbije projecten</a><br>'
menu2[3]=' &nbsp;&nbsp;&nbsp;&nbsp; <a href="groene_voeten.asp">Groene Voeten</a><br>'
menu2[4]='<a href="test.asp">Test jezelf: voetafdruk calculators</a><br>'

//Contents for menu 3, and so on
var menu3=new Array()
menu3[0]='<a href="downloads.asp?show=jaarverslagen">Jaarverslagen</a><br>'
menu3[1]='<a href="downloads.asp?show=nieuwsbrieven">Nieuwsbrieven</a><br>'
menu3[2]='<a href="downloads.asp?show=publicaties">Publicaties</a><br>'
menu3[3]='<a href="downloads.asp?show=docs">Documenten</a><br>'
menu3[4]='<a href="downloads.asp">Andere</a><br>'

//Contents for menu 4, and so on
var menu4=new Array()
menu4[0]='<a href="contact.asp?show=gegevens">Coördinaten</a><br>'
menu4[1]='<a href="contact.asp?show=formulier">Contact formulier</a><br>'
menu4[2]='<a href="contact.asp?show=openingsuren">Openingsuren</a><br>'
menu4[3]='<a href="contact.asp?show=wegbeschrijving">Wegbeschrijving</a><br>'


		
var menuwidth='165px' //default menu width
var menubgcolor='#A7C5E9'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu








/// sidemenu $

/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate

