
leftPos = 0
imageWindow = null

function newWindow(imagejpg)
{
   myImg=new Image();
   myImg.src=imagejpg;
if (!(myImg.complete))
{
   myImg.onload = function() 
   {
      myWidth=myImg.width +20;
      myHeight=myImg.height +30;
      if (screen) 
      {
         leftPos = screen.width-myWidth-10
      }
      options="width="+myWidth+",height="+myHeight+",left="+leftPos+",top=0";
      imageWindow = window.open(imagejpg,"imageWin",options)
      imageWindow.focus()
   }
}
else
{
   myWidth=myImg.width +20;
   myHeight=myImg.height +30;
    if (screen) 
    {
         leftPos = screen.width-myWidth-10
   }
   options="width="+myWidth+",height="+myHeight+",left="+leftPos+",top=0";
   imageWindow = window.open(imagejpg,"imageWin",options)
   imageWindow.focus()
}
   
}

function closeWindow()
{
   if (imageWindow && !imageWindow.closed)
   {
      imageWindow.close()
   }
}

function viewItem(imagejpg)
{
   if (!imageWindow || imageWindow.closed)
   {
      newWindow(imagejpg)
   }
   else
   {
      imageWindow.close()
      newWindow(imagejpg)
   }
}

