// JavaScript Document
var currentDiv = [];
var arrPreload = [];
var curSub = "none";
var intSub = "none";
var curSrc = "none";
var curId = "none";
var curPop = "none";

function init() {
  if(window.curMainSec) {
    document.getElementById(curMainSec).className = "subactive";
  }
  var arrDivs = document.getElementsByTagName("div");
  for(i=0;i<arrDivs.length;i++) {
    if(arrDivs[i].className=="showitem") {
	  currentDiv[currentDiv.length] = arrDivs[i];
	}
  }
  var arrAnchors = document.getElementsByTagName("a");
  for(i=0;i<arrAnchors.length;i++) {
    arrAnchors[i].onfocus = new Function("if(this.blur)this.blur()");
    if(arrAnchors[i].rel=="rollover") {
	  arrAnchors[i].onmouseover = new Function("rollOver(this)");
	  arrAnchors[i].onmouseout = new Function("rollOut(this)");
	  arrAnchors[i].imgObj = arrAnchors[i].getElementsByTagName("img")[0];
	  arrAnchors[i].origSrc = arrAnchors[i].imgObj.src;
	  arrAnchors[i].overSrc = arrAnchors[i].imgObj.src.replace("_0.","_1.");
	  preLoad(arrAnchors[i].overSrc);
	}
	if(arrAnchors[i].rel=="mainnav") {
	  arrAnchors[i].onmouseover = new Function("showSub(this)");
	  arrAnchors[i].onmouseout = new Function("subRollOut(this)");
	}
	if(arrAnchors[i].rel=="subroll") {
	  arrAnchors[i].onmouseover = new Function("subRollOver(this)");
	  arrAnchors[i].onmouseout = new Function("subRollOut(this)");
	  /*if(arrAnchors[i].href==location) {
	    arrAnchors[i].className = "subactive";
	  }*/
	}
  }
//  preLoad("../images/shared/top_nav_bg_1.gif","../images/shared/drop_nav_bg_0.gif","../images/shared/drop_nav_bg_1.gif","../images/shared/sub_nav_bg_1.gif","../images/shared/sub_nav_bg_end_1.gif");
}

// init() is now called in footer include to avoid error when user clicks nav before page loaded
// window.onload = init;

function preLoad() {
  for(j=0;j<arguments.length;j++) {
    imgTemp = new Image();
    imgTemp.src = arguments[j];
    arrPreload[arrPreload.length] = imgTemp;
  }
}

function showHideMult() {
  var showStatus = (arguments[0]=="hide") ? "hideitem" : "showitem";
  for(i=0;i<currentDiv.length;i++) {
    currentDiv[i].className = "hideitem";
  }
  currentDiv = [];
  for(i=1;i<arguments.length;i++) {
    if(showStatus=="showitem") {
      currentDiv[currentDiv.length] = document.getElementById(arguments[i]);
	}
    document.getElementById(arguments[i]).className = showStatus;
  }
}

function rollOver(objTemp) {
  objTemp.imgObj.src = objTemp.overSrc;
}

function rollOut(objTemp) {
  objTemp.imgObj.src = objTemp.origSrc;
}

function showSub(objTemp) {
  if(curSub!="none") {
    document.getElementById(curSub).style.display = "none";
  }
  if(intSub!="none") {
    clearInterval(intSub);
  }
  curSub = "sub"+objTemp.id;
  if((curSub=="subcompany") || (curSub=="sublocations")) {
    if(document.getElementById("areadropdown")!=null) {
	  document.getElementById("areadropdown").style.visibility = "hidden";
	}
  } else {
    if(document.getElementById("areadropdown")!=null) {
	  document.getElementById("areadropdown").style.visibility = "visible";
	}
  }
  document.getElementById(curSub).style.left = (document.getElementById("holder").offsetLeft + objTemp.offsetParent.offsetLeft + 18) + "px";
  document.getElementById(curSub).style.display = "block";
}

function hideSub() {
  document.getElementById(curSub).style.display = "none";
  if((curSub=="subcompany") || (curSub=="sublocations")) {
    if(document.getElementById("areadropdown")!=null) {
	  document.getElementById("areadropdown").style.visibility = "visible";
	}
  }
  if(intSub!="none") {
    clearInterval(intSub);
	intSub = "none";
  }
}

function subRollOver(objTemp) {
  if(intSub!="none") {
    clearInterval(intSub);
	intSub = "none";
  }
}

function subRollOut(objTemp) {
  intSub = setInterval("hideSub()",50);
}

function confirmDelete(strHref) {
  if(confirm("Are you sure you want to delete this item?")) {
    location = strHref;
  } else {
	return false;
  }
}

function writeEmail(strDomain,strAddress,strContact) {
  document.write('<a href="mailto:'+strAddress+'@'+strDomain+'" class="bodytext">'+strAddress+'@'+strDomain+'</a>');
}

function doOffsetOver(strId,strSrc) {
  curId = strId;
  curSrc = document.getElementById(strId).src;
  document.getElementById(strId).src = strSrc;
}
function doOffsetOut() {
  document.getElementById(curId).src = curSrc;
}

function openWin(strUrl,strWidth,strHeight,strParams) {
  if((curPop!=null) && (curPop!="none")) {
    curPop.close();
	curPop = "none";
  }
  strTempParam = "width="+strWidth+",height="+strHeight;
  if(strParams!=null) strTempParam+=","+strParams;
  var curPop = window.open(strUrl,'newwin',strTempParam);
  curPop.focus();
}
function popupwin(){
var popurl= "l_terms_of_use.asp" 
var xwidth = 320
var yheight = 100
winpops=window.open(popurl,"","width=" + xwidth + ",height=" + yheight + ",location=no,")

}	



