var basedir = "http://museum.stanford.edu/";

function preloadImages() {
	var iid;
	var iext;
	var i;
	var preloadimgs = new Array();
	var imgs = document.images;
	
	for (i=0; i<imgs.length; i++) {
		iid = imgs[i].id;
		if (iid.indexOf("ro_") == 0) {
			iext = imgs[i].src.substring(imgs[i].src.lastIndexOf("."),imgs[i].src.length);
			preloadimgs[iid] = new Image;
			preloadimgs[iid].src = basedir + "images/" + iid.substring(3,iid.length) + iext;
			preloadimgs[iid + "_over"] = new Image;
			preloadimgs[iid + "_over"].src = basedir  + "images/" + iid.substring(3,iid.length) + "_over" + iext;
			imgs[i].onmouseover = function () {this.src = preloadimgs[this.id + "_over"].src;}
			imgs[i].onmouseout = function () {this.src = preloadimgs[this.id].src;}
		}
	}
}


//Collection window popup function
function popWin(loc) {
	newwindow = window.open(basedir + "view/" + loc, "artViewWin", "width=560,height=485,scrollbars=1,resizable=1,location=0,toolbar=0,status=0,titlebar=1,menubar=0");
	if (window.focus) {newwindow.focus()}
}

//Offsite window popup function
function offsiteLink(loc) {
	var newWidth = 640;
	var newHeight = 480;
	var newX = 0;
	var newY = 0;
	
	if(this.window.screenX) {
		newX = this.window.screenX + 100;
		newY = this.window.screenY + 120;
	} else if (window.screenLeft) {
		newX = window.screenLeft + 100;
		newY = window.screenTop + 120;
	}
	newwindow = window.open(loc, "newWin" ,"width="+newWidth+",height="+newHeight+",screenX="+newX+",screenY="+newY+",left="+newX+",top="+newY+",scrollbars=1,resizable=1,location=1,toolbar=1,status=1,titlebar=1,menubar=1");
	if (window.focus) {newwindow.focus()}
}

