function toggleLayer( whichLayer , whichLink )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
  if ( vis.display == 'none' )
  	linkNameSwitch ( whichLink , 'Show' );
  else
  	linkNameSwitch ( whichLink , 'Hide' );
}

function showLayer( whichLayer , whichLink )
{
	var elem, vis;
	
	if( document.getElementById ) // this is the way the standards work
		elem = document.getElementById( whichLayer );
	else if( document.all ) // this is the way old msie versions work
		elem = document.all[whichLayer];
	else if( document.layers ) // this is the way nn4 works
		elem = document.layers[whichLayer];
		
	vis = elem.style;
	// always show
	vis.display = 'block';
	
  	linkNameSwitch ( whichLink , 'Hide' );
}

function hideLayer( whichLayer , whichLink )
{
	var elem, vis;
	
	if( document.getElementById ) // this is the way the standards work
		elem = document.getElementById( whichLayer );
	else if( document.all ) // this is the way old msie versions work
		elem = document.all[whichLayer];
	else if( document.layers ) // this is the way nn4 works
		elem = document.layers[whichLayer];
		
	vis = elem.style;
	// always show
	vis.display = 'none';
  	linkNameSwitch ( whichLink , 'Show' );
}

function linkNameSwitch ( linkID , linkText)
{
	var lnk = document.getElementById(linkID);
	var oldText = lnk.innerHTML;
	var newText = '';
	
	if ( oldText.indexOf ( linkText ) == -1 )
		if ( linkText == 'Show' )
			newText = oldText.replace( /Hide/i , 'Show' );
		else if ( linkText == 'Hide' )
			newText = oldText.replace( /Show/i , 'Hide' );
	if ( newText != '' )
		lnk.innerHTML = newText;
}


/*
	togglelayer.js
	Version 1.0
	Created 2009/03/13 by Aaron Walker
	toggleLayer function downloaded from:
		http://www.netlobo.com/div_hiding.html
	showLayer and hideLayer functions written based on toggleLayer
		
	
*/

