function previewName(filename) {
  dotIndex = filename.lastIndexOf('.');
  return dotIndex == -1 ? '' : filename.substring(0, dotIndex)+'s'+filename.substring(dotIndex)
}
function lV(filename) {       
	s = '\
<html>\
<head>\
<title>www.sgallery.net</title>\
<script>\
function maximizeWindow() {\
  moveTo(0,0);\
  resizeTo(screen.availWidth, screen.availHeight);\
}\
</script>\
</head>\
\
<body topmargin="0" leftmargin="0">\
  <applet archive="a.jar" codebase="http://sgallery.net/dir/" code="d.class" width="100%" height="100%" align="middle" MAYSCRIPT>\
    <PARAM NAME=CODE VALUE="d.class" >\
    <PARAM NAME=CODEBASE VALUE="http://sgallery.net/dir/" >\
    <PARAM NAME=ARCHIVE VALUE="a.jar" >\
    <PARAM NAME="type" VALUE="application/x-java-applet">\
    <PARAM NAME="scriptable" VALUE="false">\
    <param name="imageSource" value="'+filename+'">\
    <param name="previewSource" value="'+previewName(filename)+'">\
  </applet>\
</body>\
\
</html>';

	x = screen.availWidth/2-200;
	y = screen.availHeight/2-150;
	features='scrollbars=0,width=400,height=300';
	features += ',top='+y+',left='+x + ',screenX='+x+',screenY='+y;
	viewer=window.open('','VIEWER',features);
	viewer.document.open();
	viewer.document.write(s);
	viewer.focus();
}

function lV2(filename,x,y)
	{
		window.imagex=x;
		window.imagey=y;
		window.imagename=filename;
		viewer=window.open('/dir/z.php','VIEWER','scrollbars,resizable,width=500,height=400');
		viewer.opener=window;
		viewer.focus();
		return false;
	}
