hovercolor   = "#FFFFFF";   // color name/code
bgcolor      = "#CCDDEE";   // color name/code
//laycolor     = "#0066CC";   // color code for border lining
laycolor     = "#017ac1";   // color code for border lining
textColor    = '#003366';
imagePath    = "/vgn/enterprise/";
arrowSrc     = "/vgn/enterprise/arrow.gif";
arrowRightSrc = "/vgn/enterprise/arrowRight.gif";

// sets the distance from top of page for top-level menu
var theTop = 88;
var theHeight = '18px';

var timer;

function Show() {
   if (timer)
      clearTimeout(timer);
	  
   for (menu = 1; menu < Layer.length; menu++) {
      if (Layer[menu]) {
		 document.getElementById('L' + Layer[menu].ID).style.visibility = "hidden";
      }
   }
   
   for (i = 0; i < theSubMenu.length; i++) {
      document.getElementById(dependsOn[i]).style.background=bgcolor;
   }

   for (i = 0; i < arguments.length; i++) {
      menu = arguments[i];

      if (document.getElementById('L' + menu)) {
         document.getElementById('L' + menu).style.visibility = "visible";
	  }

      for (j = 0; j < theSubMenu.length; j++) {
         if (menu == theSubMenu[j]) {
            document.getElementById(dependsOn[j]).style.background = hovercolor;
            document.getElementById(dependsOn[j]).style.color = textColor;
         }
      }
   }
}

function Hide() {
   timer = setTimeout("Show(); setMenuHover(thisPage)", 500);
}

function createBaseItem(theName,theText,Width,Left,theLink,subLayer,singleHeight) {
   layerName = "layer" + theName;
   var theInfo = '';

   // igohn (2005/04/01) - single or double height - hardcode here for now, move later
   var heightName = "";
   var heightTop = 2;

   //if (theName == 1) {
   if (theName == 'a') {
      leftdivider = "leftside";
      adjust = 6;
   }
   else {
      leftdivider = "dividerleft";
      adjust = 5;
   }

   if (theLink.substr(0,4) != 'java')
      linkText = "top.location.href='" + theLink + "'";
   else
      linkText = theLink;

   if (thisPage == theName)
      theText = "<b>" + theText + "</b>";

   // igohn (2005/04/01) - single or double height - hardcode here for now, move later
   if (singleHeight) {
      height = 20;
   }
   else {
      heightName = "High";
      height = 35;
	  heightTop = 2;
   }

   theInfo += "<DIV ID=" + layerName + " onMouseover='setMenuHover(\"" +
	          theName + "\");' class=menuButton style='position:absolute; left:" +
	          Left + "; top:" + theTop + "'>" +
              "<table width=" + eval(Width + adjust) + " border=0 cellpadding=0 cellspacing=0>" +
			  "<tr>" +
			  "<td valign=top><img src='" + imagePath + leftdivider + heightName + ".gif'></td>" +
		      "<td valign=top height=" + height + " width=" + Width + " class=menuButton>" +
			  "<span style='position:relative; top:" + heightTop + "px; line-height: 125%'>" +
			  theText + "</span></td>" +
			  "<td valign=top><img src='" + imagePath + "dividerright" + heightName + ".gif'></td>" +
			  "</tr></table></DIV>";

   theInfo += "<DIV ID=" + layerName + "on onMouseover='Show(\"" + subLayer + "\");' " +
              "onMouseout='Hide();' onClick=\"" + linkText + ";Hide()\" class=menuButtonHover " +
			  "style='position:absolute; visibility:hidden; left:" + Left + "; top:"+theTop+"'>" +
              "<table width=" + eval(Width + adjust) + " border=0 cellpadding=0 cellspacing=0>" +
	          "<tr>" +
			  "<td valign=top><img src='" + imagePath + leftdivider + "lite" + heightName + ".gif'></td>" +
			  "<td valign=top height=" + height + " width=" + Width + " class=menuButtonHover>" +
			  "<span style='position:relative; top:" + heightTop + "px; line-height: 125%'>" +
			  theText + "</span></td>" +
			  "<td valign=top><img src='" + imagePath + "dividerrightlite" + heightName + ".gif'></td>" +
			  "</tr></table></DIV>";

   document.write(theInfo);
}

function setMenuHover(theName) {
   if (timer)
      clearTimeout(timer);

   for (i = 1; i < menuItems.length; i++) {
      layerName = "layer" + String.fromCharCode(ASCII_OFFSET + i) + "on";

      if (String.fromCharCode(ASCII_OFFSET + i) != theName) {
		 document.getElementById(layerName).style.visibility = "hidden";
      }
      else {
		 document.getElementById(layerName).style.visibility = "visible";
      }
   }
}

function LayerSpecs(Left,Top,Width,ID,leftalign,hasThirdLevelChans) {
   if (leftalign) {
      Left += 1;
   }
   else {
      Left -= 2;
   }

   this.left = Left;
   
   // was: ID > 1
   if (ID.length == 1)
      this.left -= 1;

   this.top = theTop + 19 + Top;
   this.ID = ID;

   // was: ID >= 9
   if (ID.length == 2)
      this.left -= 2;

   this.width = Width;
   this.info = "";

   links = new Array();
   show = new Array();
   texts = new Array();
   c = 1;
   for (i = 6; i < arguments.length; i += 3) {
      j = i + 1;
      k = i + 2;

      if (arguments[i].substring(0,10) == 'javascript')
	     links[c] = arguments[i].substring(11,arguments[i].length);
      else
	     links[c] = "top.location.href='" + arguments[i] + "'";

      show[c] = arguments[j];
      texts[c] = arguments[k];
      c++;
   }

   for (i = 1; i < links.length; i++) {
      layerName = "layer_" + ID + "_" + String.fromCharCode(ASCII_OFFSET + i);

      this.info += "<DIV ID=" + layerName + " class=IEmenu style='width:" +
			        Width + "; position:relative; top:0px; left:0px; background:" +
					bgcolor + ";color:" + textColor + "' onMouseOver='" + show[i] +
			        "; this.style.background=\"" + hovercolor +
			        "\";' onMouseOut='this.style.background=\"" + bgcolor +
			        "\";this.style.color=\"" + textColor + "\"' onClick=\"" + links[i] +
			        ";Hide()\">";

      // igohn - a trailing space means there's third level nav (original hack)
      if (texts[i].substr(texts[i].length-1, 1) == ' ') {
		 if (leftalign) {
            this.info += "<table border=0 cellpadding=0 cellspacing=0><tr><td>&nbsp;</td><td><span style='color:" + textColor + "'>" + texts[i] +
			              "</span><span class=IEMenu style='width:10px; position:absolute; top:2px; left:" +
			              eval(Width - 10) + "px;'><img src='" + arrowSrc + "'></span></td></tr></table>";
		 }
		 else {
            this.info += "<table border=0 cellpadding=0 cellspacing=0><tr>" +
						  "<td align=middle width=15><img src='" + arrowRightSrc + "'></td>" +
						  "<td><span style='color:" + textColor + "'>" + texts[i] +
						  "</span></td></tr></table>";
		 }
	  }
	  else {
		 if (leftalign) {
            this.info += "<table border=0 cellpadding=0 cellspacing=0><tr><td>&nbsp;</td><td><span style='color:" + textColor + "'>" + texts[i] +
			              "</span></td></tr></table>";
		 }
		 else {
		    // if we are right aligned and there are third level menus, we need to pad to line up
			if (hasThirdLevelChans) {
			   this.info += "<table border=0 cellpadding=0 cellspacing=0><tr>" +
						    "<td align=middle width=15>&nbsp;</td>" +
						    "<td><span style='color:" + textColor + "'>" + texts[i] +
						    "</span></td></tr></table>";
			}
			else {
			   this.info += "&nbsp;" + texts[i];
			}
		 }
	  }
	  
	  this.info += "</DIV>";
   }
   
   // igohn - totally breaks for more than 9 layers
   if (this.ID.length > 1) {
      theSubMenu[theSubMenuCounter] = this.ID;
      dependsOn[theSubMenuCounter] = "layer_" + this.ID.substring(0,1) + "_" + this.ID.substring(1,2);
      theSubMenuCounter++;
   }
   
   layerCounter++;
}

function createMenu() {
   for (i = 1; i < Layer.length; i++) {
      if (Layer[i]) {
	     document.write("<DIV onMouseOver='clearTimeout(timer)' onMouseOut='Hide()' ID='L" +
			            Layer[i].ID + "' STYLE='position:absolute; visibility:hidden; top:" +
				        Layer[i].top + "; left:" + Layer[i].left + "; width:" + Layer[i].width +
					    ";border:1px solid " + laycolor +
					    ";border-right-width:1px;border-bottom-width:1px;background-color:" +
			            laycolor + "'>" + Layer[i].info + "</DIV>");

      }
   }
}
