var win;
var ra=10;
var lt=10, tt=10;

function OpenImage(imgPath, title, w, h) 
{

var left = (self.opera ? iWidth : screen.availWidth)/2;    	
      
//var winDoc = win.document;    
if (title == undefined) title = 'Click to Close';    
alt=title;


var content = '<html><head><title>' + title + '</title>' +    			  
  '<style>body{overflow: hidden;margin:0;}img{border:0;}</style>' +
  '</head><body><a href="javascript:self.close()">' +    			  
  '<img alt="' + alt + '" id="image" src="' + imgPath + '" width="'+w+'" height="'+h+'" /></a></body></html>'

win.document.write(content);        
var iHeight= document.body.clientHeight, iWidth = self.innerWidth;
var _left = (self.opera ? iWidth : screen.availWidth)/2 - w/2;    	
var _top =  (self.opera ? iHeight : screen.availHeight)/2 - h/2;    	
// win.resizeTo(w+12, h+38);
win.moveTo(_left, _top);    

// win.onload = winDoc.body.onload; // special for Mozilla        
// !!! Important statement: popup onload won't execute without it!    

win.document.close();    
win.focus();

win.resizeTo(w+12, h+38);

preload_image=null;
return false;
}

var preload_image=null;
var title;

function ChkPre()
{
   if (preload_image!=null && preload_image.complete) {
     OpenImage(preload_image.src,title,preload_image.width,preload_image.height) ;
   } else {
//     win.moveTo(ra+10, ra+10);
//     win.resizeTo(lt+10, tt+10);
     setTimeout('ChkPre()',100);
   }
}

function showImg(url, _title)
{
title=alt=_title;
lt=event.clientX;
tt=event.clientY;

win = window.open('','preview',    'width=1,height=1,left=-100,top=-100,screenX=0,screenY=0,resizable=0,scrollbar=0,status=0');

   if ( !preload_image ) {
        preload_image = new Image;
        preload_image.src = url;
   }
   setTimeout('ChkPre()',10);

   return false;
}


