function initPage(){
	if (!document.getElementById('gutcheckform')){
		if (document.getElementById('content')){
			initNav();
			initCompassPop();
			initGutcheckPop();
		} else initClose();	
	}
}

function initNav(){
	var nav = document.getElementById('nav');
	var navas = nav.getElementsByTagName('a');
			
	for (var a=0; a<navas.length; a++){
		var currenthref=String(navas[a].href);
		var currentloc=String(document.location);
		if (unescape(currenthref)==unescape(currentloc)){
			navas[a].className="there"
		}
	}
}

function initCompassPop(){
 		if (document.getElementById('compass')){
		var comp = document.getElementById('compass');
		var cas = comp.getElementsByTagName('a');
			for ( var z=0; z<cas.length; z++ ){            
					addAnEvent(cas.item(z),'click',CompassPop);
			}
		}        	
}

function CompassPop(){
 		appWindow = window.open (this.href,"appWindow","width=640,height=660,toolbar=1,scrollbars=1,resizable=1");
		appWindow.focus ();
		return false;        	
}

function initGutcheckPop(){
 		if (document.getElementById('gutcheck')){
		var gc = document.getElementById('gutcheck');
		var gcas = gc.getElementsByTagName('a');
			for ( var z=0; z<gcas.length; z++ ){            
					addAnEvent(gcas.item(z),'click',GutcheckPop);
			}
		}        	
}

function GutcheckPop(){
 		appWindow = window.open (this.href,"appWindow","width=616,height=660,toolbar=1,scrollbars=1,resizable=1");
		appWindow.focus ();
		return false;        	
}

function initClose(){
	var close = document.getElementById('close');
	close.innerHTML="<a href=\"javascript:window.close()\">close window</a>"
}

function addAnEvent( target, eventName, functionName){
        eval('target.on'+eventName+'=functionName');
}


window.onload=initPage;


