
menuPrefix = 'menu';  // Prefix that all menu layers must start with
                      // All layers with this prefix will be treated
                      // as a part of the menu system.

//Menu Js
var menuTree, mouseMenu, hideTimer, doHide;
function init() {
}

function expandMenu(menuContainer,subContainer,menuLeft,menuTop) {
  // Hide all submenus thats's not below the current level
  doHide = false;
  if (menuContainer != menuTree) {
      var menuLayers = document.getElementsByTagName("DIV");
      for (i=0; i<menuLayers.length; i++) {
        if ((menuLayers[i].id.indexOf(menuContainer) != -1)){
          hideObject(menuLayers[i].id);
        }
      }
  }
  // If this is item has a submenu, display it, or it it's a toplevel menu, open it
  if (subContainer) {
    if ((menuLeft) && (menuTop)) {
    	positionObject(subContainer,menuLeft,menuTop);
    	hideAll();
    }
    else {
      	positionObject(subContainer, document.getElementById(menuContainer).offsetWidth + document.getElementById(menuContainer).style.pixelLeft - 10, mouseY);
    }
    showObject(subContainer);
    menuTree = subContainer;
  }
}

function showObject(obj) {
  document.getElementById(obj).style.visibility = "visible";
}

function hideObject(obj) {
  document.getElementById(obj).style.visibility = "hidden";
}

function positionObject(obj,x,y) {
    var foo = document.getElementById(obj).style;
    foo.left = x;
    foo.top = y;
}

function hideAll() {
    var menuLayers = document.getElementsByTagName("DIV");
    for (i=0; i<menuLayers.length; i++) {
      if (menuLayers[i].id.indexOf(menuPrefix) != -1) {
        hideObject(menuLayers[i].id);
      }
    }
}

function hideMe(hide) {
	if (hide) {
		if (doHide) { hideAll(); }
	}
	else {
		doHide = true;
		hideTimer = window.setTimeout("hideMe(true);", 1000);
	}
}

function mouseMove(e) {
  mouseY = window.event.y;
}

function getPos(el,sProp) {
	var iPos = 0;
	while (el!=null) {
		iPos+=el["offset" + sProp];
		el = el.offsetParent;
	}
	return iPos;
}
//Common Js
function CheckURL(URL) 
{ 
  var xmlhttp;
  if(window.XMLHttpRequest)
  {
     xmlhttp = new XMLHttpRequest();
  }
  else if(window.ActiveXObject)
  {
     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.open("GET",URL, false);
  try 
  {
    xmlhttp.send();
    var result = xmlhttp.status;
  }
  catch(e) {return(false); }
  if(result==200)
  {
    return true;
  }
  xmlhttp = null;
  return false;
}
function GoURL(URL,_root,tag)
{
    if(CheckURL(URL))
    {
        if(tag)
            window.open(URL);
        else
            window.location.href=URL;
    }
    else
    {
        if(_root=="/")
            window.location.href="HomePage/error.aspx";
        else
            window.location.href="error.aspx";        
    }
}
onload = function(){
    init();
    if (document.getElementById("grdv"))
    {
        formatTable("grdv");
        lockedTableHead();
    }
}
