var timer;
var toHide='';
var images = new Array();
var newWin;
var xPos = 10;

//load images
//when a new image is obtained, cut it from the 'blank' array into the 'obtained' array below
var obtained = new Array("Ag", "Ar", "As", "Au", "Ba", "Be", "Bi", "Br", "Ca", "Cd", "Ce", "Cl", "Co", "Cr", "Cs", "Cu", "Dy", "Er", "Eu", "Fe", "Fr", "Ga", "Gd", "Ge", "H", "He", "Hf", "Hg", "Ho", "I", "In", "K", "Kr", "La", "Li", "Lu", "Mn", "Mo", "Nb", "Nd", "Ni", "Os", "Pb", "Pd", "Pm", "Pr", "Pt", "Ra", "Rb", "Re", "Rh", "Ru", "Sb", "Sc", "Se", "Sm", "Sn", "Sr", "Ta", "Tb", "Tc", "Te", "Ti", "Tl", "Tm", "V", "W", "Y", "Yb", "Zn", "Zr");
var whiteBox = new Array("B", "C", "N", "O", "F", "Ne");
var blackBox = new Array("Na", "Mg", "Al", "Si", "P", "S");
for(i in obtained){
	images[obtained[i]] = new Image();
	images[obtained[i]].src = "imgs/"+obtained[i]+".jpg";
}
for(i in whiteBox){
	images[whiteBox[i]] = new Image();
	images[whiteBox[i]].src = "imgs/B.jpg";
}
for(i in blackBox){
	images[blackBox[i]] = new Image();
	images[blackBox[i]].src = "imgs/Na.jpg";
}

//set the rest to blank
var blank = new Array("Ac", "Am", "At", "Bh", "Bk", "Cf", "Cm", "Db", "Ds", "Es", "Fm", "Hs", "Ir", "Lr", "Md", "Mt", "No", "Np", "Pa", "Po", "Pu", "Rf", "Rn", "Sg", "Th", "U", "Uub", "Uuh", "Uuo", "Uup", "Uuq", "Uus", "Uut", "Uuu", "Xe");
for(i in blank){
	images[blank[i]] = new Image();
	images[blank[i]].src = "imgs/blank.jpg";
}


function show(caller){
	window.clearTimeout(timer);
	hider();
	//show text
	el=document.getElementById(caller);
	if(el!=null){
		el.style.visibility="visible";
		el.style.position="relative";
	}
	//show image
	el2=document.getElementById("sleeve");
	el2.src=images[caller].src;
	el2.alt=caller;
	el2.style.visibility="visible";
}

function hide(caller){
	/*	if the user moves the pointer off of the periodic table,
		the last album to be shown will wait a bit before disappearing. */
	if(document.getElementById(caller)!=null){
		toHide=caller;
	}
	timer = window.setTimeout('hider()', 400);
}

function hider(){
	if(toHide!=''){
		el=document.getElementById(toHide)
		if(el!=null){
			//hide image
			document.getElementById("sleeve").style.visibility="hidden";
			//hide text
			el.style.visibility="hidden";
			el.style.position="absolute";
		}
	}
}

function openPage(elementName){
	fname=elementName+".html";
	newWin=window.open(fname, elementName, 'width=550,height=700,scrollbars=1,resizeable=1,status=1,screenX='+xPos+',screenY=10');
	xPos+=20;
	if(xPos>200){
		xPos=10;
	}
	newWin.focus();
}

