function el(id)
{
  return document.getElementById(id);
}

function check_stocks_price(root_uri)
{
  var t_url = root_uri + "check_stocks_price.php";
  var http = getHTTPObject();

  http.open("GET", t_url, true);
  http.onreadystatechange = function() {
    if (http.readyState == 4) {
      var result = http.responseText;

      if (result.length) {
      	var data = eval('(' + result + ')');
      	        
      	if (el('published_dt').innerHTML != 'Prices published at: ' + data.published_dt) {
      	  // FIXME: for (..) ?
      	  el('published_dt').innerHTML = 'Published time: ' + data.published_dt;
      	  el('construction').innerHTML = '$' + data.construction;
      	  el('health').innerHTML = '$' + data.health;
      	  el('retail').innerHTML = '$' + data.retail;
      	  el('technology').innerHTML = '$' + data.technology;
      	  el('utilities').innerHTML = '$' + data.utilities;
      	}
      }
    } 	
  };
  http.send(null);
}

function check_travel_status(root_uri)
{
  var t_url = root_uri + "check_travel_status.php";
  var http = getHTTPObject();

  http.open("GET", t_url, true);
  http.onreadystatechange = function() {
    if (http.readyState == 4) {
      var result = http.responseText;

      if (!result.length) 
        window.location = root_uri;
      else if (result == "0")
        window.location = root_uri + "?page=game/travel&completed=";
    } 	
  };
  http.send(null);
}

function getHTTPObject()
{
  var xmlhttp;
  
  /*@cc_on
    @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
    @else
      xmlhttp = false;
  @end @*/

  if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }

  return xmlhttp;
}
                