var oIFramesCreated;
var bHoverSupported;

function showElement(sElementName, bUseHover)
{
	// Show the actual menu object first
	var oElement = document.getElementById(sElementName);
	
	if(bHoverSupported == null)
	{
		if(document.defaultView != null && document.defaultView.getComputedStyle(oElement, 'hover'))
			bHoverSupported = true;
		else
			bHoverSupported = false;
	}
	
	if(!bUseHover || !bHoverSupported)
	{	
		oElement.style.display = 'block';
	
		// Fix the IE layering bug if the page contains any combo boxes
		if(navigator.appName == 'Microsoft Internet Explorer' && document.all.tags('select').length > 0)
		{
			// For newer versions, dynamically create an IFRAME underneath the menu
			if(navigator.appVersion.indexOf('5.5') > -1 || navigator.appVersion.indexOf('6.0') > -1 || navigator.appVersion.indexOf('7.0') > -1)
			{
				if(oIFramesCreated == null)
					oIFramesCreated = new ActiveXObject('Scripting.Dictionary')
					
				// Get the position & size of the menu
				var iLeft = oElement.offsetLeft;
				var iTop = oElement.offsetTop;
				var iWidth = oElement.offsetWidth;
				var iHeight = oElement.offsetHeight;
				
				// It takes a bit of time to create the IFRAME, so only create it once
				if(oIFramesCreated.Exists(sElementName))
				{
					var oIFrame = oIFramesCreated.Item(sElementName);
					
					oIFrame.style.left = iLeft;
					oIFrame.style.top = iTop;
					oIFrame.style.width = iWidth;
					oIFrame.style.height = iHeight;
					oIFrame.style.display = 'block';
				}
				else // Haven't created it yet
				{	
					var sStyleString = 'display:none; position:absolute; left:' + iLeft.toString() + 'px; top:' + iTop.toString() + 'px; width=' + iWidth.toString() + 'px; height=' + iHeight.toString() + 'px;';
					
					// Create the IFRAME, and make sure it doesn't even attempt to load a page
					var sIFrameHtml = '<iframe id="' + sElementName + 'IFrame" style="' + sStyleString + '" frameBorder="0" scrolling="no" src="javascript:false"></iframe>'
					oElement.insertAdjacentHTML('beforeBegin', sIFrameHtml);
	
					// Make it visible
					var oIFrame = document.getElementById(sElementName + 'IFrame');
					oIFrame.style.display = 'block';
	
					// Cache the IFRAME
					oIFramesCreated.Add(sElementName, oIFrame);
				}
			}
			else
			{
				// For older versions, just hide the drop down lists
				setDropDownListsVisibility('hidden');
			}
		}
	}
}

function hideElement(sElementName, bUseHover)
{	
	if(!bHoverSupported || !bUseHover)
	{
		var oElement = document.getElementById(sElementName);
		oElement.style.display = 'none';
		
		// Clean up the IE6 bug fixing from before
		if(navigator.appName == 'Microsoft Internet Explorer' && document.all.tags('select').length > 0)
		{
			// Determine the appropriate restore action
			if(navigator.appVersion.indexOf('5.5') > -1 || navigator.appVersion.indexOf('6.0') > -1 || navigator.appVersion.indexOf('7.0') > -1)
			{
				var oIFrame = oIFramesCreated.Item(sElementName);
				oIFrame.style.display = 'none';
			}
			else		
				setDropDownListsVisibility('visible');
		}
	}
}

function setDropDownListsVisibility(sVisibility)
{
	for(var i = 0; i < document.all.tags('select').length; i++)
	{
		var oDropDownList = document.all.tags('select')[i];

		if(oDropDownList == null || oDropDownList.offsetParent == null)
			continue;

		oDropDownList.style.visibility = sVisibility;
	}
}