/*

  digsys-bas.js           April 2, 2008

  Copyright (c) 2008 Scandinavian Digital Systems AB

  Developed by Anders Danielsson, http://www.digsys.se/

*/

function HRefAuthor()
{
  document.write(String.fromCharCode(60,65,32,72,82,69,70,61,34,109,97,105,108,116,111,58,97,110,100,101,114,115,64,100,105,103,115,121,115,46,115,101,34,62,65,110,100,101,114,115,32,68,97,110,105,101,108,115,115,111,110,60,47,65,62));
}

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 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
}

