// define menu attributes here
menuColor="#E4E1DC"
menuColorOn="#ffffff"
menuColorOn1="#ffffff";
fontColor="#000000"
fontColorOn="#660000"
fontColorOff="#ffffff"
lineColor = "#000000"
separator="<img src=/images/blank.gif height=1 width=1>"
var navObj
function showDDNav(){

	args = showDDNav.arguments;
	if (document.readyState != "complete")
	{
		return;}
	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'){
				
				theObj.style.visibility = 'visible';
				// sets global var for use by hideElement()
				navObj = eval(args[0]);
				// activate hideElement to hide <select> boxes
				hideElement('SELECT');
			}
		}
	}
	else{return}
}

function hideDDNav(){

	args = hideDDNav.arguments;
	if(br=="N"){
		var args, theObj;
		args = hideDDNav.arguments;
		theObj = eval(args[1]);
		if (theObj) if(theObj.visibility=='show'){showElement('SELECT');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}
}

function hideDiv(){

	args = hideDiv.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		theObj=eval(args[0]);
        	showElement('SELECT');
		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';
			 showElement('SELECT');
			}				
		}
	else{return}
}

function divOver(){
	args = divOver.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		theObj=eval(args[0]);
		if (theObj) {
			theObj.style.backgroundColor=menuColorOn;
theObj.style.color=fontColorOn;
theObj.style.fontWeight="bold";
		}
		hideElement('SELECT');
	}
	else{return}
}

function divOut(){
	args = divOut.arguments;
	if(br=="N"){}
	else if(br=="IE"){
	theObj=eval(args[0]);
	if (theObj) {
		theObj.style.backgroundColor=menuColor;
theObj.style.color=fontColor;
theObj.style.fontWeight="normal";
	}
		hideElement('SELECT');
	}
	else{return}
}

function menuOver(){
	var args, theMenu;
	args = menuOver.arguments;
	theMenu = eval(args[0]);
	theMenu.bgColor=menuColorOn 
}

function menuOut(){
	var args, theMenu;
	args = menuOut.arguments;
	theMenu = eval(args[0]);
	theMenu.bgColor=menuColor 
}

function gotoUrl(){	
	args = gotoUrl.arguments;
	if (args[0] == "http://www10.tcdev1.statefarm.com/bank/demo2/demoframe.htm") {
		WhatsNew_PopUp(args[0],'BankWindow');
	}
	else {
		location.href=args[0];
	}
	
}

function hideElement(HTMLtag)
{	
	
	// set menu area
	xmat = navObj.offsetLeft + navObj.offsetParent.offsetLeft;
	ymat = navObj.offsetHeight;

	for (i = 0; i < document.all.tags(HTMLtag).length; i++)
	{
		obj = document.all.tags(HTMLtag)[i];
		if (! obj || ! obj.offsetParent)
			continue;
		objLeft   = obj.offsetLeft;
		objTop    = obj.offsetTop;
		objParent = obj.offsetParent;

		while (objParent.tagName.toUpperCase() != "BODY")
		{
			objLeft  += objParent.offsetLeft;
			objTop   += objParent.offsetTop;
			objParent = objParent.offsetParent;
		}
		// Adjust the element's offsetTop relative to the dropdown menu
		objTop = objTop - ymat;

		if (xmat > (objLeft + obj.offsetWidth) || objLeft > (xmat + navObj.offsetWidth))
			;
		else if (objTop > navObj.offsetHeight)
			;
		else if ((ymat + navObj.offsetHeight) <= 80)
			;
		else
			obj.style.visibility = "hidden";

	}
}

function showElement(HTMLtag)
{
	for (i = 0; i < document.all.tags(HTMLtag).length; i++)
	{
		obj = document.all.tags(HTMLtag)[i];
	
		obj.style.visibility = "visible";
	}
}

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; text-align:left; width:165px; z-index:2; top:"+ divTop +"px; left: " + divLeft + "; background-color: #E4E1DC; border:1 solid #A0A0A0; visibility: hidden;\" onMouseover=\"showDDNav('document.all[\\'"+ divID +"\\']')\"  onMouseout=\"hideDiv('document.all[\\'" + divID + "\\']')\">"
	objDiv += "<div id=\"spacer\" style=\"position:relative; height:15px; text-align:left; width:160px; z-index:3; left: 5; font-size:1;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']')\"></div>"
	
	for (y = 0; y < 15; y++){
	    if(menuData[x][y][0]!=null){
		objDiv += "<div id=\"bar\" style=\"position:relative; height:1; text-align:left; width:160px; z-index:3; left: 5; background-color:" + lineColor + ";\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']')\">" + separator + "</div>"	
		if (y == 0){
			objDiv += "<div id=\"x" + tdID + "\" style=\"position:relative; text-align:left; background-color:"+ menuColor +"; color:"+ fontColor +"; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; cursor:hand; width:160px; height:20; z-index:3; left: 5; \" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']')\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\">&nbsp;"+ menuData[x][y][0] +"&nbsp;</div>"
		} else {				
			objDiv += "<div id=\"x" + tdID + "\" style=\"position:relative; text-align:left; background-color:"+ menuColor +"; color:"+ fontColor +"; font-family:Arial, Helvetica, sans-serif; font-size:12px; cursor:hand; width:160px; height:20; z-index:3; left: 5; \" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']')\" 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; text-align:left; width:160px; z-index:3; left: 5; background-color:" + lineColor + ";\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']')\">" + separator + "</div>"
	objDiv += "<div id=\"spacer\" style=\"position:relative; height:6px; text-align:left; width:160px; z-index:3; left: 5; font-size:1;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']')\"></div></div>"
	
	document.write(objDiv);
}

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="netMenu";}
	else{layerInc=15;layerStyle="netMenuMac";}	

	objDiv = "<layer id=\""+ layerID +"\" Z-INDEX=1 BGCOLOR=\""+ menuColor +"\" WIDTH=160 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=155 HEIGHT=1 Z-INDEX=2 LEFT=5 TOP="+ nestTop +">"+ separator +"</layer>"
	if (y == 0){			
		objDiv += "<B><layer id=\"x"+nestLayerID+"\" class=\""+ layerStyle +"\" Z-INDEX=1 BGCOLOR=\""+ menuColor +"\" HEIGHT=19 WIDTH=155 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 id=navstyle  href=javascript:gotoUrl('"+menuData[x][y][1]+"')><font face=\"Arial, Helvetica, sans-serif\"><font size=\"2\"><font color=" + fontColorOff + ">"+ menuData[x][y][0] + "</B>"
	}
	else {
		objDiv += "<layer id=\"x"+nestLayerID+"\" class=\""+ layerStyle +"\" Z-INDEX=1 BGCOLOR=\""+ menuColor +"\" HEIGHT=19 WIDTH=155 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 id=navstyle  href=javascript:gotoUrl('"+menuData[x][y][1]+"')><font face=\"Arial, Helvetica, sans-serif\"><font size=\"2\"><font color=" + fontColorOff + ">"+ menuData[x][y][0]
	}
			objDiv +="</font></font></font></a></layer>"		
			nestLayerID=nestLayerID+1
			nestTop=nestTop+layerInc+1
			}
		}
		objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=155 LEFT=5 HEIGHT=1 Z-INDEX=2 TOP="+ nestTop +">"+ separator +"</layer>"
		objDiv +="<layer id=\"lineEnd\" BGCOLOR=\""+ menuColor +"\" WIDTH=155 HEIGHT=8 Z-INDEX=1 TOP="+ nestTop +"></layer></layer>"

	document.write(objDiv)
}

function WhatsNew_PopUp(myLink,windowName) {
	var PopUpWindow;
	PopUpWindow = window.open(myLink,windowName,
		"scrollbars=yes,menubar=no,toolbar=no,statusbar=no,width=595,height=414");
	PopUpWindow.focus();	
	myLink.target=windowName;	
}

