// stores active page element for display purposes
var displayedElement = '';

function OpenItemWin(strUrl)
{
	window.open(strUrl, "jsThottWindow");
};

function OpenWin(strUrl)
{
	window.open(strUrl, "jsLinkWin");
};

function ShowPageElement(strNewPageElementName)
{
	if (displayedElement != '')
		SetElementDisplay(displayedElement, 0);
	
	displayedElement = strNewPageElementName;
	SetElementDisplay(strNewPageElementName, 1);
};

function SetElementDisplay(strNewPageElementName, isVisible)
{
	var elem, vis;
	
	if (document.getElementById)	// this is the way the standards work
		elem = document.getElementById(strNewPageElementName);
	else if (document.all) 	// this is the way old msie versions work
		elem = document.all[strNewPageElementName];
	else if (document.layers) 	// this is the way nn4 works
		elem = document.layers[strNewPageElementName];
  
	vis = elem.style;
	vis.display = (isVisible == 0) ? 'none' : 'block';
};

function ToggleElementDisplay(strCallingElementName)
{
	var callingElem, toggleElem, vis;
	
	if (document.getElementById)	// this is the way the standards work
	{
		toggleElem = document.getElementById(strCallingElementName + 'Text');
		callingElem = document.getElementById(strCallingElementName);
	}
	else if (document.all) 	// this is the way old msie versions work
	{
		toggleElem = document.all[strCallingElementName + 'Text'];
		callingElem = document.all[strCallingElementName];
	}
	else if (document.layers) 	// this is the way nn4 works
	{
		toggleElem = document.layers[strCallingElementName + 'Text'];
		callingElem = document.layers[strCallingElementName];
	}
  
  	// toggle the display of the section
	vis = toggleElem.style;
	if (vis.display == 'block')
	{
		// hiding section
		vis.display = 'none';
		callingElem.innerHTML = '(click to show)';
	}
	else
	{
		vis.display = 'block';
		callingElem.innerHTML = '(click to hide)';
	}
};

function InitDynamicView(strDisplayedElement)
{
	// see if the querystring has an element, otherwise use supplied default
	var query = window.location.search.substring(1);
  	var vars = query.split("&");
  	var suppliedElement = '';
  	for (var i=0; i < vars.length; i++)
  	{
    	var pair = vars[i].split("=");
    	if (pair[0] == 'initExampleNumber') 
    	{
    		suppliedElement = pair[1];
      		break;
    	}
  	}
  	
	displayedElement = strDisplayedElement;
	if (suppliedElement != '')
		ShowPageElement(suppliedElement);
};

