/**** logic to "show" and "hide" divs -- logic provides auto-closing of previously-shown divs 
 ****   and assumes only one div is open at a time (using these functions)
 ****/
 
	var divNameOpen = ""; // id (name) of the "open" hidden div
	var showGrayOverlay = false; // only do this if specified

	// function to display specified hidden div
	function ShowDiv(divName)
	{
		showDiv(divName);
	}
	
	function showDiv(divName)
	{
		showGrayOverlay = false;
		//alert("@ShowDiv(" + divName + ") : divOpen=[" + divNameOpen + "]");
		if (divNameOpen != "")
		{
			if (divName == divNameOpen)		// chk if div is already visible
				return;
			HideDiv(divNameOpen);		// else hide other div
		}
		var divobj = document.getElementById(divName)
		if (divobj)
		{
			divobj.style.display = "block";
			divNameOpen = divName;		// remember name of open div
		}
	}

	// function to display hidden div and also display the gray background overlay
	function ShowDivWithOverlay(divName)
	{
		//alert("@ShowDivWithOverlay(" + divName + ")");
		ShowDiv(divName);
		ShowOverlay(true);
	}

	// function to hide specified div and also hide the gray background overlay
	function HideDiv(divName)
	{
		if (!divName)
			divName = divNameOpen;
		var divobj = document.getElementById(divName)
		if (divobj)
		{
			divobj.style.display = "none";
			divNameOpen = "";
			if (showGrayOverlay)
				ShowOverlay(false);		// hide the overlay
		}
	}

	function ShowOverlay(show)
	{
		var fld = document.getElementById('overlay');
		if (fld != null)
		{
			showGrayOverlay = show;
			if (show)
			{
				show = 'block';
				//show only if the browser supports opacity
				if ('opacity' in document.documentElement.style)	// newer FireFox
				{
					//alert("'opacity' is in document.documentElement.style");
				}
				else
				{
					browserdetect = fld.filters ? "ie" : typeof fld.style.MozOpacity == "string" ? "mozilla" : ""
					//alert("browser=" + browserdetect);
					if (browserdetect == "ie")
					{
						fld.filters.alpha.opacity = 75;
						//fld.style.z-index = "2";
						return; 	// defeat this for IE because when it displays it also covers the intended div
					}
					else
						fld.style.MozOpacity = .75; 	// older FireFox (pre 1.0)
				}
			}
			else
				show = 'none';
			
			//alert("ShowOverlay:show=[" + show + "]");
			fld.style.display = show;
		}
	}

