


// Generic JavaScript code for Experian E-Series Applications
// Used for drop down navigation menus
// Version 3.03
// January 24 2002
// Copyright 2002, Experian Ltd

// ****************************************
// Javascript for Drop-down Navigation Bar 
// ****************************************

var imagePath = "images/";
var mnuSelected = "";
var rightx = 0;
var leftx = 0;
var righty = 0;

// Sets the propeties of each menu item.  
// text is the actual displayed text, link is the hyperlink for the menu item,
// target will specify a target frame.

function menuItem(text, link, target, title){
 this.text = text;
 this.link = link;
 this.title = title;
 if (target) {
  this.target = target;
 } else {
  this.target = "PageContent";
 }
}

// Sets up a new instance of a menu class containing properties and methods for its items.

function menu(){
	var itemArray = new Array();
	var args = menu.arguments;
	this.name = args[0];
	for(i=1; i<args.length; i++){
		itemArray[i-1] = args[i];
	}
	this.menuItems = itemArray;
	this.write = writeMenu;
	this.position = positionMenu;
}

// Positions the drop down on the screen

function positionMenu(top,left,width) {
	this.top = top;
	this.left = left;
	//this.width = width;
}

// Calculates the desired left hand position of the drop down menu in relation to its heading.  Different
// properties for Netscape 4.x

function calcLeftPos(element,indent) {
	var leftpos = 0;
	
	if (document.layers) {
		leftpos = getElement('mnuHeadings').document.layers[element].pageX + indent;
	} else {
		leftpos = getElement(element).offsetLeft + indent;
	}
	return leftpos;
}

// Calculates the desired top position of the drop down menu in relation to its heading.  Different
// properties for Netscape 4.x

function calcTopPos(element) {
	var toppos = 0;
		
	if (document.layers) {
		toppos = getElement(element).clip.height;
	} else {
		toppos = getElement(element).offsetHeight;
	}
	return toppos;
}


// Calculates width of window.  Note clientWidth returns 0 in Netscape 7, when frames scrolling is turned off using
// 'no' due to a bug 

function calcScreenWidth() {
	var screenWidth;
	
	if (document.layers) {
		screenWidth = innerWidth;
	} else {
		screenWidth = document.body.clientWidth;
		if (screenWidth == 0 || !screenWidth) {
			screenWidth = document.body.offsetWidth;
		}
	}
	
	return screenWidth;
}

// Displays the drop down menu using its visibility property.  
// Usually called from onMouseOver event of menu heading.  
var trgColour
function showMenu(menu,leftpos,toppos) {

	var leftindent = 5;	
	var bannerHeight = 65;
	var subMenuID = getElement(menu);
	if(!menu)
		return;
		
	if (mnuSelected != "" && mnuSelected != menu) {
		hideMenu();
	}
	
	if(menu!="mnuDefault"){
		var trgID = getElement("trg"+menu.substr(3));
		trgColour = trgID.style.background;
		if(szLockedMenu)
			getElement(szLockedMenu).style.background=trgColour;
		trgID.style.background="#000066";
	}
	
	if (getElement('esbanner')) {
		bannerHeight = calcTopPos('esbanner');
	}
		

	//if (document.getElementById) {
	//	subMenuID.style.width = subMenuID.childNodes[0].offsetWidth + 16;
	//} else if (document.all) {
	//	subMenuID.style.width = subMenuID.children[0].clientWidth + 16;
	//} 
	//
	//if (leftpos != null) {
	//	if (document.layers) {
	//		subMenuID.left = leftpos;
	//	} else {
	//		if ((leftpos + parseInt(subMenuID.style.width)) >= (calcScreenWidth() - 10)) {
	//			var fitleft = calcScreenWidth() - parseInt(subMenuID.style.width);
	//			subMenuID.style.left = fitleft;
	//		} else {
	//			subMenuID.style.left = leftpos;
	//		}
	//	}
	//}
	
	subMenuID.style.width="100%"
	
	if (toppos != null) {
		if (document.layers) {
			var extraHeight=0;
			if(arguments[3]) extraHeight=arguments[3];
			subMenuID.top = toppos + bannerHeight + extraHeight;
		} else {
			subMenuID.style.top = toppos + bannerHeight;
		}
	}
	
	if (document.layers) {
		leftx = subMenuID.left;
		rightx = leftx + subMenuID.clip.width;
		righty = subMenuID.top + subMenuID.clip.height;
		subMenuID.visibility = 'show';
	} else {
		subMenuID.style.visibility = 'visible';
	}
	
	mnuSelected = menu;
}

// Hide the drop down menu from view.
// Usually called from onMouseOut/onMouseClick events to hide the drop down menu.

function hideMenu(e) {
	if (mnuSelected) {
		if (document.getElementById) {
			getElement(mnuSelected).style.visibility = 'hidden';
			var oMenu = getElement("trg"+mnuSelected.substr(3));
			var oMenuStyle= oMenu.style;
			oMenuStyle.background=trgColour;
			if(szLockedMenu)
				getElement(szLockedMenu).style.background="#000066"
		} else if (document.all) {
			if (event.srcElement.tagName != "A") {
				getElement(mnuSelected).style.visibility = 'hidden';
			}
		} else if (document.layers) {
			if (e) {
				var posX = e.pageX;
				var posY = e.pageY;
			
				if (posX > rightx || posX < leftx) {
					getElement(mnuSelected).visibility = 'hide';
				} else if (posY > righty) {
					getElement(mnuSelected).visibility = 'hide';
				}
			} else {
				getElement(mnuSelected).visibility = 'hide';
			}
		}
	}
}

// Causes drop-down to dissappear when mouse moves out of menuheading area.  This is
// separate to hideMenu to prevent menus hanging around on IE4.

	function hideMenuHeading() {
		if (mnuSelected) {
			getElement(mnuSelected).style.visibility = 'hidden';
			getElement("trg"+mnuSelected.substr(3)).style.background=trgColour;
			if(szLockedMenu)
				getElement(szLockedMenu).style.background="#000066"
		}
	}
		
// Builds the drop-down menu using the information passed in.  Keeps it hidden initially, ready
// to be displayed onMouseOver.
var szLockedMenu="";
function lockMenu(id){
	getElement("mnuDefault").innerHTML=getElement(id).innerHTML
	szLockedMenu = "trg"+id.substr(3)
	getElement(szLockedMenu).style.background="#000066"
	showMenu("mnuDefault",0,calcTopPos('mnuHeadings'))
	mnuSelected="";
}

function writeMenu() {
	var menuText;
	menuText = '<div id="' 
	menuText += this.name;
	menuText += '" style="background:#66ccff;position:absolute;z-index:1;visibility:hidden;left:0"';
	
	menuText+='onClick="hideMenu();" onMouseOver="showMenu(mnuSelected,null,null)" onMouseOut="hideMenu();">';
	menuText+='<table cellpadding="1"><tr>';
	
	//Consumer one
	for(i=0; i<this.menuItems.length; i++){
		menuText += '<td>';
		menuText += '<a class="menulink2" ';
		menuText += 'onclick="lockMenu(\'' + this.name + '\')" ';
		menuText += 'target="' + this.menuItems[i].target + '" href="' + this.menuItems[i].link + '" title="' + this.menuItems[i].title + '">';
		menuText += this.menuItems[i].text + '</a></td>';
		if(i<this.menuItems.length-1) menuText += '<td class="menuseparator1">|</td>';	
	}
	
	menuText+='</tr></table></div>';
		
	document.write(menuText);
	document.close();	
}

function writeMenuOLD() {
	
	if (document.layers) {
		var menuText = '<layer id="';
	} else {
		var menuText = '<div id="';
	}
	menuText += this.name;
	if (document.layers) {
		menuText += '" visibility="hide" z-index="1"'; 
	} else {
		menuText += '"  style="';
		menuText += 'position:absolute;z-index:1;visibility:hidden;top: ';
		menuText += this.top;
		menuText += ';left: ';
		menuText += this.left + '"';
	}
	menuText += '>';
	menuText += '<table cellpadding="0" cellspacing="0" border="0" width="';
	menuText += this.width;
	menuText += '" onClick="hideMenu();" onMouseOver="showMenu(mnuSelected,null,null)" onMouseOut="hideMenu();">';
	for(i=0; i<this.menuItems.length; i++){
		menuText += '<tr bgcolor="#000066">';
		menuText += '<td width="5px" class="menuside">&nbsp;</td>';
		menuText += '<td class="menulink2" nowrap="nowrap"><a ';
		menuText += 'target="' + this.menuItems[i].target + '" class="menulink2"  href="' + this.menuItems[i].link + '">';
		menuText += this.menuItems[i].text + '</a></td>';
		menuText += '<td width="5px" class="menuside">&nbsp;</td>';
		menuText += '</tr>';
	}
	menuText += '<tr valign="top"><td width="5px" class="menuside"><img src="' + imagePath + 'mnu_bottomleft.gif" border="0"></td><td ';
	if (document.layers) {menuText += ' width="98%"'};
	menuText += ' bgcolor="#000066" class="menuside">&nbsp;</td><td><img border="0" src="' + imagePath + 'mnu_bottomright.gif"></td></tr>';
	menuText += '</table>';
	if (document.layers) {
		menuText += '</layer>';
	} else {
		menuText += '</div>';								
	}
	
	document.write(menuText);
	document.close();	
}

// Capture mouse move event in Netscape 4 to aid in release of drop down.

if (document.layers)
{
	window.captureEvents(Event.MOUSEMOVE);
	window.onmousemove = hideMenu;
}


// ------------------------------------------------------
//	LINES ADDED IN CASE OF STRIPPING BY R and D SCRIPTS
// ------------------------------------------------------
