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 (ie) {
//	document.write('<link rel="STYLESHEET" type="text/css" href="menuDemo/style_ie.css">');
//} else {
//	document.write('<link rel="STYLESHEET" type="text/css" href="menuDemo/style_ns.css">');
//}

function writeMenu(menu) {
	if ( !menu ) { return; }
  else if ( menu.length == 0 ) { menuCount++; 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="161" height="' + (menuHeight) + '" bgcolor="white" >');
	document.write('<tr>');
	document.write('<td bgcolor="' + menuColorBack + '"><img src="' + strSpacer + '" width="1" height="' + menuHeight + '" alt="" border="0"></td>');
	document.write('<td>');
	document.write('<table cellspacing="0" cellpadding="0" border="0" width="159" height="' + menuHeight + '" bgcolor="' + menuTextColor + '">');
	document.write('<tr><td bgcolor="' + menuColorBack + '" colspan="2"><img src="' + strSpacer + '" width="159" height="1" alt="" border="0"></td></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 align="left"><a href="' + menu[i+1] + '" class="SubMenuItem' + menuCount +'" style="color-hover=#FFFFFF;" >' + menu[i] + '</a></td>');
		document.write('</tr>');
		document.write('<tr><td bgcolor="' + menuColorBack + '" colspan="2"><img src="' + strSpacer + '" width="159" height="1" alt="" border="0"></td></tr>');
	}
	document.write('</table>');
	document.write('</td>');
	document.write('<td bgcolor="' + menuColorBack + '"><img src="' + strSpacer + '" width="1" height="' + menuHeight + '" alt="" border="0"></td>');
	document.write('</tr>');
	document.write('</table>');
	if (ie || document.getElementById) {
		document.write('</div>');
	} else {
		document.write('</layer>');
	}

	menuCount+=1;
}


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);
			theColor = eval('menuColorHighlight'+menu);
		} else {
			theObj = document.getElementById('menu'+menu); //NS6+
			theRow = document.getElementById('menuRow'+menu);
			theItem = document.getElementById('menuItem'+menu);
			theColor = document.getElementById('menuColorHighlight'+menu);
		}
		if (theObj) 
    {
      theObj.style.visibility = 'visible'; 
      theObj.style.top = theRow.offsetTop +
        theRow.offsetParent.offsetTop +
        theRow.offsetParent.offsetParent.offsetTop + 
        theRow.offsetParent.offsetParent.offsetParent.offsetTop; 
      theObj.style.left = theRow.offsetWidth;
    }
		theRow.style.backgroundColor = theColor //'#69A6A2';
		theItem.style.color = menuTextColorHighlight;
	}
	else {
		if (eval('document.menu'+menu)) { eval('document.menu'+menu+'.visibility = "show"'); }
	}
	cur_menu = menu;
}

function showMenuHoriz( 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 );
      theColor = eval( 'menuColorHighlight' + menu );
    }
    else
    {
      theObj = document.getElementById( 'menu' + menu ); //NS6+
      theRow = document.getElementById( 'menuRow' + menu );
      theItem = document.getElementById( 'menuItem' + menu );
      theColor = document.getElementById( 'menuColorHighlight' + menu );
    }

    // Override the position of the submenu
    if ( theObj )
    {
      theObj.style.visibility = 'visible';
      theObj.style.top = menuSubHorizTop + theRow.offsetHeight;
      theObj.style.left =
        theRow.offsetLeft + 
        theRow.offsetParent.offsetLeft + 
        theRow.offsetParent.offsetParent.offsetLeft;
    }

    theRow.style.backgroundColor = theColor //'#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;
}