var r = 0;
var i = 0;
var pathwidth;
var pathheight;
var x = 0;
var y = 0;
// Hide timeout.
var menutime = 0;
var menutimeout=500;


function loadImg(path, hyper, imgno)
{
	e=event;
	//e = (e) ? e : ((window.event) ? window.event : null);
	var m1= document.getElementById("divpiczoom");
	//alert(m1.style.display);
	var itm =  document.getElementById("imgZoom",e);
	m1.style.display = "block";

	//x = e.clientX;
	//y = e.clientY;
	
	//x = itm.style.left + (itm.offsetWidth / 2); dock to top left
	//y = itm.style.top + (itm.offsetHeight / 2); dock to top left
	
	
	x = GetX(document.getElementById(imgno));
	y = GetY(document.getElementById(imgno));
	x = x + (document.getElementById(imgno).offsetWidth / 2);
	y = y + (document.getElementById(imgno).offsetHeight / 2);
	//alert(x);
	//alert(y);
	


	if (e.clientX > (document.body.offsetWidth / 2)) {//alert(itm.offsetWidth);
		//m1.style.left = e.clientX - 350;
		//m1.style.left = e.clientX - 125;
		//m1.style.left = (e.clientX - itm.offsetWidth) + 'px';
		}
	else {
		//m1.style.left = e.clientX + 100;
		//m1.style.left = e.clientX - 125;
		//m1.style.left = e.clientX + 'px';
		}
	//m1.style.top = (e.clientY + document.body.scrollTop - (itm.offsetHeight/2)) + 'px';
	r = 0;
	img=new Image;
	img.src = path;
	pathwidth = img.width;
	pathheight = img.height;

	m1.style.width = '0px';
	m1.style.height = '0px';
	m1.style.visibility = "hidden";

	document.getElementById("imgZoom").style.width=0;
	document.getElementById("imgZoom").style.height=0;
	document.getElementById("imgZoom").src = path;
	document.getElementById("imgZoomHyper").href = hyper;
	
	r = 0;
	m1.style.top = y;
	m1.style.left = x; 
	aniZoom(pathwidth, pathheight);

}	

function GetX(oElement) {
	var ix = 0;
	
	while(oElement != null) {
		ix += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}
	return ix;
}
function GetY(oElement) {
	var iy = 0;
	
	while(oElement != null) {
		iy += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return iy;
}

function hideImg()
{
	document.getElementById("divpiczoom").style.display = "none";
	//aniUnZoom();
}

function aniZoom() {
	var m1 = document.getElementById("divpiczoom");
	m1.style.visibility = "visible";
	r = r + 2;
	
	//alert(x - (r/2));
	if (pathwidth <= pathheight) {
		if (r <= pathwidth) {
		m1.style.left = x - (r/2) + 'px';
		m1.style.top = y - (r/2) + 'px';
		document.getElementById("imgZoom").style.width= r + 'px';
		document.getElementById("imgZoom").style.height= r + 'px';
		setTimeout('aniZoom()', 2);
		}
		if (r >= pathwidth && r <= pathheight) {
		m1.style.top = y - (r/2) + 'px';
		document.getElementById("imgZoom").style.width= pathwidth + 'px';
		document.getElementById("imgZoom").style.height= r + 'px';
		setTimeout('aniZoom()', 2);
		}
		}
	else {
	
		if (r <= pathheight) {
		m1.style.left = x - (r/2) + 'px';
		m1.style.top = y - (r/2) + 'px';
		document.getElementById("imgZoom").style.width= r + 'px';
		document.getElementById("imgZoom").style.height= r + 'px';
		setTimeout('aniZoom()', 2);
		}
		if (r >= pathheight && r <= pathwidth) {
		m1.style.left = x - (r/2) + 'px';
		document.getElementById("imgZoom").style.width= r + 'px';
		document.getElementById("imgZoom").style.height= pathheight  + 'px';
		setTimeout('aniZoom()', 2);
		}
		}
}
function aniUnZoom() {
	var m1 = document.getElementById("divpiczoom");
	m1.style.visibility = "visible";
	r = r - 2;
	
	if (pathwidth <= pathheight) {
	//alert(r);
		if (r <= pathwidth && r >= 1) {
		m1.style.left = x - (r/2) + 'px';
		m1.style.top = y - (r/2) + 'px';
		document.getElementById("imgZoom").style.width= r + 'px';
		document.getElementById("imgZoom").style.height= r + 'px';
		setTimeout('aniUnZoom()', 2);
		}
		if (r > pathwidth && r <= pathheight && r >= 1) {
		m1.style.top = y - (r/2) + 'px';
		document.getElementById("imgZoom").style.width= pathwidth + 'px';
		document.getElementById("imgZoom").style.height= r + 'px';
		setTimeout('aniUnZoom()', 2);
		}
 		if (r <=1) {document.getElementById("divpiczoom").style.display = "none";}
		}
	else {
		if (r <= pathheight && r >= 1) {
		m1.style.left = x - (r/2) + 'px';
		m1.style.top = y - (r/2) + 'px';
		document.getElementById("imgZoom").style.width= r + 'px';
		document.getElementById("imgZoom").style.height= r + 'px';
		setTimeout('aniUnZoom()', 2);
		}
		if (r > pathheight && r <= pathwidth && r >= 1) {
		m1.style.left = x - (r/2) + 'px';
		document.getElementById("imgZoom").style.width= r + 'px';
		document.getElementById("imgZoom").style.height= pathheight  + 'px';
		setTimeout('aniUnZoom()', 2);
		}
 		if (r <=1) {document.getElementById("divpiczoom").style.display = "none";}
		}
}

function link() {
	window.location.href="default.asp?WCI=Policy"
}

function showspecials() {
	document.getElementById('prodspecials').style.display = 'block';
	document.getElementById('prodspecials').style.top = 100 + 'px';
}
function hidespecials() {
	document.getElementById('prodspecials').style.display = 'none';
	//document.getElementById('prodspecials').style.visibility = 'hidden';
}

function fwdcheckout() {
	window.location.href="default.ASP?WCI=ShoppingBagCustInfo";
}