/*find a college map 07*/
var currentstate=null;
function showstate(statename,statevisibility){
	if(document.getElementById){
		var stateclassname=(statevisibility)?("map_"+statename):("map_"+window.currentstate);
		document.getElementById('statemapinner').className=stateclassname;
	}
}
function setstate(statename){
	if(document.getElementById){
		for(i=0;i<document.searchform.X.length;i++){
			if(document.searchform.X[i].value==statename){
				if(window.currentstate!=null&&window.currentstate!=statename)document.getElementById('statemapinner').className="map_"+statename;
				document.searchform.X[i].checked=true;
				window.currentstate=statename;
			}
		}
	}
}
function changemap(statename){
	if(document.getElementById){
		if(statename!="all")document.getElementById('statemapinner').className="map_"+statename;
		else if(window.currentstate!="all"&&window.currentstate!=null)document.getElementById('statemapinner').className="";
		window.currentstate=statename;
	}
}
	/*legacy find a college map funcs*/	
	function checkForm(fm)
	{
		var chk = false;
		for (i =0; i < document.searchform.X.length; i++)
		{
			if (document.searchform.X[i].checked == true)
			{
				chk = true;
			}
		}
		if (!chk)
		{
			alert("You must select one State.");
			return false;
		}
		chk = false;
		if (document.searchform.cid)
		{
			for (i =0; i < document.searchform.cid.length; i++)
			{
				if (document.searchform.cid[i].checked == true)
				{
					chk = true;
				}
			}
			if (!chk)
			{
				alert("You must select one Course.");
				return false;
			}
		}
		
		return true;
	}


/*template enhancements 07*/
mb_initscripts=function(){
	
	//add mouseover effect to home page buttons
	if(document.getElementById('buttons')){
		var buttonobjs=document.getElementById('buttons').getElementsByTagName('LI'),buttonindex=0;
		while((buttonobj=buttonobjs[buttonindex])!=null){
			buttonobj.getElementsByTagName('A')[0].onmouseover=function(){
				var siblingindex=0;
				while((siblingobj=buttonobjs[siblingindex])!=null){
					if(siblingobj!=this.parentNode)siblingobj.className+=" faded";
					siblingindex++;
				}
			}
			buttonobj.getElementsByTagName('A')[0].onmouseout=function(){
				var siblingindex=0;
				while((siblingobj=buttonobjs[siblingindex])!=null){
					if(siblingobj!=this.parentNode)siblingobj.className=siblingobj.className.replace(" faded","");
					siblingindex++;
				}
			}
			buttonindex++;
		}
	}
	
	//remove target attributes from content menus and assign class to first text link
	if(document.getElementById('contentmenu')){
		var linkobjs=document.getElementById('contentmenu').getElementsByTagName('A'),linkindex=0;
		//if(linkobjs[1])linkobjs[1].className="firstelement";
		while((linkobj=linkobjs[linkindex])!=null){
			linkobj.target="_self";
			linkindex++;
		}
	}
	
	//add library url to edit link for editing content pages
	if(document.getElementById('edit_link')){
		var editurl="/index.cgi?E=hsvalidator",i=editurl.length;
		if(window.location.href.indexOf("?")!=-1){
			var queryvars=window.location.href.split("?")[1].split("&");
			while((querypair=queryvars.pop())!=null){
				querypair=querypair.split("=");
				editurl+=(querypair[0]=="Lev1"||querypair[0]=="Lev2")?("&"+querypair.join("=")):"";
			}
			if(editurl.length>i)document.getElementById('edit_link').href=editurl+"&PT=ed&template=library";
			else document.getElementById('edit_link').href=editurl+"&template=mntlib";
		}
	}
	
	//add and position content text background image
	if(document.getElementById('contentbody')){
		var headings=document.getElementById('contentbody').getElementsByTagName('H1');
		if(headings[0]){
			if(headings[0].offsetHeight)var ypos=headings[0].offsetHeight;
			//if(ypos)document.getElementById('contentbody').style.backgroundPosition="0 "+ypos+"px";
		}
	}
}
if(document.getElementById)window.onload=mb_initscripts;