var popupHandle

function popup(picUrlString, windowWidth, windowHeight) {

  // Close old popup
  if(popupHandle || popupHandle!=null)
  {
    if (!popupHandle.closed) popupHandle.close();
  }
  popupHandle=null;

  // create a feature string
  var x=(screen.width-windowWidth)/2
  var y=(screen.height-windowHeight)/2
  var featureString = "toolbar=no,scrollbars=no,resizable=no"
  featureString = ',left='+x + ',top='+y
  featureString += ',width='+windowWidth+',height='+windowHeight

  // html content for the popup
  var htmlString = "<html><head><title>Click image to close </title></head>"
  htmlString += "<body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 bgcolor=black text=\"white\" onclick=\"self.close()\">"
  htmlString += "<a href=\"javascript:window.close();\" title=\"Click image to close \" >"
  htmlString += "<img src=\"" + picUrlString + "\" border=\"0\" width=" + windowWidth + " height=" + windowHeight + "></a>"
  htmlString += "</body></html>"

  popupHandle = window.open("" ,"popup",featureString)
  popupHandle = window.open("" ,"popup")
  popupHandle.document.clear();
  popupHandle.document.writeln(htmlString);
  popupHandle.focus();
  popupHandle.document.close(); // start picture loading
  return popupHandle;
}

function winclose() {
  if (window.popupHandle!=null && !window.popupHandle.closed)
  {
    window.popupHandle.close();
  }
}
