// define menu attributes here
menuColor="#ffcc33"
menuColorOn="#ff9900"
fontColorOn="blue"
fontColorOff="blue"
lineColor = "#ffcc33"
layerWidth=200		//layer width
layerWidth1=180		//highlight width
layerWidth2=180		//text width

separator="<img src=blank.gif height=1 width=1>"


//*---------------------------------------------------
// shows the drop down menu 
// expected arg is active div
//--------------------------------------------------*/
function showDDNav(){
	args = showDDNav.arguments;
	if(br=="N"){
		var args, theObj;
		args = showDDNav.arguments;
		theObj = eval(args[1]);
  		if (theObj) if(theObj.visibility=='hide'){theObj.visibility = 'show';}
	}
	else if(br=="IE"){
		theObj=eval(args[0]);
		if (theObj){
			if(theObj.style.visibility=='hidden'){
				// activate hideElement to hide <select> boxes
				// hideElement('SELECT');
				theObj.style.visibility = 'visible'
			}
		}
	}
	else{return}
}

//*---------------------------------------------------
// hides the drop down menu 
// expected arg is active div 
//--------------------------------------------------*/
function hideDDNav(){
	args = hideDDNav.arguments;
	if(br=="N"){
		var args, theObj;
		args = hideDDNav.arguments;
		theObj = eval(args[1]);
		if (theObj) if(theObj.visibility=='show'){theObj.visibility = 'hide';}
	}
	else if(br=="IE"){
		theObj=eval(args[0]);
		if (theObj) if(theObj.style.visibility=='visible'){showElement('SELECT');theObj.style.visibility = 'hidden'}
		}
	else{return}
}

//*---------------------------------------------------
// hides drop down menu when menu is active
// expected arg is active menu
//--------------------------------------------------*/
function hideDiv(){
	args = hideDiv.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		theObj=eval(args[0]);
		// 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';
			 // activate showElement to show <select> menu's
			 //showElement('SELECT');
			}				
		}
	else{return}
}

//*---------------------------------------------------
// highlight menuitem
// expected arg is active menuitem
//--------------------------------------------------*/
function divOver(){
	args = divOver.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		theObj=eval(args[0]);
		theObj.style.backgroundColor=menuColorOn;
	}
	else{return}
}

//*---------------------------------------------------
// highlight off menuitem
// expected arg is active menuitem
//--------------------------------------------------*/
function divOut(){
	args = divOut.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		theObj=eval(args[0]);
		theObj.style.backgroundColor=menuColor;
	}
	else{return}
}

//*---------------------------------------------------
// highlight on menuitem in netscape
// expected arg is active menuitem
//--------------------------------------------------*/
function menuOver(){
	var args, theMenu;
	args = menuOver.arguments;
	theMenu = eval(args[0]);
	theMenu.bgColor=menuColorOn 
}

//*---------------------------------------------------
// highlight off menuitem in netscape
// expected arg is active menuitem
//--------------------------------------------------*/
function menuOut(){
	var args, theMenu;
	args = menuOut.arguments;
	theMenu = eval(args[0]);
	theMenu.bgColor=menuColor 
}

//*---------------------------------------------------
// goes to specified url
// expected arg is url 
//--------------------------------------------------*/
function gotoUrl(){
	args = gotoUrl.arguments;
	CM_Location = args[0]
	location.href = (CM_Location)
}

//*---------------------------------------------------
// hides specified tag
//--------------------------------------------------*/
function hideElement(HTMLtag)
{
	for (i = 0; i < document.all.tags(HTMLtag).length; i++)
	{
		obj = document.all.tags(HTMLtag)[i];
		obj.style.visibility = "hidden";
	}
}

//*---------------------------------------------------
// shows specified tag
//--------------------------------------------------*/
function showElement(HTMLtag)
{
	for (i = 1; i < document.all.tags(HTMLtag).length; i++)
	{
		obj = document.all.tags(HTMLtag)[i];
		obj.style.visibility = "visible";
	}
}

//*---------------------------------------------------
// build the divs for IE
// expected args are 'div name','x in menudata aray',
// 'menu left coord','top in pixels' 
//--------------------------------------------------*/
var tdID = 0
function doDiv(){
	args = doDiv.arguments;
	var divID = args[0];
	var x = args[1];
	var divLeft = args[2];
	var divTop = args[3];
	objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; width:" + layerWidth + "; z-index:12; top:"+ divTop +"px; left: " + divLeft + "; background-color: #ffcc33; border:2 outset #ffcc33; visibility: hidden;\" onMouseover=\"showDDNav('document.all[\\'"+ divID +"\\']')\"  onMouseout=\"hideDiv('document.all[\\'" + divID + "\\']')\">"
	objDiv += "<div id=\"spacer\" style=\"position:relative; height:6px; width:10px; z-index:3; left: 5; font-size:1;\"></div>"
	
	for (y = 0; y < 15; y++){
	    if(menuData[x][y][0]!=null){
		objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:10px; z-index:13; left: 5; background-color:" + lineColor + ";\">" + separator + "</div>"
		objDiv += "<div id=\"x" + tdID + "\" style=\"position:relative; background-color:"+ menuColor +"; width:" + layerWidth1 + "; z-index:3; left: 5;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']')\" style=\"font-family: Arial, Helvetica, sans-serif; font-size: x-small; font-weight: bold; color: blue; text-decoration: none; cursor:hand; line-height:15px;\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\">&nbsp;"+ menuData[x][y][0] +"&nbsp;</div>"
		tdID = tdID +1
		}
	}
	objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:10px; z-index:14; left: 5; background-color:" + lineColor + ";\">" + separator + "</div>"
	objDiv += "<div id=\"spacer\" style=\"position:relative; height:6px; width:" + layerWidth2 + "; z-index:3; left: 5; font-size:1;\"></div></div>"
	
	document.write(objDiv);
}


//*---------------------------------------------------
// build the layers for netscape
// expected args are 'div name','x in menudata aray',
// 'menu left coord','top in pixels' 
//--------------------------------------------------*/
function doLayer(){
	args = doLayer.arguments;
	var nestLayerID=0
	var layerID = args[0];
	var x = args[1];
	var layerLeft = args[2];
	var layerTop = args[3];

	if(navigator.platform.indexOf("Win") < 0){layerInc=16;layerStyle="netMenuMac";}
	else{layerInc=15;layerStyle="netMenu";}	
		
	objDiv = "<layer id=\""+ layerID +"\" Z-INDEX=12 BGCOLOR=\""+ menuColor +"\" WIDTH=\"" + layerWidth +"\" LEFT="+ layerLeft +" TOP="+ layerTop +" VISIBILITY=HIDE onmouseover=\"showDDNav('','document.layers[\\'"+ layerID +"\\']')\" onmouseout=\"hideDDNav('','document.layers[\\'"+ layerID +"\\']')\">"
	var nestTop=10
		for (y = 0; y < 15; y++){
		    if(menuData[x][y][0]!=null){
			objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=10 HEIGHT=1 Z-INDEX=8 LEFT=5 TOP="+ nestTop +">"+ separator +"</layer>"
			objDiv += "<layer id=\"x"+nestLayerID+"\" class=\""+ layerStyle +"\" Z-INDEX=17 BGCOLOR=\""+ menuColor +"\" HEIGHT=19 WIDTH=\"" + layerWidth1 +"\" LEFT=5 TOP="+ nestTop +" onmouseover=\"menuOver('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']')\" onmouseout=\"menuOut('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']')\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\"><a class='dd' href=javascript:gotoUrl('"+menuData[x][y][1]+"')><font color=" + fontColorOff + ">"+ menuData[x][y][0]
			objDiv +="</font></a></layer>"		
			nestLayerID=nestLayerID+1
			nestTop=nestTop+layerInc+1
			}
		}
		objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=10 LEFT=5 HEIGHT=1 Z-INDEX=18 TOP="+ nestTop +">"+ separator +"</layer>"
		objDiv +="<layer id=\"lineEnd\" BGCOLOR=\""+ menuColor +"\" WIDTH=\"" + layerWidth2 +"\" HEIGHT=8 Z-INDEX=17 TOP="+ nestTop +"></layer></layer>"

	document.write(objDiv)
}

// Dropdown menu position

var br
if(navigator.appName == "Netscape" && document.layers != null && navigator.appVersion.charAt(0)=="4"){br="N";}
else if(navigator.appName == "Microsoft Internet Explorer" && document.all != null){br="IE";}
else if(navigator.appName == "Netscape" && document.getElementById != null && navigator.appVersion.charAt(0)=="5"){br="N5";}
else{br=null}

function mOvr(src,clrOver) 
	{ if (!src.contains(event.fromElement)) 
	{ src.style.cursor = 'hand'; src.bgColor = clrOver; }}
function mOut(src,clrIn) 
	{ if (!src.contains(event.toElement)) 
	{ src.style.cursor = 'default'; src.bgColor = clrIn; }} 
function mClk(src) 
	{ if(event.srcElement.tagName=='TD')
	{src.children.tags('A')[0].click();} }


//=====================//
// SIMPLE CLOCK SCRIPT //
//=====================//
function clock(){
day = new Date();
hr = day.getHours();
mn = day.getMinutes();	
sc = day.getSeconds();
MyTime = hr+":"+mn+":"+sc
if (br=="N") document.forms[0].MyTime.value = MyTime;
if (br!="N") MyTimes.innerHTML = "<font color='white'><b>" + MyTime + "</b></font>"
setTimeout('clock()', 1000);
}
//----------------------//
// GetCookie(name)      //
//----------------------//
function GetCookie(name){
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen)
                {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                if (i == 0) break;
                }
        return null;
}

//------------------------//
// getCookieVal(offset)   //
//------------------------//
function getCookieVal (offset) {
        var endstr = document.cookie.indexOf (";", offset);
        if (endstr == -1)
                endstr = document.cookie.length;
        return unescape(document.cookie.substring(offset, endstr));
}

//--------------------------------------------------------------//
// SetCookie(name,value,expiration date,path,domain,security)   //
//--------------------------------------------------------------//
function SetCookie (name,value,expires,path,domain,secure) {
        document.cookie = name + "=" + escape (value) +
                        ((expires) ? "; expires=" + expires.toGMTString() : "") +
                        ((path) ? "; path=" + path : "") +
                        ((domain) ? "; domain=" + domain : "") +
                        ((secure) ? "; secure" : "");
}