// centerpop - open popup in center of screen

var IE=document.all;
var handle;

// See:
// C:/Tips & Tricks/JavaScript/get screen size - browser position and size.txt

function centerpop(url, target, width, height)
{
// See:
// C:/Tips & Tricks/JavaScript/get screen size - browser position and size.txt

// center it in main browser window
// (use the browser width and height and position)
   if(!IE)
   {
      if (width > self.screen.width) width = self.screen.width;
      if (height> self.screen.height) height = self.screen.height;

      var left = ((self.outerWidth - width) / 2) + self.screenX;
   }
   else
   {
      if (width > screen.availWidth) width = screen.availWidth;
      if (height> screen.availHeight) height = screen.availHeight - 80;

      var left = ((document.body.clientWidth - width) / 2) +
               window.screenLeft;
   }

   if(!IE)
   {
      var top = ((self.outerHeight - height  + self.screenY) / 2);
   }
   else
   {
      var top = (screen.availHeight - height - 80) / 2 ;
   }

var features =
        'top='             + top +
        ',left='           + left +
        ',width='          + width +
        ',height='         + height +
        ',resizeable=yes,' +
        ',menubar=yes,'    +
        'scrollbars=yes';

/*
   alert(features);
*/

   var handle = window.open(url, target, features);
   handle.focus();
}

function Restore(width, height)
{
   if (!IE)
   {
      if (width > self.screen.width) width = self.screen.width;
      if (height > self.screen.height) height = self.screen.height;

      var left = ((opener.outerWidth - width) / 2) + opener.screenX;
      var top = ((opener.outerHeight - height  + opener.screenY) / 2);

      window.innerWidth = width;
      window.innerHeight = height;

      window.screenX = left;
      window.screenY = top;
   }
   else
   {
      if (width > screen.availWidth) width = screen.availWidth;
      if (height > screen.availHeight) height = screen.availHeight - 80;

      var left = ((opener.document.body.clientWidth - width) / 2) +
               opener.screenLeft;
      var top = (screen.availHeight - height - 80) / 2 ;

      self.resizeTo(width+10, height+75); // taskbar?
      self.moveTo(left, top); // taskbar and chrome?
   }

   /*
   alwaysLowered = true;
   */
}

function Maximize()
{
   if (!IE)
   {
      window.innerWidth = screen.width - 5; // window borders
      window.innerHeight = screen.height - 75; // taskbar
      window.screenX = 0;
      window.screenY = 0;
   }
   else
   {
      self.resizeTo(screen.availWidth, screen.availHeight);
      self.moveTo(0, 0);
   }

   /*
   alwaysLowered = false;
   */
}

/*******************************************/
/* for maximize and restore - photo albums */
/*******************************************/
if (!IE)
{
   old_left = window.screenX;
   old_top = window.screenY;
}
else
{
   old_left = window.screenLeft;
   old_top = window.screenTop;
}
