var toolbar=',toolbar=yes';
var status=',status=yes';
var uselocation=',location=yes';
var menubar=',menubar=yes';
var resizable=',resizable=yes';
var noscroll=',scrollbars=no';
var junkdate='junkdate';
var alwaysRaised='alwaysRaised=yes';
var popup, popupDocument;

if( popup == null ) {
  popup=function( width, height, url, wname ) {
    try {
      var scrollspecified=false;
      var opts='';
      var left=( screen.width-width )/2;
      var top=( screen.height-height )/2;
      if( popup.arguments.length < 4 || wname == null ) {
        wname=''+(new Date()).valueOf();
      }
      if( url.indexOf('?') == -1 ) {
        url+='?';
      }
      for( var i=4; i < popup.arguments.length; i++ ) {
        if( popup.arguments[i] == noscroll ) {
          scrollspecified=true;
        }
        else if( popup.arguments[i] == junkdate ) {
          url+='&junkdate='+(new Date()).valueOf();
          continue;
        }
        opts+=popup.arguments[i];
      }
      if( !scrollspecified ) {
        opts+=',scrollbars=yes';
      }
      var pWin=open( url, wname, 'width='+width+',height='+height+',left='+left+',top='+top+opts );
      if( pWin != null ) {
        try {
          pWin.focus();
          if( pWin.screenX != null ) {
            pWin.screenX=left;
            pWin.screenY=top;
          }
        }
        catch( ex ) {}
        return pWin;
      }
      alert( 'A FLiCA window has been blocked.\nYou must disable the pop-up blocker on your computer for FLiCA.Net to work properly.' );
      return null;
    }
    catch( ex ) {
      throw Error( ex.message+' in popup.js/popup()' );
    }
  }
}

var dtStrict="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"
var dtTransitional="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html40/loose.dtd\">"

if( popupDocument == null ) {
  popupDocument=function( win, title, style, dt ) {
    try{
      if( !win ) {
        return;
      }
      var doc=win.document;
      if( title == null ) {
        title='FLiCA.Net';
      }
      if( dt != null ) {
        doc.writeln( dt );
      }
      if( style == null ) {
        style='';
      }
      doc.writeln( "<html>" );
      doc.writeln( "  <head id=\"theHead\">" );
      doc.writeln( "    <title>"+title+"</title>" );
      doc.writeln( "    <meta http-equiv=\"Pragma\" name=\"Pragma\" content=\"no-cache\">" );
      doc.writeln( "    <meta http-equiv=\"Cache-Control\" meta.content=\"no-cache\">" );
      doc.writeln( "    <meta name=\"robots\" content=\"noindex\">" );
      doc.writeln( "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" );
      doc.writeln( "    <style type=\"text/css\">\n"+style+"</style>" );
      doc.writeln( "  </head>" );
      doc.writeln( "  <body id=\"theBody\">" );
      doc.writeln( "</body></html>" );
      doc.close();
      this.head=doc.getElementById( "theHead" );
      this.headScript=this.head.appendChild( doc.createElement("script") );
      this.body=doc.getElementById( "theBody" );
      this.createElement=doc.createElement;
    }
    catch( ex ) {
      throw Error( ex.message+' in popup.js/popupDocument()' );
    }
  }
}

var modalGearboxWindow;
var focuser;

function maintainFocus() {
  try {
    if( modalGearboxWindow.closed ) {
      window.clearInterval( focuser );
      return;
    }
    modalGearboxWindow.focus();
  }
  catch( ex ) {}
}

function showModalGearbox() {
  modalGearboxWindow=popup( 360, 200, '/rbc/timeticker.html', 'GearBox', noscroll );
  focuser=window.setInterval( "maintainFocus()", 5 );
}

function hideModalGearbox() {
  if( modalGearboxWindow && modalGearboxWindow.open ) {
    modalGearboxWindow.close();
  }
}
