function viewPic(img) {
	picfile = new Image();
	picfile.src =(img);
	fileCheck(img);
}

function fileCheck(img) {
	if( (picfile.width!=0) && (picfile.height!=0) ) {
	makeWindow(img);
	}
	else {
	funzione="fileCheck('" + img + "')";
	intervallo=setTimeout(funzione,10);
	}
}

function makeWindow(img) {
	pht = picfile.height;
	pwd = picfile.width;
	avht = screen.availHeight;
	avwd = screen.availWidth;
	scrollyn = "no";
	ht = pht;
	wd = pwd;
	dht = 0;
	dwd = 0;

	if (( pht + 40) >= avht) {
		ht = avht - 40;
		scrollyn = "yes";
		dwd = 16;
	}

	if (( pwd + 40) >= avwd ) {
		wd = avwd -40;
		scrollyn = "yes";
		dht = 16;
	}	
	ht += dht;
	wd += dwd;
	
	var args= "height=" + ht + ",innerHeight=" + ht;
	args += ",width=" + wd + ",innerWidth=" + wd;
	var xcen = (avwd - wd) / 2;
	var ycen = (avht - ht) / 2;
	args += ",left=" + xcen + ",screenX=" + xcen;
	args += ",top=" + ycen + ",screenY=" + ycen;
	args += ",scrollbars=" + scrollyn;
	args += ",resizable=no,status=no"; 	

	popwin=window.open("","",args)
	popwin.document.open()
	popwin.document.write('<html><head><title>Library Picture</title></head><body bgcolor=white scroll='+ scrollyn +' topmargin=0 leftmargin=0 rightmargin=0 bottomargin=0 marginheight=0 marginwidth=0><div style="position: absolute; top:0px;left:0px"><a title="Click here to close window" href="javascript:window.close()"><img alt="Click here to close window" src="' + img + '" width="' + pwd + '" height="' + pht + '" border="0"></a></div></body></html>')
	popwin.document.close()
}