var Map_map;
var Map_req;

function Map_load() {
    if (GBrowserIsCompatible()) {
        _map = new GMap2(document.getElementById("map"));
        var typeList = _map.getMapTypes();
        //remove street map, show satellite image
        _map.removeMapType(typeList[0]);
        //Kansas City, MO
        _map.setCenter(new GLatLng(39.1041, -94.5987), 3);

        //var icon = new GIcon();
        var icon = new GIcon(G_DEFAULT_ICON,"http://earthstandingstill.org/mapMarker.png");
        icon.iconAnchor = new GPoint(0,0);
        icon.iconSize = new GSize(5,5);
        _req = loadXMLDoc("http://earthstandingstill.org/cgi-bin/getZipLatLong.cgi?id=ess",true,Map_addZipCodes);
    }
}

function Map_addZipCodes() {
    if (typeof asyncRequest_req == 'undefined' || asyncRequest_req == null) return;
    if (asyncRequest_req.readyState != 4) return;

    var xml = asyncRequest_req.responseXML;
    if (xml == null) {
        //BM - uncomment for debugging purposes; otherwise, just quit
        //alert('Error: ' + asyncRequest_req.responseText);
        return(false);
    }

    var rsp = xml.documentElement;
    var latResultList = rsp.getElementsByTagName('lt');
    var longResultList = rsp.getElementsByTagName('lg');
    var result = '';
    if ((latResultList != null) && (latResultList.length > 0)) {
        var i;
        for (i = 0; i < latResultList.length; i++) {
            var lt = latResultList[i].firstChild.data;
            var lg = longResultList[i].firstChild.data;

            var icon = new GIcon(G_DEFAULT_ICON,"http://earthstandingstill.org/mapMarker.png");
            icon.iconAnchor = new GPoint(0,0);
            icon.iconSize = new GSize(5,5);

            var point = new GLatLng(lt, lg);
            _map.addOverlay(new GMarker(point,icon));
        }
    }
}
