/**************************************
* Copyright 2005 Web Site Tech
* http://www.wstech.net
* Unauthorized use of this script is
* prohibited.
***************************************/

// Popup Menu functions

var hide = true;
var isOpen = null;
var deHighLightColor = "EDF1F7";
var highLightColor = "839CC9";
var offSetX = 160;
var offSetY = 0;
var timeId;
var xpos;
var ypos;

function setHighLightColor(highColor)
{
  highLightColor = highColor;
}
function setDeHighLightColor(deColor)
{
  deHighLightColor = deColor;
}
function setOffSetX(offX)
{
  offSetX = offX;
}
function setOffSetY(offY)
{
  offSetY = offY;
}
function highLight(ob)
{
  if(getObj(ob) != null)
    ob = getObj(ob);
  ob.style.backgroundColor=highLightColor;
  ob.style.cursor="pointer";
}  
function deHighLight(ob)
{
  if(getObj(ob) != null)
    ob = getObj(ob);
  ob.style.backgroundColor=deHighLightColor;
  ob.style.cursor="arrow";
}  
function findPosX(obj)
{
  var curleft = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curleft += obj.offsetLeft
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
  curleft += obj.x;
  return curleft;
}
function findPosY(obj)
{
  var curtop = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curtop += obj.offsetTop
      obj = obj.offsetParent;
    }
  }
  else if (obj.y)
    curtop += obj.y;
  return curtop;
} 
function getObj(name)
{
  if (document.getElementById)
  {
    return document.getElementById(name);
  }
  else if (document.all)
  {
    return document.all[name];
  }
  else if (document.layers)
  {
    return document.layers[name];
  }
}
function showAndPlaceLayer(obj, layerName)
{
  var x = new getObj(layerName);
  if(isOpen != null)
  {
    hide = true;
    doHideLayer(isOpen);
  }
  isOpen = layerName;
  if(x.style != null)
  {
    hide = false;
    x.style.visibility = (hide) ? 'hidden' : 'visible';
    setLyr(obj,layerName);
  }
}
function showLayer(layerName)
{
  var x = new getObj(layerName);
  isOpen = layerName;
  if(x.style != null)
  {
    hide = false;
    x.style.visibility = (hide) ? 'hidden' : 'visible';
  }
}
function hideLayer(layerName)
{
  hide = true; 
  clearTimeout(timeId);
  timeId = setTimeout("doHideLayer('" + layerName + "')",300);
}
function doHideLayer(layerName)
{
  if(hide == true)
  {
    var x = new getObj(layerName);
    if(x.style != null)
    {
      hide = true;
      x.style.visibility = (hide) ? 'hidden' : 'visible';
    }
  }
}
function showhide(obj)
{
  var x = new getObj('submenu');
  hide = !hide;
  if(x.style != null)
  {
    x.style.visibility = (hide) ? 'hidden' : 'visible';
    setLyr(obj,'submenu');
  }
}
function setLyr(obj,lyr)
{
  var newX = findPosX(obj) + offSetX;
  var newY = findPosY(obj) + offSetY;
  var x = new getObj(lyr);
  x.style.top = newY + 'px';
  x.style.left = newX + 'px';
}
function delay(millis)
{
  date = new Date();
  var curDate = null;

  do { var curDate = new Date(); }
  while(curDate-date < millis);
} 