// index.js
// onload init function

function init() { 
  var http = new XmlHttp();
  var url = 'maps/xml/stationStatus.php';
  http.request(url,true,function(data,code) { 
    if( code != 200 ) { 
      alert("Load failed.");
      return false;
    }

    var dom = http.parse(data);

    var metas = dom.getElementsByTagName("meta");
    if( metas.length < 1 ) { 
      alert("Couldn't find metadata.");
      return false;
    }

    // Load statistic: total records
    var el = document.getElementById("nFiles");
    if( typeof(el) != "undefined" ) { 
      el.innerHTML = metas[0].getAttribute("nFiles");
    }

    // Load statistic: number of physical sites
    el = document.getElementById("nSites");
    if( typeof(el) != "undefined" ) { 
      el.innerHTML = metas[0].getAttribute("nSites");
    }

    // Load statistic: number of networks
    el = document.getElementById("nNets");
    if( typeof(el) != "undefined" ) { 
      el.innerHTML = metas[0].getAttribute("nNets");
    }

    // Load statistic: Update time
    el = document.getElementById("rTime");
    if( typeof(el) != "undefined" ) { 
      el.innerHTML = metas[0].getAttribute("rTime");
    }

  });
}

window.onload = init;
