/*
	General javascripts used on all pages in the ESBE faculty site
	Author: Jonas Altin - Ariadne Designs
	Date: 17/09/2003
*/

/* SCRIPTS THAT HANDLE THE ROLLOVER BUTTONS IN TOP OF PAGE */

// PRELOAD IMAGES
if (document.images) {
	imagedir='/images/'; // Dir where top images are located

	leftarrowoff = new Image();
	leftarrowon = new Image();
	leftarrowoff.src = "/images/leftnav_off.gif";
	leftarrowon.src = "/images/leftnav_on.gif";

	homeoff = new Image();
	homeon = new Image();
	homeoff.src=	imagedir + "tab_home_off.gif";
	homeon.src	=	imagedir + "tab_home_on.gif";
	contactoff = new Image();
	contacton = new Image();
	contactoff.src=	imagedir + "tab_contact_off.gif";
	contacton.src	=	imagedir + "tab_contact_on.gif";
	fundsoff = new Image();
	fundson = new Image();
	fundsoff.src=	imagedir + "tab_funds_off.gif";
	fundson.src	=	imagedir + "tab_funds_on.gif";
	researchoff = new Image();
	researchon = new Image();
	researchoff.src=	imagedir + "tab_research_off.gif";
	researchon.src	=	imagedir + "tab_research_on.gif";
	currencyoff = new Image();
	currencyon = new Image();
	currencyoff.src=	imagedir + "tab_currency_off.gif";
	currencyon.src	=	imagedir + "tab_currency_on.gif";
}

function setTopButton(imageName) {
	if (document.images){
		document[imageName].src = eval(imageName + "on.src");
		document.selectedButton = imageName;
		//status_message(msg);
	}
}
/* ROLL IN & OUT OF TOP LINKS */
function rollin(imageName, msg){
	if (document.images){
		document[imageName].src = eval(imageName + "on.src");
		//status_message(msg);
	}
}
function rollout(imageName, msg) {
  if (document.images) {
	if(document.selectedButton != imageName) {
		document[imageName].src = eval(imageName + "off.src");
		//status_message(msg);
	}
  }
}


/* FUNCTION THAT SETS THE STYLE FOR THE SELECTED SUB LINK */
function setSubNav(selectedLink) {
	thisLink = document.getElementById(selectedLink);
	thisLink.style.color='#FFFFFF';
}


/* FUNCTION THAT SETS THE STYLE FOR THE SELECTED LEFT LINK */
function setLeftLink(selectedLink) {
	thisLeftLink = document.getElementById(selectedLink);
	thisLeftLink.style.color='#FFFFFF';

	row = thisLeftLink.id + "row";
	thisRow = document.getElementById(row);
	thisRow.bgColor = "#6666AA";
	//for(P in thisRow) {
	//	alert(P);
	//}

	if (document.images){
		//arrow = selectedLink + "Arrow";
		img = thisLeftLink.id + "Arrow"; //eval(thisLeftLink.id + "i");
		document[img].src = leftarrowon.src;
	}

/*
	for(i=0; i < document.links.length; i++) {
		if(document.links[i].name == selectedLink) { // Selected
			document.links[i].style.color='#FFFFFF';
			if (document.images){
				arrow = selectedLink + "Arrow";
				//document['link1Arrow'].src = leftarrowon.src
				document[selectedLink].src = leftarrowon.src;
			}
		}
	}
*/
}




/*
	=================================================
	SCRIPTS TO HANDLE DISCLAIMER INFORMATION LINKING.
	=================================================
*/

var showdisclaimer = true; // Indicates if disclaimer info is to be presented

function get_cookie(Name) {
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search)
		if (offset != -1) { // if cookie exists
			offset += search.length
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset);
			// set index of end of cookie value
			if (end == -1)
				end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

function checkDisclaimer(){
	if (showdisclaimer){ // Check if disclaimer has been viewed already
		if (get_cookie('disclaimerviewed')==''){
			document.cookie="disclaimerviewed=yes;path=/;";
			location.href = "/disclaimer.shtml";
		}
	}
}

// Do the disclaimer check (only done if set to on)
checkDisclaimer();