/*----------------------------------------------------
// dd_functions.js
//--------------------------------------------------*/

// define menu attributes here
//menuColorOff="#ffffff"
menuColorOff="#dddddd"

menuColorOn="#072072"
fontColorOff="#000000"
fontColorOn="#ffffff"

lineColor = "#000000"
baseMenuColor = "#000000"

separator="<img src=images/spacer.gif height=1 width=1>"

//*---------------------------------------------------
// shows the drop down menu 
// expected arg is active div
//--------------------------------------------------*/
function showDDNav(ind){
	var args, theObj;
	args = showDDNav.arguments;
	if(br=="N"){
		theObj = eval("document.layers['" + ind + "']");
  		if (theObj) if(theObj.visibility=='hide'){theObj.visibility = 'show';}
	}
	else if(br=="N6"){
		theObj=eval("document.getElementById('" + ind + "')");
		if (theObj){ 			
			if(theObj.style.visibility=='hidden'){theObj.style.visibility = 'visible';}
		}
	}
	else if(br=="IE"){
		theObj=eval("document.all['" + ind + "']");
		if (theObj){ 			
			if(theObj.style.visibility=='hidden'){theObj.style.visibility = 'visible';}
		}
	}	
	else{return}
}

//*---------------------------------------------------
// hides the drop down menu 
// expected arg is active div 
//--------------------------------------------------*/
function hideDDNav(ind){
	var args, theObj;
	args = hideDDNav.arguments;
	if(br=="N"){
		theObj = eval("document.layers['" + ind + "']");
		if (theObj) if(theObj.visibility=='show'){theObj.visibility = 'hide';}
	}
	else if(br=="N6"){
		theObj=eval("document.getElementById('" + ind + "')");
		if (theObj) if(theObj.style.visibility=='visible'){theObj.style.visibility = 'hidden'}
		}
	else if(br=="IE"){
		theObj=eval("document.all['" + ind + "']");
		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=="N6") {
		theObj=args[0];
		eval("document.getElementById('" + theObj + "').style.backgroundColor=menuColorOn;")
		eval("document.getElementById('" + theObj + "').style.color=fontColorOn;")
		}
	else if(br=="IE") {
		theObj=eval(args[0]);
		theObj.style.backgroundColor=menuColorOn;
		theObj.style.color=fontColorOn;		
		}
	else{return}
}

//*---------------------------------------------------
// highlight off menuitem
// expected arg is active menuitem
//--------------------------------------------------*/
function divOut(){
	args = divOut.arguments;
	
	if(br=="N"){}
	else if(br=="N6") {
		theObj=args[0];
		eval("document.getElementById('" + theObj + "').style.backgroundColor=menuColorOff;")
		eval("document.getElementById('" + theObj + "').style.color=fontColorOff;")
		}
	else if(br=="IE") {
		theObj=eval(args[0]);
		theObj.style.backgroundColor=menuColorOff;
		theObj.style.color=fontColorOff;
		}
	else{return}
}

//*---------------------------------------------------
// highlight on menuitem in netscape
// expected arg is active menuitem
//--------------------------------------------------*/
function menuOver(){
	var args, theMenu;
	args = menuOver.arguments;

	daObj = "document.layers['" + args[0] + "'].document.layers['" + args[1] + "']"
	theMenu = eval(daObj)
	theMenu.bgColor=menuColorOn;
	
	rep_mDxy = args[3].replace("~~","'")
	daString = "<table width=100 cellspacing=0 cellpadding=0 border=0><tr><td width=100 class=\"newNetMenu\"><center><a id=navstyle href=javascript:gotoUrl('"+ args[2] +"')><font color='" + fontColorOn + "'>"+ rep_mDxy + "</font></a></center></td></tr></table>"
	writeToLayer(theMenu,daString)
}

//*---------------------------------------------------
// highlight off menuitem in netscape
// expected arg is active menuitem
//--------------------------------------------------*/
function menuOut(){//alert("in menuOut")
	var args, theMenu;
	args = menuOut.arguments;
	daString = "document.layers['" + args[0] + "'].document.layers['" + args[1] + "']"
	theMenu = eval(daString);
	theMenu.bgColor=menuColorOff;

	rep_mDxy = args[3].replace("~~","'")
	daString = "<table width=100 cellspacing=0 cellpadding=0 border=0><tr><td width=100 class=\"newNetMenu\"><center><a id=navstyle href=javascript:gotoUrl('"+ args[2] +"')><font color='" + fontColorOff + "'>"+ rep_mDxy + "</font></a></center></td></tr></table>"
	writeToLayer(theMenu,daString)
}

//-----------------------
function writeToLayer(obj,content)
{
	if(br=="IE") document.all[''+obj+''].innerHTML = content;//needs work
	else if(br=="N"){
		//sprite=document.layers[''+obj+''].document;
		sprite=obj.document;
		sprite.open();
		sprite.write(content);
		sprite.close();
		}
	else if(br=="N6"){			//needs work
		rng = document.createRange();
		el = document.getElementById(''+obj+'');
		rng.setStartBefore(el);
		htmlFrag = rng.createContextualFragment(content)
		while(el.hasChildNodes()) el.removeChild(el.lastChild);
		el.appendChild(htmlFrag);
		}
}

//*---------------------------------------------------
// goes to specified url
// expected arg is url 
//--------------------------------------------------*/
//function gotoUrl(){
function gotoUrl(loc){

/*
	args = gotoUrl.arguments;
	var CM_RefferingURL, CM_Location, CM_Exists;
	CM_ReferringURL = window.location.href;
	CM_ReferringURL = CM_ReferringURL.split("&referringurl=");
	CM_ReferringURL = CM_ReferringURL[0].split("?referringurl=");
	CM_Exists = args[0].indexOf('?');
	
	if (CM_Exists == -1) {
		CM_Location = args[0] + '?referringurl=' + escape(CM_ReferringURL[0])
	}
	else {
		CM_Location = args[0] + '&referringurl=' + escape(CM_ReferringURL[0])
	}
	location.href = (CM_Location)
	
*/
location.href = loc;

}

//*---------------------------------------------------
// 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:102px; z-index:5; top:"+ divTop +"px; left: " + divLeft + "; background-color: " + baseMenuColor + "; border:0 solid #A0A0A0; visibility: hidden;\" onMouseover=\"showDDNav('"+ divID +"')\"  onMouseout=\"hideDiv('" + divID + "')\">"
	
	for (y = 0; y < 15; y++){
	    if(menuData[x][y][0]!=null){
		objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:100px; z-index:8; left: 1; background-color:" + lineColor + ";\">" + separator + "</div>"
		objDiv += "<div id=\"x" + tdID + "\" style=\"position:relative; width:100px; z-index:8; left: 1; background-color:" + menuColorOff +";\" onMouseover=\"divOver('x" + tdID + "')\" onMouseout=\"divOut('x" + tdID + "')\" class=\"dhtmlNav\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\"><center>&nbsp;"+ menuData[x][y][0] +"&nbsp;</center></div>"
		tdID = tdID +1
		}
	}
	objDiv += "<div id=\"bar\" style=\"position:relative;    height:1px; width:100px; z-index:8; left: 1; background-color:" + lineColor + ";\">" + separator + "</div>"
	objDiv += "</div>"
	document.write(objDiv);
}


//*---------------------------------------------------
// build the divs for IE
// expected args are 'div name','x in menudata aray',
// 'menu left coord','top in pixels' 
//--------------------------------------------------*/
var tdID = 0
function doN6Div(){
	args = doN6Div.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:102px; z-index:5; top:"+ divTop +"px; left: " + divLeft + "; background-color: " + baseMenuColor + "; border:1 solid #A0A0A0; visibility: hidden;\" onMouseover=\"showDDNav('"+ divID +"')\"  onMouseout=\"hideDDNav('" + divID + "')\">"
	objDiv += "<div id=\"spacer\" style=\"position:relative; height:1px; width:100px; z-index:8; left: 1; 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:100px; z-index:8; left: 1; background-color:" + lineColor + ";\">" + separator + "</div>"
		objDiv += "<div id=\"x" + tdID + "\" style=\"position:relative; background-color:"+ menuColorOff +"; width:100px; z-index:8; left: 1;\" onMouseover=\"divOver('x" + tdID + "')\" onMouseout=\"divOut('x" + tdID + "')\" class=\"dhtmlNav\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\"><center>&nbsp;"+ menuData[x][y][0] +"&nbsp;</center></div>"
		tdID = tdID +1
		}
	}
	objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:100px; z-index:8; left: 1; background-color:" + lineColor + ";\">" + separator + "</div>"
	objDiv += "<div id=\"spacer\" style=\"position:relative; height:1px; width:100px; z-index:8; left: 1; 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' 
//--------------------------------------------------*/

layerStyle = ""

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=5 BGCOLOR=\""+ baseMenuColor +"\" WIDTH=102 LEFT="+ layerLeft +" TOP="+ layerTop +" VISIBILITY=HIDE onmouseover=\"showDDNav('"+ layerID +"')\" onmouseout=\"hideDDNav('"+ layerID +"')\">"
	
	var nestTop=0
		for (y = 0; y < 15; y++){
		    if(menuData[x][y][0]!=null){

			mDxy0 = menuData[x][y][0]
			mDxy1 = menuData[x][y][1]
			rep_mDxy0 = mDxy0.replace("'","~~")
			rep_mDxy1 = mDxy1.replace("'","~~")

			objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=100 HEIGHT=1 Z-INDEX=8 LEFT=1 TOP="+ nestTop +">"+ separator +"</layer>"
			objDiv += "<layer id=\"x"+nestLayerID+"\" class=\""+ layerStyle +"\" Z-INDEX=7 BGCOLOR=\""+ menuColorOff +"\" HEIGHT=17 WIDTH=100 LEFT=1 TOP="+ nestTop + " onmouseover=\"menuOver('" + layerID + "','x" + nestLayerID + "','" + rep_mDxy1 + "','" + rep_mDxy0 + "')\" onmouseout=\"menuOut('" + layerID + "','x" + nestLayerID + "','" + rep_mDxy1 + "','" + rep_mDxy0 + "')\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\"><center><a id=navstyle  href=javascript:gotoUrl('"+menuData[x][y][1]+"')><font color='" + fontColorOff + "'>"+ menuData[x][y][0]
			
			
			objDiv +="</font></a></center></layer>"		
			nestLayerID=nestLayerID+1
			nestTop=nestTop+layerInc+1
			}
		}
		objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=100 LEFT=1 HEIGHT=1 Z-INDEX=8 TOP="+ nestTop +">"+ separator +"</layer></layer>"
		objDiv +="<layer id=\"lineEnd\" BGCOLOR=\""+ menuColorOff +"\" WIDTH=102 HEIGHT=1 Z-INDEX=7 TOP="+ nestTop +"></layer></layer>"

	document.write(objDiv)
}

//*---------------------------------------------------
// What's New Pop-up function
//--------------------------------------------------*/

function WhatsNew_PopUp() {
	PopUpWindow = window.open("", "WhatsNew_PopUp",
		"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=480,height=281,left=100,top=100");
	PopUpWindow.focus();
}

function Tutorial_PopUp() {
	PopUpWindow = window.open("", "Tutorial_PopUp",
		"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=520,height=300,left=100,top=100");
	PopUpWindow.focus();
}