function r2(n)
{
  ans = n * 1000
  ans = Math.round(ans /10) + ""
  while (ans.length < 3) {ans = "0" + ans}
  len = ans.length
  ans = ans.substring(0,len-2) + "." + ans.substring(len-2,len)
  return ans
}

var xmlHttpArray = new Array;
var targetdivArray = new Array;

function loadResults(url, target)
{
  var thiscount = xmlHttpArray.length;

  // code for Mozilla, etc.
  if (typeof XMLHttpRequest != 'undefined')
  {
    xmlHttpArray[thiscount] = new XMLHttpRequest();
  }

  // code for IE
  else if (window.ActiveXObject)
  {
    try
    {
      xmlHttpArray[thiscount] = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttpArray[thiscount] = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e2)
      {
        xmlHttpArray[thiscount] = false;
      }
    }
  }

  targetdivArray[thiscount]  = target;

  xmlHttpArray[thiscount].open("GET", url, true);

  changeCursor("wait");

  // Setup a function for the server to run when it's done
  xmlHttpArray[thiscount].onreadystatechange = showResults;

  // Send the request
  xmlHttpArray[thiscount].send(null);
}

function showResults()
{
  var thiscount = 0;
  for(thiscount in xmlHttpArray)
  {
    if (typeof xmlHttpArray[thiscount] != 'number')
    {
      if (xmlHttpArray[thiscount].readyState == 4)
      {
        changeCursor("default");
        var response = xmlHttpArray[thiscount].responseText;
        xmlHttpArray[thiscount] = 0;
        var scriptstart = "<script type=\"text/javascript\">";
        var scriptend = "</script>";
        var i = response.indexOf(scriptstart);
        if (i != -1)
        {
          htmlresponse = response.substr(0,i);
          scriptresponse = response.substr(i+scriptstart.length,response.length-(i+scriptstart.length+scriptend.length));
        }
        else
        {
          htmlresponse = response;
          scriptresponse = '';
        }

        //alert(scriptresponse);
        if (htmlresponse.length > 0)
        {
          document.getElementById(targetdivArray[thiscount]).innerHTML += htmlresponse;
        }
        if (scriptresponse.length > 0)
        {
          if (window.execScript)
          {
            window.execScript(scriptresponse);
          }
          else
          {
            window.eval(scriptresponse);
          }
        }
      }
    }
  }
}

function changeCursor(cursorType)
{
  document.body.style.cursor = cursorType;
}
