// JavaScript Document
imgpops = new Array();
imgovers = new Array();
var j = 0;

//makes an array "imgpops" using every img with the class "imgpop"
for (i=0;i<document.images.length;i++) {
	if (document.images[i].className == "imgpop") {
		imgpops[j] = document.images[i];
		var url = imgpops[j].src;
		var newsrc = url.replace(/thumb/,'over');
		imgovers[j] = newsrc;
		j++;
	}
}

//places mouseover images in a hidden div for preload purposes
for (i in imgovers) {
	newimg = document.createElement('img');
	newimg.src = imgovers[i];
	document.getElementById('holdovers').appendChild(newimg);	
}

function changeimg() {
	var url = this.src;
	oldurl = url;
	var newsrc = url.replace(/thumb/,'over');
	this.src = newsrc;
	momstyle = this.parentNode.parentNode.style; //style of the div holding the <a> holding the image
	momstyle.width = '150px';
	momstyle.height = '150px';
	momstyle.margin = '-25px -25px -0px -0px';
	momstyle.zIndex = '100'
	newimg = this;
	dothenew(newimg);
}

//positions new image centered in newly sized div
function dothenew(img) {
	img.style.marginTop = ((150 - img.height+.2)*.5) + 'px';
}

function restoreimg() {
	this.src = oldurl;
	this.style.margin = 0;
	var momstyle = this.parentNode.parentNode.style;
	momstyle.width = '100px';
	momstyle.height = '100px';
	momstyle.margin = '0 0 25px 25px';
	momstyle.zIndex = 0;
	}

for (i=0;i<imgpops.length;i++) {
	imgpops[i].onmouseover = changeimg;
	imgpops[i].onmouseout = restoreimg;
}


