// $Id: popup_image.js,v 1.4 2005/12/21 13:01:22 max Exp $
function popup_image(type, id, max_x, max_y, title) {

	var bimg=new Image();
        var imgpl=document.getElementById('product_thumbnail');
	bimg.src=imgpl.src;
	var width=bimg.width;
	var height=bimg.height;
	if(width>780 || height>450)
	{
	 var cx=width/780;
	 var cy=height/450;
	 if(cy>cx)
	 {
	  cx=cy;
	 }
	 width=Math.ceil(width/cx);
	 height=Math.ceil(height/cx);
	}
	imgdiv=document.getElementById('forbig');
	samp4=document.getElementById('sample4');
	imgdiv.innerHTML='<div style="text-align:right;padding-right:5px;"><a href="javascript:void(0);" onClick="close_popup(); return false;" title="Click for close"><img src="/skin1/images/close.jpg" border="0" width="60" height="40"></a></div><table width="100%" height="100%"><tr><td><img src="'+bimg.src+'" width="'+width+'" height="'+height+'"></td></tr></table>';
	samp4.zIndex="5000";
	var clientH=0;
	if(window.innerHeight!=null)
	{
	 clientH=window.innerHeight;
	}else
	 {
	  clientH=document.body.offsetHeight;
	 }
	if(clientH>800)
	{
	 clientH=450;
	}
	var divleft=(document.body.clientWidth-800)/2;
//	alert(clientH+" - "+divheight+" - "+parseInt(document.documentElement.scrollTop,10))
	var divtop=(clientH-550)/2+parseInt(document.documentElement.scrollTop,10);
	samp4.style.left=divleft+"px";
	samp4.style.top=divtop+"px";
	samp4.style.display="block";

/*
	max_x = parseInt(max_x);
	max_y = parseInt(max_y);

	if (!max_x)
		max_x = 160;
	else
		max_x += 25;
	if (!max_y)
		max_y = 120;
	else
		max_y += 25;

	return window.open(xcart_web_dir+'/popup_image.php?type='+type+'&id='+id+'&title='+title,'images','width='+max_x+',height='+max_y+',toolbar=no,status=no,scrollbars=yes,resizable=yes,menubar=no,location=no,direction=no');
*/
}

function close_popup(){
	imgdiv=document.getElementById('sample4');
	imgdiv.style.display="none";
}
function clickThumb(num)
{
	hinp=document.getElementById('thurl'+num);
	ImgUrl=hinp.value;
	iinp=document.getElementById('product_thumbnail');
	iinp.src=ImgUrl;
	selectedImg=num;
	return false;
}

function rollSlide(pp)
{
	if(pp<0)
	{
	 if(TCpos<=0)
	 {
	  return false;
	 }
	 TCpos--;
	}
	if(pp>0)
	{
	 if(TCpos+3>=Tcnt)
	 {
	  return false;
	 }
	 TCpos++;
	}
	pos=TCpos;
	for(i=1;i<=3;i++)
	{
	 imgi=document.getElementById('thumb'+i);
	 imgi.src=TImages[pos].src;
	 hidi=document.getElementById('thurl'+i);
	 hidi.value=URLs[pos];
	 pos++;
	 if(pos>Tcnt)
	 {
	  return false;
	 }
	}
	return false;
}
