function popup(img,title)
{
// img=img.substring(0,img.lastIndexOf('.'))+"_big.jpg";

		picfile = new Image();
		picfile.src =(img);
		fileCheck(img,title); 
	}

	function fileCheck(img,title)
	{
		if( (picfile.width!=0) && (picfile.height!=0) )
		{
			makeWindow(img,title);
		}
		else
		{
		funzione="fileCheck('"+img+"')";
		intervallo=setTimeout(funzione,50);
		}
	}

	function makeWindow(img,title)
	{

		if(picfile.height>(screen.availHeight-200)){
			ht=screen.availHeight-200;
			wd = picfile.width+20;
		}
		else{
			ht = picfile.height;
			wd = picfile.width;
		}
		
		
		var args= "height=" + ht; + ",innerHeight=" + ht;
		args += ",width=" + wd; + ",innerWidth=" + wd;
		if (window.screen) 
		{
			var avht = screen.availHeight;
			var avwd = screen.availWidth;
			var xcen = (avwd - wd) / 2; 
			var ycen = (avht - ht) / 2;
			args += ",left=" + xcen + ",screenX=" + xcen;
			args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=0";

			if(picfile.height>(screen.availHeight-200)) args += ", scrollbars=1";
		}
		popwin=window.open("","_blank",args)
		popwin.document.open()
		popwin.document.write('<html><head><title></title></head><body bgcolor=white topmargin=0 leftmargin=0 rightmargin=0 bottomargin=0 marginheight=0 marginwidth=0><div style="position: absolute; top:0px;left:0px"><a href="javascript:window.close()">  <img src="'+img+'" width="'+picfile.width+'" height="'+picfile.height+'" border="0"></a></div></body></html>')
		popwin.document.close()
	}

