
	var currentMenu, currentSubMenu, selectedSection  
	
	selectedSection = '';
	var browser = new BrowserDetectLite();
	var x_coord, y_coord, x_offset, y_offset; 
	x_offset = 0; y_offset = 0;
	
	function MOver(strSource, strID, isMore, positionIndex) {

		var RIGHT_X;
		var sourceObj, thisDiv;		
			
		RIGHT_X = getRightPosition();
//		RIGHT_X = <%=Session("Width")%>-50;
		
		sourceObj = document.getElementById(strSource); 
		x_coord = getRealLeft(sourceObj);
		y_coord = getRealTop(sourceObj);

		if (isNaN(sourceObj.clientHeight)) { // netscape doesn't recognize clientHeight 
			y_offset = sourceObj.offsetHeight + 1;
		} else {
			y_offset = sourceObj.clientHeight + 1;
		}
		
		// hide previous menu
		if (currentMenu && currentMenu != strSource) {
			if (currentSubMenu) {
				document.getElementById(currentSubMenu).style.display = 'none'; 
				if (!isMore && subMenuExist(currentMenu)) {
					swapTopMenuClass(currentMenu, false);
				}
			}
		}

		// special case for "MORE"; pin the MORE table if it's selected 
		if (document.getElementById('TOPMENU_MORE_SUBMENU')) {
			if (isMore) {
				document.getElementById('TOPMENU_MORE_SUBMENU').style.display = 'block'; 
			} else {
				document.getElementById('TOPMENU_MORE_SUBMENU').style.display = 'none';
				if (subMenuExist('TOPMENU_MORE')) {
					swapTopMenuClass('TOPMENU_MORE', false);
				}				
			}
		}

		thisDiv=document.getElementById(strID);
		document.getElementById(strID).style.display = 'block'; 
		
		if (isMore) { // adjustment for "MORE" box
			thisDiv.style.left = x_coord - 101;
			thisDiv.style.top = y_coord + y_offset - 20;	
		} else {
			if (!browser.isIE5xMac) {
//				if it goes over the right margin, align it along the right border
				if (!(strSource == 'TOPMENU0') && (thisDiv.offsetWidth + x_coord > RIGHT_X || strSource == lastCellID)) {
//				if (!(strSource == 'TOPMENU0') && (thisDiv.offsetWidth + x_coord > RIGHT_X)) {
					thisDiv.style.left = RIGHT_X - thisDiv.offsetWidth;
				} else {
					thisDiv.style.left = x_coord + x_offset;
				}
				 thisDiv.style.top = y_coord + y_offset;	
			} else {
				 thisDiv.style.left = x_coord - 200;	// adjust for ie mac 
			}
		} 	

		// alert("left: " + thisDiv.style.left + "; " + "top: " + thisDiv.style.top);
		document.getElementById(strID).style.display = 'block'; 
                currentMenu = strSource; 
		currentSubMenu = strID; 
		
		
		// block the gap between selected menu and its submenu
		var blockLeft, blockTop, blockWidth

		if (isMore) {
			blockLeft = getRealLeft(document.getElementById('TOPMENU_MORE'));
			blockTop = getRealTop(document.getElementById('TOPMENU_MORE')) + 19;
			if (isNaN(sourceObj.clientHeight)) {
				blockWidth = document.getElementById('TOPMENU_MORE').offsetWidth -2;
			} else {
				blockWidth = document.getElementById('TOPMENU_MORE').clientWidth;
			}

		} else {
			blockLeft = x_coord; 
			blockTop = y_coord + 19;
			if (isNaN(sourceObj.clientHeight)) {
				blockWidth = sourceObj.offsetWidth -2;
			} else {
				blockWidth = sourceObj.clientWidth;
			}			
		}
		
		if (!browser.isIE5xMac) {
			displayBlock(blockLeft, blockTop, blockWidth);
		}

		// swap image class
		if (subMenuExist(strSource)) {
			swapTopMenuClass(strSource, true)
		}
		// this function is customized for each script
		// no need to customize if there's no SELECT input
		// SELECT always gets top-focus, and it blocks div submenus when they're overlapped
		// use this function to hide SELECT input element 
		
		selectCurrentSection();
		MOverCorrectionFunction();
	}
		
		
function displayBlock(x, y, w) {
	if(document.getElementById('TOPMENU_BLOCK')) {
		document.getElementById('TOPMENU_BLOCK').style.display = 'block';
		document.getElementById('TOPMENU_BLOCK').style.left = x;
		document.getElementById('TOPMENU_BLOCK').style.top = y -1;
		document.getElementById('TOPMENU_BLOCK').style.width = w;
		document.getElementById('TOPMENU_BLOCK').style.height = '3px';
//		document.getElementById('TOPMENU_BLOCK').style.border = '1px solid #cc0000';
	}
}		

function MOut() {
	 if (menuExist(currentSubMenu)) {
	 	document.getElementById(currentSubMenu).style.display = 'none'; 
	}	
	// swap image class
	if (subMenuExist(currentMenu)) {
		swapTopMenuClass(currentMenu, false)
	}	
	// if MORE Submenu is open
	if (document.getElementById('TOPMENU_MORE_SUBMENU')) {
		if (document.getElementById('TOPMENU_MORE_SUBMENU').style.display == 'block') {
			document.getElementById('TOPMENU_MORE_SUBMENU').style.display = 'none';
			if (subMenuExist('TOPMENU_MORE')) {
				swapTopMenuClass('TOPMENU_MORE', false)
			}			
		}
	}
	if(document.getElementById('TOPMENU_BLOCK')) {
		document.getElementById('TOPMENU_BLOCK').style.display = 'none';	
	}

// AK: don't select current section on mout (never mind)
	selectCurrentSection();
	MOutCorrectionFunction();	
}

function subMenuExist(id) {
	if (document.getElementById(id+"_1")) {
		return true;
	} else {
		return false;
	}
}

function menuExist(id) {
	if (document.getElementById(id)) {
		return true;
	} else {
		return false;
	}
}

function swapTopMenuClass(id, selected) {
	if (selected) {
		if (document.getElementById(id+"_1")) {
			document.getElementById(id+"_3").className="top-mainmenu-header-end-selected color1-background";
			document.getElementById(id+"_1").className="top-mainmenu-header-start-selected color1-background";
			document.getElementById(id+"_2").className="top-mainmenu-header-middle-selected color1-background";
		}												
	} else {
		if (document.getElementById(id+"_1")) {
			document.getElementById(id+"_3").className="top-mainmenu-header-end";	
			document.getElementById(id+"_1").className="top-mainmenu-header-start";
			document.getElementById(id+"_2").className="top-mainmenu-header-middle";
		}
	}
}
	
function getRightPosition() {
	// determine right-most position
	var x;
	
	if (menuExist(lastCellID)) {
		x = getRealLeft(document.getElementById(lastCellID)) + document.getElementById(lastCellID).offsetWidth;
	}
	return x;
}

function getRealLeft(el) {
	// alert('inside func');
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getRealTop(el) {
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}

function selectCurrentSection() {
	if (selectedSection != '') {
		swapTopMenuClass(selectedSection, true)
	}
}	

function MOverCorrectionFunction () {
}

function MOutCorrectionFunction () {

}

