var iFileSize = 268945; 
var objImage = new Image();
objImage.onload = StopWatch;
var objDate = new Date();
var objStartTime = objDate.getTime();
var objStopTime = objDate.getTime();
var objTimerHandle = 0;
var iIterations = 0;

function Working()
{
  document.outform.output.value = document.outform.output.value + ".";
  iIterations++;
  if (iIterations < 3600)
    {
    objTimerHandle = setTimeout("Working();", 500);
    }  
  else 
    {
    document.outform.output.value = document.outform.output.value + "\nERROR:  Either the test 'load test' file could not be found, or your network is too slow or not functioning properly. (Took more than 30 minutes to complete.)";
    }
}

function StartWatch()
{

  objDate = new Date()
  objStartTime = objDate.getTime();
  objImage.src = "/images/City003.jpg?Epoch=" + objStartTime ;
  objTimerHandle = setTimeout("Working();", 500);
}

function StopWatch()
{
  objDate = new Date()
  objStopTime = objDate.getTime();
  if (objTimerHandle) 
    {
    clearTimeout(objTimerHandle);
    objTimerHandle=0;
    }
  var iDuration = (objStopTime - objStartTime) / 1000;  // the number of seconds it took
  var iThroughPut = (iFileSize / iDuration) / 1024;
  var iThroughPutBits = ((iFileSize * 8) / iDuration) / 1024;
  iThroughPut = (Math.round(iThroughPut * 100)) / 100
  iThroughPutBits = (Math.round(iThroughPutBits * 100)) / 100

  document.outform.output.value = document.outform.output.value + iThroughPut + " kbs \n";
  iIterations = 0;
}
