// JavaScript Document
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var headerHeight = document.getElementById('header').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (document.getElementById('container').offsetHeight >= document.getElementById('rightColumn').offsetHeight){
				contentHeight = document.getElementById('container').offsetHeight;
			} else {
				contentHeight = document.getElementById('rightColumn').offsetHeight;
			}			
			if (windowHeight - (headerHeight + contentHeight + footerHeight) >= 0) {
				footerElement.style.position = 'absolute';
				footerElement.style.top = (windowHeight - footerHeight) + 'px';
			}
			else {
				footerElement.style.position = 'static';
			}
		}
	}
}
window.onresize = function() {
	setFooter();
}


server = "http://interactive.redtettemer.com/wharton/whs005"; // "http://"+window.location.host
server = "http://www.wharton.upenn.edu/alumni/wharton125"; // "http://"+window.location.host
server = "http://leadershipconference.wharton.upenn.edu"; // "http://"+window.location.host


function on(imgName) {
	if (document[imgName].src == eval(imgName + "_off.src")){
		document[imgName].src = eval(imgName + "_on.src");
		imageRolledOver = document[imgName].src;
	}
}

// OFF Function
function off(imgName) {
	if (imageRolledOver == document[imgName].src){
		document[imgName].src = eval(imgName + "_off.src");
	}
}

// Preloaded images 
if (document.images) {
	
	nav_chr_on = new Image();
	nav_chr_on.src = server + "/images/nav_chr_on.gif";
	
	nav_chr_off = new Image();
	nav_chr_off.src = server + "/images/nav_chr_off.gif";

	nav_clcm_on = new Image();
	nav_clcm_on.src = server + "/images/nav_clcm_on.gif";
	
	nav_clcm_off = new Image();
	nav_clcm_off.src = server + "/images/nav_clcm_off.gif";

	nav_wee_on = new Image();
	nav_wee_on.src = server + "/images/nav_wee_on.gif";
	
	nav_wee_off = new Image();
	nav_wee_off.src = server + "/images/nav_wee_off.gif";
	

	nav_whartonsite_on = new Image();
	nav_whartonsite_on.src = server + "/images/nav_whartonsite_on.gif";
	
	nav_whartonsite_off = new Image();
	nav_whartonsite_off.src = server + "/images/nav_whartonsite_off.gif";

	nav_pennsite_on = new Image();
	nav_pennsite_on.src = server + "/images/nav_pennsite_on.gif";
	
	nav_pennsite_off = new Image();
	nav_pennsite_off.src = server + "/images/nav_pennsite_off.gif";
}

function createPrimaryNavElement(name, a, activeSection){
	var nav_element = "<a href=\""+a+"\" onmouseover=\"javascript:on('"+name+"');\" onmouseout=\"off('"+name+"')\"><img src=\""+server+"/images/"+name;
	if (name == activeSection){
		nav_element += "_on";
	} else {
		nav_element += "_off";
	}
	nav_element += ".gif\" border=\"0\" name=\""+name+"\"></a>";
	document.write(nav_element);
}

function createPrimaryNav(activeSection){
	createPrimaryNavElement("nav_chr", "http://www-management.wharton.upenn.edu/chr/", activeSection);
	createPrimaryNavElement("nav_clcm", "http://leadership.wharton.upenn.edu/welcome/index.shtml", activeSection);
	createPrimaryNavElement("nav_wee", "http://executiveeducation.wharton.upenn.edu/", activeSection);
}

function createFooterNav(activeSection){
	createPrimaryNavElement("nav_whartonsite", "http://www.wharton.upenn.edu", activeSection);
	createPrimaryNavElement("nav_pennsite", "http://www.upenn.edu", activeSection);	
}


function toggleLayer(layerToShow, layerToHide){
	if (document.getElementById){
		// this is the way the standards work
		var showLayer = document.getElementById(layerToShow).style;
		showLayer.display = showLayer.display? "":"block";
	} else if (document.all) {
		// this is the way old msie versions work
		var showLayer = document.all[layerToShow].style;
		showLayer.display = showLayer.display? "":"block";
	} else if (document.layers) {
		// this is the way nn4 works
		var showLayer = document.layers[layerToShow].style;
		showLayer.display = styshowLayer.display? "":"block";
	}
	setFooter();
}


function playvideo(){
	window.open('http://www.wharton.upenn.edu/alumni/wharton125/video/video.html','myWin', 'toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no, width=700, height=432');
}