var isMac = navigator.platform=="MacPPC"?true:false
function popup(imagefile,width,height) {
	var totalheight = Number(height);
	isMac?totalheight=480:totalheight
	var totalwidth = Number(width);
	isMac?totalwidth=640:totalwidth
	var mytitle = new String(imagefile)
	var newTop = Math.round((screen.height/2)-(height/2));
	var newLeft = Math.round((screen.width/2)-(width/2));
	var winname = mytitle.substring(mytitle.lastIndexOf("/",mytitle.length)+1, mytitle.indexOf(".",0))

	if (totalwidth==0)
	{
		totalwidth=1;
	}
	if (totalheight==0)
	{
		totalheight=1;
	}
	
	picWindow = window.open("template.htm?FileName=" + imagefile,winname,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=" + newTop + ",left=" + newLeft + ",width=" +totalwidth + ",height=" +  totalheight );
	//picWindow = window.open("template.htm",winName,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,top=0,left=0,width=" +totalwidth + ",height=" +  totalheight );
	

}
function controlla(imgfile){
		if((myImage.width!=0)&&(myImage.height!=0)){
			popup(imgfile,myImage.width,myImage.height);
		}
		else{
			funzione="controlla('"+imgfile+"')";
			intervalo=setTimeout(funzione,10);
		}
	}

	function openWin(imgfile){
		myImage = new Image;
		myImage.src = imgfile;
		!isMac?controlla(imgfile):popup(imgfile,'','');
		controlla(imgfile);
		//popup(imgfile,myImage.width,myImage.height,imgname);		
	}