
//homepage random welcome image
function randImg(numberImgs){
	var rand = Math.floor((Math.random() * numberImgs) + 1);
	document.write('<img src="assets/university/home/welcomeImage_'+rand+'.jpg" alt="Welcome" width="565" height="355" border="0"><br>');
}


//homepage flash header
function flashHeader(){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="755" height="60" id="header" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="http://www.hamline.edu/header.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="assets/university/home/header.swf" quality="high" bgcolor="#ffffff" width="755" height="60" name="header" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

//DHTML NAV used for global university navigation
	
	//make sure only one showing at a time: be good children
	var wLayerVis1 = null;
	var trackRoll;
	
	//---------------------------------------------------------
	//      Roll Functions
	
	//roll level 2 nav
	function menu(wlayer, active){
		
	
		if (trackRoll != wlayer){
			//show
			
			//kill other layers
			if (wLayerVis1 != null){ 
				hideLayer(wLayerVis1);
			}

			showLayer(wlayer);
			wLayerVis1 = wlayer;
			trackRoll = wlayer;

		}
		else{
			//hide
			hideLayer(wlayer);
			trackRoll = null;
			wLayerVis1 = null;
		}
	}
	
	
	function showLayer(wLayer) {
		document.getElementById("parent" + wLayer).style.backgroundColor='#900';
		document.getElementById("parent" + wLayer).style.color='#fff';
		document.getElementById("menu" + wLayer).style.display='block';
	}
	
	
	function hideLayer(wLayer) {
		document.getElementById("parent" + wLayer).style.backgroundColor='#E7E5CE';
		document.getElementById("parent" + wLayer).style.color='#900';
		document.getElementById("menu" + wLayer).style.display='none';
	}





/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

	function initRollovers() {
		if (!document.getElementById) return
		
		var aPreLoad = new Array();
		var sTempSrc;
		var aImages = document.getElementsByTagName('img');
	
		for (var i = 0; i < aImages.length; i++) {		
			if (aImages[i].className == 'imgover') {
				var src = aImages[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_o'+ftype);
	
				aImages[i].setAttribute('hsrc', hsrc);
				
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				
				aImages[i].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}	
				
				aImages[i].onmouseout = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
	
				aImages[i].onclick = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
	
			}
		}
	}
	



/*
	Expandable Listmenu Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/
	
	function initMenus() {
		if (!document.getElementsByTagName) return;
	
		/* adapted from squidfingers.com */
		var a=document.getElementsByTagName("a");
		for(var i=0;i<a.length;i++){
			a[i].onfocus=function(){this.blur()};
		}
	
	
		var aMenus = document.getElementsByTagName("LI");
		for (var i = 0; i < aMenus.length; i++) {
			var mclass = aMenus[i].className;
			if (mclass.indexOf("treenode") > -1) {
				var submenu = aMenus[i].childNodes;
				for (var j = 0; j < submenu.length; j++) {
					if (submenu[j].tagName == "A") {
						
						submenu[j].onclick = function() {
							var node = this.nextSibling;
												
							while (1) {
								if (node != null) {
									if (node.tagName == "UL") {
										var d = (node.style.display == "none")
										node.style.display = (d) ? "block" : "none";
										//this.className = (d) ? "treeopen" : "treeclosed";
										return false;
									}
									node = node.nextSibling;
								} else {
									return false;
								}
							}
							return false;
						}
						
						//submenu[j].className = (mclass.indexOf("open") > -1) ? "treeopen" : "treeclosed";
					}
					
					if (submenu[j].tagName == "UL")
						submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
				}
			}
		}
	}


//calls functions on page load
window.onload=function() {
	initMenus();
	initRollovers();
 //positionFooter();
}



//code for popup windows
	var myWin = null;
	function gen_popup(theUrl, theTitle, theDim) {
		if ((! myWin) || (myWin.closed)) {
			if (! theDim) {
				theDim = "width=444,height=222,left=15,top=15,";
			}
			theDim = theDim + 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,';
			myWin = window.open(theUrl, theTitle, theDim);
			myWin.opener = window;
		} else {
			myWin.location = theUrl;
			myWin.focus();
			myWin.opener = window;
		}
	}


	function p_link(mylink, closeme){
	if ( (window.focus&& window.opener)){
		window.opener.focus();
		window.opener.location.href=mylink;
		}
	if (closeme){
		window.close();
		}
	}

