window.onload = function(){
	doc = document;
	doc.dhtml = dhtml;
	numOfCaseStudies = 2;
	//loc = window.parent.location.href.toLowerCase();
	currentNav = "overview";
	doc.getElementById("mainContentOverview").style.display = "block";
	doc.getElementById(currentNav).style.background = "url(images/navOverviewOn.gif) left top no-repeat";
	
	arrNavigation = new Array("overview","alerts","academics","convenience","safety","caseStudies");
	for(i = 0; i < arrNavigation.length; i++){
		doc.dhtml.addEvent(arrNavigation[i], "mouseover", swapMainImg, false);
		doc.dhtml.addEvent(arrNavigation[i], "mouseout", swapMainImg, false)
		doc.dhtml.addEvent(arrNavigation[i], "click", navigate, false)
	}
	originalSrc = doc.getElementById("mainImg").src.split("/");
	originalImgSrc = originalSrc[originalSrc.length - 1];
	
	arrCaseStudyLinks = new Array("caseStudy1Link", "caseStudy2Link");
	for(i = 0; i < arrCaseStudyLinks.length; i++){
		doc.dhtml.addEvent(arrCaseStudyLinks[i], "click", swapCaseStudy, false)
	}
}
function swapMainImg(e){
	var e = doc.dhtml.getEvent(e);
	var theElement = dhtml.getTarget(e);
	strLen = theElement.id.length;
	navObj = theElement.id.substring(0,1).toUpperCase() + theElement.id.substring(1,strLen);
	if (e.type == "mouseover"){
		doc.getElementById("mainImg").src = "images/" + theElement.id + "Main.jpg";
		doc.getElementById(theElement.id).style.background = "url(images/nav" + navObj + "On.gif) left top no-repeat";
	}
	if (e.type == "mouseout"){
		doc.getElementById("mainImg").src = "images/" + originalImgSrc;
		if(currentNav != theElement.id)
			doc.getElementById(theElement.id).style.background = "url(images/nav" + navObj + ".gif) left top no-repeat";
	}
}
function navigate(e){
	var e = doc.dhtml.getEvent(e);
	var theElement = dhtml.getTarget(e)
	
	if (e.type == "click"){
		currentNav = theElement.id;
		originalImgSrc = theElement.id + "Main.jpg";
		for(i = 0; i < arrNavigation.length; i++){
			strLen = arrNavigation[i].length;
			navObj = arrNavigation[i].substring(0,1).toUpperCase() + arrNavigation[i].substring(1,strLen);
			divToHide = "mainContent" + arrNavigation[i].substring(0,1).toUpperCase() + arrNavigation[i].substring(1,strLen);
			doc.getElementById(divToHide).style.display = "none";
			doc.getElementById(arrNavigation[i]).style.background = "url(images/nav" + navObj + ".gif) left top no-repeat";
		}
		strLen = theElement.id.length;
		divToShow = "mainContent" + theElement.id.substring(0,1).toUpperCase() + theElement.id.substring(1,strLen);
		doc.getElementById(divToShow).style.display = "block";

		strLen = theElement.id.length;
		navObj = theElement.id.substring(0,1).toUpperCase() + theElement.id.substring(1,strLen);
		theElement.style.background = "url(images/nav" + navObj + "On.gif) left top no-repeat";
	}
}

function openWin(url, w, h)
{
	var winprop = "width=" + w + ",height=" + h + "left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No"; 
	openwin = window.open(url,'',winprop); 
	
}

function swapCaseStudy(e){
	var e = doc.dhtml.getEvent(e);
	var theElement = dhtml.getTarget(e)
	strLen = theElement.id.length;
	if (e.type == "click"){
		for(iCaseStudies = 1; iCaseStudies <= numOfCaseStudies; iCaseStudies++){
			doc.getElementById("caseStudy" + iCaseStudies + "Link").className = "";
			doc.getElementById("caseStudy" + iCaseStudies).style.display = "none";
		}
		theElement.className = "highlighted";
		doc.getElementById(theElement.id.substring(0,strLen-4)).style.display = "block";
	}
}