﻿/* The IE navigation fixes (fix to prevent IE navs from losing z-index over select box, fix so that IE lists can recognize a hover event */
navManager = function() {
	if(document.getElementById("navContainer")){
		sfHover("navContainer","UL LI"," navHover"," navHoverOff", "selected");
	}
	if(document.getElementById("subNav")){
		sfHover("subNav","UL LI"," subNavHover"," subNavHoverOff", "selected");
	}
	if(document.getElementById("leftNav")){
		sfHover("leftNav","UL LI"," leftNavHover"," leftNavHoverOff", "subSelected");
	}	
	if(document.getElementById("leftNav")){
		sfHover("leftNav","DIV"," leftNavHover"," leftNavHoverOff", "leftSelected");
	}		

	$j("#subNav>ul>li>ul").bgiframe();

}


function setHover(nav) {
	var ieULs = nav.getElementsByTagName('ul');
	// IE script to cover <select> elements with <iframe>s
	for (j=0; j<ieULs.length; j++) {
		ieULs[j].innerHTML = ('<iframe src="about:blank" scrolling="no" frameborder="0" style="filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);"></iframe>' + ieULs[j].innerHTML);
		var ieMat = ieULs[j].firstChild;
		ieMat.style.width=ieULs[j].offsetWidth+"px";	
		ieMat.style.zIndex="-1";
		ieULs[j].style.zIndex="101";
	}
}


function sfHover(id, tagType, hoverClass, hoverClassOff, selectedClass)
{
	var sfEls = $j( "#" + id + ">" + tagType ).not( ".nohover" );
	for (var i=0; i<sfEls.length; i++)
	{
		if(sfEls[i].className != selectedClass && sfEls[i].id != selectedClass  )
		{

			sfEls[i].onmouseover=function() {
				$j(this).addClass( hoverClass );

			}

			sfEls[i].onmouseout=function() {
				$j(this).removeClass( hoverClass );
			}

		}
		else
		{
			var selectedClassOver = selectedClass + "Over";
			sfEls[i].onmouseover=function() {
				$j(this).removeClass( selectedClass );
				$j(this).addClass( selectedClassOver );

			}
			sfEls[i].onmouseout=function() {
				$j(this).removeClass( selectedClassOver );
				$j(this).addClass( selectedClass );
			}
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

if ( $j.browser.msie )
{
	window.attachEvent("onload", navManager);
}

imageArray=new Array();
numImages=new Array();
currentImage=new Array();

function switchImage(imgname)
{
	document[imgname].src=imageArray[imgname+(currentImage[imgname]+1)];
	currentImage[imgname]=(currentImage[imgname]+1)%numImages[imgname];
	setTimeout("switchImage(\""+imgname+"\")",5000);
}

function imgRollover(loadImg, onImg)
{
	// prevent this routine from running twice
	if (! loadImg.outImg)
	{
		// set src of the "on" image
		loadImg.outImg = new Image();
		loadImg.outImg.src = loadImg.src;
		loadImg.onmouseout=img_mouseOut;

		// set the src of the "over" image
		loadImg.overImg = new Image();
		loadImg.overImg.src = onImg
		loadImg.onmouseover=img_mouseOver;
	}
}
     
// event handler for OnMouseOut
function img_mouseOut()  {this.src = this.outImg.src;}
     
// event handler for OnMouseOver
function img_mouseOver() {this.src = this.overImg.src;}

function showDiv(id)
{
	document.getElementById(id).style.display="block";
}

function hideDiv(id)
{
	document.getElementById(id).style.display="none";	
}

currentemail=0;

function email_link()
{
  if (currentemail==0)
  {
	hideDiv("bodyContent");
	showDiv("emailContent");
	currentemail=1;
  }
  else
  {
	showDiv("bodyContent");
	hideDiv("emailContent");
	currentemail=0;
  }
}

function openWin( url, w, h, x, y) {
    msgWindow = window.open('','newWin','width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',top=' + x + ',left=' + y + ',scrollbars=yes,menubar=yes,resizable=yes,toolbar=yes,location=yes,status=yes');
    msgWindow.location.href = url;
	if (window.focus) {msgWindow.focus()}
	return false;
}

function redirectWin( url ) {
    window.location.href = url;
    return false;
}


//Track using G-Code 
function trackLinks(clientLogin,parentLink,reportSuite) {		
s_linkTrackVars="prop9";
s_linkTrackEvents="None";
s_linkType="o";
s_linkName=clientLogin;
s_prop9=parentLink; 
s_lnk=s_co(this); 
s_gs(reportSuite);  

} 

	$j(document).ready(function() {
	
		if ( $j.browser.msie )
		{
			// prevent IE bg image flicker
			document.execCommand("BackgroundImageCache", false, true);

			//  enforce min height for IE
			var crHeight = $j( "#contentRight" ).height();
			if ( crHeight < 400 )
			{
				$j( "#contentRight" ).height( 410 );
			}
			else
			{
				var heightVal = $j( "#globalNav" ).height() + $j( "#logoSearch" ).height() + $j( "#navContainer" ).height() + $j( "#subNav" ).height() + $j( "#containerbg" ).height();
				if ( heightVal < 530 )
				{
					var newHeight = 530 - heightVal;
					// expand content by the difference
					$j( "#contentRight" ).height( $j( "#containerbg" ).height() + newHeight );
				}
			}
		}

		// add wrapper DIV to hold pointer for selected leftNav items
		$j( "div#leftNav>div#leftSelected" ).children().wrapAll( "<div id='indent'></div>" );
		$j( "div#leftNav>div>a" ).wrap( "<div id='indent'></div>" );

		// add class to distinguish first leftNav item for separator bar display
		$j( "div#leftNav>div:first" ).addClass("firstNode");

		// apply class for styling of Country Sites link in Utility nav
		// also strip trailing slash from previous item in navigation
		var countryNode = $j("#globalNav #utilSearch ul li a[title*=Country]").parent();
		if ( (countryNode != null) && (countryNode.prev() != null) && (countryNode.prev().html() != null) )
		{
		    $j("#globalNav #utilSearch ul li a[title*=Country]").parent().addClass("country").prev().html( countryNode.prev().html().split("&nbsp;/")[0] );
		}

		$j('.news').newsWidget();

	});
	
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
//-->