// JK Pop up image viewer script- By http://JavaScriptKit.com

var popbg="oldpaper.gif" //specify backcolor or background image for pop window
var wintitle="Image Window"  //pop window title

function detect(obj)
  {
  return (typeof obj !="undefined")
  }

function popimg(imgpath, popw, poph, desc)
  {

  function getpos()
  {
  leftpos=(detect(window.screenLeft))? screenLeft+document.body.clientWidth/2-popw/2 : detect(window.screenX)? screenX+innerWidth/2-popw/2 : 0
  toppos=(detect(window.screenTop))? screenTop+document.body.clientHeight/2-poph/2 : detect(window.screenY)? screenY+innerHeight/2-poph/2 : 0
  if (window.opera)
    {
    leftpos-=screenLeft
    toppos-=screenTop
    }
  }

  getpos()
  toppos = toppos-300;
  popw = popw+30;
  poph = poph+50;
  var winattr='width='+popw+',height='+poph+',resizable=yes,left='+leftpos+',top='+toppos
  var bodyattr=(popbg.indexOf(".")!=-1)? 'background="'+popbg+'"' : 'bgcolor="'+popbg+'"'
   if (typeof popwin=="undefined" || popwin.closed)
      popwin=window.open("","",winattr)
   else 
      {
    //getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
    //popwin.moveTo(leftpos, toppos)
      popwin.resizeTo(popw, poph+50)
      }
   popwin.document.open()
   popwin.document.write('<html><title>'+wintitle+'</title><body '+bodyattr+'><center><img src="'+imgpath+'" style="margin-bottom: 0.5em"><br><b>'+desc+'</b></center></body></html>')
   popwin.document.close()
   popwin.focus()
}