function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isGK    = false;  // Gecko
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
	this.isIE = true;
	this.version = parseFloat(ua.substr(i + s.length));
	return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
	this.isNS = true;
	this.version = parseFloat(ua.substr(i + s.length));
	return;
  }

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
	this.isGK = true;
	this.version = 6.1;
	return;
  }
}
var browser = new Browser();

function ImagePopup(imgPath, title, alt)
{
    var win = window.open('','preview', 'width=50,height=50,left=0,top=0,screenX=0,screenY=0,resizable=1,scrollbar=0,status=0');
    
    var winDoc = win.document;
    if (title == undefined) title = 'My Image, Click to Close';
    if (alt   == undefined) alt   = 'My Image, Click to Close';
    var content = '<html><head><title>' + title + '</title>' + '<style>body{overflow:hidden;margin:0;background-color:black}img{border:0;}</style>' +
    			  '</head><body><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"><tr><td height="100%" valign="middle" align="center">' +
				  '<a href="javascript:self.close()">' + '<img alt="' + alt + '" id="image" src="' + imgPath + '" /></a></td></tr></table></body></html>'
    winDoc.write(content);
    
    winDoc.body.onload = function() {
    	var obj = winDoc.getElementById('image');
    	var w = obj.width, h = obj.height;
    	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;
		
		if (browser.isGK)
		{
			w += 8 + 2;
			h += 51 + 2;
		}
		else if (browser.isIE)
		{
			w += 12 + 2;
			h += 31 + 2;
		}
		
    	win.resizeTo(w, h);
    	win.moveTo(left, top);
    }
    
    win.onload = winDoc.body.onload; // Gecko
    
    // popup onload won't execute without
    winDoc.close();
    win.focus();
}