﻿<!--//--><![CDATA[//><!--

  //The hover function for the main navigation
  sfHover = function() {
  	var sfEls = document.getElementById("inMainNav").getElementsByTagName("LI");
  	for (var i=0; i<sfEls.length; i++) {
  		//if(sfEls[i].id != "mn-tab1") - removed to fix ie6 error on first navigation
  		//{
  			sfEls[i].onmouseover=function() {
  				this.className+=" sfhover";
  			}
  			sfEls[i].onmouseout=function() {
  				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
  			}
  		//}
  	}
  }
  if (window.attachEvent) window.attachEvent("onload", sfHover);

  //The new window function called by all pages
  var newwindow;
  function popit(url,winHeight,winWidth){
  	newwindow=window.open(url,null,"height=" + winHeight + ",width=" + winWidth + ",status=yes,toolbar=no,menubar=no,location=no,resizable=yes");
  	if (window.focus) {
  		newwindow.focus()
  	}
  }

  //Clears the search box.
  function CheckSearch(searchControl, defaultText)
  	{
  		if (searchControl.value == defaultText)
  		{
  			searchControl.value = "";
  		}
  	}

//--><!]]>

/***************************
Additional functions to keep top level elements highlighted
on secondary nav roll-over
***************************/
function showTopLevelHighlight(e) {
    var topLi, topA;

    if (e["target"]) {
        topLi = e["target"].parentNode.parentNode.parentNode;
    } else if (e["srcElement"]) {
        topLi = e["srcElement"].parentNode.parentNode.parentNode;
    }

	//e.style.height = "22px"

    topA = topLi.getElementsByTagName("A")[0];

	topA.style.backgroundColor = "transparent";
    topA.style.backgroundImage = "url(http://media.monster.com/mm/homepage/hover_Tab_left.gif)";
    topA.style.backgroundRepeat = "no-repeat";
    topA.style.backgroundPositionX = "left";
    topA.style.backgroundPositionY = "top";
}

function hideTopLevelHighlight(e) {
    var topLi, topA;

    if (e["target"]) {
        topLi = e["target"].parentNode.parentNode.parentNode;
    } else if (e["srcElement"]) {
        topLi = e["srcElement"].parentNode.parentNode.parentNode;
    }

    topA = topLi.getElementsByTagName("A")[0];

    topA.style.backgroundImage = "";
}

function initTopLevelHighlightEvents() {
    var isDom2 = (window.addEventListener) ? true : false;

    var mainNavUl = document.getElementById("inMainnavigation");
    var topLevels = mainNavUl.getElementsByTagName("LI");
    var secondLevelLinks;
    var i, j;

    for (i = 0; i < topLevels.length; i++) {
        if (topLevels[i].getElementsByTagName("UL").length == 0) continue;

        secondLevelLinks = topLevels[i].getElementsByTagName("UL")[0].getElementsByTagName("A");

        for (j = 0; j < secondLevelLinks.length; j++) {
            if (isDom2) {
                secondLevelLinks[j].addEventListener("mouseover", showTopLevelHighlight, false);
                secondLevelLinks[j].addEventListener("mouseout", hideTopLevelHighlight, false);
            } else {
                secondLevelLinks[j].attachEvent("onmouseover", showTopLevelHighlight);
                secondLevelLinks[j].attachEvent("onmouseout", hideTopLevelHighlight);
            }
        }
    }
}

var temp_onload = window.onload;
window.onload = function ()
{
   //Are there any exising onload functions?
   //NO
   if (typeof temp_onload != "function")
   {
      initTopLevelHighlightEvents();
   }
   //YES
   else
   {
      temp_onload();
      initTopLevelHighlightEvents();
   }
}
