// The following functions must be called from the site's parent window.
// For functions that must be called from one of the popup windows, proceed
// the name of the function with "opener."

// The parent window and *first* popup should call onLoadHandler()

// The parent window should call initVariables()

// The *first* popup must have
// onLoad="popSecond(...);"

// The *secondary* popup must have
// onLoad="doneLoading();"

function initVariables()
{
   document.wins          = new Array(0,0);
   document.windowLoading = new Array(0,0);
}

function onLoadHandler()
{
   var ns4 = (document.layers);
   var ns6 = false;
   if ((navigator.appName=="Netscape") && 
       (navigator.appVersion.substring(0,1) >= 5))
   {
      document.all = document.getElementsByTagName('div');
      ns6 = true;
   }

   document.ie = ((!ns4) && (!ns6));
 
   var mac  = (navigator.appVersion.indexOf("Mac") != -1);
   var add1 = (mac) ? '_mc':'_pc';
   var add2 = (ns4) ? '_ns':'_ie';

   if (ns6)
   {
      add2 = 'ns6';
   }

   document.heighttune = 0;
   document.widthtune  = 0;
   if ((mac) && (document.ie))
   {
      document.heighttune = 0;
      document.widthtune  = 0;
   }
   if ((mac) && (ns4))
   {
      document.heighttune = 0;
      document.widthtune  = 0;
   }
}

function doneLoading()
{
   document.windowLoading[0] = 0;
   document.windowLoading[1] = 0;
}

function closeWindow(which)
{
   if (document.windowLoading[which] == 0)
   {
      setTimeout('doCloseWindows()', 100);
   }
}

function doCloseWindows()
{
   if (!document.wins[0].closed)
   {
      if (document.wins[0] != 0)
      {
         document.wins[0].close();
      }
   }
   if (!document.wins[1].closed)
   {
      if (document.wins[1] != 0)
      {
         document.wins[1].close();
      }
   }
}

function popFirst(where,x,y,width,height)
{
   options = ('height=' + (height+document.heighttune) + ',width=' + (width+document.widthtune) +
              ',location=0,menubar=0,scrollbars=0,status=0,toolbar=0,' +
              'screenX=' + x + ',screenY=' + y);

   document.wins[0] = window.open(where,'popup1',options);

   if (document.ie)
   {
      setTimeout('document.wins[0].moveTo('+x+','+y+')', 2000);
   }

   document.wins[0].focus();
}

function popSecond(where,x,y,width,height)
{
   options = ('height=' + (height+document.heighttune) + ',width=' + (width+document.widthtune) +
              ',location=0,menubar=0,scrollbars=0,status=0,toolbar=0,' +
              'screenX=' + x + ',screenY=' + y);

   document.wins[1] = window.open(where,'popup2',options);

   if (document.ie)
   {
      setTimeout('document.wins[1].moveTo('+x+','+y+')', 2000);
   }

   document.wins[0].focus();
}

function doNavigation(where1, where2)
{
   document.windowLoading[0] = 1;
   document.windowLoading[1] = 1;
   if (where1 != where2)
   {
      document.wins[0].location = where1;
	  document.wins[1].location = where2;
   }
   else
   {
      document.wins[1].location = where1;
   }
}