/*  Hitting Illustrated JavaScript: Product Images  */

function prodImgSetup () 
{
	prodImgs = document.getElementsByTagName("img");
	for (i=0; i<prodImgs.length; i++)
	{
		prodImg = prodImgs[i];
		if (prodImg.className == "ProdImg")
		{
			prodImg.onmouseover = function ()
						  {
							this.className += " Over";
						  }
			prodImg.onmouseout = function ()
						  {
							this.className = this.className.replace("Over","");
						  }
			prodImg.onclick = function ()
						{
							source = this.src.replace("T.gif",".gif");
							openImage(source);
						}
		}
	}
}


function openImage(source)
{
	var fullImg = document.createElement("img");
	fullImg.setAttribute("src",source);
	var imgH = fullImg.height + 20;
	var imgW = fullImg.width + 20;
	var top = (screen.height - imgH) / 2;
	var left = (screen.width - imgW) / 2;
	var viewImg = window.open(fullImg.src, "_blank", "scrollbars=no, menubar=no, height=" + imgH + ", width=" + imgW + ", resizable=no, location=no, statusbar=no, left=" + left + ", top=" + top);
	if (imgH<=20 && imgW<=20)
	{
		viewImg.close();
		imgH = fullImg.height + 20;
		imgW = fullImg.width + 20;
		top = (screen.height - imgH) / 2;
		left = (screen.width - imgW) / 2;
		window.open(fullImg.src, "_blank", "scrollbars=no, menubar=no, height=" + imgH + ", width=" + imgW + ", resizable=no, location=no, statusbar=no, left=" + left + ", top=" + top);
	}
}


function hbhDemo()
{
	var top = (screen.height - 290) / 2;
	var left = (screen.width - 340) / 2;
	window.open("../handsBackHitter/hbhDemo.html", "_blank", "scrollbars=no, menubar=no, height=290, width=340, resizable=no, location=no, statusbar=no, left=" + left + ", top=" + top);
}


function ppDemo()
{
	var top = (screen.height - 300) / 2;
	var left = (screen.width - 380) / 2;
	window.open("http://www.personalpitcher.com/spcvideo1.html", "_blank", "scrollbars=no, menubar=no, height=300, width=380, resizable=no, location=no, statusbar=no, left=" + left + ", top=" + top);
}


addEvent(window, "load", prodImgSetup);
removeEvent(window, "unload", prodImgSetup);