// JavaScript Document

//The following function creates the HTML for a dropdown menu from the information passed to it
	//The function takes an indefinite number of parameters, each in the form of a two-member, one-dimensional array:
	//First member is the menu item's text, the second is the URL to which the item is linked

function createDropMenu(menuItems) {	
	if (menuItems.length > 0) {
		strMenu	= '';
		strMenu += '<table class="dropShadow" cellspacing="0" cellpadding="0" style="z-index: 10;">';
		strMenu += '<tr><td>';
		strMenu += '<table class="dropMenu" cellspacing="0" style="z-index: 10; background-image: url(' + jsRootPath + 'Images/Global/dropMenuGrad.gif); background-repeat: repeat-y;">';
		for (i=0; i<menuItems.length; i++) {			
			strMenu = strMenu + '<tr><td class="dropMenu" onMouseOver="hoverMnuOpt(this)" onMouseOut="hoverMnuOpt(this)"' +
			' onClick="cellClicked(' + "'" + menuItems[i].target + "','" + menuItems[i].URL + "'" + ')"' + 
			' style="">' +
			menuItems[i].text +
			'</td></tr>';
		}
		strMenu += '</table>';
		strMenu += '</td></tr></table>';
	} else {
		strMenu = '';
	}
	return strMenu;
}

function hoverMnuOpt(cell) {
	if ((cell.style.backgroundColor==hoverBackground)||(cell.style.backgroundColor==formatColor(hoverBackground,'Netscape'))) {
		OkToClose = true;
		cell.style.backgroundColor = 'transparent';
		cell.style.color = offText;		
		t = setTimeout('closeAllMenus(menuHolder,menuFrame)',1000);
	} else {		
		cell.style.backgroundColor = hoverBackground;
		cell.style.color = hoverText;
		//cell.style.cursor = "hand"
		OkToClose = false;
		hoverTab(lastTabHovered,false);
	}
	//rgb(130,0,60) = #82003c
}

function cellClicked(target,URL) {
	OkToClose = true;
	closeAllMenus(menuHolder,menuFrame);
	switch(target) {
		case 'blank':
			window.open(URL,'newWind');
			break;
		default:
			eval(target).location.href = URL;
	}	
}

function closeAllMenus(holder,frame){
	if (OkToClose) {
			document.getElementById(holder).style.visibility = 'hidden';
			document.getElementById(frame).innerHTML = '';
			releaseTab(lastTabHovered,true);			
	}
	clearTimeout(t);
}

function keepMenuOpen(){
	OkToClose = false;
}

function menuItem(itemText,linkURL,linkTarget) {
	if (linkTarget==null) {
		linkTarget = 'top';
	}
	this.text = itemText;
	this.URL = linkURL;
	this.target = linkTarget;
}

function addMenuItem(menu,itemText,linkURL,linkTarget) {
	obj = eval('arr'+menu);
	obj[obj.length] = new menuItem(itemText,linkURL,linkTarget);
}

function setColors(hoverBg,hoverTxt,offBg,offTxt) {
	hoverBackground = hoverBg;
	hoverText = hoverTxt;
	offBackground = offBg;
	offText = offTxt;
}

function formatColor(rgbColor,formatName) {
	switch (formatName) {
		case 'Netscape':
			posComma = -1;
			while (rgbColor.indexOf(',',(posComma+1))!=-1) {
				posComma = rgbColor.indexOf(',',(posComma+1))
				rgbColor = rgbColor.substring(0,posComma) + ', ' + rgbColor.substring((posComma+1),rgbColor.length);				
			}
			break;
	}
	return rgbColor;
}