function initMenu() {
	timerID2 = null;
	theHmenu = document.getElementById('horizontal');
	theDmenu = document.getElementById('dropdown');
	
	if(theHmenu) {
		theLis = theHmenu.childNodes;
		for(i=0;i<theLis.length;i++) {
			if(theLis[i].tagName == 'LI') {
				for(j=0;j<theLis[i].childNodes.length;j++) {
					if(theLis[i].childNodes[j].tagName == 'UL') {
						theLis[i].getElementsByTagName('A')[0].onmouseover = function() {
							showSub(this);									
							this.className += ' hi';
						}
						theLis[i].getElementsByTagName('A')[0].onmouseout = function() {
							releaseSub(this);
						}
					}
				}
			}
		}
	}
	
	if(theDmenu) {
		// corrections for browser dependable placing of i-frames 
		theWOffset = 0;
		theYOffset = 95;
		theXOffset = 20;
		if (navigator.appVersion.indexOf("MSIE")!=-1) {
			theWOffset = -2;
			theYOffset = 92;
			theXOffset = 223;
			if (navigator.appVersion.indexOf("7.")!=-1) {
				theWOffset = -2;
				theYOffset = 92;
				theXOffset = 121;
			}
		} else if (navigator.appVersion.indexOf("Safari")!=-1) {
			theXOffset = 129;
		} else if (navigator.userAgent.indexOf("Opera")!=-1 && (navigator.userAgent.indexOf('Win') != -1)) {
			theXOffset = 156;
		}
		initIframes(theDmenu);
		//document.body.onresize = initIframes(theDmenu);
	}
}		

// add drop functionality to menu items
function toggleMenu() {
	for (i=0; i<theMenuLis.length; i++) {
		if (theMenuLis[i].tagName == 'LI') {
			for (j=0; j<theMenuLis[i].childNodes.length; j++) {
				if (theMenuLis[i].childNodes[j].tagName == 'A') {
					if (theMenuLis[i].childNodes[j+2]) {
						theMenuLis[i].childNodes[j].count = i;
						theMenuLis[i].childNodes[j].onmouseover = function () {
							this.parentNode.getElementsByTagName('UL')[0].style.display = 'block';
							document.getElementById(this.count).style.display = 'block';
						}
						theMenuLis[i].childNodes[j].onmouseout = function () {
							this.parentNode.getElementsByTagName('UL')[0].style.display = 'none';
							document.getElementById(this.count).style.display = 'none';
						}
						theMenuLis[i].childNodes[j].onclick = function () {
							//return false; /* wtf is this for?? */
						}
					}
				}
				if (theMenuLis[i].childNodes[j].tagName == 'UL') {
					theMenuLis[i].childNodes[j].count = i;
					theMenuLis[i].childNodes[j].onmouseover = function () {
						this.style.display = 'block';
						document.getElementById(this.count).style.display = 'block';
					}
					theMenuLis[i].childNodes[j].onmouseout = function () {
						this.style.display = 'none';
						document.getElementById(this.count).style.display = 'none';
					}
				}
			}
		}
	}
}


// build i-frames to block possible form dropdowns
function initIframes(theMenuUl) {
	theMenuUl.parentNode.parentNode.style.backgroundColor = 'transparent';
	theMenuUl.parentNode.parentNode.style.marginBottom = '0px';
	document.getElementById('contentHolder').style.margin = '0px';
	theMenuLis = theMenuUl.childNodes;
	theBody = document.getElementById('dropdown');
	for (i=0; i<theMenuLis.length; i++) {
		if (theMenuLis[i].tagName == 'LI') {
			for (k=0; k<theMenuLis[i].childNodes.length; k++) {
				if (theMenuLis[i].childNodes[k].tagName == 'UL') {
					//alert(theMenuLis[i].childNodes[k].className);
						theMenuLis[i].childNodes[k].style.visibility = "hidden";
						theMenuLis[i].childNodes[k].style.display = 'block';
						theMenuLis[i].childNodes[k].style.left = theMenuLis[i].getElementsByTagName('A')[0].offsetLeft + 'px';
						iframe = document.createElement('iframe');
						iframe.frameBorder = 0;
						iframe.scrolling = 'no';
						/* test iframe position / height */
						iframe.id = i;
						iframe.src = 'about:blank';
						iframe.style.position = 'absolute';
						iframe.style.zIndex = '2';
						iframe.width = theMenuLis[i].childNodes[k].offsetWidth - 2 + theWOffset + 'px';
						iframe.height = theMenuLis[i].childNodes[k].offsetHeight - 2 + theWOffset + 'px';
						iframe.style.top = findPosY(theMenuLis[i].getElementsByTagName('A')[0]) - theYOffset + 'px';
						//iframe.style.left = findPosX(theMenuLis[i].getElementsByTagName('A')[0]) - theXOffset +'px';
						iframe.style.left = theMenuLis[i].getElementsByTagName('A')[0].offsetLeft + "px";
						iframe.style.display = 'none';
						//iframe.style.border = '20px solid #ff0000';
						theBody.appendChild(iframe);
						theMenuLis[i].childNodes[k].style.visibility = "visible"
						theMenuLis[i].childNodes[k].style.display = 'none'
				}
			}
		}
	}
	toggleMenu();			
}


function showSub(xx) {
	// verberg open subs indien andere subs open zijn
	for(i=0;i<theLis.length;i++) {
		if(theLis[i].tagName == 'LI') {
			for(j=0;j<theLis[i].childNodes.length;j++) {
				if(theLis[i].childNodes[j].tagName == 'UL') {
					theLis[i].getElementsByTagName('A')[0].className = theLis[i].getElementsByTagName('A')[0].className.replace(/ hi/,'');
					theLis[i].childNodes[j].style.visibility = 'hidden';
				}
			}
		}
	}
	resetSub();
	xx.parentNode.getElementsByTagName('UL')[0].style.visibility = 'visible';			
}

function resetSub() {
	if (timerID2!=null) clearTimeout(timerID2);
}

function releaseSub(yy) {
	timerID2=setTimeout('hideSub()',6000)
}

function hideSub() {
	for(i=0;i<theLis.length;i++) {
		if(theLis[i].tagName == 'LI') {
			for(j=0;j<theLis[i].childNodes.length;j++) {
				if(theLis[i].childNodes[j].tagName == 'UL') {
					theLis[i].getElementsByTagName('A')[0].className = theLis[i].getElementsByTagName('A')[0].className.replace(/ hi/,'');
					theLis[i].childNodes[j].style.visibility = 'hidden';
				}
			}
		}
	}
	resetSub();
}

function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x){
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
	


