// JavaScript Document
// Drop Down Menu 
// April 6, 2006
// Programmed for The Chicago School
// By Tad Renstrom
// Thirdwave, LLC

//Browser Detection

var ua = navigator.userAgent.toLowerCase();
var os,browser,version,data;

if (detect('konqueror')) {browser = "Konqueror"; os = "Linux";}
else if (detect('safari')) browser = "Safari";
else if (detect('omniweb')) browser = "OmniWeb";
else if (detect('firefox')) browser = "Firefox";
else if (detect('opera')) browser = "Opera";
else if (detect('webtv')) browser = "WebTV";
else if (detect('icab')) browser = "iCab";
else if (detect('msie')) browser = "Internet Explorer";
else if (!detect('compatible')) {browser = "Netscape Navigator"; version = ua.charAt(8);}
else browser = "An unknown browser";

if (!version) version = ua.charAt(stringposition + data.length);

if (!os) {
   if (detect('linux')) os = "Linux";
   else if (detect('x11')) os = "Unix";
   else if (detect('mac')) os = "Mac";
   else if (detect('win')) os = "Windows";
   else os = "An unknown operating system";
}

function detect(text) {
   stringposition = ua.indexOf(text) + 1;
   data = text;
   return stringposition;
   }

tempObj=new Object();
//Margins on either side of drop down menu. To Close Dropdown
var drpmar=10;



//Organize the dropdowns
function orgnNav(){
	
	
// Lock down A tag
// main nav item with classname assigned to it
locateAtag=document.getElementsByTagName("a");

// Lock down Div tags
// drop down container element
locateDivtag=document.getElementsByTagName("div");


// Rotate threw A tags, single out A tags that have dropdown and id them, and Array them
// Should be unique to just a tags that have drop downs and no other a tags
AtagClass="headnav_wd";
navIDrot=0;
TMnavi = new Array()


for(ARot=0; ARot<locateAtag.length; ARot++){
	if(locateAtag[ARot].className == AtagClass){
		locateAtag[ARot].id="dp_nav"+navIDrot
	    //if(document.all){
			//locateAtag[ARot].className="iecor";
		//}
		//locateAtag[ARot].onMouseOver="MenuOpen('"+navIDrot+"')"
		
		TMnavi[navIDrot] = new Object();
		TMnavi[navIDrot].id="dp_nav"+navIDrot
		TMnavi[navIDrot].height=locateAtag[ARot].offsetHeight
		TMnavi[navIDrot].width=locateAtag[ARot].offsetWidth
		//TMnavi[navIDrot].onMouseOver=locateAtag[ARot].onMouseOver
		navIDrot++
		}
	}

// Rotate threw Div tags, single out Div tags that are the dropdown divs and id them, and Array them
// once more should be unique to just the dropdown divs and no other divs
DivtagClass="subnavigation_dd";
navDivrot=0

for(DivRot=0; DivRot<locateDivtag.length; DivRot++){
	if(locateDivtag[DivRot].className == DivtagClass){
		locateDivtag[DivRot].id="adp_nav"+navDivrot;
		TMnavi[navDivrot].divid="adp_nav"+navDivrot;
		TMnavi[navDivrot].Divwidth=locateDivtag[DivRot].offsetWidth
		navDivrot++
		}
	}
	
for(LocDe=0;LocDe<TMnavi.length;LocDe++){
			var offsetTrail = document.getElementById(TMnavi[LocDe].id);
			var offsetLeft=0;
			var offsetTop=0;
				while(offsetTrail) {
						offsetLeft += offsetTrail.offsetLeft;
						offsetTop += offsetTrail.offsetTop;
						offsetTrail= offsetTrail.offsetParent;
					}
							
					if(navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined"){
						offsetLeft += document.body.leftMargin;
						offsetTop +=document.body.topMargin;
					
			}
			
			if(os == "Mac"){
				if(browser != "Opera"){
			TMnavi[LocDe].top=offsetTop+2;
			TMnavi[LocDe].bottom=offsetTop+TMnavi[LocDe].height;
			TMnavi[LocDe].left=offsetLeft-2;
			
			if(LocDe==2){
								document.getElementById("adp_nav2").className="subnavigation_dd xtraWide";
								
								}
			
				}else{
					TMnavi[LocDe].top=offsetTop-6;
					TMnavi[LocDe].bottom=offsetTop+TMnavi[LocDe].height;
					TMnavi[LocDe].left=offsetLeft-33;
					}
				}
				else{
					if(browser != "Opera"){
			TMnavi[LocDe].top=offsetTop+2;
			TMnavi[LocDe].bottom=offsetTop+TMnavi[LocDe].height;
			if(browser != "Internet Explorer"){
			TMnavi[LocDe].left=offsetLeft-2;}
			else{TMnavi[LocDe].left=offsetLeft}
					}else{
						TMnavi[LocDe].top=offsetTop-1;
						TMnavi[LocDe].bottom=offsetTop+TMnavi[LocDe].height;
						TMnavi[LocDe].left=offsetLeft-3;}
									
							if(LocDe==2){
								document.getElementById("adp_nav2").className="subnavigation_dd xtraWide";
								
								}
							
						}
						
						
document.getElementById(TMnavi[LocDe].divid).style.top=TMnavi[LocDe].top+TMnavi[LocDe].height+"px";
document.getElementById(TMnavi[LocDe].divid).style.left=TMnavi[LocDe].left+"px";
document.getElementById(TMnavi[LocDe].divid).style.visibility="visible";
document.getElementById(TMnavi[LocDe].divid).style.display="none";

if (backgroundPick !="NONE"){
	document.getElementById("utilitynavigation").className="bg_"+backgroundPick;
	try{
	document.getElementById("title").className="fc_"+backgroundPick;
	}
	catch(e){erro="yes"}
	
	try{
	document.getElementById("footernavigation").className="bg_"+backgroundPick;
	document.getElementById("contentstretch").className="stretchy_"+backgroundPick+"_BG";}
	catch(e){
		document.getElementById("footernavigation_h").className="bg_"+backgroundPick;
		document.getElementById("contentstretch_h").className="stretchy_"+backgroundPick+"_BG";
		}
	
	
	document.getElementById("contentstretchtd").className="stretchy_"+backgroundPick+"_BG";
	document.getElementById("subnavigation").className="bg_"+backgroundPick;
	try{document.getElementById("footpriv").className="bg_"+backgroundPick;}
	catch(e){
		
			
			xx="hwy";	
				
			
		}
	//document.getElementById().className=""
	}else{
		document.getElementById("utilitynavigation").className="bg_default";
		try{document.getElementById("footernavigation").className="bg_default";}
	catch(e){
		document.getElementById("footernavigation_h").className="bg_default";
		
		}
		try{
			document.getElementById("subnavigation").className="bg_default";}
		catch(e){no="noting";}
		}
//alert(document.getElementById("contentstretchtd").className)
}
//alert(TMnavi[2].left)
//for(mrtest=0;mrtest<TMnavi.length;mrtest++){
	//alert(TMnavi[mrtest].id+" "+TMnavi[mrtest].divid+" "+TMnavi[mrtest].width)
	//}
	
}

//Close all open drop downs.
function EmgCrashClose(){
	for(ec=0;ec<TMnavi.length;ec++){
		document.getElementById(TMnavi[ec].divid).style.display="none";
		document.getElementById(TMnavi[ec].divid).style.zIndex="0";
		}
		if(setImg.ID){
			
		document.getElementById(setImg.ID).src=setImg.src;}
		
			
	
	}

//draw area to close drop downs.

//navigation close for dropdowns in ie
	function followmouse1(){
		
		
		
		 if (event.clientY < TMnavi[tempObj.id].bottom){
			 tempss=TMnavi[tempObj.id].width+TMnavi[tempObj.id].left;
		if (event.clientX < TMnavi[tempObj.id].left || event.clientX > tempss) {
		 
	
	EmgCrashClose()
	document.onmousemove=null;
	
																						   
	}
	
	}
	
	if (event.clientY > TMnavi[tempObj.id].bottom){
		  tempsl=TMnavi[tempObj.id].left-drpmar
		  tempsr=TMnavi[tempObj.id].Divwidth+TMnavi[tempObj.id].left+drpmar
		  
		  //hardcodes override width for programs dropdown
		    if (tempObj.id == 2){
			tempsr=tempsr+165;
		  }
		  
		 if (event.clientX < tempsl || event.clientX > tempsr) {
			 
		  EmgCrashClose()
		  document.onmousemove=null;
		 
	}
	}
	
}
	
	//navigation close for dropdowns in all other (mozilla)
	function followmouse2(e){

	 if (e.pageY <  TMnavi[tempObj.id].bottom){
		
		tempss=TMnavi[tempObj.id].width+TMnavi[tempObj.id].left;
		 if (e.pageX < TMnavi[tempObj.id].left || e.pageX > tempss) {
			 
		EmgCrashClose()

		}}
	 
	 
	  if (e.pageY >  TMnavi[tempObj.id].bottom){
		  tempsl=TMnavi[tempObj.id].left-drpmar
		  tempsr=TMnavi[tempObj.id].Divwidth+TMnavi[tempObj.id].left+drpmar
		  
		  //hardcodes override width for programs dropdown
		  if (tempObj.id == 2){
			tempsr=tempsr+165;
		  }
		  
		 if (e.pageX < tempsl || e.pageX > tempsr) {
			
			 //alert(tempss)
		EmgCrashClose()
		 
			
			
		}}
		
		
		
		
		
}
	
	
	
	//open drop down menu.
	setImg=new Object()
function MenuOpen(mitem){
    EmgCrashClose()
	setImg.src=document.getElementById("NavImg"+mitem).src;
	setImg.ID="NavImg"+mitem;
	document.getElementById("NavImg"+mitem).src=RollOverTime[mitem].src;
	document.getElementById(TMnavi[mitem].divid).style.display="block";
	
	document.getElementById(TMnavi[mitem].divid).style.zIndex="100";
	
	
	tempObj.id=mitem
	
	
	if (document.all){
		     
			 document.onmousemove=followmouse1
		}
		else{
			  window.captureEvents(Event.MOUSEMOVE)
			  window.onmousemove=followmouse2
		}
	}
	
	

	function CompareCol(){
		
		try{
	    var leftC=document.getElementById("columnleft").offsetHeight;
		var centerC=document.getElementById("columnCenterContent").offsetHeight;
		var rightC=document.getElementById("largecontentarea").offsetHeight;
		
		//alert(leftC+" "+centerC+" "+rightC)
		if (leftC > centerC){
			document.getElementById("centerInnerLine").style.height=leftC-2+"px";
			}
		if(rightC > centerC){
			document.getElementById("centerInnerLine").style.height=rightC-2+"px";
			
			}}
			catch(e){//alert()
				try{
				 var leftC=document.getElementById("home_left").offsetHeight;
				 var centerC=document.getElementById("home_center").offsetHeight;
				 var rightC=document.getElementById("home_right").offsetHeight;
				 
				 if (leftC > centerC){
					document.getElementById("home_center_inner").style.height=leftC-4+"px";
				}
				if(rightC > centerC){
					document.getElementById("home_center_inner").style.height=rightC-4+"px";
				}}catch(e){errIs="WideColu"}
			}
		}
	
	

	document.onload=orgnNav();
	//document.onload=setTimeout("CompareCol()", 500);
	window.onload=function(){
		setTimeout("CompareCol()", 500);
		}

	