var n4 = (document.layers) ? 1:0
var ie = (document.all) ? 1:0
var dom = (document.getElementById && !document.all) ? 1:0
var pageLoaded = 0

var oOldOnLoad = window.onload;

// Sets Active Global Nav for page
function setActiveNav() {
	if(activeNav != "") {
		TDname = "nav" + activeNav
		if(ie){document.all(TDname).className = "navBckgrndActive";}
		else if(dom){document.getElementById(TDname).className = "navBckgrndActive";}
	}

	positionSNav();

	// We need to call the rotating ad's init function if this is the home page...
	if ( ie && document.all( "spotlightPhoto" ) ) F0();
	
	if ( oOldOnLoad ) oOldOnLoad();
}
onload = setActiveNav;

// DETECT NS Version
function BrowserDetectLite() {
   var ua = navigator.userAgent.toLowerCase();

   // browser name
   this.isGecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isMozilla   = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );

   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);   // spoofing and compatible browsers

   this.versionMinor = parseFloat(navigator.appVersion);   // browser version

   if (this.isNS && this.isGecko) {   // correct version number
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   this.versionMajor = parseInt(this.versionMinor);
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );

   // specific browser shortcuts
	n = ua.indexOf('netscape')
	NSversion = ua.substring(n+8,n+9)
}
var theBrowser = new BrowserDetectLite();
// *********************************


// Reposition SubNavs ********************************************
function positionSNav(){
	for ( i = 1; i <= numOfNavs; i++ )
	{
		var oMenu = document.getElementById( "nav" + i );

		theTop		= getY( oMenu ) + oMenu.offsetHeight;
		theLeft		= getX( oMenu );
		
		if ( document.getElementById( "TopNav2_SubPage" ) != null )
			theTop += 4;

		theDiv		=  "snav" + i;

		theRight	= theLeft + 200;
		theWidth = theRight - theLeft;// + 20;

		if ( i == numOfNavs )
		{
		    theLeft = theLeft + oMenu.offsetWidth - theWidth - 2;
		}

		if ( ie )
		{
			document.all(theDiv).style.left	= theLeft;
			document.all(theDiv).style.top	= theTop;
			//document.all(theDiv).style.height = 300;
		}
		else if ( dom )  //For NS6
		{
			document.getElementById(theDiv).style.left	= theLeft;
			document.getElementById(theDiv).style.top	= theTop;
			//document.getElementById(theDiv).style.height = 300;
		}

		if ( ie )
		{
			document.all(theDiv).style.width = theWidth;
		}
		else if ( dom ) //For NS6
		{
			if ( theBrowser.isNS6x )
			{
				document.getElementById(theDiv).style.width = theWidth + 80;
			}
			else
			{
				document.getElementById(theDiv).style.width = theWidth;
			}
		}
	}
	pageLoaded = 1;
}

// Get position of nav for DIV placement *****************************************************
function getLeftPos(which){
var img = document.images[which];
	if(ie || dom){return( getX(img))}
	if(ns4){return(getXNS(which))}
	}
function getX(obj){
	return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) );
	}
function getXNS(name){
	return(document.images[name].x)
	}
function getTopPos(which){
var img = document.images[which];
	if(ie || dom){return( getY(img))}
	}
function getY(obj){
	return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) );
	}
	

// Helps Setup SubNavDropDown Kill for MacIE *************************************************
function BrowserDetectVeryLite(){
	var ua = navigator.userAgent.toLowerCase(); 
	this.isMac   = (ua.indexOf('mac') != -1);
	this.isIE    = ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) ); 
	
	// browser version
	this.versionMinor = parseFloat(navigator.appVersion); 
	// correct version number
	if (this.isIE && this.versionMinor >= 4) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );}
	}
var browser = new BrowserDetectVeryLite();

getVer = browser.versionMinor.toString()
isIE50 = (getVer.indexOf('5.0')!=-1?true:false)
var killDropDowns = false;
if(browser.isMac && browser.isIE){killDropDowns = true} 
if(isIE50){killDropDowns = true} 
if(NSversion == "6"){killDropDowns = true} 

// Show Hide Layers *******************************************************
var timer;

function showHide(which,v){
if(pageLoaded!=1){return}
//changeNavCSS(which,v);
if(killDropDowns == true){return};

d = document
layerName = "snav" + which
	if (v==0){option='hidden'}
	else if (v==1){option='visible';}
	if(ie){ //For IE 4
		d.all(layerName).style.visibility = option;}
	else if(dom){ //For NS6
		d.getElementById(layerName).style.visibility = option;}
	else if(ns4){ //For NS4
		d.layers[layerName].visibility = option;}
}
function killDelay(){
	if(dom && timer!=null){
		window.clearTimeout(timer)}
	else{return}
}
	
function delayHide(which,v){
	lName = which
	if(dom){ //For NS6
		timer = setTimeout("showHide(lName,0)",10)}
	else {showHide(lName,0)}
}
	
// Change CSS of Nav and Subnavs *****************************************
function changeNavCSS(which, v)
{
    TDname = "nav" + which;
    d = document;
	
	if(ie){
		if(which != activeNav){
			if(v==1){d.all(TDname).className = "navBckgrndOver";}
			else if(v==0){d.all(TDname).className = "navBckgrnd";}
		} else {
			if(v==1){d.all(TDname).className = "navBckgrndOver";}
			else if(v==0){d.all(TDname).className = "navBckgrndActive";}
		}
	}
	else if(dom){
		if(which != activeNav){
			if(v==1){d.getElementById(TDname).className = "navBckgrndOver";}
			else{d.getElementById(TDname).className = "navBckgrnd";}
		} else {
			if(v==1){d.getElementById(TDname).className = "navBckgrndOver";}
			else if(v==0){d.getElementById(TDname).className = "navBckgrndActive";}
		}
	}
}

function changeSubNavCSS(which)
{
    tableName = "snav" + which + "table";
    d = document;
    
	if(ie){
		if(d.all(tableName).className == "snavBckgrnd"){
			d.all(tableName).className = "snavBckgrndOver";}
		else{
			d.all(tableName).className = "snavBckgrnd";}
	}
	else if(dom){
		if(d.getElementById(tableName).className == "snavBckgrnd"){
			d.getElementById(tableName).className = "snavBckgrndOver";}
		else{
			d.getElementById(tableName).className = "snavBckgrnd";}
	}
}


function openPopUp(a)
{
/* Original:
    window.open(
        a.href,
        '',
        'scrollbars=yes,resizable=yes,width=360,height=270,left=180,top=210,screenX=180,screenY=210');
*/
    window.open(
        a.href,
        '',
        'scrollbars=yes,resizable=yes,width=500,height=400,left=180,top=210,screenX=180,screenY=210');
    
    window.event.returnValue = false;
}

function navOver(a, i)
{
	//a.oldClass  = a.className;
	a.className = "Hover";  //a.classHover;

	positionSNav();

	showHide(i, 1);
}


function navOut(a, i)
{
	a.className = "link";  //a.oldClass;
	showHide(i, 0);
}