﻿
//---------------------------------------------------------------------------
// cross-browser get-element-by-id function
function GetElement(sID)
{
	return (document.getElementById ? document.getElementById(sID) : (document.all ? document.all[sID] : null));
}

//---------------------------------------------------------------------------
// open a popup window
// oLink: reference to a html anchor
// nWidth, nHeight, bScroll: optionally set width, height, show scroll bars
function OpenAsPopup(oLink, nWidth, nHeight, bScroll)
{
	// set defaults when paramaters are missing
	if(!nWidth) nWidth = 800;
	if(!nHeight) nHeight = 500;
	if(bScroll == null) bScroll = 1;
	var sAttribs = "width=" + nWidth + ",height=" + nHeight + ",resizable=0,location=0,toolbar=0,status=1,scrollbars=" + bScroll;
	
	var oWin = window.open(oLink.href, "_blank", sAttribs);
	if(oWin != null)
		oWin.focus();  // ensure popup is on top
}

//---------------------------------------------------------------------------
// Search stylesheets and reset element visibility to show/hide items that
// should only be visible/hidden if javascript is enabled
function AdjustCssForJS()
{
	var rulelist;
	for ( s = 0 ; s < document.styleSheets.length ; s++)
	{
		// IE uses rules, Moz uses cssRules
		rulelist = (document.styleSheets[s].rules != null) ? document.styleSheets[s].rules : document.styleSheets[s].cssRules;

		for ( r = 0 ; r < rulelist.length; r++)
		{
			switch(rulelist[r].selectorText)
			{
				case ".showwithjs" :
					rulelist[r].style.visibility = "visible";
					break;
				case ".hidewithjs" :
					rulelist[r].style.visibility = "hidden";
					break;
				case ".showblockwithjs" :
					rulelist[r].style.display = "block";
					break;
				case ".showinlinewithjs" :
					rulelist[r].style.display = "inline";
					break;
				case ".removewithjs" :
					rulelist[r].style.display = "none";
					break;
			}
		}
	}
}


