// JavaScript Document
function showDetail(productID) {
	showURL = "product_detail.php?id=" + productID;
	window.showModalDialog(showURL,'','dialogHeight:370px; dialogWidth:320px; scroll:yes');
	//win = window.open (showURL ,'showDetail','location=no,status=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=320,height=370');
	//win.focus();
	//win.moveTo(0,0);
}

function popwindow(strURL,wname,mwidth,mheight)
{ 
	var mwidth = mwidth+20;
	var mheight = mheight+20;
	win = window.open (strURL ,wname,'location=no,status=yes,directories=no,menubar=no,scrollbars=yes,resizable=no,width=' + mwidth + ',height=' + mheight);
	//win.focus();
	//win.moveTo(0,0);
}

function popDialogWindow(strURL,wname,mwidth,mheight)
{
	win = window.showModalDialog(strURL,wname,'dialogHeight:' + mheight + 'px; dialogWidth:' + mwidth + 'px')
}

NS6 = (document.getElementById&&!document.all) ? 1: 0; 
NS = (document.layers) ? 1 : 0; IE = (document.all) ? 1: 0; 

function getWinWidth() 
{
	if (NS||NS6) return(window.innerWidth);
	else if (IE) return(document.documentElement.clientWidth);
	else return(null);
}

function getWinHeight() 
{
	if (NS||NS6) return(window.innerHeight);
	else if (IE) return(document.documentElement.clientHeight);
	else return(null);
}

var k=0;
function fadeShadow(k) {
	clearTimeout();
	WinWidth = getWinWidth(); 
	WinHeight = getWinHeight(); 
	document.getElementById('shadowScreen').style.width=WinWidth;
	document.getElementById('shadowScreen').style.height=WinHeight;
	document.getElementById('shadowScreen').style.display='block';
	k=k+10;
	eval("document.getElementById('shadowScreen').style.filter='alpha(opacity = "+k+")'");
	if (k<70) { 
		setTimeout("fadeShadow("+k+")", 1); 
  } else {
	  document.getElementById('picScreen').style.display='block';
  }
}

function clearShadow(l) {
	clearTimeout();
	l=l-10;
	eval("document.getElementById('shadowScreen').style.filter='alpha(opacity = "+l+")'");
	if (l>0) { 
		setTimeout("clearShadow("+l+")", 1); 
  } else {
	  document.getElementById('shadowScreen').style.display='none';
  }
}

var imageWidth=0;
var imageHeight=0;
function popImageWindow(strURL,wname,mwidth,mheight)
{ 
	WinCenterWidth = Math.round(getWinWidth()/2);
	WinCenterHeight = Math.round(getWinHeight()/2);
	PosX=WinCenterWidth-(Math.round(mwidth/2));
	PosY=WinCenterHeight-(Math.round(mheight/2));
	imageWidth=mwidth;
	imageHeight=mheight;
	if (document.images) {
     showPopImg = new Image(); 
     showPopImg.src = strURL;
  }
		document.getElementById('picScreen').style.left=PosX;
		document.getElementById('picScreen').style.top=PosY;
		fadeShadow(k);
		showPic (strURL);
		//eval("document.getElementById('imgPlaceHolder').innerHTML='<img src=\""+strURL+"\">'");
}

function showPic (whichpic) {
 if (document.getElementById) {
  document.getElementById('imgPlaceHolder').src = whichpic; 
  return false;
 } else {
  return true;
 }
}

function displayImage(showPopImg) {
	 if (showPopImg.complete) {
		  eval("document.getElementById('imgPlaceHolder').innerHTML='<img src=\""+strURL+"\">'");
	 } else {
	 	  setTimeout("displayImage("+showPopImg+")", 500);
	 }
}

function closePicViewer() {
	document.getElementById('picScreen').style.display='none';
	clearShadow(70);
}

function resizePicViewer() {
	WinCenterWidth = Math.round(getWinWidth()/2);
	WinCenterHeight = Math.round(getWinHeight()/2);
	PosX=WinCenterWidth-(Math.round(imageWidth/2));
	PosY=WinCenterHeight-(Math.round(imageHeight/2));
	  document.getElementById('picScreen').style.left=PosX;
	  document.getElementById('picScreen').style.top=PosY;
}
