// JavaScript Document

if (document.images) {
 img1_on =new Image(); img1_on.src ="img/toe_on.png"; 
 img1_off=new Image(); img1_off.src="img/toe_off.png"; 

 img2_on =new Image(); img2_on.src ="img/tip_on.png"; 
 img2_off=new Image(); img2_off.src="img/tip_off.png"; 

 img3_on =new Image(); img3_on.src ="img/folder_on.png"; 
 img3_off=new Image(); img3_off.src="img/folder_off.png"; 

 img4_on =new Image(); img4_on.src ="img/materialen_on.png"; 
 img4_off=new Image(); img4_off.src="img/materialen_off.png"; 

 img5_on =new Image(); img5_on.src ="img/bestellen_on.png"; 
 img5_off=new Image(); img5_off.src="img/bestellen_off.png"; 
 
 img6_on =new Image(); img6_on.src ="img/webbased_on.png"; 
 img6_off=new Image(); img6_off.src="img/webbased_off.png"; 
 
 img7_on =new Image(); img7_on.src ="img/toetssite_on.png"; 
 img7_off=new Image(); img7_off.src="img/toetssite_off.png"; 

 img8_on =new Image(); img8_on.src ="img/lka_on.png"; 
 img8_off=new Image(); img8_off.src="img/lka_off.png"; 

 img9_on =new Image(); img9_on.src ="img/menu_vll_on.png"; 
 img9_off=new Image(); img9_off.src="img/menu_vll_off.png"; 

 img10_on =new Image(); img10_on.src ="img/menu_vsvs_on.png"; 
 img10_off=new Image(); img10_off.src="img/menu_vsvs_off.png"; 

 img11_on =new Image(); img11_on.src ="img/menu_gebruikers_on.png"; 
 img11_off=new Image(); img11_off.src="img/menu_gebruikers_off.png"; 

 img12_on =new Image(); img12_on.src ="img/menu_ouders_on.png"; 
 img12_off=new Image(); img12_off.src="img/menu_ouders_off.png"; 

}


function movr(k) {
 if (document.images) 
  eval('document.img'+k+'.src=img'+k+'_on.src');
}

function mout(k) {
 if (document.images) 
  eval('document.img'+k+'.src=img'+k+'_off.src');
}

function handleOver() {
 if (document.images) 
  document.imgName.src=img_on.src;
}

function handleOut() {
 if (document.images) 
  document.imgName.src=img_off.src;
}







function switch_div (divId, vorigedivId, positie) {
	var divteller = 0;
	if (divId == 0) {
		while (divteller <= 2000) {
			if (document.getElementById(divteller)) {

				document.getElementById(divteller).style.visibility = 'hidden';
			}
		divteller = divteller + 1;
		}
		
	} 
	else {
		//var mijnId = document.getElementById(divId).id;
		while (divteller <=2000) {
			if (document.getElementById(divteller)) {
				if (document.getElementById(divteller).id == divId) {
				document.getElementById(divteller).style.visibility = "visible";
				} 
				else if (document.getElementById(divteller).id == vorigedivId) {
				document.getElementById(divteller).style.visibility = "visible";
				}
				else {
				document.getElementById(divteller).style.visibility = "hidden";
				}
			}
		divteller = divteller + 1;
		}
	}
	divId = 0;
	vorigedivId = 0;
}




function getXmlHttpObject() {
		
	
	var xmlHTTP=null;
	
	if (navigator.appName != 'Microsoft Internet Explorer' || navigator.appVersion.indexOf("MSIE 6.0") == -1) {
		
		xmlHTTP = new XMLHttpRequest();
		
	} else {
			
		
			try {
				xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");			
			}
	}
	return xmlHTTP;
}

function get_AJX_Menu(hoofdgroepid, volgorde, nummer) {

xmlhttp = getXmlHttpObject();
	if (xmlhttp == null) {
		alert("Unable to build dynamic menu. Check browser scripting restrictions...");
		return;
	}
	var url = "ajx_ddmenu.asp?hoofdgroepid=" + hoofdgroepid;
	xmlhttp.onreadystatechange=function() {buildMenu(volgorde);};
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}

function buildMenu (volgorde) {
	
	document.getElementById("ddmenu").style.visibility = "visible";
	var vorig_hoofdmenu_el = 0;
	var volgnr_in_div = 0;
	var volgnr_in_hoofdmenu  = 0;
	var pos = 0;
	var divinhoud = "<div class='test'>";
	var vertpos = volgorde * 62;
	
	
	if(xmlhttp.readyState == 4) {
		
		//check browsertype IE of Moz
		var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
		
		if (moz) {
			
			var xmlDoc = xmlhttp.responseXML.getElementsByTagName("menu");
			var myMenu = xmlDoc[0].getElementsByTagName("menuItem");
			
			if (myMenu.length > 0) {
			
			var aantallijnen = myMenu.length;
			
			for (i=0; i<aantallijnen; i++) {
				if (vorig_hoofdmenu_el == myMenu[i].childNodes[0].firstChild.nodeValue) {
					//submenu niveau2
					divinhoud = divinhoud + "<div class='niveau-2'><a href='vll.asp?";
					divinhoud = divinhoud + "id=" + myMenu[i].childNodes[1].firstChild.nodeValue;					
					divinhoud = divinhoud + "' style='position:relative; top:0px; left:0px; z-index:99;'>";
					divinhoud = divinhoud + myMenu[i].childNodes[3].firstChild.nodeValue + "</a></div>";
				} else {
					
					if (vorig_hoofdmenu_el > 0) {
						divinhoud = divinhoud + "</div>";
						
					} else {
					}
					//hoofdmenu item
					divinhoud = divinhoud + "<div class='niveau-2'><a href='vll.asp?";
					divinhoud = divinhoud + "id=" + myMenu[i].childNodes[0].firstChild.nodeValue;
					divinhoud = divinhoud + "' style='position:relative; top:" + pos + "px; left:0px; z-index:99;' OnMouseOver='switch_div(";
					divinhoud = divinhoud + myMenu[i].childNodes[0].firstChild.nodeValue +  ", 20)'>";
					divinhoud = divinhoud + myMenu[i].childNodes[2].firstChild.nodeValue + "</a></div>";
					
					vorig_hoofdmenu_el = myMenu[i].childNodes[0].firstChild.nodeValue;
										
					//submenu niveau2 item1
					divinhoud = divinhoud + "<div id='" + myMenu[i].childNodes[1].firstChild.nodeValue;
					divinhoud = divinhoud + "' style='position:absolute; left:200px; z-index:99; top:" + pos + "px; visibility:hidden'>";

					if (myMenu[i].childNodes[0].firstChild.nodeValue == myMenu[i].childNodes[1].firstChild.nodeValue) {
					} else {
						
						//divinhoud = divinhoud + "<div class='niveau-2'><a href='vll.asp?";
						divinhoud = divinhoud + "id=" + myMenu[i].childNodes[1].firstChild.nodeValue;						
						divinhoud = divinhoud + "' style='position:relative; top:" + ypos + "px; left:0px;'>";
						//divinhoud = divinhoud+ myMenu[i].childNodes[3].firstChild.nodeValue + "</a></div>";
					//volgnr_in_div += 1;
				//pos = volgnr_in_div*27;
					}
				
				
				}
			
			
			}
			}
		} else {
		
			var xmlDoc = xmlhttp.responseXML.documentElement;
			
			if (xmlDoc.hasChildNodes()==true) {
			
			var aantallijnen = xmlDoc.childNodes.length;
			
			
			for (i=0; i<aantallijnen; i++) {
				if (vorig_hoofdmenu_el == xmlDoc.childNodes[i].getElementsByTagName("groepId")[0].firstChild.text) {
					divinhoud = divinhoud + "<div class='niveau-2'><a href='vll.asp?";
					divinhoud = divinhoud + "id=" + xmlDoc.childNodes[i].getElementsByTagName("methId")[0].firstChild.text;
					divinhoud = divinhoud + "'>";
					divinhoud = divinhoud + xmlDoc.childNodes[i].getElementsByTagName("methOms")[0].firstChild.text + "</a></div>";
				} else {
					
					if (vorig_hoofdmenu_el > 0) {
						divinhoud = divinhoud + "</div>";
					} else {
					}
					
					divinhoud = divinhoud + "<div class='niveau-2'><a href='vll.asp?";
					divinhoud = divinhoud + "id=" + xmlDoc.childNodes[i].getElementsByTagName("groepId")[0].firstChild.text;
					divinhoud = divinhoud + "' style='position:relative; z-index:99; left:0px;' OnMouseOver='switch_div(";
					divinhoud = divinhoud + xmlDoc.childNodes[i].getElementsByTagName("methId")[0].firstChild.text +  ", 20)'>";
					divinhoud = divinhoud + xmlDoc.childNodes[i].getElementsByTagName("groepOms")[0].firstChild.text + "</a></div>";
					
					vorig_hoofdmenu_el = xmlDoc.childNodes[i].getElementsByTagName("groepId")[0].firstChild.text;
					
					divinhoud = divinhoud + "<div id='" + xmlDoc.childNodes[i].getElementsByTagName("groepId")[0].firstChild.text
					divinhoud = divinhoud + "' style='border-left:1px solid #ffffff; position:absolute; left:200px; z-index:99; top:" + pos + "px; visibility:hidden'>"

					if (xmlDoc.childNodes[i].getElementsByTagName("groepId")[0].firstChild.text == xmlDoc.childNodes[i].getElementsByTagName("groepId")[0].firstChild.text) {
					} else {
						divinhoud = divinhoud + "<div class='niveau-2'><a href='vll.asp?";
						divinhoud = divinhoud + "id=" + xmlDoc.childNodes[i].getElementsByTagName("groepId")[0].firstChild.text;
						
						divinhoud = divinhoud + "'>"; 
						divinhoud = divinhoud+ xmlDoc.childNodes[i].getElementsByTagName("groepOms")[0].firstChild.text + "</a></div>";
					}
				volgnr_in_div += 1;
				pos = volgnr_in_div*27;
				}
				// 
			
			}
		}
			
			
	}
		
}
//vertpos = vertpos + 60;
var x, y;
document.getElementById("ddmenu").style.position = 'absolute';
x = document.getElementById("nulpunt").offsetTop;
// document.getElementById("ddmenu").style.position = x + "px";
y = x + (62 * volgorde);
document.getElementById("ddmenu").style.top = y + "px";
document.getElementById("ddmenu").innerHTML = divinhoud;
}

function get_AJX_zoekSuggesties(zoekterm) {

	xmlhttp = getXmlHttpObject();
	
	var url = "ajx/ajx_zoeksuggesties.asp?zoekterm=" + zoekterm;
	xmlhttp.onreadystatechange=toonZoekSuggesties;
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}

function toonZoekSuggesties() {
	
	var divinhoud = "";	
	
	if(xmlhttp.readyState == 4) {
		
		//check browsertype IE of Moz
		var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
		
		if (moz) {
			
			var xmlDoc = xmlhttp.responseXML.getElementsByTagName("zoekRes");
			var myZoekRes = xmlDoc[0].getElementsByTagName("zoekItem");
			
			if (myZoekRes.length > 0) {
			
			var aantallijnen = myZoekRes.length;
			
			
			for (i=0; i<aantallijnen; i++) {
				
					divinhoud = divinhoud + "<span class='niveau-2'><a class='niveau-2' href='vll.asp?";
					divinhoud = divinhoud + "id=" + myZoekRes[i].childNodes[0].firstChild.nodeValue;					
					divinhoud = divinhoud + "'>";
					divinhoud = divinhoud + myZoekRes[i].childNodes[1].firstChild.nodeValue + "</a></span>";
				
				volgnr_in_div += 1;
				pos = volgnr_in_div*29;
				
			}
			
		} else {
		
			var xmlDoc = xmlhttp.responseXML.documentElement;
			
			if (xmlDoc.hasChildNodes()==true) {
			
			var aantallijnen = xmlDoc.childNodes.length;
			
			
			for (i=0; i<aantallijnen; i++) {
				
					divinhoud = divinhoud + "<span class='niveau-2'><a class='niveau-2' href='vll.asp?";
					divinhoud = divinhoud + "id=" + xmlDoc.childNodes[i].getElementsByTagName("methId")[0].firstChild.text;
					divinhoud = divinhoud + "'>";
					divinhoud = divinhoud + xmlDoc.childNodes[i].getElementsByTagName("methOms")[0].firstChild.text + "</a></span>";
				
				volgnr_in_div += 1;
				pos = volgnr_in_div*29;
				
				// 
			
			}
		}
		}
			
	}divinhoud = divinhoud + "</div>";
		
}
document.getElementById("menuSuggesties").innerHTML = divinhoud;
}

  

