var oldll = '74.455746,-112.851563';
var newll;
var visitor;
var speed = 5000;
var zoom = 12;

function handleHttpResponse() {
	if (http.readyState == 4) {
    
		results = http.responseText.split("|");
		
		if (results[1]) {
	
			newll = results[0] + ',' + results[1];
		
			if (newll != oldll) {
			


				map.panTo(new GLatLng(results[0],results[1]),zoom);
				map.addControl(new GLargeMapControl());
	
				var mohoIcon = new GIcon(G_DEFAULT_ICON);
				mohoIcon.iconSize = new GSize(65, 50);
				mohoIcon.shadowSize = new GSize(65, 50);
				mohoIcon.iconAnchor = new GPoint(20, 40);
				mohoIcon.shadow = "http://www.stephenoachs.com/img/google-icon-moho-shadow.png";
				mohoIcon.image = "http://www.stephenoachs.com/img/google-icon-moho.png";

				// Set up our GMarkerOptions object
				markerOptions = { icon:mohoIcon };
				
				map.addOverlay(new GMarker(new GLatLng(results[0],results[1]),markerOptions));

				//map.openInfoWindow(map.getCenter(),document.createTextNode("...zzz"),{maxWidth:50});

				oldll = newll;
				//alert(newll + '-' + oldll);
			}
		}
	}
}

function GetLatLon() {

	var random = Math.random();
	var url = "inc/live-map.func.php?r=" + random;

	http.open("GET", url, true);
	http.onreadystatechange = handleHttpResponse;
	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 != 'unknown') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

var http = getHTTPObject();


function DoGeo() {
	setInterval("GetLatLon()",speed);
}


function StartMap() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("geomap"));
		map.setCenter(new GLatLng(oldll),zoom);
	}
}