// Browser Capability Variables
var isStnd = document.getElementById ? true : false; // Standards compliant
var isIE = document.all ? true : false; // IE 4/5
var isNN4 = document.layers ? true : false; // NN 4.x
var DHTML = (isStnd || isIE || isNN4); // Any of the above

var isMac = (navigator.appVersion.indexOf( "Macintosh" ) != -1) ? true : false; // Macintosh
var isSafari = (navigator.appVersion.indexOf( "Safari" ) != -1) ? true : false; // Macintosh
var ie5 = false;
var ieSubVers = 0;
var pre_w3c = false;

var adjusted = 0;
var adjID = 0;
var pageName = "";
var newWindow = null;


// Layer effect variables. Note: 'DYN' denotes value that will need to be assigned at runtime.
var numTips = 16; // DYN
var currTipID = "tip1"; // keep track of tooltip
var lastTipID = "tip1"; // keep track of tooltip
var tipOpen = false; // is a tooltip open?
var fadeOn = false; // is fade effect on? value toggled via function setFade
var fadeTime; // delay time between fade intervals
var closeTime = 2000;  // delay time to hide tooltip after it is open
var ctID = 0; // id for close timeout
var fadeLayer, amount, clipTop, clipWidth, clipBottom, clipMid, lyrheight; // used by fade functions 
var mouseX = 0; // for use with layer positioning off mouse coords
var mouseY = 0; // for use with layer positioning off mouse coords

var tooltips = new Object(); // object to hold all tooltips

w3c();
MM_preloadImages('../images/logo_over.gif');

// Flash functions
var reqFlashVersion = 7;
var afv = 0;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

function checkFlash(){
	if ( plugin ) {
		// Netscape
		afv = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1));
		plugin = afv >= reqFlashVersion;
	} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
		// MSIE & PC
		document.write('<SCRIPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('plugin = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');
		document.write('<\/SCRIPT\> \n');
	}
}

function wfjs(n,file,w,h,bgcolor){
	if(bgcolor == null) bgcolor = "#FFFFFF";
	document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"" + w + "\" height=\"" + h + "\" id=\"" + n + "\" align=\"middle\">");
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
	document.write("<param name=\"movie\" value=\"" + file + "\" />");
	document.write("<param name=\"quality\" value=\"high\" />");
	document.write("<param name=\"wmode\" value=\"opaque\" />");
	document.write("<param name=\"bgcolor\" value=\"" + bgcolor + "\" />");
	document.write("<embed src=\"" + file + "\" quality=\"high\" bgcolor=\"" + bgcolor + "\" wmode=\"opaque\" width=\"" + w + "\" height=\"" + h + "\" name=\"" + n + "\" swLiveConnect=\"true\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />");
	document.write("</object>");
}

function home(){
	initTooltips();
	if(!pre_w3c){
		//xAddEventListener(window, "resize", adjustLayoutResize, false); 
		//adjustLayout();
	}
	if(isSafari) adjustLayout();
}

function checkIt(){
	var elem = "entry1";
	var div = new getObj(elem);
	if(div != null){
		var tip = new getObj(tooltips[elem].tipID);
		alert("Tip visible: " + (tip.style.visibility));
	}else{
		alert("Element " + elem + " not present!");
	}
}

function w3c()  { 
  if (navigator.appName.indexOf("Netscape") != -1) {
   var version = navigator.appVersion
    var subVersion = version.substring(0,3)
    var subVersion_p = parseFloat(subVersion)
     if (subVersion_p < 5)  {
		pre_w3c = true;
		isNS = false;
    }  
  }   
 if (navigator.appName.indexOf("Explorer") != -1) {
    var version = navigator.appVersion
    var subVersion = version.substring(22,25)
    ieSubVers = parseFloat(subVersion)
     if (ieSubVers < 5)  {
	   pre_w3c = true;
	   isNS = false;
	 }
	 if ((ieSubVers == 5) || (ieSubVers == 5.5))  {
	   ie5 = true;
	 }
  }
}  

function w3c_test()  { 
  if (navigator.appName.indexOf("Netscape") != -1) {
   var version = navigator.appVersion
    var subVersion = version.substring(0,3)
    var subVersion_p = parseFloat(subVersion)
     if (subVersion_p < 5)  {
		pre_w3c = true;
		isNS = false;
    }  
  }   
 if (navigator.appName.indexOf("Explorer") != -1) {
	 alert("Explorer");
    var version = navigator.appVersion
    var subVersion = version.substring(22,25)
    var subVersion_p = parseFloat(subVersion)
     if (subVersion_p < 5)  {
	   pre_w3c = true;
	   isNS = false;
	 }
	 if ((subVersion_p == 5) || (subVersion_p == 5.5))  {
	   ie5 = true;
	 }
  }
}  

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function adjustLayoutResize(){
	if(adjID) clearTimeout(adjID);
	adjusted = false;
	adjustLayout();
}

function adjustLayout(){
	//alert("adjusting " + adjusted);
	if(adjusted<2){
		// Calculate content columns to accomodate Mac-IE5
		
		pageName = getPageFileName();
		//alert("Pagename is " + pageName);
		var adj = 0;
		var margins = 39;
		var corimg = (!isIE) ? 214 : 282; // 10/20/04: Changed from isSafari to !isIE.
										  // Safari needs 214 adjustment to level1 height

		var rgtcolheight = xHeight("rightcol");
		var lftcolheight = xHeight("leftcol");
		var mediaheight = xHeight("media");
		
		// 10/20/04: Added !isIE to level1 adjustment
		if((pageName == "index.php") || (pageName == "pause.htm") || (pageName == "index_test1.htm") || !isIE){
			var mainheight = (xHeight("level1") - corimg);
		} else {
			var mainheight = xHeight("level1");
		}
		
		//alert(xHeight("rightcol"));
		// NS needs media div to have height, but we need to change specific to page
		if(gbi("media") != null){
			if (mediaheight < 1){
				//alert("Adjusting media height");
				mediaheight = 215;
				if((pageName == "community.php") || (pageName == "community_8.php")) mediaheight = 282;
			}
		}
		
		var maxheight = Math.max(mainheight, Math.max((lftcolheight+margins), (rgtcolheight+margins)))+adj;		
		//alert("mainheight=" + mainheight + ",rgtcolheight=" + rgtcolheight + ",lftcolheight=" + lftcolheight + ", maxheight=" + maxheight);
		
		//alert("rightcol=" + rgtcolheight + ", all=" + (xHeight("commTop")+xHeight("commBot")));
		/* Level1 parent container adjustment */
		//alert("maxheight=" + maxheight);
		
		if(rgtcolheight == mainheight){
			// If right column is absolute and is actually taller than the main/level1 div, NS will
			// show the div as equal to level1.
			// TODO: Find better for this problem on NS; why can we get the height of absolute elements?
			maxheight = maxheight + 200;
		}
		
		if((mainheight+adj) < maxheight){
			//alert("adjusting level1");
			xHeight("level1", maxheight);
		}
		
		
		/* Right column adjustment */
			xHeight("rightcol", (maxheight-margins));
			
		/* Left column adjustment */
		// Need to calculate total height of elements within the media div
		// Add any additional components in the media div to this list
		var titleheight = 0; //xHeight("cname");
		var crumbheight = 0; //xHeight("breadCrumb");
		
		// TODO: Why do we need the following? If we don't do this, leftcol is set to high
		// Since titleheight varies in height depending on whether its text or graphic,
		// set titleheight above to the default instead of 0
		if((pageName == "community.php") || (pageName == "community_8.php") || (pageName == "new-home.php")){
			titleheight = 17;
			//titleheight = xHeight("cname");
			crumbheight = xHeight("breadCrumb");
		}
		var totalmediaheight = (mediaheight+titleheight+crumbheight);
		//alert("maxheight=" + maxheight + ", totalheight=" + totalmediaheight + ", margins=" + margins);
		xHeight("leftcol", (maxheight-totalmediaheight-margins));
	
		// Move down redbar on homepage
		// xTop("redbar")

		// Adjust again in a bit to catch any last second
		// auto formatting / breaking of text.
		// This fixes inconsistent breaking that may occur on 
		// long words.
		adjID = setTimeout('adjustLayout()', 60);
		adjusted += 1;
	} else {
		//adjust the page twice
		if(adjusted > 2){
			//alert("Clearing timeout: adjusted = " + adjusted);
			adjusted = 0;
			if(adjID) clearTimeout(adjID);
		}
	}
} 

function adjustToDiv(){
	//alert("adjusting " + adjusted);
	var margins = 39;
	if(adjusted<2){
		
		var mediaheight = xHeight("media");
		var mainheight = xHeight("level1");
		var rgtcolheight = xHeight("rightcol");
		var lftcolheight = xHeight("leftcol");
		
		adj = mediaheight;
		
		//alert("Main=" + mainheight + ", rgtcol=" + rgtcolheight + ", lftcolheight=" + lftcolheight);
		var maxheight = Math.max(mainheight, Math.max((lftcolheight+margins), (rgtcolheight+margins)));		
		
		//xHeight("level1", maxheight+adj);
		//xHeight("rightcol", maxheight);
		xHeight("leftcol",(rgtcolheight-margins));
	
		adjID = setTimeout("adjustToDiv()", 60);
		adjusted += 1;
	} else {
		//adjust the page twice
		if(adjusted > 2){
			//alert("Clearing timeout: adjusted = " + adjusted);
			adjusted = 0;
			if(adjID) clearTimeout(adjID);
		}
	}
} 

// GetPageFileName returns name of current file
function getPageFileName(){
	var f = document.location.href;
	var ix  = f.lastIndexOf('/');
	if ( ix > -1 ) f = f.substring( ix + 1 );
	var ix  = f.indexOf('?');
	if ( ix > -1 ) f = f.substring(0, ix);
	if(f==""){
		return "index.php";
	}else{
		return f;
	}
	//var page  = parseInt( ( f.substring( f.indexOf('Page') + 4 ) ), 10 );
}

/*
	util:implCheck use to check implementation on standards compliant browsers.
	Requires: none
	Returns: boolean
	Example: implCheck("DOM","2.0");
*/
function implCheck(feature, version){
	if (document.implementation &&
		  document.implementation.hasFeature &&
		  document.implementation.hasFeature(feature, version))
	   alert(feature + " version " + version + " support available");
	else
	   alert(feature + " version " + version + " NOT available");
}

/*
	HandleMouseMove handles onmousemove events as defined in function initTooltips.
	Requires: Event object
	Returns: mouseX, mouseY, and displays coords in browser status bar.
*/
function handleMouseMove(evt) {
	//if(!tipOpen){
		//mouseX = isNN4 ? evt.pageX : window.event.clientX;
  		//mouseY = isNN4 ? evt.pageY : window.event.clientY;
	if((typeof(window.event) == 'undefined') || isNN4){
  		mouseX = evt.pageX;
  		mouseY = evt.pageY;
	} else {
		mouseX = window.event.clientX;
  		mouseY = window.event.clientY;
	}
  		//window.status = "Mouse: "+mouseX+","+mouseY;
	//}
  return false;
}

/*
	InitTooltips defines event listeners (if supported) or event handlers at body.onload.
	Requires: tooltips object populated in function writeTooltips
	Returns: nothing / TODO return false if 1) tooltips object has not been populated
	Error checking: TODO - availability of tootips and divs that need to have been written previously.
*/
function initTooltips(){
	
	if (!DHTML) return; 
	for (var i in tooltips){
		var div = gbi(i);
		
		var tip = gbi(tooltips[i].tipID);
		
		//var div = new getObj(i);
		//var tip = new getObj(tooltips[i].tipID);
		if (div == null) alert ("Div " + i + " is null");
		if(div.addEventListener){
			// for Mozilla
			div.addEventListener('mouseover', showTooltip, false);
			div.addEventListener('mousemove', delayHideTooltip, false);
			tip.addEventListener('mousemove', delayHideTooltip, false);
		}else{
			// for IE
			div.onmouseover = showTooltip;
			div.onmousemove = delayHideTooltip;
			tip.onmousemove = delayHideTooltip;
		}
		//alert("Onmouseover listener for " + div.id + " is " + div.onmouseover);
	}
	
	if (isNN4) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = handleMouseMove;
}

/*
	HideTooltips all tooltip layers.
	Requires: tooltip layers
	Returns: sets tipOpen = false
	Error checking: none
*/
function hideTooltips(){
	if (!DHTML) return; 
	if(document.releaseCapture){
		document.releaseCapture();
	}
	if(isStnd){
		for (var i in tooltips){
			var div = new getObj(tooltips[i].tipID); 
			//var div = gbi(tooltips[i].tipID);
			if((div != null) && (div.style) && (div.style.visibility != null)){
				//alert(div.style.visibility);
				div.style.visibility = "hidden";
			}
		}
	}
	tipOpen = false;
	if (ctID) clearTimeout(ctID); 
}

/*
	HideTooltip hides one tooltip layer.
	Requires: parameter tooltip layer
	Returns: sets tipOpen = false
	Error checking: none
*/
function hideTooltip(tid){
	if (!DHTML) return;
	//alert("Hiding tip");
	if(isStnd){
		if(typeof(tid) == "object"){
			var div = tid;
		}else if(typeof(tid) == "string"){
			//var div = gbi(tid);
			var div = new getObj(tid); 
		}else{
			;
		}
		
		if((div != null) && (div.style) && (div.style.visibility != null)){
			div.style.visibility = "hidden";
		}
	}
	if (ctID) clearTimeout(ctID);
}

/*
	delayHideTooltip closes a layer after the closeTime amount of time.
	Requires: nothing
	Returns: sets timeout
	Error checking: TODO - Check availability of currTipID
*/
function delayHideTooltip(){
	if (!DHTML) return; 
	//alert("ctID is " + ctID);
	if (ctID) clearTimeout(ctID); 
	var timeoutstr = "hideTooltip(\'" + currTipID + "\');";
	ctID = setTimeout(timeoutstr, closeTime);
}

/*
	showTooltip opens and starts any transitional effects.
	Requires: Event object
	Returns: nothing
	Error checking: none
*/
function showTooltip(evt){
	//alert("Showing tooltip");
	if (!DHTML) return; 
	var offsetX =150, offsetY =0;
	hideTooltips();
	tipOpen = true;
	evt = (evt) ? evt : ((event) ? event : null);
	if(evt){
		var elem = (evt.target) ? evt.target : evt.srcElement;
		if(elem.nodeType == 3){
			elem = elem.parentNode;
		}

		if(elem.className == "tipEntry"){
			//lastTipID = currTipID;
			currTipID = tooltips[elem.id].tipID;
			
			var tooltip = gbi(currTipID);
			// turn on IE mouse capture
			if(tooltip.mouseCapture){		
				tooltip.mouseCapture();
			}
			// Uncomment to position off div
			var coords = getCoordsByElement(elem); 
			// Uncomment to position off mouse
			//var coords = getCoordsByMouseXY();
			
			tooltip.style.left = (coords.x + offsetX) + "px";
			tooltip.style.top = (coords.y + offsetY) + "px";
			tooltip.style.zIndex = "9"; // required by NN7
			
			if ( fadeOn ) { 
				firstFade = true; 
				prepLyr(lastTipID, true ); 
				startFade(lastTipID, 50, 25); 
			} else { 
				visib(lastTipID, false); 
				visib(currTipID, true); 
			} 
			lastTipID = currTipID; 
			
			if(evt.preventDefault){
				evt.preventDefault();
			}
			evt.returnValue = false;
			delayHideTooltip();
		}
	}
}

/*
	getCoordsByMouseXY retrieves point array containing current mouse coordinates.
	Requires: Event object
	Returns: Coordinates coords[]
	Error checking: none
*/
 function getCoordsByMouseXY(evt) {
   var offsetX=10, offsetY =10;
   var maxY = 420;
	var coords = {x: 0, y: 0};
	coords.x = mouseX;
	if(mouseY > maxY){
		coords.y = (mouseY-120);
	}else{
		coords.y = mouseY;
	}
	return coords;
 }

/*
	getCoordsByElement retrieves point array containing elements position on the page.
	Requires: Event object
	Returns: Coordinates coords[]
	Error checking: none
*/
function getCoordsByElement (el) {
  var coords = {x: 0, y: 0};
  while(el){
	if(el.pageX){
		coords.x += el.pageX;
		coords.y += el.pageY;
	}else if (el.offsetLeft || el.offsetTop){
		coords.x += el.offsetLeft;
		coords.y += el.offsetTop;
	}else if (el.offsetX || el.offsetY){
		coords.x += el.offsetX;
		coords.y += el.offsetY;
	}else if (el.clientX){
		coords.x += el.clientX;
		coords.y += el.clientY;
	}
	el = el.offsetParent;
  }
  return coords;
}

// Open window functions

// For lotmaps
function fsi(theURL) {
	if(isIE){
		strFeatures = "top=0,left=0,scrollbars=no,resizeable=no,menubar=no,location=no,directories=no,status=no,titlebar=no,fullscreen=yes";
	}else{
		strFeatures = "top=0,left=0,scrollbars=no,resizeable=no,menubar=no,location=no,directories=no,status=no,titlebar=no";
	}
	newWindow = window.open(theURL, '', strFeatures, '');
}

function openWindow(page,width,height,sbars) {
	if (newWindow != null){
		if(navigator.appName.indexOf("Netscape")>=0){
			if(newWindow.name){
				newWindow.close();
			}
		}else{
			// IE on Mac doesn't like this
			if(!isMac){
				newWindow.close();
			}
		}
	}
	newWindow = window.open("", "newWin", "width=" + width + ",height=" + height + ",screenX=0,screenY=0,top=0,left=0,status=no,toolbar=no,menubar=no,location=no,scrollbars=" + sbars + ",resizable=yes");
	newWindow.location.href = page;
	if (newWindow.opener == null) newWindow.opener = window;

}

function openWindow2(page,width,height,sbars) {
	if (newWindow != null){
		if(navigator.appName.indexOf("Netscape")>=0){
			if(newWindow.name){
		 		newWindow.close();
			}
		}else{
			newWindow.close();
		}
	}
	newWindow = window.open(page, "newWin", "width=" + width + ",height=" + height + ",screenX=0,screenY=0,top=0,left=0,status=yes,toolbar=no,menubar=no,location=no,scrollbars=" + sbars + ",resizable=yes");
	//newWindow.location.href = page;
	if (newWindow.opener == null) newWindow.opener = window;

}

function openWindow_nobars(page,width,height,sbars) {
	if (newWindow != null){
		if(navigator.appName.indexOf("Netscape")>=0){
			if(newWindow.name){
		 		newWindow.close();
			}
		}else{
			newWindow.close();
		}
	}
	newWindow = window.open("", "newWin", "width=" + width + ",height=" + height + ",screenX=0,screenY=0,top=0,left=0,status=yes,toolbar=no,menubar=no,location=no,scrollbars=" + sbars + ",resizable=yes");
	newWindow.location.href = page;
	if (newWindow.opener == null) newWindow.opener = window;

}

// interestingly, NS7 will throw an error if the following 
// function is called fullscreen
function fs(theURL) {
	window.open(theURL, '', 'scrollbars=no, fullscreen=yes');
}

// Delay clear window (esp. for MacIE5)
function doClearWindow(){
	if(newWindow != null){
		newWindow.close();
		setTimeout ( "clearWindow", 2000 );
	}
}
function clearWindow(){
	newWindow = null;
}
// Fade functions
/*
	Fade:startFade is called to begin fade on a component after it has been prepped.
	Requires: layer name, amount to fade (?), and interval between fade steps
	Returns: nothing
	Error checking: none
*/
function startFade(layername, amt, tim) { 
	if (!DHTML) return; 
	fadeLayer = new getObj( layername ); 
	if (!fadeLayer) return; 
	amount = amt; 
	fadeTime = tim; 
	fadeAction(); 
} 

/*
	Fade:stopFade cancels the fade timeout essentially stopping the fade.
	Requires: nothing
	Returns: nothing
	Error checking: none
*/
function stopFade() { 
	if (fadeTimeID) clearTimeout(fadeTimeID); 
} 

/*
	Fade:fadeAction is called by start fade and then continually until layer is fully visible.
	Requires: globals
	Returns: nothing
	Error checking: none
*/
function fadeAction() { 
	//clipTop += amount; 
	clipBottom -= amount; 
	//if (clipTop < 0 || clipBottom > lyrheight || clipTop > clipMid) {
	//alert(clipBottom);
	if (clipBottom < 0 || clipBottom > lyrheight) {
		//alert(clipBottom);
		//if ( clipTop > clipMid ) fadeLayer.style.visibility = 'hidden';
		if ( clipBottom < clipTop ) fadeLayer.style.visibility = 'hidden';
		if ( firstFade ) nextFade(); 
		return; 
	} 
	if (isStnd || isIE) { 
		clipstring = 'rect('+clipTop+' '+clipWidth+' '+clipBottom+' 0)';
		//alert(clipstring);
		fadeLayer.style.clip = clipstring; 
	} else if (isNN4) { 
	
		fadeLayer.style.clip.top = clipTop; 
		fadeLayer.style.clip.bottom = clipBottom; 
	} 
	fadeTimeID = setTimeout('fadeAction()',fadeTime); 
} 

var firstFade = true; 
function nextFade() { 
	firstFade = false; 
	prepLyr(currTipID, false); 
	startFade(currTipID, -10, 15); // first arg is amount, second is frequency
} 

/*
	Fade:setFade called after page load that turns the fade transition on or off
	Requires: boolean (on | off)
	Returns: nothing
	Error checking: none
*/
function setFade(switchFade) {// Fade switch function 
	if ( !fadeOn ) { 
		prepLyr(currTipID, true); 
	} else { // No fade 
		stopFade(); 
		hideTooltips();
	} 
	fadeOn = switchFade; 
} 

/*
	Fade:prepLyr preps intial layer values prior to a fade / transition.
	Requires: layer name and layer visibility
	Returns: nothing
	Error checking: none
*/
function prepLyr(lyr, vis) {
	if (!DHTML) return; 
	x = new getObj( lyr ); 
	if (isStnd || isIE) { 
		lyrheight = x.obj.offsetHeight +8;
		clipWidth = x.obj.offsetWidth; 
		if ( vis ) { 
			clipTop = 0; 
			clipMid =  Math.round(lyrheight/2); 
			clipBottom = lyrheight; 
		} else { 
			// if hidden, crop to center of layer
			clipMid = Math.round(lyrheight/2); 
			//clipBottom = clipMid; 
			//clipTop = clipMid; 
			clipTop = 0;
			clipBottom = clipTop;
		} 
		// top width bottom height
		x.style.clip = 'rect('+clipTop+' '+clipWidth+' '+ clipBottom +' 0)'; 
		visib(lyr, true); 
	} else if (isNN4) { 
		lyrheight = x.style.clip.bottom; 
		clipWidth = x.style.clip.right; 
		if ( vis ) { 
			clipTop = 0; 
			clipMid = Math.round(lyrheight/2); 
			clipBottom = lyrheight; 
		} else { 
			clipMid = Math.round(lyrheight/2); 
			//clipBottom = clipMid; 
			//clipTop = clipMid; 
			clipTop = 0;
			clipBottom = 0;
		} 
		
		x.style.clip.top = clipTop; 
		x.style.clip.left = 0; 
		x.style.clip.right = clipWidth; 
		x.style.clip.bottom = clipBottom; 
		x.style.visibility = 'show'; 
	} else {
		return;
	}
} 

/*
	Utility:getObj creates crossbrowser layer object.
	Requires: layer name
	Returns: self with obj and style reference
	Error checking: TODO check presence of 'objName' layer
*/
function getObj(objName) { 
	if (isStnd) { 
		this.obj = document.getElementById(objName); 
		this.style = document.getElementById(objName).style; 
	} else if (isIE) { 
		alert("Document.all");
		this.obj = document.all[objName]; 
		this.style = document.all[objName].style; 
	} else if (isNN4) { 
		//this.obj = document.layers[objName]; 
		//this.style = document.layers[objName]; 
		this.obj = xLayer(objName);
		this.style = xLayer(objName);
	} else {
		// Other browsers
		
	}
} 

/*
	Utility:visib toggle visibility of layer.
	Requires: layer name, boolean (show | hide)
	Returns: nothing
	Error checking: TODO check presence of 'objName' layer
*/
function visib(objName, flag) { // triggers layer visibility 
	x = new getObj(objName); 
	x.style.visibility = (flag) ? 'visible' : 'hidden'; 
} 


// Layer functions 
function gbi(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else if(document.layers) e=xLayer(e);
  else e=null;
  return e;
}

function xLayer(id,root) { // only for nn4
  var i,layer,found=null;
  if (!root) root=window;
  for(i=0; i<root.document.layers.length; i++) {
    layer=root.document.layers[i];
    if(layer.id==id) return layer;
    if(layer.document.layers.length) found=xLayer(id,layer);
    if(found) return found;
  }
  return null;
}