var useFocus = 0;  // to focus the window
var openWin = 1;  // to open a window

var defaultOpts = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=560,height=400";
var winName = "tinywindow";
var smallwin = null;  // object name for the opened window
var openhref = null;  // URL of the opened page

// SNIFF OUT SOME BROWSERS
var verNum = navigator.appVersion.substring(0, navigator.appVersion.indexOf(' '));

// CHECK FOR THE GOODS
if (navigator.appName == 'Netscape' && verNum >= 3 
 || navigator.appName == 'Microsoft Internet Explorer' && verNum >= 5
 || navigator.appVersion.indexOf('MSIE 5.') != -1) {
 // Netscape Navigator 4.x or above and Internet 
 // Explorer 5.x and above the focus ability
 useFocus = 1; 
} 

function defaultWinOpen(filename) {
 winOpen(filename, 'null');
}

function winOpen(filename, winOpts) 
// Main function for the window opener utility -- see comments and 
// description above.
{
 // SET DEFAULT OPTIONS FOR THE WINDOW OPENER IF NONE ARE SUPPLIED
 if (winOpts == '' || winOpts == 'null' || !winOpts)
  winOpts = defaultOpts;

 // DO THE DEFAULT OPENER FIRST
 if (!useFocus) {
  window.open(filename,winName,winOpts);
  return;    
 }

 // CHECK FOR A 'smallwin' WINDOW OBJECT
 if (smallwin) { 
  // is this a new address (ie. a different link)?
  // and can we get a focus event for the window?
  if (openhref == filename && smallwin.focus) {
   smallwin.focus();   
  
  } else {
   // either a new address or cannot focus on the smallwin
   // window object.  close the window and pop a new one open.
   if (smallwin.close)
    smallwin.close();
   smallwin = null;
   openhref = null;
   winOpen(filename,winOpts);
   //smallwin = window.open(filename,winName,winOpts);
   if (smallwin.focus) 
    smallwin.focus();
  }

 } else { 
  // NO OPEN WINDOW OBJECT... POP A NEW ONE OPEN

  // open the small window and load address
  smallwin = window.open(filename,winName,winOpts);
  // set the address for the last clicked link 
  openhref = filename;
//  // set the opener property
//  if (!smallwin.opener) {
//   smallwin.opener = self;
//  }
 } 

 return;
} // winOpen()


