var clr1 = "#3779B9";
var clr2 = "#6d6370";

function hideBox(){
	var boxcount = document.getElementsByTagName('div');
	for (var i = 0; i < boxcount.length; i++){
		if (boxcount[i].className == "cBox"){
			var n = boxcount[i].getAttribute("id");
			document.getElementById(n).style.display = "none";
			document.getElementById(n).style.lineHeight = "0px";
		}
	}
}

function mapIt(){
	var mapArray = new Array();
	var mapcount = document.getElementsByTagName('*');
	for (var i = 0; i < mapcount.length; i++){
		if (mapcount[i].className == "maplink") {// if the class is map, build mouseover state
			mapcount[i].onmouseover = function(){//build onmouseover events
				var y = this.getAttribute('title')+"div";
				var x = this.getAttribute('title');
				document.getElementById(y).style.display = "block";	
				document.getElementById(x).style.color = clr1;
			}
			mapcount[i].onclick = function() {//build onmouseout events
				if (typeof(window.show) != 'undefined'){
					document.getElementById(window.show).style.color = clr2;
					document.getElementById(window.show+"div").style.display = "none";					
				}
				hideBox();
				var n = this.getAttribute('title');
				document.getElementById(n+"box").style.display = "block";
				document.getElementById(n+"box").style.lineHeight = "1.5em";
				window.show = n;
			}
			mapcount[i].onmouseout = function() {//build onmouseout events
				var x = this.getAttribute('title');
				if(x != window.show){
					document.getElementById(x).style.color = clr2;
					document.getElementById(x+"div").style.display = "none";
				}
			}				
		}//end if	
	}//end for
}//end mapIt

function getExt(string){
	imgIndex = string.indexOf('images/');
	actSrc = string.slice(imgIndex); 
	imgFile = actSrc.split('.');
	imgType = imgFile[1];	
	return imgType;
}

function init(){
	var imgArray = new Array();
	var imgcount = document.getElementsByTagName('img');
	for (var i = 0; i < imgcount.length; i++){
		// if the class is img, build rollover
		if (imgcount[i].className == "img") {
			var n = imgcount[i].getAttribute('id');
			imgArray[n] = imgcount[i].getAttribute('src');//set, in array, name of the original src
			imgcount[i].src = imgArray[n];// this sets original source and onmouseover events
			imgcount[i].style.visibility = "visible";
			imgcount[i].onmouseover = function(){
				imgOriginSrc = this.getAttribute('src');
				getExt(imgOriginSrc);
				imgNewSrc = imgOriginSrc.slice(0, -8)+"_on."+imgType;
				//alert(imgOriginSrc);
				this.setAttribute('src', imgNewSrc); // set the image
			}
			imgcount[i].onmouseout = function() {
				this.setAttribute('src',imgOriginSrc);
	        }
		}
		// if the imgon is set, then make the image static, w/o rollover states
		if (imgcount[i].className == "imgon"){
			var n = imgcount[i].getAttribute('id');
			imgArray[n] = imgcount[i].getAttribute('src');
			getExt(imgArray[n]);
			imgcount[i].src = imgArray[n].slice(0, -8)+"_on."+imgType;
			imgcount[i].style.visibility = "visible";
		}
		// if the imgon is set, then make the image static, w/o rollover states
		if (imgcount[i].className == "imghl"){
			var n = imgcount[i].getAttribute('id');
			imgArray[n] = imgcount[i].getAttribute('src');
			getExt(imgArray[n]);
			imgcount[i].src = imgArray[n].slice(0, -8)+"_hl."+imgType;
			imgcount[i].style.visibility = "visible";
		}
	}
}

navHover = function() {
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);


window.onload=function(){
init();
mapIt();
}
