function toggleLayer(whichLayer)
{
	//alert("called");
		
	if (document.getElementById)
	{
		// this is the way the standards work
		var div = document.getElementById(whichLayer);
		var style2 = div.style;
		//alert(style2.display);
		//alert(whichLayer + "is a:" + div);
		if(style2.display=="") {
			style2.display = "none";	
		} else { 
			style2.display = style2.display=="block"? "none":"block";
		}
	}
	/*else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}*/
}
function toggleLayerFromOff(whichLayer)
{
	//alert("called toggleLayerFromOff");
	
	if (document.getElementById)
	{
		// this is the way the standards work
		var div = document.getElementById(whichLayer);
		var style2 = div.style;
		//alert(style2.display);
		//alert(whichLayer + "is a:" + div);
		if(style2.display=="") {
			style2.display = "block";	
		} else { 
			style2.display = style2.display=="block"? "none":"block";
		}
	}
}
function disableSubmit(whichButton)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		document.getElementById(whichButton).disabled = true;
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		document.all[whichButton].disabled = true;
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		document.layers[whichButton].disabled = true;
	}
}

function confirmDelete()
{
    var agree=confirm("Are you sure you wish to delete this entry?");
    if (agree)
        return true;
    else
        return false;
}

function returnObjById( id )
{
	if (document.getElementById)
		var returnVar = document.getElementById(id);
	else if (document.all)
		var returnVar = document.all[id];
	else if (document.layers)
		var returnVar = document.layers[id];
	return returnVar;
}

function setHandler( tagType, clsName, eventType, func )
{
	elements = document.getElementsByTagName( tagType );
	for( var t = 0; t < elements.length; t++ )
	{
		if( elements[t].className.indexOf( clsName ) >= 0 )
		{
			var code = "elements[t]." + eventType + " = " + func;
			eval( code );
		}
	}
}

function toggleColor( )
{
	alert("tc called:" + elem);
	var style = elem.style;
	style.color = "#FFFF00";
}
/*function toggleColor( strelem )
{
	var elem = document.getElementById(strelem);
	alert("tce called." + elem);
	var style = elem.style;
	style.color = style.color? "":"#FFFF00";
}*/
function toggleBgColor( elem )
{
	var style2 = elem.style;
	style2.backgroundColor = style2.backgroundColor? "":"#FFFF00";
}

function externalLinks( )
{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}

function initpage( )
{
	setHandler( 'tr', 'toggle', 'onclick', 'toggleColor' );
	setHandler( 'span', 'heading', 'onmouseover', 'toggleColor' );
	setHandler( 'span', 'heading', 'onmouseout', 'toggleColor' );
	externalLinks( );
}

//window.onload = initpage;
