/*

  digsys-bas.js           April 2, 2008

  Copyright (c) 2008 Scandinavian Digital Systems AB

  Developed by Anders Danielsson, http://www.digsys.se/

*/

function DocWrCrypt()
{
  var i;
  var nSeed=32173;
  var len=arguments.length;
  var outstr="";
  for (i=0; i<len; i++)
  {
    nSeed=(31721*nSeed+29717)&0xFFFF;
    outstr+=String.fromCharCode((arguments[i]^(nSeed>>8))&0xFF);
  }
  document.write(outstr);
}

function HRefAuthor()
{
  DocWrCrypt(201,93,228,55,102,12,81,199,189,184,191,180,203,103,165,163,90,223,111,216,30,76,240,190,32,41,186,6,144,67,20,89,107,19,219,204,232,123,3,50,155,139,156,198,142,181,33,27,108,221,31,44,91,101,68);
}

function Rand(low,high)
{
  return Math.floor(low+Math.random()*(1+high-low));
}

function LZ(n)
{
  return (n<10?"0":"")+n.toString();
}

var idTimeout;
var TimeOffset;
var TimeRun=0;
var TimeMS=0;
var TimeSec=0;
var TimeMin=0;
var TimeHour=0;

function TimeUpdate()
{
  var date = new Date();
  var time = date.getTime();
  var n;

  idTimeout=setTimeout("TimeUpdate()",200);
  TimeMS+=time-TimeOffset;
  TimeOffset=time;
  if (TimeMS>=1000)
  {
    // If the computer sleeps no calls to 'TimeUpdate()' will be done until the computer wakes up again
    n=Math.floor(TimeMS/1000);
    TimeMS-=n*1000;
    TimeSec+=n;
    if (TimeSec>=60)
    {
      n=Math.floor(TimeSec/60);
      TimeSec-=n*60;
      TimeMin+=n;
      if (TimeMin>=60)
      {
        n=Math.floor(TimeMin/60);
        TimeMin-=n*60;
        TimeHour+=n;
      }
    }
    document.getElementById('TxtTime').innerHTML=LZ(TimeHour)+":"+LZ(TimeMin)+":"+LZ(TimeSec);
  }
}

function TimeStart()
{
  if (TimeRun==0)
  {
    var date = new Date();
    TimeOffset=date.getTime();
    TimeRun=1;
    idTimeout=setTimeout("TimeUpdate()",200);
  }
}

function TimeReset()
{
  TimeMS=0;
  TimeSec=0;
  TimeMin=0;
  TimeHour=0;
  document.getElementById('TxtTime').innerHTML="00:00:00";
}

function TimeStop()
{
  if (TimeRun!=0)
  {
    clearTimeout(idTimeout);
    TimeRun=0;
    var date = new Date();
    TimeMS+=date.getTime()-TimeOffset;
  }
}

function ProgressBar1Draw(dDiv)
{
  var nWidth=document.getElementById('ProgressBar1Outer').offsetWidth-4; // Remove border size
  var nBar=Math.round(nWidth*dDiv); // or Math.floor
  document.getElementById('ProgressBar1Inner').style.width=nBar.toString()+"px";
  document.getElementById('ProgressBar1Text').innerHTML=Math.round(dDiv*100).toString()+"%"; // or Math.floor
}

function ProgressBar2Draw(dDiv)
{
  var nWidth=document.getElementById('ProgressBar2Outer').offsetWidth-4; // Remove border size
  var nBar=Math.round(nWidth*dDiv); // or Math.floor
  document.getElementById('ProgressBar2Inner').style.width=nBar.toString()+"px";
  document.getElementById('ProgressBar2Text').innerHTML=Math.round(dDiv*100).toString()+"%"; // or Math.floor
}


