// JavaScript Document
function popup(doc, name, width, height){
	var left =  (screen.availWidth-width)/2;
	var popup = window.open(doc, name,'height='+(height)+',width='+(width)+', left='+(left)+',top='+(200)+'toolbar=no,menubar=no,resizable=yes,scrollbars=yes,location=no,directories=no,status=no');
	popup.focus();
}

function setSize(){
	if (! imageOriginal) return;
}
// Holds a copy of the original image for rezizing puposes
var imageOriginal;

startList = function() {
	navRoot = document.getElementById("nav");
	if (navRoot){
		for (i=0; i<navRoot.childNodes.length; i++){
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onclick=function() {
					// Remove classes from all objects
					for (i=0; i<navRoot.childNodes.length; i++){
						node = navRoot.childNodes[i];
						if (node.nodeName=="LI") {
							node.removeAttribute("class");
							node.removeAttribute("className");
							
						}
					}
					this.className+=" over";
					var image = document.images.randomimage;
					var src = "scripts/randomimage.php?folder=images/random%20images&fix="+Math.random(); // Math.radmom makes mozilla think it's a new url.
					
					image.src = src;
				
					//image.style.display = "none";
					// Get a copy of the original image for rezizing puposes
					imageOriginal = new Image();
					imageOriginal.onload = setSize;
					imageOriginal.src = src;
					image.style.display = "inline";
				}
			}
		}
	}
}
window.onload=startList;