rightPos=0
if (window.screen) {
	rightPos = window.screen.width-540
}

function ShowImage(x) {
	document.images["prod_img"].src = viewArray[x].src;
}

function ShowPhotoGallery() {
   document.getElementById("vPlayer").style.visibility = "hidden";
}

// pop up window for with menubar
function openNBWindow(url1,url2) {
	popUpWin = window.open('','','toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=540,height=600,right='+rightPos+',top=0');
	url = url1 + escape(url2);
	popUpWin.location = url;
	if (navigator.appName == 'Netscape') {
		popUpWin.focus();
	}
}

// pop up window with menubar
function openPDWindow(url1,url2) {
	// popUpWin = window.open('','productdemo','width=330,height=550,status=no,scrollbars=no,resizable=no,toolbar=no,left=200,screenX=200,top=100,screenY=100');
	popUpWin = window.open('','','width=587,height=375,status=no,scrollbars=no,resizable=no,toolbar=no,left=0,screenX=0,top=0,screenY=0');
	url = url1 + escape(url2);
	popUpWin.location = url;
	if (navigator.appName == 'Netscape') {
		popUpWin.focus();
	}
}

//action when mounse click on the photo
//change style of thumbnail image and show this image in other place
function imgClick(img, imgotherplaceid)
{
	for (i=1; i<6; i++){ 
		if (document.images["photo"+i].style.display != 'none')
			document.images["photo"+i].className = 'imagethumnail'; 
	}
	img.className = 'selectedimg';
	document.images[imgotherplaceid].src = './../lib/thumbnail.php?image='+realSrc(img.src)+'&width=300';
	//alert(realSrc(img.src));
	//document.images[imgotherplaceid].src = img.src;
}
//move the photo up on the click btn in the tab of photo
function updateTabPhoto(photos, currentIndex_, offset){
	if ((offset+currentIndex+5) > photos.length)
		offset = photos.length - (currentIndex+5);
	if (currentIndex_ < photos.length-5){
		document.getElementById('back').disabled = false;
		for (i = 1; i < 6; i++){
			if ((ind = (currentIndex_+offset-1+i)) > photos.length)
				//break;
				document.images["photo"+i].style.display = 'hidden';
			else document.images["photo"+i].src = "./../lib/thumbnail.php?image="+photos[ind]+"&width=60";
		}
		currentIndex += offset;
	}else document.getElementById('go').disabled = true;
}
//move the photo up on the click btn in the tab of photo
//5 is the number of photo displayed in the tab
function updateTabPhoto_(photos, currentIndex_, offset){
	if ((-offset+currentIndex) < 0)
		offset = currentIndex;
	if (currentIndex_ > 0){
		document.getElementById('go').disabled = false;
		for (i = 1; i < 6; i++){ ind = (currentIndex_-offset-1+i);
			/*if ((ind = (currentIndex_-offset-1+i)) > photos.length)
				document.images["photo"+i].style.display = 'hidden';
			else */document.images["photo"+i].src = "./../lib/thumbnail.php?image="+photos[ind]+"&width=60";
		}
		currentIndex -= offset;
	}
	else document.getElementById('back').disabled = true;
}
function showphoto(src) 
{ 
   var sOption="toolbar=no,location=no,directories=no,menubar=no,"; 
       sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

   var winprint=window.open("","",sOption); 
   winprint.document.open(); 
   
   winprint.document.write('<html><head><script type="text/javascript" src="./../lib/js/page_security.js">	disableClick();	</script><meta http-equiv="Content-Type" content="text/html; charset="ISO-8859-1" /><META Http-Equiv="Cache-Control" Content="no-cache"><META Http-Equiv="Pragma" Content="no-cache"><META Http-Equiv="Expires" Content="0"><META HTTP-EQUIV="imagetoolbar" CONTENT="no"><title>Photo pr&eacute;vue</title>'); 
/*   winprint.document.write('<script language="JavaScript"> 
								var message="";
								function clickIE(){
									if (document.all){
										(message);
										return false;
									}
								}
								 
								function clickNS(e) {
									if(document.layers||(document.getElementById&&!document.all)){
										if (e.which==2||e.which==3) {
											(message);
											return false;
										}
									}
								}
								if (document.layers){
									document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
								else{
									document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
								document.oncontextmenu=new Function("return false");
								</script></head><body>');*/
   image = '<center><img src="'+realSrc(src)+'" width="735" hieght="600" /></center>';
   winprint.document.write(image);
   winprint.document.write('</body><script type="text/javascript" src="./../lib/js/page_security.js"> alert("alskjdflaskjflaskj"); disableSelection(document.body); document.onkeydown=key; </script></html>');
   winprint.document.close();
   winprint.focus();
}
//function to find the real src of image
function realSrc(src){
	firstIndex = src.indexOf("=") +1 ;
	lastIndex  = src.lastIndexOf("&");
	real = src.substring(firstIndex, lastIndex);
	return real;
}
