// JavaScript Document

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, horizpos) {

xmlhttp = getXmlHttpObject();
	if (xmlhttp == null) {
		alert("Unable to build dynamic menu. Check browser scripting restrictions...");
		return;
	}
	var url = "ajx/ajx_ddmenu.asp?hoofdgroepid=" + hoofdgroepid;
	xmlhttp.onreadystatechange=function() {buildMenu(horizpos);};
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}

function buildMenu (horizpos) {
	
	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 = "";
		
	if(xmlhttp.readyState == 4) {
		
		//check browsertype IE of Moz
		var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
		var strdesc;
		
		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) {
					divinhoud = divinhoud + "<div class='h-niveau-2'><a href='method.asp?";
					divinhoud = divinhoud + "id=" + myMenu[i].childNodes[1].firstChild.nodeValue;
					strdesc = escape(myMenu[i].childNodes[3].firstChild.nodeValue);
					divinhoud = divinhoud + "&desc=" + strdesc + "'>";
					divinhoud = divinhoud + myMenu[i].childNodes[3].firstChild.nodeValue + "</a></div>";
				} else {
					
					if (vorig_hoofdmenu_el > 0) {
						divinhoud = divinhoud + "</div>";
					} else {
					}
					
					divinhoud = divinhoud + "<div class='h-niveau-2'><a href='method.asp?";
					divinhoud = divinhoud + "id=" + myMenu[i].childNodes[1].firstChild.nodeValue;
					strdesc = escape(myMenu[i].childNodes[3].firstChild.nodeValue);
					divinhoud = divinhoud + "&desc=" + strdesc + "' style='position:relative; left:0px;' 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;
					
					divinhoud = divinhoud + "<div id='" + myMenu[i].childNodes[0].firstChild.nodeValue;
					divinhoud = divinhoud + "' style='border-left:2px solid #7fbade; position:absolute; left:214px; top:" + pos + "px; visibility:hidden'>";

					if (myMenu[i].childNodes[0].firstChild.nodeValue == myMenu[i].childNodes[1].firstChild.nodeValue) {
					} else {
						divinhoud = divinhoud + "<div class='h-niveau-2'><a href='method.asp?";
						divinhoud = divinhoud + "id=" + myMenu[i].childNodes[1].firstChild.nodeValue;
						strdesc = escape(myMenu[i].childNodes[3].firstChild.nodeValue);
						divinhoud = divinhoud + "&desc=" + strdesc + "'>";
						divinhoud = divinhoud+ myMenu[i].childNodes[3].firstChild.nodeValue + "</a></div>";
					}
				volgnr_in_div += 1;
				pos = volgnr_in_div*24;
				}
				// 
			
			}
			}
		} 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='h-niveau-2'><a href='method.asp?";
					divinhoud = divinhoud + "id=" + xmlDoc.childNodes[i].getElementsByTagName("methId")[0].firstChild.text;
					strdesc=xmlDoc.childNodes[i].getElementsByTagName("methOms")[0].firstChild.text;
					divinhoud = divinhoud + "&desc=" + strdesc + "'>";
					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='h-niveau-2'><a href='method.asp?";
					divinhoud = divinhoud + "id=" + xmlDoc.childNodes[i].getElementsByTagName("groepId")[0].firstChild.text;
					strdesc=xmlDoc.childNodes[i].getElementsByTagName("methOms")[0].firstChild.text;
					divinhoud = divinhoud + "&desc=" + strdesc + "' style='position:relative; 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:2px solid #7fbade; position:absolute; left:214px; 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='h-niveau-2'><a href='method.asp?";
						divinhoud = divinhoud + "id=" + xmlDoc.childNodes[i].getElementsByTagName("groepId")[0].firstChild.text;
						strdesc=xmlDoc.childNodes[i].getElementsByTagName("methOms")[0].firstChild.text;
						divinhoud = divinhoud + "&desc=" + strdesc + "'>"; 
						divinhoud = divinhoud+ xmlDoc.childNodes[i].getElementsByTagName("groepOms")[0].firstChild.text + "</a></div>";
					}
				volgnr_in_div += 1;
				pos = volgnr_in_div*24;
				}
				// 
			
			}
		}
			
			
	}
		
}
//horizpos = horizpos + 250;
document.getElementById("ddmenu").style.left = horizpos + "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='method.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*24;
				
			}
			
		} 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='method.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*24;
				
				// 
			
			}
		}
		}
			
	}
		
}
document.getElementById("menuSuggesties").innerHTML = divinhoud;
}

  

