/*
Jason R. Sebring, National Systems and Research E-Division, 8/8/2002

JRS DHTML MENUS version 1.0 - known compatibility: NETSCAPE 6 and IE 4+ on PC

Change ID	:	WINV030018
Date		:	05-16-2003
Author		:	PrioritySupport
Comments	:	Disable Drop Down Feature on Top Nav Bar.


Change ID	: WIAZ030004
Date		: 06-27-2003
Author		: Priority Support
Comments	: Drop Down Menus in Nestcape: The Data Analysis Drop Down in IE has been Left Justified. IT needs to be the same in Netscape also

Change ID	: WIOH030005
Date		: 07-28-2003
Author		: Priority Support
Comments	: Changed letters in the drop down menu should be in Sentence Case

Change ID	: 
Date		: 2-2-2005
Author		: Dan Kahle
Comments	: The menu has been hiding select elements to keep them from overlaying the menu. 
				This is only needed for IE as netscape selects don't overlap. This change implements
				an iframe modification for IE only that clears up the problem without having to hide 
				the select elements. If we ever need to hide the selects (or any other element) again,
				I've put SELECT_HIDING blocks everywhere where I commented or defeated the select 
				hiding code.

' Change ID	: WI3.1_CHANGES
' Date			: 02-01-2006
' Author		: Dan Kahle
' Comments	: Change UI template code


'Change ID	:	WI_3.1_ADA_Change
'Date		:	08.23.06
'Author		:	Murali Vijay
'Comments	:	Remove all alt="decor" entries, add alt="" to layout .gif images
'			and add Skip To Content link to the head. 

*/

var DHTMLMenu_interval = null;
var DHTMLMenu_openMenus = new Array();
var DHTMLMenu_selectStyle;
var isIE = navigator.userAgent.indexOf("MSIE") > 0

//START_SELECT_HIDING
//This sets up the select hiding
/* 
SetStyleRules();

// ---------------------------------
function SetStyleRules() {
// ---------------------------------
	var arrRules;
	if(document.styleSheets.length > 0)
	{
		if(document.styleSheets[0].cssRules) { arrRules = document.styleSheets[0].cssRules; }
		else if(document.styleSheets[0].rules) { arrRules = document.styleSheets[0].rules; }
	}
	
	for(var i = 0; i < arrRules.length; i++) 
	{
		switch(arrRules[i].selectorText.toLowerCase()) {
			case 'select':
				DHTMLMenu_selectStyle = arrRules[i];
				return;
		}
	}
}
*/
//END_SELECT_HIDING

// ---------------------------------
function HideFormElements(blnHide) {
// ---------------------------------

//START_SELECT_HIDING
	return; // this easily defeats the select hiding.
//END_SELECT_HIDING

	var strVisibility;
	
	if(blnHide) { strVisibility = 'hidden'; }
	else { strVisibility = 'visible'; }
	
	DHTMLMenu_selectStyle.style.visibility = strVisibility;
}




// ---------------------------------
function GetObjById(strId) {
// ---------------------------------
	if(document.getElementById) {
		return document.getElementById(strId);
	} else if(isIE) {
		return document.all[strId];
	} else if(document.layers) {
		return document.layers[strId];
	}
}

// ---------------------------------
function DrawMenu() {
// ---------------------------------
	if(isIE || document.getElementById) {
		document.write('<div id="' + this.id + '"   style="display:none;position:absolute;z-index:100;border:1px solid #000000;">');
	} else if(document.layers) {
		document.write('<layer id="' + this.id + '" style="display:none;position:absolute;z-index:100;border:1px solid #000000;">');
	}

	if(isIE) 
	{
		var div = document.getElementById(this.id);
		div.iframe = div.parentNode.insertBefore(document.createElement("IFRAME"), div);
		div.iframe.style.display = "none";
		div.iframe.style.position = "absolute";
	}

	document.write('<table cellpadding="0" cellspacing="0" border="0">');

	var strHref;
	var strStyle = '';
	
	if(isIE) {
		strStyle = 'width:100%;';
	}
	
	for(var i = 0; i < this.links.length; i++) {
		//WIOH030005
		//this.links[i].label = this.links[i].label.toLowerCase();
		if(this.links[i].address != '') {
			strHref = 'href="' + this.links[i].address + '"'
		} else {
			strHref = '';
		}
		if(this.links[i].menu != '') {
			document.write(
			'		<tr id="'+ this.links[i].menu + '_row" onmouseout="Handle_OnMouseOut();" onmouseover="Handle_OnMouseOver(this, \'' + this.id + '\', \'' + this.links[i].menu + '\');" class="navBgColor">' +
			'		<td nowrap><span class="navBgColor"><a class="detailedMenuLink" '+ strHref +' unselectable="on" style="'+strStyle+'">'+ this.links[i].label +'</a></td><td><a class="topNavText" style="font-family:webdings;font-size:8pt;'+strStyle+'" unselectable="on" '+ strHref +'>4</a></span></td>' +
			'		</tr>'
			);
		} else {
			document.write (
			'		<tr id="'+ this.links[i].menu + '_row" onmouseover="Handle_OnMouseOver(this, \'' + this.id + '\');" onmouseout="Handle_OnMouseOut(this);" class="navBgColor">' +
			'			<td nowrap><span class="navBgColor"><a class="detailedMenuLink" '+ strHref +' unselectable="on" style="'+strStyle+'">'+ this.links[i].label +'</a></td><td><a class="topNavText" '+ strHref +' unselectable="on" style="'+strStyle+'">&nbsp;</a></span></td>' +
			'		</tr>'
			);
		}
	}
	document.write('</table>');
	if(isIE || document.getElementById) {
		document.write('</div>');
	} else if(document.layers) {
		document.write('</layer>');
	}

}

//WI3.1_CHANGES: Add baseUrlForDotNetOnly parameter, then prepend the 8 images/... paths with it.
// ---------------------------------
function DrawRoot(strLabel, strMenuId,link,title,pageId, currentPageId, baseUrlForDotNetOnly) {
// ---------------------------------
   	if(baseUrlForDotNetOnly == null)
		baseUrlForDotNetOnly = "";
	strLabel = '&nbsp;' + strLabel + '&nbsp;'
	document.write('<div unselectable="on" class="topNavBg" onmouseover="Handle_OnMouseOverForRoot(this,\''+strMenuId+'_row\',\''+strMenuId+'\');"  onmouseout="Handle_OnMouseOut();" id="'+strMenuId+'_row">');
	/*document.write('<span class="topNavText">')
	document.write(strLabel);
	document.write('</span>');*/
	//document.write('<span style="font-family:webdings;">6</span>');
   
   if(pageId!=currentPageId) 
   {	
		document.write('<table border="0" cellpadding="0" cellspacing="0">')
			document.write('<tr>')
				document.write('<td rowspan="3" width="1" height="20"><img class="img" src="' + baseUrlForDotNetOnly + 'images/topNavLeft.gif" alt="" width="1" height="20" /></td>')
				document.write('<td height="1" bgcolor="#ffffff"><img class="img" src="' + baseUrlForDotNetOnly + 'images/onepix.gif" height="1" width="1" alt="" /></td>')
				document.write('<td rowspan="3" width="2" height="20"><img class="img" src="' + baseUrlForDotNetOnly + 'images/topNavRight.gif" alt="" width="2" height="20" /></td>')
			document.write('</tr>')
			document.write('<tr>')
				document.write('<td class="topNavBg"><a href="'+link+'" title="'+title+'" border="0" class="topNavText">'+strLabel+'</a></td>')
			document.write('</tr>')
			document.write('<tr>')
				document.write('<td background="' + baseUrlForDotNetOnly + 'images/topNavBottom.gif" height="2"><img class="img" src="' + baseUrlForDotNetOnly + 'images/onepix.gif" alt="" width="1" height="2" /></td>')
			document.write('</tr>')
		document.write('</table>')
	}
	else
	{
		document.write('<table border="0" cellpadding="0" cellspacing="0">')
		document.write('<tr>')
			document.write('<td class="topNavBgSelected" rowspan="3" width="3" height="20"><img class="img" src="' + baseUrlForDotNetOnly + 'images/topNavLeftSelected.gif" alt="" width="3" height="20" /></td>')
			document.write('<td background="' + baseUrlForDotNetOnly + 'images/topNavTopSelected.gif" height="3"><img class="img" src="' + baseUrlForDotNetOnly + 'images/onepix.gif" alt="" height="3" width="1" /></td>')
			document.write('<td class="topNavBgSelected" rowspan="3" width="3" height="20"><img class="img" src="' + baseUrlForDotNetOnly + 'images/topNavRightSelected.gif" alt="" width="3" height="20" /></td>')
		document.write('</tr>')
		document.write('<tr>')
			document.write('<td class="topNavBgSelected"><a href="'+link+'" title="'+title+'"  border="0" class="topNavTextSelected">'+strLabel+'</a></td>')
		document.write('</tr>')
		document.write('<tr>')
			document.write('<td background="' + baseUrlForDotNetOnly + 'images/topNavBottomSelected.gif" width="1" height="3"><img class="img" src="' + baseUrlForDotNetOnly + 'images/onepix.gif" alt="" width="1" height="3" /></td>')
		document.write('</tr>')
	 document.write('</table>')
	
	}
	
	document.write('</div>');
}





// ---------------------------------
function DrawRootLink(strLabel, strMenuId, strAddress) {
// ---------------------------------
	document.write('<div unselectable="on" class="topNavBg" onmouseover="Handle_OnMouseOverForRoot(this);"  onmouseout="Handle_OnMouseOut(this);" id="'+strMenuId+'_row">');
	if(arguments.length == 3)
	{
		document.write('<a href="'+strAddress+'" class="topNavBg">'+strLabel+'</a>');
	}
	else
	{
		document.write(strLabel);
	}
	document.write('</div>');
}

// ---------------------------------
function Handle_OnMouseOverForRoot(objRow, strMenuId, strChildMenuId) {
// ---------------------------------
	//objRow.className = 'navBgColor';
	// disable rollover effect:
	return;
	if(DHTMLMenu_interval) {
		window.clearTimeout(DHTMLMenu_interval);
	}
	closeMenus(strMenuId, strChildMenuId);
	if(arguments.length==3) {
		HideFormElements(true);
		OpenChildMenu(objRow, strChildMenuId);
	}
}


// ---------------------------------
function OpenChildMenu(el, strId)
// ---------------------------------
{
    //alert(strId);
	if(DHTMLMenu_interval) {
		window.clearTimeout(DHTMLMenu_interval);
	}
	if(isIE || document.getElementById) {
		var x		= getRealLeft(el);
		//alert(x);
		var y		= getRealTop(el);
		//alert(x);
		var width	= x;
		var height	= y + el.offsetHeight;

		//el.className="navBgColor";
		if(arguments.length == 2 && strId) 
		{
			var div = GetObjById(strId);
			//el.className = 'navBgColor';
			
			// WIAZ030004 - Reduce the width.
			var bName = navigator.appName;
			if (!isIE && strId=="DataAnalysis")
				div.style.left	= (width-160)+'px';
			else
				div.style.left	= width+'px';
			//WIAZ030004 Ends here ...
			
			div.style.top	= height+'px';
			div.style.filter	='progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color="gray", Positive="true")'
			div.style.display	= 'block';

			if (isIE)
			{
				div.iframe.style.left = div.style.left;
				div.iframe.style.top  = div.style.top;
				div.iframe.style.width  = div.offsetWidth + "px";
				div.iframe.style.height = div.offsetHeight + "px";
				div.iframe.style.display = "";
			}
			
			MoveOnScreen(strId);
		}
	} else if(document.layers) {
	}
	if(DHTMLMenu_openMenus[DHTMLMenu_openMenus.length - 1] != strId) {
		DHTMLMenu_openMenus[DHTMLMenu_openMenus.length] = strId;
	}
}

// ---------------------------------
function Handle_OnMouseOver(objRow, strMenuId, strChildMenuId) {
// ---------------------------------
	//objRow.className = 'navBgColor';
	if(DHTMLMenu_interval) {
		window.clearTimeout(DHTMLMenu_interval);
	}
	closeMenus(strMenuId, strChildMenuId);
	if(arguments.length==3) {
		HideFormElements(true);
		openMenu(objRow, strChildMenuId);
	}
}

// ---------------------------------
function Handle_OnMouseOut(objRow) {
// ---------------------------------
	
	if(arguments.length == 1) {
		//objRow.className = 'navBgColor';
	}

	DHTMLMenu_interval = window.setTimeout("closeAllMenus()", 500);
}

// ---------------------------------
function closeAllMenus() {
// ---------------------------------
	var i;
	for(i = DHTMLMenu_openMenus.length; i > 0; i--) {
		if(isIE || document.getElementById) 
		{
			GetObjById(DHTMLMenu_openMenus[i - 1]).style.display = 'none';
			//GetObjById(DHTMLMenu_openMenus[i - 1] + '_row').className = 'navBgColor';
			if(isIE)
				GetObjById(DHTMLMenu_openMenus[i - 1]).iframe.style.display = 'none';

		} else if(document.layers) {

		}
	}
	DHTMLMenu_openMenus.length = 0;
	HideFormElements(false);
}

// ---------------------------------
function closeMenus(strMenuId, strChildMenuId) {
// ---------------------------------
	var i, intCloseCount = 0;
	if(DHTMLMenu_openMenus.length == 0) { return; }
	if(arguments.length == 2) {
		for(i = 0; i < DHTMLMenu_openMenus.length; i++) {
			if(DHTMLMenu_openMenus[i] == strChildMenuId) { return; }
		}
	}
	for(i = DHTMLMenu_openMenus.length; i > 0; i--) {
		if(DHTMLMenu_openMenus[i-1] == strMenuId) { break; }
		if(isIE || document.getElementById) {
				GetObjById(DHTMLMenu_openMenus[i - 1]).style.display = 'none';
				//GetObjById(DHTMLMenu_openMenus[i - 1] + '_row').className = 'navBgColor';
			if(isIE)
				GetObjById(DHTMLMenu_openMenus[i - 1]).iframe.style.display = 'none';

		} else if(document.layers) {

		}
		intCloseCount++;
	}
	DHTMLMenu_openMenus.length = DHTMLMenu_openMenus.length - intCloseCount;
	if(DHTMLMenu_openMenus.length==0) { HideFormElements(false); }
}

// ---------------------------------
function cLink(strLabel, strAddress, strMenu, strId) {
// ---------------------------------
	this.label = strLabel;
	this.address = strAddress;
	this.menu = strMenu;
	this.menuName = strId;
}

// ---------------------------------
function AddLink(strLabel_in, strAddress_in, strMenu_in) {
// ---------------------------------
	var strLabel, strAddress, strMenu;
	if(arguments.length < 3) {
		strMenu = '';
	} else {
		strMenu = strMenu_in;
	}
	if(arguments.length < 2) {
		strAddress = '';
	} else {
		strAddress = strAddress_in;
	}
	if(arguments.length == 0) {
		strLabel = 'label';
	} else {
		strLabel = strLabel_in;
	}

	this.links[this.links.length] = new cLink(strLabel, strAddress, strMenu, this.id);
}

// ---------------------------------
function cMenu(strId)
// ---------------------------------
{
	this.id = strId;
	this.links = new Array();
	this.addLink = AddLink;
	this.draw = DrawMenu;
}

// ---------------------------------
function openMenu(el, strId)
// ---------------------------------
{
	if(isIE || document.getElementById) {
		var x		= getRealLeft(el);
		var y		= getRealTop(el);
		var width	= x + el.offsetWidth;
		var height	= el.offsetHeight;

		//el.className="navBgColor";

		if(arguments.length == 2 && strId) {
			GetObjById(strId).style.display	= 'block';
			GetObjById(strId).style.left	= width;
			GetObjById(strId).style.top	= y;
		}
	} else if(document.layers) {

	}
	if(DHTMLMenu_openMenus[DHTMLMenu_openMenus.length - 1] != strId) {
		DHTMLMenu_openMenus[DHTMLMenu_openMenus.length] = strId;
	}
}

// ---------------------------------
function getRealLeft(el) {
// ---------------------------------
    if (arguments.length==0) { el = this; }
    var xPos = el.offsetLeft;
    var tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

// ---------------------------------
function getRealTop(el) {
// ---------------------------------
    if (arguments.length==0) { el = this; }
    var yPos = el.offsetTop;
    var tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}

// ---------------------------------
function AddMenu(strId) {
// ---------------------------------
	eval('this.' + strId + '= new cMenu(\'' + strId + '\');');
	this.menu[this.menu.length] = strId;
}

// ---------------------------------
function DrawMenus() {
// ---------------------------------
	for(i = 0; i < this.menu.length; i++) {
		this[this.menu[i]].draw();
	}
	this.menu = null;
}

// ---------------------------------
function DHTMLMenu() {
// ---------------------------------
	this.menu = new Array();
	this.addMenu = AddMenu;
	this.draw = DrawMenus;
}

// ---------------------------------
function DHTMLBox(strID) {
// ---------------------------------
	this.minX = 0;
	this.minY = 0;
	this.maxX = 0;
	this.maxY = 0;
	this.el = document.getElementById(strID);

	this.getMinX = getRealLeft;

	this.getMinY = getRealTop;

	this.minX = this.getMinX(this.el);
	this.maxX = this.minX + this.el.offsetWidth;
	this.minY = this.getMinY(this.el);
	this.maxY = this.minY + this.el.offsetHeight;
}
// ---------------------------------
function MoveOnScreen(strID) {
// ---------------------------------
	var objBox = new DHTMLBox(strID);

	var BodyMinX = document.body.scrollLeft;
	var BodyMinY = document.body.scrollTop;
	
	if(document.body.clientWidth)  // IE 4+
	{
		BodyMinX = document.body.scrollLeft;
		BodyMaxX = BodyMinX + document.body.clientWidth;
		BodyMinY = document.body.scrollTop;
		BodyMaxY = BodyMinY + document.body.clientHeight;
	}
	else if(document.getElementById) // NS6+
	{
		BodyMinX = document.body.scrollLeft;
		BodyMaxX = BodyMinX + window.innerWidth;
		BodyMinY = document.body.scrollTop;
		BodyMaxY = BodyMinY + window.innerHeight;
	}
	else
	{
		return;
	}

	var left=-1, top=-1;

	if(objBox.minX < BodyMinX)
		left = BodyMinX;
	else if(objBox.maxX > BodyMaxX)
	{
		var newX = BodyMaxX - objBox.el.offsetWidth;
		if(newX < BodyMinX)
			left = BodyMinX;
		else
			left = newX;
	}
	
	if(objBox.minY < BodyMinY)
		top = BodyMinY;
	else if(objBox.maxY > BodyMaxY)
	{
		var newY = BodyMaxY - objBox.el.offsetHeight;
		if(newY < BodyMinY)
			top = BodyMinY;
		else
			top = newY;
	}
	
	if(left != -1)
	{
		objBox.el.style.left = left;
		if(isIE)
			objBox.el.iframe.style.left = left;
	}
	
	if(top != -1)
	{
		objBox.el.style.top = top;
		if(isIE)
			objBox.el.iframe.style.top = top;
	}
	
}