var imgObj;
var sBaseCmd = "toolbar=no,location=no,status=no,menubar=no,resizable=no";

var bName = navigator.appName;
nc = (bName == "Netscape") ? true : false;
ie = (bName == "Microsoft Internet Explorer") ? true : false;

function chkImg(strURL,winName){
  if (typeof(imgObj) == "object"){
  	var Scrollbar="no";
  	var imgw=imgObj.width;
  	var imgh=imgObj.height;
     if ((imgw != 0) && (imgh != 0)) { //ie
    	 if  (imgw >= screen.availWidth) {imgw = screen.availWidth; Scrollbar = "yes";}
    	 if  (imgh >= screen.availHeight) {imgh = screen.availHeight; Scrollbar = "yes";}
    	 if (Scrollbar == "yes") Scrollbar += ",top=0,left=0";
    	 else Scrollbar += ",top=" + (screen.availHeight-imgh)/2 + ",left=" + (screen.availWidth-imgw)/2;
      showpicwin(strURL,winName, ",scrollbars=" + Scrollbar + ",width=" + imgw + ",height=" + imgh);
     }
     else showpicwin(strURL,winName, ",scrollbars=no"); //nc
  }
}

function showpicwin(strURL,winName,features) {
  var vPic;
  if (features == null || features == ""){
    imgObj = new Image();
    imgObj.src = strURL;
    
    chkImg(strURL, winName);
  }
  else{
	vPic = window.open("",winName, sBaseCmd + features);
	vPic.opener = self;
	//vPic.document.writeln('<IMG SRC="' + strURL + '" BORDER=0>');
	//vPic.document.bgColor="#F4FCCD";
	vPic.document.writeln ("<html><head>");
	vPic.document.writeln ("<title>Picture</title>");
	vPic.document.writeln ("</head><body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">");
	vPic.document.write ("<a href='javascript:this.close();opener.window.focus();'><img src='");
	vPic.document.write (strURL);
	vPic.document.write ("' border='0' alt='CLOSE' galleryimg='false'");
	if(nc) vPic.document.write ("' onLoad='reSize(this)'");
	vPic.document.writeln ("></a>");
	if(nc) {
		vPic.document.writeln ("<script language=\"javascript\">");
		vPic.document.writeln ("function reSize(theImage) { ");
		vPic.document.writeln ("var imgw=theImage.width+6;\nvar imgh=theImage.height+55;");
		vPic.document.writeln ("if (imgw >= screen.availWidth) {imgw = screen.availWidth;scrollbars.visible=true;}");
		vPic.document.writeln ("if (imgh >= screen.availHeight) {imgh = screen.availHeight;scrollbars.visible=true;}");
		vPic.document.writeln ("x=(screen.width-imgw)/2;");
		vPic.document.writeln ("y=(screen.height-imgh)/2;");
		//vPic.document.writeln ("alert('W='+imgw+',H='+imgh);");
		vPic.document.writeln ("resizeTo(imgw,imgh);");
		vPic.document.writeln ("moveTo(x,y);/*alert('height=' + theImage.height+ '; width=' + theImage.width + '; hspace=' + theImage.hspace + '; vspace=' + theImage.vspace)*/");
		vPic.document.writeln ("}</script>");
	}
	vPic.document.write ("</body></html>");
	vPic.document.close();
	vPic.focus();
	return false;
  }
}

