window.name = 'main';

/*
 * Layer Visibility Control
 *
 * Functions for showing and hiding content layers
*/

function toggleLayer(wh) {
	
	var state = layerState(wh);
	
	if (state=='none') {
		return showLayer(wh);
	}
	else {
		return hideLayer(wh);
	}
	
	return false
}

/* Toggles the Link Text for a `Show/Hide` link intended to control layer visibility */
function toggleLayerLink(wh) {
	
	if (layerState(wh)=='none') // Layer is hidden
		document.all.linktext.innerHTML = 'Show' // Link to Show the layer
	else // Assume layer is visible
		document.all.linktext.innerHTML = 'Hide' // Link to Hide the layer
}

/* Returns the current visibility state of the specified Layer */
function layerState(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style.display
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style.display
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style.display
	}
	
	return style2;
}

function showLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"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 hideLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		document.getElementById(whichLayer).style.display = 'none';
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		document.all[whichLayer].style.display = 'none';
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		document.layers[whichLayer].style.display = 'none';
	}
}

function popup(header,content) {

	top.consoleRef=window.open('','Popup_Window',
		  'width=350,height=400'
		   +',menubar=0'
		   +',toolbar=0'
		   +',status=0'
		   +',scrollbars=1'
		   +',resizable=0'
		   +',location=0')
	top.consoleRef.document.writeln(
		  '<html><body bgcolor=white onLoad=\"self.focus()\"><h4>'
		   +header
		   +'</h4>'
		   +content
		   +'</body></html>')
	top.consoleRef.document.close()
}

function addslashes(str) {
	
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	
	return str;
}

function stripslashes(str) {
	
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	
	return str;
}

function raiseError(desc) {
	
	var error = 'An error occured on this page.<p>'
		+'Error Description: '
		+desc;
	
	alert(error);
}
