var currentDropdownId, currentDropdownMenuId, showDropdownDelay, hideDropdownDelay, currentDropdownHasCapture,currSelectedMenuId;
var showTimerId, hideTimerId;

showDelay = 50;
hideDelay = 1000;

function showDropdown(dropdownMenuId, show, selectedMenuId) {
	var dropdownId;
	currSelectedMenuId = selectedMenuId;
	dropdownId = dropdownMenuId + "_sub";
	if (show) {
		dropdown = document.getElementById(dropdownId);

		if (currentDropdownId && currentDropdownId != dropdownId) {
			currentDropdown = document.getElementById(currentDropdownId);
			if (currentDropdown) {
				currentDropdown.style.display = "none";
				var IfrRef = document.getElementById("selectblocker_"+currentDropdownId);
				IfrRef.style.display = "none";
			}
			if (currentDropdownMenuId != selectedMenuId) {
				currentDropdownMenu = document
						.getElementById(currentDropdownMenuId);
				if (currentDropdownMenu) {
					currentDropdownMenu.className = "topNav_drk";
				}
			}
		}

		currentDropdownHasCapture = true;

		currentDropdownId = dropdownId;
		currentDropdownMenuId = dropdownMenuId;

		if (showTimerId) {
			clearTimeout(showTimerId);
		}
		if (dropdownMenuId) {
			showTimerId = setTimeout("showDropdownContainer('" + dropdownId
					+ "', true)", showDelay);
		}
	} else {
		currentDropdownHasCapture = false;

		hideTimerId = setTimeout("showDropdownContainer('" + dropdownId
				+ "', false)", hideDelay);
	}
}
function showDropdownContainer(dropdownId, show, forceHide) {
	var dropdown, li;
	if (!show && currentDropdownHasCapture) {
		return;
	}
	li = document.getElementById(currentDropdownMenuId);
	if (currentDropdownMenuId != currSelectedMenuId){
		if (li) {
			li.className = show ? "topNav_lite" : "topNav_drk";
		}
	}
	dropdown = document.getElementById(dropdownId);
	if (dropdown) {
		dropdown.style.display = show ? "block" : "none";
		if (show) {
			var x = getX(li);
			dropdown.style.left = x + 'px';
			
			var IfrRef = document.getElementById("selectblocker_"+dropdownId);
			IfrRef.style.width = dropdown.offsetWidth + 'px';
			IfrRef.style.height = dropdown.offsetHeight + 'px';
			IfrRef.style.top = dropdown.style.top;
			IfrRef.style.left = dropdown.style.left;
			IfrRef.style.zIndex = dropdown.style.zIndex - 1; 
			IfrRef.style.display = "block";
		} else {
			var IfrRef = document.getElementById("selectblocker_"+dropdownId);
			IfrRef.style.display = "none";
		}
	}
}
function getDropdownCapture() {
	currentDropdownHasCapture = true;
}
function getY(oElement) {
	var iReturnValue = 0;
	while (oElement != null) {
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}
function getX(oElement) {
	var iReturnValue = 0;
	if (oElement != null) {
		iReturnValue += oElement.offsetLeft;
	}
	return iReturnValue;
}
