var visShow, visHide;

function showLayer(layerID) {
	var searchBox = document.getElementById('searchBox');

	for (i=0; i<menuArray.length; i++) {			
		if (document.getElementById) {			
			document.getElementById(menuArray[i]).style.visibility = "hidden";
			
			if(searchBox != null)
				searchBox.style.visibility = 'visible';
		}
		else if (document.layers) {			
			document.layers[menuArray[i]].visibility = "hide";			
		}
		else {
			document.all(menuArray[i]).style.visibility = "hidden";
		}
	}
	
	if (layerID != "") {
	
		if (document.getElementById || document.all) {
			if (document.getElementById) 
			{
				layerVis = document.getElementById(layerID).style;
				if ((layerID == "supportmenu") && searchBox != null) 
					searchBox.style.visibility = 'hidden';
			}
			else
			{
				if ((layerID == "supportmenu") && searchBox != null) 
					document.all('searchBox').style.visibility = 'hidden';
					
				layerVis = document.all(layerID).style;
			}
			visShow = "visible";
			visHide = "hidden";
		}	
		else if (document.layers) {
			layerVis = document.layers[layerID];	
			visShow = "show";
			visHide = "hide";	
		}
    
		if (layerVis == visShow) {
			layerVis.visibility = visHide;		
		}
		else {
			layerVis.visibility = visShow;
		}
	}	
}
function CalcOffset()
{
        if (document.body.offsetWidth < 996)
                return 1;
        else
                return document.body.offsetWidth - 996;

        //document.body.clientWidth  - 996
}

function setLyr(obj,lyr,xOffset)
{
//      if(obj && obj.tagName == 'MAP' && document.all)
        var newX = findPosX(obj);
        //var newY = findPosY(obj);
        var x = new getObj(lyr);
        newX += xOffset //give it a nudge
        if(x.obj) {
                x.style.left = newX + 'px';

                //detect bottom edge
                //if(bMax > 0){
                //      if (newY + x.obj.offsetHeight > bMax){
                //              var adj = bMax - x.obj.offsetHeight
                //              adj += (document.all) ? 1 :  29;
                //              x.style.top = adj + 'px'
                //              }
                //      else
                //              x.style.top = newY + 'px';
                //}
        }
        delete x; //free up the memory
}

function iMapDD(pObj,lyr,xOffset) {
        var p = new getObj(pObj);
        if(p.obj)       setLyr(p.obj,lyr,xOffset);
        showLayer(lyr);
        delete p;
}


function findPosY(obj)
{
        var curtop = (document.all) ? 0 : -28;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curtop += obj.offsetTop
                        obj = obj.offsetParent;
                }
        }
        else if (obj.y)
                curtop += obj.y;
        return curtop;
}
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 getObj(name) {
        visShow = 'visible';
        visHide = 'hidden';
  if (document.getElementById)
  {
        this.obj = document.getElementById(name);
                if(this.obj)
                        this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
                this.obj = document.all[name];
                if(this.obj)
                        this.style = document.all[name].style;
  }
  else if (document.layers)
  {
        this.obj = document.layers[name];
                if(this.obj)
                this.style = document.layers[name];
                visShow = 'show';
                visHide = 'hide';
  }
}
