var imgPreLoad = new Array();
var oldSrc = "";
var oldHeight = 1;
var oldWidth = 1;
var oldText = "";
var fullImgSrc = "";


function showImg(src) {
	var img = document.images["prodImage"];
	
	for(var i=0;i<imgPreLoad.length; i++) {
		if(imgPreLoad[i].src.toLowerCase() == src.toLowerCase() || 
				imgPreLoad[i].src.toLowerCase().indexOf(escape(src.toLowerCase())) != -1) {
			img.height = imgPreLoad[i].height;
			img.width = imgPreLoad[i].width;
			fullImgSrc = imgPreLoad[i].originalSrc;
			
			if(document.getElementById) {
				var desc = document.getElementById("imgDescription");
				oldText = img.alt = desc.innerHTML = imgPreLoad[i].alt;
				img.alt = img.alt + " - Click to view original full size image"; 
			}
			break;
		}
	}
	img.src = src;
	oldSrc = img.src;
	oldHeight = img.height;
	oldWidth = img.width;
}						

function rOverImage(src) {
	var img = document.images["prodImage"];
	//oldSrc = img.src;
	oldHeight = img.height;
	oldWidth = img.width;	
	
	for(var i=0;i<imgPreLoad.length; i++) {
		if(imgPreLoad[i].src.toLowerCase().indexOf(escape(src.toLowerCase())) != -1) {
			img.height = imgPreLoad[i].height;
			img.width = imgPreLoad[i].width;
			if(document.getElementById) {
				var desc = document.getElementById("imgDescription");
				desc.innerHTML = imgPreLoad[i].alt;
			}
			break;
		}
	}
	img.src = src;						
}

function rOutImage() {
	var img = document.images["prodImage"];
	img.src = oldSrc;					
	img.height = oldHeight;
	img.width = oldWidth;
	if(document.getElementById) {
		var desc = document.getElementById("imgDescription");
		desc.innerHTML = oldText;
	}
}	

function loadFirstImage() {
	showImg(imgPreLoad[0].src);
}

function fittedImage() {
	window.open("/w3a_dyn/fittedImage.aspx?src=" + fullImgSrc + "&title=" + oldText,"fittedImage","height=100, width=100, scrollbars=no, location=no, address=no, resizable=yes");
}