var ids=new Array('about','undergraduate','graduate','executive','real-learning','news','students','directory','alumni','ethics');
var uri = new Object();
//document.write("<link rel=\"shortcut icon\" href=\"/favicon.ico\" type=\"image/x-icon\" />");
getURL(uri);

function expandText(id) { 
	var theSection = document.getElementById(id);
	arrowName = 'arrow'+id;
	
//	document.getElementByID(arrowName).src="/images/arrow_d.gif";

	if (theSection.style.display=='none') {
		hideallids();
		theSection.style.display = 'block';
	}	
	
	else  {	hideallids(); }	
}

/*
this function highlights the current subnav page on the navigation bar
*/
function highlightPage(id){
	var theSection = document.getElementById(id);
	
	if(theSection) {
		theSection.firstChild.style.backgroundColor = '#F36E21';
		theSection.firstChild.style.color = '#F0EFDB';		
	}
}

function overwriteCurrent(element) {
	element.style.backgroundColor = '#FFF';
}

function pageload() {
	hideallids();
//	expandText("Media");
	var url=document.URL.split("//"); // separate protocol from URL
	
	//this is to retrieve the stuff after "...rit.edu/" no matter what it is
	var splitURL = url[1].split("/");
	var endURL = "";
	for( var i=1; i<splitURL.length; i++ ) {
		endURL += "/"+splitURL[i];
	}
	
	//this splits off the second param if it exists and the anchor if it exists
	var url2 = endURL.split("&")[0].split("#")[0];
	var url3 = url[1].split("/");
	
	//grab the page name from the url -- without the params
	var pagename = url3[url3.length-1].split("?")[0];
	
	//hack for aha stuff, since its not in a true sub directory
	if(pagename.substr(0,4) == "aha_") highlightPage("/"+url3[1]+"/aha.php");
	//hack for events.php?id=NUM ... and other pages... rewriting this in the future would be nice
	else if(pagename == "events.php" || pagename=="connect.php" || pagename=="succeed.php" || pagename=="innovate.php") highlightPage("/"+url3[1]+"/"+pagename);
	else if(url3.length > 3) highlightPage("/"+url3[1]+"/"+url3[2]+"/index.php");
	else highlightPage(url2);
	
	url = (url[1] ? url[1] : url[0]).split("/");   //split url into pieces
//Do not uncomment the line below. It makes the script stop working in both IE
//and firefox.. unless the firebug console is open
	//if (console.log !== undefined) console.info(url[1]);
	//alert(url[1]);
	switch (url[1]) {
		case ids[0]:
			expandText(ids[0]);
			break;
		case ids[1]:
			expandText(ids[1]);
			break;
		case ids[2]:
			expandText(ids[2]);
			break;
		case ids[3]:
			expandText(ids[3]);
			break;
		case ids[4]:
			expandText(ids[4]);
			break;
		case ids[5]:
			expandText(ids[5]);
			break;
		case ids[6]:
			expandText(ids[6]);
			break;
		case ids[7]:
			expandText(ids[7]);
			break;
		case ids[8]:
			expandText(ids[8]);
			break;
		case ids[9]:
			expandText(ids[9]);
			break;
	}
	
	
	

	return null;	   
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}
	
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display != 'none') { 
			document.getElementById(id).style.display = 'none';
		}
		else {
			document.getElementById(id).style.display = 'block';
		}
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
		if (document.all.id.style.display != 'block') { 
			document.all.id.style.display = 'block';
		}
		else {document.all.id.style.display = 'none';}
		}
	}
}



// Current Page Reference
// copyright Stephen Chapman, 1st Jan 2005
// you may copy this function but please keep the copyright notice with it
function getURL(uri) {
	uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
	uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
	uri.path = ''; var pos = uri.dom.indexOf('\/');
	if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
	uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
	pos = uri.page.indexOf('?');
	if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	pos = uri.page.indexOf('#');
	if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	uri.ext = ''; pos = uri.page.indexOf('.');
	if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
	uri.file = uri.page;
	if (uri.ext != '') uri.file += '.' + uri.ext;
	if (uri.file == '') uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	return uri;
}   


