var br;

if ( navigator . appName == 'Netscape' && document . layers != null ) {
	br = "NS";
}
else if ( navigator . appName == 'Microsoft Internet Explorer' && document . all != null ) {
	br = "IE";
}
else {
	br = null ;
}

var bgColorOff  = "#eef7ff";
var bgColorOver = "#a2bed6";
var menuWidth   = 220;
var fromTop     = 139;


//-----------------------------------------------------
//  Show the drop down menu 
//  expected arg is active div
//----------------------------------------------------
function showDDNav() {
	args = showDDNav.arguments;
	if( br == "NS" ){
		var args, theObj;
		args = showDDNav.arguments;
		theObj = eval( args[2] );
  		if( theObj ) {
			if( theObj.visibility == 'hide' ) {
				theObj.visibility = 'show';
			}
		}
	}
	else if( br=="IE" ){
		theObj = eval( args[1] );
		if (theObj) {
			if( theObj.style.visibility == 'hidden' ) {
				theObj.style.visibility = 'visible';
				theObj.style.border = 'solid darkblue 1px';
				if (args[0]!='') {
					light_link(eval(args[0]));
				}
			}
		}
	}
	else { 
		return;
	}
}

//----------------------------------------------------
//  Hide the drop down menu 
//  expected arg is active div 
//----------------------------------------------------
function hideDDNav() {
	args = hideDDNav.arguments;
	if( br == "NS" ){
		var args, theObj;
		args = hideDDNav.arguments;
		theObj = eval( args[2] );
		if( theObj ) {
			if( theObj.visibility=='show' ) {
				theObj.visibility = 'hide';
			}
		}
	}
	else if( br == "IE" ){
		theObj = eval( args[1] );
			// calculate active size of menu
		leftDiv	= theObj.offsetLeft +2
		rightDiv	= theObj.offsetLeft + theObj.clientWidth -2
		topDiv	= theObj.offsetTop +2
		bottomDiv	= theObj.offsetTop + theObj.clientHeight -2
		if( window.event.clientY > bottomDiv || 
			window.event.clientY < topDiv || 
			window.event.clientX < leftDiv || 
			window.event.clientX > rightDiv) {
				theObj.style.visibility = 'hidden';
				dark_link();
			}
	}
	else{
		return
	}
}

//----------------------------------------------------
//  MenuItemOver
//  expected arg is active menuitem
//----------------------------------------------------
function menuOver() {
	var argsNS, theMenu;
	argsNS = menuOver.arguments;
	argsIE = menuOver.arguments;
	if( br == "NS" ) {
		theMenu = eval( argsNS[0] );
		theMenu.bgColor = bgColorOver;
	}
	else if( br == "IE") {
		theObj = eval( argsIE[0] );
		theObj.style.backgroundColor = bgColorOver;
	}
	else {
		return;
	}
}

//----------------------------------------------------
//  MenuItemOut
//  expected arg is active menuitem
//----------------------------------------------------
function menuOut() {
	var argsNS, theMenu;
	argsNS = menuOut.arguments;
	argsIE = menuOut.arguments;
	if( br == "NS" ) {
		theMenu = eval( argsNS[0] );
		theMenu.bgColor = bgColorOff;
	}
	else if ( br == "IE" ) {
		theObj = eval( argsIE[0] );
		theObj.style.backgroundColor = bgColorOff;
	}
	else { 
		return;
	}
}

//----------------------------------------------------
//  Redirect to specified url
//  expected arg is url 
//----------------------------------------------------
function gotoUrl() {
	args = gotoUrl.arguments;
	location.href = args[0]
}

//-----------------------------------------------------
//  MSIE: build the divs 
//  expected args are 'div name','x in menudata aray',
//  'menu left coord','arrow alignment','top in pixels' 
//-----------------------------------------------------
var tdID = 0
function doDiv() {
	args			= doDiv.arguments;
	var divID		= args[0];
	var x			= args[1];
	var fromLeft	= args[2];
	
		// Display the submenu box
	objDiv  = "<div " +
		"id = \"" + divID + "\" " +
		"style = \" " +
			"position: absolute; " +
			"left: "+ fromLeft +"px; " +
			"top:  "+ fromTop +"px; " +
			"width: "+ menuWidth +"px; " +
			"z-index: 1; " +
			"background-color: " + bgColorOff + "; " + 
			"visibility: hidden; " +
			"padding-right: 0;\" " +
			"onMouseover = \"showDDNav('','document.all[ \\'"+ divID +"\\' ]' )\"  " +
			"onMouseout  = \"hideDDNav('','document.all[ \\'" + divID + "\\' ]' )\">"

		// Display the first blank cell
	objDiv +="<div " +
		"id = blank1 " +
		"style = \" " +
			"position: relative; " +
			"height: 10px; \"><img " +
			"src=menu/dummy.gif width=1 height=1></div>";
	
		// Build the menu box
	for( y = 0; y < 20; y++ ) {
		if( menuData[x][y][0]!=null ) {
				// Display the blue line
			objDiv += "<div " +
				"id = line " +
				"style= \"" +
					"position: relative; " +
					"height: 001px; \"><img " +
					"src=menu/blue.jpg width="+ menuWidth +"px height=1></div>";
				// Display a cell for each menu item
			objDiv += "<div " +
				"id= \"x" + tdID + "\" " +
				"style= \"" +
					"position: relative; " +
					"padding-top: 1;\" " +
					"background-color: " + bgColorOff + "; " +
					"width: "+ menuWidth +"px;\" " +
					"onMouseover = \"menuOver( 'document.all[ \\'x" + tdID + "\\' ]' )\" " +
					"onMouseout  = \"menuOut( 'document.all[ \\'x" + tdID + "\\' ]' )\"><span " +
					"class= \"nav\" " +
					"onClick = \"gotoUrl( '"+menuData[x][y][1]+"' )\"><img " +
					"src=menu/dummy.gif width=4 height=1 border=0><img " +
					"src=menu/ar_right.gif vspace=5 align=absmiddle border=0><img " +
					"src=menu/dummy.gif width=2 height=1 border=0>"+ menuData[x][y][0] +"</span></div>"
			tdID = tdID +1
		}
	}
	
		// Display the second blank cell
	objDiv +="<div " +
		"id = blank2 " +
		"style = \" " +
			"position: relative; " +
			"height: 10px; \"><img " +
			"src=menu/blue.jpg width="+ menuWidth +" height=1></div></div>";
	
	document.write(objDiv);
}

//-----------------------------------------------------
//  NETSCAPE: build the layers 
//  expected args are 'div name','x in menudata aray',
//  'menu left coord','arrow alignment','top in pixels' 
//-----------------------------------------------------
function doLayer(){
	args			= doLayer.arguments;
	var nestLayerID	= 0
	var layerID		= args[0];
	var x			= args[1];
	var fromLeft	= args[2];

	if( navigator.platform.indexOf("Win") < 0) {
		layerInc	= 16;
		layerStyle	= "netMenuMac";
	}
	else {
		layerInc	= 19;
		layerStyle	= "netMenu";
	}	

		// Display the menu box
	objDiv = "<layer " +
		"id = \""+ layerID +"\" " +
		"z-index = 5 " +
		"bgcolor = " + bgColorOff + " " +
		"width = " + menuWidth + " " +
		"left = "+ fromLeft +" " +
		"top = "+ fromTop +" " +
		"visibility = hide " +
		"onmouseover = \"showDDNav( '','document.layers[ \\'"+ layerID +"\\' ]' )\" " +
		"onmouseout = \"hideDDNav( '','document.layers[ \\'"+ layerID +"\\' ]' )\">"

		// Display content for the blank cell 
	objDiv += "<layer " +
		"id = blank1 " +
		"z-index = 1 " +
		"bgcolor = " + bgColorOff + " " +
		"width = " + menuWidth + " " +
		"height = 10 " +
		"top = 0><font face=Arial size=1 color=#000000></font></layer>"

		// Display the blue line 
	objDiv += "<layer " +
		"id = line1 " +
		"z-index = 3 " +
		"bgcolor = " + bgColorOff + " " +
		"width = " + menuWidth + " " +
		"height = 1 " +
			// Control the height of the first blank cell
		"top = 10><img " +
		"src=menu/blue.jpg width=" + menuWidth + " height=1 border=0 vspace=0></layer>"

		// Control the height of the first menu cell
		// from top plus the blue line height
	var nestTop=11  

		// Display next menu cell for each item
	for ( y = 0; y < 15; y++ ) {
		if( menuData[x][y][0]!=null ) {
		objDiv += "<layer " +
			"id = \"x" + nestLayerID + "\" " +
			"z-index = 2 " +
				// Control the hilighted area
				// from left, from top( first cell ), width, height( last cell )
			"clip = \"0,-1," + menuWidth + ",20\" " +
			"class = \""+ layerStyle +"\" " +
			"bgcolor = " + bgColorOff + " " +
			"width = " + menuWidth + " " +
			"top = "+ nestTop +" " +
			"onmouseover = \"menuOver( 'document.layers[ \\'"+ layerID +"\\' ].document.layers[ \\'x"+nestLayerID+"\\' ]' )\" " +
			"onmouseout = \"menuOut( 'document.layers[ \\'"+ layerID +"\\' ].document.layers[ \\'x"+nestLayerID+"\\' ]' )\"><a " +
			"href = javascript:gotoUrl('" + menuData [x][y][1] + "')><img " +
			"src=menu/ar_right.gif vspace=0 border=0><img " +
			"src=menu/dummy.gif width=2 height=1 border=0><font " +
			"face=Arial size=1 color=#000000>" + menuData[x][y][0] + "</font></a></layer>"		

	nestLayerID = nestLayerID + 1
	nestTop = nestTop + layerInc

		// Display blue line after each menu item
	objDiv += "<layer " +
		"id = line2 " +
		"z-index = 7 " +
		"bgcolor = " + bgColorOff + " " +
		"width = " + menuWidth + " " +
		"height = 1 " +
		"top = "+ nestTop +"><div align=right><img " +
		"src=menu/blue.jpg width=" + menuWidth + " height=1 border=0 vspace=0></div></layer>"
	nestTop=nestTop+2
			}
		}

		// Display the second blank cell
	objDiv += "<layer " +
		"id = blank2 " +
		"bgcolor = " + bgColorOff + " " +
		"width = " + menuWidth + " " +
		"height = 10 " +
		"z-index = 7 " +
		"top = "+ nestTop +"></layer></layer>"

	document.write(objDiv)

}
