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 loadDictionary(imgno, content)
{
	//e=event;
	//e = (e) ? e : ((window.event) ? window.event : null);
	var temp;
	var m1= document.getElementById("divdictzoom");
	//alert(m1.style.display);
	m1.style.display = "block";

	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;

	m1.style.width = '350';
	//m1.style.height = '100';
	
	temp = '<table class="dictionarycontent" border="0" width="100%" cellspacing="0" cellpadding="0">';
	temp = temp + '<tr><td><span style="text-align:right;"><img style="cursor:pointer; float: right;" alt="Close" onclick="hideDict();" src="images/removefilter.gif"></span>';
	temp = temp + '<br /><span style="text-align:left;">' + content + '</span></td></tr></table>';
	m1.innerHTML = temp;
	//document.getElementById("content").innerHTML = content;
	//m1.style.visibility = "hidden";

	r = 0;
	m1.style.top = y - m1.clientHeight - 20;
	m1.style.left = x - 150; 

	showDict();
}	
function showDict()
{
	r = r + .1;
	document.getElementById("divdictzoom").visibility = 'visible';
	document.getElementById("divdictzoom").style.display = 'block';
	if (r <= 1) {
		document.getElementById("divdictzoom").style.opacity = r; //non-IE
		document.getElementById("divdictzoom").style.filter = 'alpha(opacity=' + r*100 + ')'; //IE
		setTimeout('showDict()', 50);
	}
}

function hideDict()
{
	document.getElementById("divdictzoom").style.display = "none";
	//aniUnZoom();
}

function loadProdPreview(divNo)
{
	//e=event;
	//e = (e) ? e : ((window.event) ? window.event : null);
	var temp;
	var m1= document.getElementById("divdictzoom" + divNo);
	//alert(m1);
	m1.style.display = "block";

	//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;

	m1.style.width = '350';
	//m1.style.height = '100';
	
	temp = '<table class="dictionarycontent" border="0" width="100%" cellspacing="0" cellpadding="0">';
	temp = temp + '<tr><td><span style="text-align:right;"><img style="cursor:pointer; float: right;" alt="Close" onclick="hideDict();" src="images/removefilter.gif"></span>';
	temp = temp + '<br /><span style="text-align:left;">' + '</span></td></tr></table>';
	//m1.innerHTML = temp;
	//document.getElementById("content").innerHTML = content;
	//m1.style.visibility = "hidden";
	r = 0;
	m1.style.top = y - m1.clientHeight + 60;
	m1.style.left = x - 150; 
	
	//alert(document.body.scrollTop);
	//alert(window.screenTop);
	m1.style.top = document.body.scrollTop + 20; //(document.all)?window.screenLeft:window.screenY - window.document.documentElement.offsetHeight;
	m1.style.left = (window.document.documentElement.offsetWidth - 336) / 2; //(document.all)?window.screenTop:window.screenX;
	m1.style.width = '600px';
	showProdPreview(divNo);
	//whereisit();

}

function showProdPreview(divNo)
{
	r = r + .1;
	document.getElementById("divdictzoom" + divNo).visibility = 'visible';
	document.getElementById("divdictzoom" + divNo).style.display = 'block';
	if (r <= 1) {
		document.getElementById("divdictzoom" + divNo).style.opacity = r; //non-IE
		document.getElementById("divdictzoom" + divNo).style.filter = 'alpha(opacity=' + r*100 + ')'; //IE
		setTimeout('showProdPreview(' + divNo + ')', 50);
	}
}

function justShowProdPreview(divNo)
{
	document.getElementById("divdictzoom" + divNo).visibility = 'visible';
	document.getElementById("divdictzoom" + divNo).style.display = 'block';
}

function hideProdPreview(divNo)
{
	document.getElementById("divdictzoom" + divNo).style.display = "none";
	//aniUnZoom();
}

function whereisit () {
	if (navigator.appName.indexOf("Netscape")!=-1
		&&parseInt(navigator.appVersion)>=5) {
	     x = "Value of Left coordinate is: " + window.screenX;
         alert(x);
         y = "Value of Top coordinate is: " +  window.screenY;
         alert(y);
	}		
	else if (navigator.appName.indexOf("Microsoft")!= -1 
	  &&parseInt(navigator.appVersion)>=4) {
	     x = "Value of Left coordinate is: " + window.screenLeft;
         alert(x);
         y = "Value of Top coordinate is: " +  window.screenTop;
         alert(y);
	}
}

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=Products&amp;%20WCE=%5especialpromotions%5eSpecials"
}
