var ns=document.layers;
var ie=document.all;
var ie5=document.uniqueID;	// uniqueID = explorer 5+, wordt gebruikt om 
var mac = navigator.platform.toString().toLowerCase().indexOf('mac')!=-1;
var ns6=(!ns && !ie && (parseInt(navigator.appVersion) > 4));
var cur_menu
var menuTimer=null
var menuCount=1;

if (typeof(rootDir)=='undefined') { rootDir = '../' }

if (ie) {
	document.write('<link rel="STYLESHEET" type="text/css" href="' + rootDir + 'css/style_ie.css">');
} else {
	document.write('<link rel="STYLESHEET" type="text/css" href="' + rootDir + 'css/style_ns.css">');
}

function writeMenu(menu) {
	if (!menu) return;
	
	menuHeight = ((menu.length)/2) * menuSubItemHeight + 4;
	if (ie || document.getElementById) {
		document.write('<div id="menu' + menuCount + '" style="position: absolute; top: ' + (menuSubTop + (menuCount-1)*menuItemHeight) + 'px; left: ' + menuSubLeft + 'px; width: 131px; height: 44px; visibility: hidden; z-index: 100;" onmouseover="resetMenuTimer()" onmouseout="hideMenuTimed()">');
	} else {
		document.write('<LAYER LEFT="' + menuSubLeft + '" TOP="' + (menuSubTop + (menuCount-1)*menuItemHeight) + '" width="131" NAME="menu' + menuCount + '" visibility="hide" z-index="100" onmouseover="resetMenuTimer()" onmouseout="hideMenuTimed()">');
	}
	document.write('<table cellspacing="0" cellpadding="0" border="0" width="131" height="' + (menuHeight+2) + '" bgcolor="white">');
	document.write('<tr>');
	document.write('<td align="center">');
	document.write('<table cellspacing="0" cellpadding="0" border="0" width="129" height="' + menuHeight + '" bgcolor="' + submenuColorBack + '">');
	document.write('<tr>');
	document.write('<td colspan="3"><img src="' + strSpacer + '" width="1" height="2" alt="" border="0"></td>');
	document.write('</tr>');
	for (i=0; i< menu.length; i+=2) {
		document.write('<tr>');
		document.write('<td><img src="' + strSpacer + '" width="8" height="1" alt="" border="0"></td>');
		document.write('<td width="105"><a href="' + rootDir + menu[i+1] + '" class="SubMenuItem">' + menu[i] + '</a></td>');
		document.write('<td><img src="' + strSpacer + '" width="8" height="1" alt="" border="0"></td>');
		document.write('</tr>');
	}
	document.write('<tr>');
	document.write('<td colspan="3"><img src="' + strSpacer + '" width="1" height="2" alt="" border="0"></td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
	if (ie || document.getElementById) {
		document.write('</div>');
	} else {
		document.write('</layer>');
	}
	
	menuCount+=1;
} 

function createLinks(linkArray) {
	linkCount = linkArray.length/2;
	
	if (linkVAlign) {
		if (linkVAlign=="bottom") {	
			topMargin = linkMaxHeight - (linkCount * linkItemHeight);
		} else {
			topMargin = Math.floor((linkMaxHeight - (linkCount * linkItemHeight)) / 2);
		}
	} else {
		topMargin = Math.floor((linkMaxHeight - (linkCount * linkItemHeight)) / 2);
	}

	if (ie || document.getElementById) {
		document.write('<div id="Links" style="position: absolute; top: ' + (linkTop + topMargin) + 'px; left: ' + linkLeft + 'px; width: ' + linkWidth + 'px; height: ' + (linkCount * linkItemHeight) + 'px; visibility: visible; z-index: 1;">');
	} else {
		document.write('<LAYER LEFT="' + linkLeft + '" TOP="' + (linkTop + topMargin) + '" width="' + linkWidth + '" NAME="Links" visibility="show" z-index="100">');
	}
	document.write('<table border="0" cellspacing="0" cellpadding="0" width="' + linkWidth + '">');
	for (i=0; i < linkArray.length; i+=2) {
		document.write('<tr>');
		document.write('<td height="' + linkItemHeight + '"><a href="' + linkArray[i+1] + '">' + linkArray[i] + '<img src="' + linkArrow + '" width="10" height="10" border="0"></a></td>');
		document.write('</tr>');
	}	
	document.write('</table>');
	if (ie || document.getElementById) {
		document.write('</div>');
	} else {
		document.write('</layer>');
	}
}

function resetMenuTimer() {
	if (menuTimer!=null) {
		clearTimeout(menuTimer)
		menuTimer!=null
	}
}

function showMenuTimed(menu) {
	if (menuTimer!=null) clearTimeout(menuTimer)
	menuTimer=setTimeout("showMenu(" + menu + ")", 100)
}

function hideMenuTimed() {
	if (menuTimer!=null) clearTimeout(menuTimer)
	menuTimer=setTimeout("hideMenu()", 1000)
}

function showMenu(menu) {
	resetMenuTimer()
	hideMenu()
	if (ie || document.getElementById) {	//voor NS6+, IE3+ en IE op de Mac
		if (ie) {
			theObj = document.all('menu'+menu);  //IE3 en IE op de Mac
			theRow = eval('menuRow'+menu);
			theItem = eval('menuItem'+menu);
		} else {
			theObj = document.getElementById('menu'+menu); //NS6+
			theRow = document.getElementById('menuRow'+menu);
			theItem = document.getElementById('menuItem'+menu);
		}
		if (theObj) { theObj.style.visibility = 'visible'; }
		theRow.style.backgroundColor = menuColorHighlight //'#69A6A2';
		theItem.style.color = menuTextColorHighlight;
	} 
	else {
		if (eval('document.menu'+menu)) { eval('document.menu'+menu+'.visibility = "show"'); }
	}
	cur_menu = menu;
}

function hideMenu() {
	if (cur_menu) {
		if (ie || document.getElementById) {	//voor NS6+, IE3 en IE op de Mac
			if (ie) {
				theObj = document.all('menu'+cur_menu);  //IE3 en IE op de Mac
				theRow = eval('menuRow'+cur_menu);
				theItem = eval('menuItem'+cur_menu);
			} else {
				theObj = document.getElementById('menu'+cur_menu); //NS6+
				theRow = document.getElementById('menuRow'+cur_menu);
				theItem = document.getElementById('menuItem'+cur_menu);
			}
			if (theObj) { theObj.style.visibility = 'hidden'; }
			theRow.style.backgroundColor = menuColorBack; //'#80C0BC';
			theItem.style.color = menuTextColor;
		} 
		else {
			if (eval('document.menu'+cur_menu)) { eval('document.menu'+cur_menu+'.visibility = "hide"'); }
		}
	}
	cur_menu=null;
}

function openWindow(htmlFile,windowName,params) {
	window.open(htmlFile,windowName,params)
	return;
}
