/*
* Global Variables
*/
var appVer = navigator.appVersion.toLowerCase();
var userAgt = navigator.userAgent.toLowerCase();
var mac = (appVer.indexOf("mac") != -1);
var win = (appVer.indexOf("win") != -1);
var nn = (navigator.appName == "Netscape");
var ie = (navigator.appName == "Microsoft Internet Explorer");
var ver = (ie) ? parseFloat(appVer.substring((appVer.indexOf('msie') + 5), appVer.length)) : parseFloat(appVer);
var aol = (userAgt.indexOf("aol") != -1);
var opera = (userAgt.indexOf("opera") != -1);
var v4 = (parseInt(appVer) == 4);
var cssp = (document.getElementById || document.all || document.layers);
var docload = false;

/*
* FUNCTION: winFocus
* checks to see if browser supports window.focus method
* screens out ie 4.0 and below on Mac, which throw an error when checking for support of window.focus
*/
function winFocus() {
if(ie && mac && ver < 4.5) return false;
if(window.focus) return true;
return false;
}

/*
* Closes an open popup window unless it's closed already
*/
function winClose(winName) {
  if(winName) {
    if(winName.closed) {
        return;
        }
        else {
        winName.close();
    winName = null;
    }
  }
}

/*
* FUNCTION: getWidth
* returns the correct window width for a window with all features & no frames
* or account for a scrollbar with an optional argument
*/
function getWidth(width) { 
var args = getWidth.arguments;

  if(args[1]) {     // Checks for scrolling boolean variable in the arguments
    if(mac) {
      if(ie && v4) width += 2;
      if(nn) width += 17;
    }
    if(win) {
    width += 16;
      if(aol) width += 10;
    }
  }
  else {            // For non-scrolling windows
    if(mac) {
    if(ie && v4) width -= 17;
    if(ie && (ver > 4.5)) width += 10;
    }
    if(win) {
      if(aol) width += 10;
    }
  }
return width;
}

/*
* FUNCTION: getHeight
* returns the correct window height for a window with all features & no frames
*/
function getHeight(height) {
var args = getHeight.arguments;

  if(args[1]) {     // Checks for scrolling boolean variable in the arguments
    if(mac) {
      if(ie && v4) height -= 5;
    }
    if(win) {
      if(aol) height += 5;
    }
  }
  else {            // For non-scrolling windows
    if(mac) {
      if(ie && v4) height -= 5;
      if(ie && (ver > 4.5)) height += 10;
    }
    if(win) {
      if(aol) height += 7;
    }
  }
return height;
}

function remoteOpen() {
var args = remoteOpen.arguments;

var n = (args[1]) ? args[1] : 'remote';
var t = (args[4]) ? args[4] : 0;
var l = (args[5]) ? args[5] : 0;
var f = (args[6]) ? args[6] : "";

var scrollSwitch = (f.indexOf("scrollbars") != -1) ? "" : "scrollbars=0,";

remote = window.open(args[0],n,'width='+getWidth(args[2])+',height='+getHeight(args[3])+',top='+t+',left='+l+',directories=0,'+ scrollSwitch +f);

if(remote.opener == null || remote.opener != self) remote.opener = self;

if(winFocus()) remote.focus();
}