// JavaScript Document
function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

var popupTimerHandle = null;

function openMenu(div) {
	mDivObj = document.getElementById(div);
	mDivObj.style.zIndex = '5';
	//change menu column name color
	styleByClass('#685D47');
	//change link color
	mDivObj.className = "menu";
	//change arrow color
	arrowElem = document.getElementById('menu_arrow');
	arrowElem.src = "/assets/templates/default/images/i_cat_menu_arrow_h.gif";
}

function showLayer(div) {
	if (popupTimerHandle != null) {
		clearTimeout(popupTimerHandle);
		popupTimerHandle = null;
	}
}

function hideLayer(div) {
	popupTimerHandle = setTimeout("reallyHideLayer('" + div + "');", 250);
}

function reallyHideLayer(div) {
	//alert('reallyHideLayer ' + div);
    divObj = document.getElementById(div);
	if (divObj.style.zIndex=='5'){
		divObj.style.zIndex = '-2';
		toggleLayer('hotspot');

	//change menu column name color back
	styleByClass('#D79536');
	//change back to normal link colors
	mDivObj.className = "";
	//change arrow color back
	arrowElem.src = "/assets/templates/default/images/i_cat_menu_arrow.gif";
	}
}

/* toggling column name color */
//global arr
clssNodeArr = new Array();
// parameters
// e = element
// v = class value
function createClassNodeArr(e,v){
if(document.getElementsByTagName)//check for obj
   {
   var nodes = document.getElementsByTagName(e)
   var max = nodes.length
   for(var i = 0;i < max;i++)
      {
      var nodeObj = nodes.item(i);
      var attrMax = nodeObj.attributes.length
      for(var j = 0; j < attrMax; j++)
         {
          if(nodeObj.attributes.item(j).nodeName == 'class')
             {
             if(nodeObj.attributes.item(j).nodeValue == v)
              {
               clssNodeArr[clssNodeArr.length] = nodeObj
              }
             }
         }
      }
   }
}

function styleByClass(clr){
if(document.getElementsByTagName)//check for obj
   {
   var max = clssNodeArr.length;
   for(var i = 0;i < max;i++)
      {
      var nodeObj = clssNodeArr[i];
      nodeObj.style.color = clr;
      }
   }
}

