var currentLayer = "none";
var mouseOverMenu = 0;
var timerID;
var numDHTMLimages = 5;
var DimgLoded = 0;
var initial = 0;
var dinitial = 0;


function beginCachingDHTML()
{
var topBorder = new Image();
var rightBorder = new Image();
var rightBorder2 = new Image();
var leftBorder = new Image();
var spacer = new Image();
topBorder.onload = countDHTMLimages;
topBorder.src = "images/glo_menuborder_top.gif";
rightBorder.onload = countDHTMLimages;
rightBorder.src = "images/glo_menuborder_mid.gif";
rightBorder2.onload = countDHTMLimages;
rightBorder2.src = "images/glo_menuborder_mid.gif";
leftBorder.onload = countDHTMLimages;
leftBorder.src = "images/glo_menuborder_btm.gif";
spacer.onload = countDHTMLimages;spacer.src = "images/glo_pxl_white.gif";

if ((navigator.appName.indexOf("Netscape") != -1)&& (navigator.appVersion.indexOf("4.") != -1))loadN4DHTMLCacheLayer();
}


function countDHTMLimages()
{
++DimgLoded;
if(DimgLoded==numDHTMLimages)
{
DHTMLen = 1;
beginCachingRollovers();
}
}


function loadN4DHTMLCacheLayer()
{

dinitial = 1;
document.main.document.dhtmlcacher.src = 'javastuf/cacher_dhtml.html';
}


function checkN4DHTMLCacheLayer()
{
if (document.main.document.dhtmlcacher.img_counter==numDHTMLimages)
{
DHTMLen = 1;beginCachingRollovers();
}
else timevar = setTimeout("checkN4DHTMLCacheLayer()", 50);
}


function openMenu(whichMenu)
{
clearTimeout(timerID);
var whatLayer = menuList[whichMenu];
if(currentLayer!=whatLayer)
{
closeMenu();
showLayer(whatLayer);
currentLayer = whatLayer;
}
}


function timeOutMenu()
{
timerID = setTimeout("if(!mouseOverMenu)closeMenu();",50)
}
function closeMenu()
{
if(currentLayer!="none" && menuList[curNav]!=currentLayer)
{
hideLayer(currentLayer);
currentLayer = "none";
}
}


function createMenu(menuName,originX,originY,height)
{
var loopCounter = 1;
var ast = "";
var thisItem = "";
var thisLink = "";
var tV1 = "";
var tV2 = "";
var cst='"><IMG SRC="images/glo_';
ast += '<TABLE WIDTH="253" CELLPADDING="0" CELLSPACING="0" BORDER="0">';
ast += '<TR>';
ast += '  <TD WIDTH="253" COLSPAN="3"'+cst+'menuborder_top.gif" WIDTH="253" HEIGHT="9" BORDER="0" HSPACE="0" VSPACE="0"></TD>';
ast += '</TR>';
tV1 = eval(menuName + "Menu['numItems']");
tV2 = eval(menuName + "Menu['I1href']");
if((tV2=="null")&&(tV1==1))
{
var itemHeight;
ast += '<TR>';
itemHeight = eval(menuName + "Menu['I1height']");
ast += '  <TD WIDTH="15" BGCOLOR="#FFFFFF" ROWSPAN="' + itemHeight + '"'+cst+'pxl_white.gif" WIDTH="15" HEIGHT="1" BORDER="0"></TD>';
ast += '  <TD WIDTH="220" BGCOLOR="#FFFFFF" ROWSPAN="' + itemHeight + '">';
ast += '    <FONT FACE="ARIAL,HELVETICA" SIZE="2" COLOR="#000000">';
thisItem = eval(menuName + "Menu['I1']");ast += thisItem;ast += '    </FONT>';
ast += '  </TD>';ast += '  <TD WIDTH="18"'+cst+'menuborder_mid.gif" WIDTH="18" HEIGHT="26" BORDER="0"></TD>';ast += '</TR>';
for(loopCounter=1;loopCounter<itemHeight;++loopCounter)
{
ast += '<TR>';
ast += '  <TD WIDTH="18"'+cst+'menuborder_mid.gif" WIDTH="18" HEIGHT="26" BORDER="0"></TD>';
ast += '</TR>';
}
}
else
{
for(loopCounter=1;loopCounter<=eval(menuName + "Menu['numItems']");++loopCounter)
{
thisItem = eval(menuName + "Menu['I" + loopCounter + "']");
thisLink = eval(menuName + "Menu['I" + loopCounter + "href']");
ast += '<TR>';
ast += '  <TD WIDTH="15" BGCOLOR="#FFFFFF"'+cst+'pxl_white.gif" WIDTH="15" HEIGHT="1" BORDER="0"></TD>';
ast += '  <TD WIDTH="220" BGCOLOR="#FFFFFF">';
ast += '    <FONT FACE="ARIAL,HELVETICA" SIZE="2" COLOR="#000000">';
ast += '      <A HREF="' + thisLink + '"><FONT FACE="ARIAL,HELVETICA" SIZE="2" COLOR="#000000">' + thisItem + '</FONT></A>';
ast += '    </FONT>';ast += '  </TD>';
if(thisItem.length > 34)
ast += '  <TD WIDTH="18"'+cst+'menuborder_mid2.gif" WIDTH="18" HEIGHT="50" BORDER="0"></TD>';
else
ast += '  <TD WIDTH="18"'+cst+'menuborder_mid.gif" WIDTH="18" HEIGHT="26" BORDER="0"></TD>';
ast += '</TR>';
}
}
ast += '<TR><TD WIDTH="253" COLSPAN="3"'+cst+'menuborder_btm.gif" WIDTH="253" HEIGHT="9" BORDER="0"></TD></TR>';
ast += '<TR>';
ast += '  <TD WIDTH="15"'+cst+'pxl_trans.gif" WIDTH="15" HEIGHT="1" BORDER="0"></TD>';
ast += '  <TD WIDTH="220"'+cst+'pxl_trans.gif" WIDTH="220" HEIGHT="1" BORDER="0"></TD>';
ast += '  <TD WIDTH="18"'+cst+'pxl_trans.gif" WIDTH="18" HEIGHT="1" BORDER="0"></TD>';
ast += '</TR>';
ast += '</TABLE>';
createLayer(menuName, originX, originY, 262, height, 0, ast)
}
var layerList = new Array();


function createLayer(name, left, top, width, height, visible, content)
{
var z = layerList.length;
var layer;
layerList[z] = name;
if (document.layers)
{
document.writeln('<layer name="' + name + '" left=' + left + ' top=' + top + ' width=' + width + ' height=' + height +  ' visibility=' + (visible ? '"show"' : '"hide"') + ' z-index=' + z + ' onMouseOver="mouseOverLayer(\'' + name + '\');" onMouseOut="mouseOutLayer(\'' + name + '\');">');
document.writeln(content);
document.writeln('</layer>');
layer = getLayer(name);
layer.width = width;
layer.height = height;
}
if (document.all)
{
document.writeln('<div id="' + name + '" style="position:absolute; overflow:none; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') + ' z-index:' + z + '" onMouseOver="mouseOverLayer(\'' + name + '\');" onMouseOut="mouseOutLayer(\'' + name + '\');">');
document.writeln(content);
document.writeln('</div>');
}
clipLayer(name, 0, 0, width, height);
}


function mouseOverLayer(name)
{
if(rollEn)clearTimeout(rolloverTimer);
mouseOverMenu = 1;clearTimeout(timerID);
}


function mouseOutLayer(name)
{
setTimeout("rolloverMenuOut()", 100);
mouseOverMenu = 0;timeOutMenu();
}


function hideLayer(name)
{var layer = getLayer(name);
if (document.layers)layer.visibility = "hide";
if (document.all)layer.visibility = "hidden";
}


function showLayer(name)
{var layer = getLayer(name);
if (document.layers)layer.visibility = "show";
if (document.all)layer.visibility = "visible";
}


function isVisible(name)
{var layer = getLayer(name);
if (document.layers && layer.visibility == "show")return(true);
if (document.all && layer.visibility == "visible")return(true);
return(false);
}
function clipLayer(name, clipleft, cliptop, clipright, clipbottom) {var layer = getLayer(name);
if (document.layers)
{
layer.clip.left   = clipleft;
layer.clip.top    = cliptop;
layer.clip.right  = clipright;
layer.clip.bottom = clipbottom;
}
if (document.all)layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
}


function getLayer(name)
{
if (document.layers)return(document.layers[name]);
else if (document.all)
{
layer = eval('document.all.' + name + '.style');
return(layer);
}
else return(null);
}
