//
// new ajax link tracking code [4/2/2009 - jrs]
//

var _internalLinksAccessed = new Array();

function trackClick( strName ) {

	//f
	// only track the link one time per page load
	// so if this function gets called over and over
	// we'll only actually talk back to the server
	// the first time it is called
	//
	
	if( _internalLinksAccessed[strName] != true) {
		_internalLinksAccessed[strName] = true;

		var xhr = getXMLHttpRequest();

		if(xhr != null) {
			xhr.onreadystatechange = function() {};
			var linkTrackURL="/internalLinkTrack.php?n=" + escape(strName);
			xhr.open('GET', linkTrackURL, true);
			xhr.send(null);
		}
	}
}

function getXMLHttpRequest() {
	if(window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}
// end new ajax link tracking code
    
// Load the subnav items
downArrow = CreateImage( "/global/images/arrowup.gif" );
upArrow = CreateImage( "/global/images/arrowdown.gif" );

// include stylesheet if javascript enabled; overrides submenus-ns.css(styles for javascript disabled users);
document.write('<link rel="stylesheet" href="/global/css/submenus-js.css" type="text/css" media="screen, print"  />');

// Show Left Menu
var strSelectedMenu = String( "" );
function showMenu( strMenu )
{
    if ( strSelectedMenu != strMenu )
    {	       
        // Hide/show Menus
        if (  strSelectedMenu != "" )
        {
            ChangeImage( 'imgA'+strSelectedMenu, 'downArrow' );
            DocumentObject( 'menuChild' + strSelectedMenu, true ).display = "none";
        }	
        ChangeImage( 'imgA' + strMenu, 'upArrow' );	
        DocumentObject( 'menuChild' + strMenu, true ).display = "block";
        
	    strSelectedMenu = strMenu
    }
    else
    {
        // Hide/show Menus
        if (  strSelectedMenu != "" )
        {
            DocumentObject( 'menuChild' + strSelectedMenu, true ).display = "none";
            ChangeImage( 'imgA'+strSelectedMenu, 'downArrow' );
            
            strSelectedMenu = ""
        }
    }
}

function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
}

function showHideLayers() {
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style	; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

// top drop down menus
/*startList = function() {
    if (document.all&&document.getElementById) {
		if ( document.getElementById("nav") ) {
			navRoot = document.getElementById("nav");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
    }
}*/

// updated script for drop down menus
startList = function() {

	if ( document.getElementById("nav") != null )
	{
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			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", startList);


//initialize top drop down menus
window.onload=function(){
    Init_Load();
	
	// ensure if function exists
	if(typeof window.menuSetup == 'function') { 	
		menuSetup();
	}
	
	// ensure function exists
	if(typeof window.readCookie == 'function') { 
		var cookie = readCookie("style");
		var title = cookie ? cookie : getPreferredStyleSheet();
		setActiveStyleSheet(title);
	} 

}
