/****************************************
 ** system.js  --  supplies main API   **
 ****************************************
 ** Version 3.00.0                     **
 ** Copyright (C) by XenoAntares,      **
 ** VI 1998-I 2001.                    **
 ** All rights reserved.               **
 ****************************************/

// ******* Global constants
var isFrame = (self == parent)? false: true;   // is self really accessed as frame?
var isIndex = (String(window.location.path).indexOf('index.htm',0) >= 0)? true: false;
var local=(window.location.protocol=='file:')? true: false;


// ******** Version check
var UAVer=parseFloat(navigator.appVersion);
var txtAlert='';
//if (isIndex) verCheck();


////////// verCheck
function verCheck()
{
  if (navigator.appName.substring(1,4)!='ets')
    txtAlert='You are using '+navigator.appName+' '+UAVer+'.';
   else // Netscape OK, check version:
    { if (UAVer<4.0)  txtAlert='You are using a Netscape Version prior to 4.0!'; }
  if ((!isFrame)&(txtAlert!=''))
    alert(txtAlert+'\nThis site is best viewed with Netscape 4.0+ or any other HTML 4.0+ and Sun JavaScript compliant browser.');
  return true;
}



//*********************************************************
//*********************************************************

//******** Statusbar Access
if (!isFrame)  {
   var scrText="";
   var scrLenText=scrText.length;
   var scrWidth=100;
   var scrPos=1-scrWidth;
   var scrDelay=500;
   var scrWait=false;      // flag set if scroller in waitstate
   var scrActive=false;    // flag set if scrtxt active
   var sbActive=false;
   var scrTimerID=null;
   var sbTimerID=null;
}


////////// donescr
// Destructor for scroller
function donescr()
{
  if (isFrame)  { return parent.donescr(); }
  if (scrTimerID!=null)  clearTimeout(scrTimerID); //++ clearInterval(scrTimerID);
  scrActive=false;
  window.status=" ";
  //window.defaultStatus="";
  return true;
}

////////// initscr
// Constructor for scroller
function initscr(txt)
{
  if (isFrame)  { return parent.initscr(txt); }
  donescr();
  scrText=((txt=="")||(txt==null))? "Xenocryst is always watching...             ...thou!": txt;
  scrLenText=scrText.length;
  scrPos=1-scrWidth;
  scrWait=false;
  scrActive=true;
  //++ scrTimerID=setInterval("scroll()",scrDelay);
  scrTimerID=setTimeout("scroll()",scrDelay);
  return true;
}

////////// scroll
// Perform scrolling event
function scroll()
{
  if (scrActive) {
     if (!scrWait) {
        scrPos++;
        var scroller="";
        if (scrPos==scrLenText)  scrPos=1-scrWidth;
        if (scrPos<0) {
           for (var i=1; i<=Math.abs(scrPos); i++)  scroller+=" ";
           scroller+=scrText.substring(0,scrWidth-i+1);
        } else {
           scroller+=scrText.substring(scrPos,scrWidth+scrPos);
        }
        window.status=scroller;
     } // if !scrWait
     scrTimerID=setTimeout("scroll()",scrDelay); // [ms]
  } else {
     if (scrTimerID!=null)  clearTimeout(scrTimerID); //++ clearInterval(scrTimerID);
  } // if scrActive
  return true;
}

////////// statbar
// Pause scroller activity and display message
function statbar(txt)
{
   if (isFrame)  { return parent.statbar(txt); }
   if (!sbActive) {
      sbActive=true;
      if (scrActive) {
         if (scrTimerID!=null)  clearTimeout(scrTimerID); //++ clearInterval(scrTimerID); // clear scrollerevent
         scrTimerID=null;
         scrWait=true;
      }
      window.status=txt;
      sbTimerID=setTimeout("erase()",15000); // timeout: 15 sec
   }
   return true;
}

////////// erase
// Erase message and reactivate scroller
function erase() {
   if (isFrame)  { return parent.erase(); }
   if (sbActive) {
      if (sbTimerID!=null)  { clearTimeout(sbTimerID);  sbTimerID=null; }
      window.status=" ";
      if (scrActive)  {
          scrWait=false;
          //++ scrTimerID=setInterval("scroll()",scrDelay); // reactivate scroller
          scroll(); // reactivate scroller
      }
      sbActive=false;
   }
   return true;
}

