//*****************************************************************************
// JS code required for cross-browser Son Of Suckerfish dropdown support.



function isFunction(a) {
    return typeof a == 'function';
}

function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}


sfHover = function() {
  // In case we don't have the top_navlist element on a given page
  if (document.getElementById("top_navlist"))
	{
	
  var sfEls = document.getElementById("top_navlist").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {		
		
		// Define the onmouseover function
		sfEls[i].onmouseover=function() {
			
		  // IE form select kludge.
	    if (document.getElementById("nav_go_form"))
	      {
	      var zselects=document.getElementById("nav_go_form").getElementsByTagName("SELECT");
	      for (var j=0; j<zselects.length; j++)
	        {
	        zselects[j].style.visibility="hidden";	
	        }
	      }
		
     if (this.className=="separator")
        {
        this.className+=" sfsephover";	
        }
     else if (this.className=="ancestor") 
        {
      	this.className+=" sfhover sfahover";
			  myhref=this.getElementsByTagName("A");
		    if (isObject(myhref[0])) myhref[0].className+=" sfhover";
        }
/*		
     else if (this.className=="locked") 
        {
      	this.className+=" sfhover sflhover";
			  myhref=this.getElementsByTagName("A");
		    if (isObject(myhref[0])) myhref[0].className+=" sfhover";
        }
*/		
      else 
        {
			  this.className+=" sfhover";
			  myhref=this.getElementsByTagName("A");
		    if (isObject(myhref[0])) myhref[0].className+=" sfhover";
			  }
		}
		sfEls[i].onmouseout=function() {
		  
	    // IE form select kludge.
	    if (document.getElementById("nav_go_form"))
	      {
	      var zselects=document.getElementById("nav_go_form").getElementsByTagName("SELECT");
	      for (var j=0; j<zselects.length; j++)
	        {
	        zselects[j].style.visibility="visible";	
	        }
	      }
	  
			this.className=this.className.replace(new RegExp(" sfsephover\\b"), "");	
			this.className=this.className.replace(new RegExp(" sfhover sflhover\\b"), "");		
			this.className=this.className.replace(new RegExp(" sfhover sfahover\\b"), "");
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			myhref=this.getElementsByTagName("A");
		  if (isObject(myhref[0])) myhref[0].className=myhref[0].className.replace(new RegExp(" sfhover\\b"), "");
		  }
		}
	}
}

var sfClickFired=false;
sfClick = function() {
  // In case we don't have the top_navlist element on a given page
  if (document.getElementById("top_navlist"))
	{
  var sfEls = document.getElementById("top_navlist").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {	  
		
		// Handle another IE issue that also applies to Moz.
		// We pull the HREF from the first contained A
		// and attach it as a location.href to all LI elements onclick.
		// Because all nested LIs fire their onclicks from innermost out,
		// we flip sfClickFired to true after our desired event. 
		sfEls[i].onclick=function()
		  {
		  mychref=this.getElementsByTagName("A");
		  if (mychref[0].href && (sfClickFired==false)) 
		    {
		    sfClickFired=true;
		    
		    /* handle the case where we spawn a new window with target="blah" */
		    if (mychref[0].target=='') 
		      {
		      document.location.href=mychref[0].href;
		      }
		    }	
		  }
	  }
	}
}

// IE
if (window.attachEvent) 
  {
  window.attachEvent("onload", sfHover);
  window.attachEvent("onload", sfClick);  
  }
// Mozilla
if (window.addEventListener) 
  {
  window.addEventListener("load", sfClick, false);
  }

