////////////////////////////////////////////////////////////////////////////
// Popup Window functions

// popwin: Open a generic popup window
function popwin(targeturl, callerurl, w, h, wname, args)
{
  var screenmargin=40;
  var screenHmax=screen.availHeight-screenmargin;
  var screenWmax=screen.availWidth-screenmargin;
  
  if (typeof callerurl == "string") {
    hash = '';
    if ((hi=targeturl.indexOf("#")) >= 0) {
      // There's a hash.  It needs to stay at the end.
      hash = targeturl.substr(hi);
      targeturl = targeturl.substr(0, hi);
    }
    if (targeturl.indexOf("?") >= 0) c="&";
    else c="?";
    targeturl=targeturl + c + 'refreshcaller='+callerurl + hash;
  }
  // Set or reset height and width
  if (typeof h == "string" && h == "max") h = screenHmax;
  if (typeof w == "string" && w == "max") w = screenWmax;
  if (typeof w != "number") w = 500; // Default width
  if (typeof h != "number") h = 300; // Default height
  if (h > screenHmax) h = screenHmax;
  if (w > screenWmax) w = screenWmax;
  
  if (typeof wname != "string") wname = '_new';
  if (typeof args != "string") args = 'resizable,scrollbars';
  //alert("popwin: window.open("+targeturl+", "+wname+", ... )");
  pw=window.open(targeturl, wname, 'width='+w+',height='+h+','+args); 
  pw.focus(); 
  return pw;
} // popwin

// End of popup window functions
////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////
// Misc. Utilities
//
// NNselect conditionally puts out one thing if the browser is NN4,
// another thing for all other browsers.
function NNselect( NNvariant, Normlvariant )
{
  with (navigator) {
    if ((appName=="Netscape")&&(parseInt(appVersion)==4))
      document.write( NNvariant );
    else
      document.write( Normlvariant );
  }
}

// CSSSelect puts out links to separate CSS files, depending on the 
// browser and platform.  This version assumes that the default CSS
// file is ALWAYS used, and the platform-specific files are supplemental.
function CSSSelect(csspath)
{
  defaultCSS = "sitestyle.php";
  NNWinCSS = "sitestyleNNWin.php";
  NNMacCSS = "sitestyleNNMac.php";
  CSS = defaultCSS;
  document.write('<link rel="stylesheet" href="', csspath, CSS, '" type="text/css">');
  with (navigator) {
    if (appName=="Netscape") {
      if (platform.indexOf("Win")==0)
        CSS = NNWinCSS;
      else if (platform.indexOf("Mac")==0)
        CSS = NNMacCSS;
      else // Probably Unix
        CSS = NNMacCSS;  // Font settings for the Mac are the largest.
      document.write('<link rel="stylesheet" href="', csspath, CSS, '" type="text/css">');
    }
  }
} // CSSSelect

// MM_reloadPage is MacroMedia's workaround for NN4's crummy page resize handling
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
// *** uncomment this line to turn it on. ***
// MM_reloadPage(true);

// end  
