/*
http://simonwillison.net/2004/May/26/addLoadEvent/
*/
function addLoadEvent(func)
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function')
  {
    window.onload = func;
  }
  else
  {
    window.onload = function()
    {
      if (oldonload)
      {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(photo_setup);

function photo_setup()
{
  var elObj;
  var elObjReg;

  if (!document.getElementById)
  {
    return;
  }
  if (elObj = document.getElementById("footer"))
  {
    if (elObjReg = document.getElementsByTagName("a"))
    {
      for (var i=0;i<elObjReg.length;i++)
      {
        var elObjHref = elObjReg[i].href;
        if (elObjHref.indexOf('photos.php') != -1)
        {
          elObjReg[i].onclick = function () { return pictureOpen(this.href,800,720); }
//          elObjReg[i].onclick = function () { window.open(this.href); return false; }
        }
      }
    }
  }
  else
  {
    setTimeout("photo_setup()",10);
  }
}


/***************
 * image popup *
 ***************/

PWin = null;
//make sure this is kept synchronised with the page margins in photos.php
PWinMargin = 0;

function pictureOpen(pname,pwidth,pheight)
{
  pictureClose();

  PTotalWidth = PWinMargin+pwidth+PWinMargin;
  PTotalHeight = PWinMargin+pheight+PWinMargin;

  PWin = window.open(pname,'PWin','width='+PTotalWidth+',height='+PTotalHeight+',scrollbars=1,toolbars=0,resizable=1');
  PWin.moveTo(120,120);
  PWin.focus();
  return false;
}

function pictureClose()
{
  if (PWin)
    PWin.close();
}
