window.onload=function(){
	if(window.document.body.id){
		switch(window.document.body.id){
			case "home":
				preload_home();
				break;
			case "int":
				preload_int();
				break;
		}
	}
	initLinks();
};

function preload_home() {
	if(document.images) {
		var ImgArray = new Array();
		for (var i = 0; i < 6; i++) {
			ImgArray[i] = new Image();
		}    
		ImgArray[0].src = "images/collaboration-h.gif";
		ImgArray[1].src = "images/exhibits-h.gif";
		ImgArray[2].src = "images/logo-bpl-h.gif";
		ImgArray[3].src = "images/logo-imls-h.gif";
		ImgArray[4].src = "images/logo-maah-h.gif";
		ImgArray[5].src = "images/resources-h.gif";
	}
}

function preload_int() {
	if(document.images) {
		var ImgArray = new Array();
		for (var i = 0; i < 4; i++) {
			ImgArray[i] = new Image();
		}    
		ImgArray[0].src = "images/nav-collaboration-h.gif";
		ImgArray[1].src = "images/nav-exhibits-h.gif";
		ImgArray[2].src = "images/nav-resources-h.gif";
		ImgArray[3].src = "images/nav-home-h.gif";
	}
}

function on(imgName,imgType){ ((document.images) ? (document.images[imgName].src='images/'+imgName+'-h.'+imgType) : false); }

function off(imgName,imgType){ ((document.images) ? (document.images[imgName].src='images/'+imgName+'.'+imgType) : false); }

function at(imgName,imgType){ ((document.images) ? (document.images[imgName].src='images/'+imgName+'-at.'+imgType) : false); }

function initLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href")){
			if(anchor.className.match('roll')){
				anchor.onmouseover = function(){
					on(this.name.substr(4),this.name.substr(0,3));
				};
				anchor.onmouseout = function(){
					off(this.name.substr(4),this.name.substr(0,3));
				};
			}
			if(anchor.className.match('at')){
				anchor.onmouseover = function(){
					on(this.name.substr(4),this.name.substr(0,3));
				};
				anchor.onmouseout = function(){
					at(this.name.substr(4),this.name.substr(0,3));
				};
			}
			if(anchor.getAttribute("rel")=="external"){
				anchor.target = "_blank";
			}
		}
	}
}

function show(whichDiv){ ((document.getElementById) ? (document.getElementById(whichDiv).style.display = 'block') : false);}
function hide(whichDiv){ ((document.getElementById) ? (document.getElementById(whichDiv).style.display = 'none') : false);}