    var map = null;
    var geocoder = null;
    var point = null;
    var side_bar_html = "";
    var gmarkers = [];
    var htmls = [];
    var i = 0;

    function getTotals(point) {
        var url = 'http://masterweb1.newsok.com/map/ct-summary.php';
        var params = 'point=' + point;
        //alert(url+'?'+params);
        new Ajax.Updater('results_bar', url, {asynchronous:true, parameters:params});
    }

    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
                map.addControl(new GLargeMapControl());
                map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(35.4677, -97.5165), 11);
        geocoder = new GClientGeocoder();
      }
    }

    function showAddress(thisform) {
      if (geocoder) {
                address = thisform.address.value;
                city = thisform.city.value;
                //if (thisform.city[0].checked) {;
                //   city = " Oklahoma City, OK";
                //} else {
                //   city = " Midwest City, OK";
                //}
                address = address+", "+city;
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert("The address you entered: "+ address + "\ncould not be mapped.\n\nPlease try your query again.\n\nNote: If you are searching for a Midwest City address, try using Oklahoma City, Google lists most of MWC as OKC addresses.");
            } else {
              map.setCenter(point, 15);
              var marker = new GMarker(point);

              //var polyline = createPolyline(point);
              //map.addOverlay(polyline);

              map.addOverlay(marker);
              marker.openInfoWindowHtml(address);

                GDownloadUrl("/map/ct-xml.php?point="+point, function(data) {
                  var xml = GXml.parse(data);
                  var markers = xml.documentElement.getElementsByTagName("marker");
                  for (var i = 0; i < markers.length; i++) {
                        var address = markers[i].getAttribute("address");
                        var desc = markers[i].getAttribute("desc");
                        var type = markers[i].getAttribute("type");
                        var date = markers[i].getAttribute("date");
                        var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                                                        parseFloat(markers[i].getAttribute("lng")));
                        var marker = createMarker(point, address, desc, date, type);
                        map.addOverlay(marker);
                  }
                  document.getElementById("side_bar").innerHTML = side_bar_html;
                  getTotals(point);
                });
            }
          }
        );
      }
    }

        function createPolyline(point) {
          strPoint = String(point);
          lat = strPoint.substr(1,strPoint.indexOf(",",1)-1);
          lng = strPoint.substr(strPoint.indexOf(",",1)+1,11);
          lng = lng.substr(1,strPoint.indexOf(")",1)-1)
          lat = Number(lat);
          lng = Number(lng);

          var polyline = new GPolyline([
                new GLatLng(lat-.0086, lng-.0086),
                new GLatLng(lat-.0086, lng+.0086),
                new GLatLng(lat+.0086, lng+.0086),
                new GLatLng(lat+.0086, lng-.0086),
                new GLatLng(lat-.0086, lng-.0086)
          ], "#0000FF", 3);
          return polyline;
        }

        function createMarker(point, address, desc, date, type) {
          var marker = new GMarker(point, customIcons[type]);
          var html = "<b>" + type + "</b> <br/>" + date + "<br/>" + address +  "<br/>" + desc;
          GEvent.addListener(marker, 'click', function() {
                marker.openInfoWindowHtml(html);
          });
          gmarkers[i] = marker;
          htmls[i] = html;
          side_bar_html += type + ' - ' + date + '<br/><a href="javascript:myclick(' + i + ')">' + address + '</a><p/>';
          i++;
          return marker;
        }

        function myclick(i) {
                gmarkers[i].openInfoWindowHtml(htmls[i]);
        }

	function popup(url) {
		newwindow=window.open(url,'name','height=500,width=450,scrollbars=1');
		if (window.focus) {newwindow.focus()}
		return false;
	}

        var iconBlue = new GIcon();
        iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
        iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
        iconBlue.iconSize = new GSize(12, 20);
        iconBlue.shadowSize = new GSize(22, 20);
        iconBlue.iconAnchor = new GPoint(6, 20);
        iconBlue.infoWindowAnchor = new GPoint(5, 1);

        var iconRed = new GIcon();
        iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
        iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
        iconRed.iconSize = new GSize(12, 20);
        iconRed.shadowSize = new GSize(22, 20);
        iconRed.iconAnchor = new GPoint(6, 20);
        iconRed.infoWindowAnchor = new GPoint(5, 1);

        var iconGreen = new GIcon();
        iconGreen.image = 'http://labs.google.com/ridefinder/images/mm_20_green.png';
        iconGreen.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
        iconGreen.iconSize = new GSize(12, 20);
        iconGreen.shadowSize = new GSize(22, 20);
        iconGreen.iconAnchor = new GPoint(6, 20);
        iconGreen.infoWindowAnchor = new GPoint(5, 1);

        var iconYellow = new GIcon();
        iconYellow.image = 'http://labs.google.com/ridefinder/images/mm_20_yellow.png';
        iconYellow.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
        iconYellow.iconSize = new GSize(12, 20);
        iconYellow.shadowSize = new GSize(22, 20);
        iconYellow.iconAnchor = new GPoint(6, 20);
        iconYellow.infoWindowAnchor = new GPoint(5, 1);

        var iconBlack = new GIcon();
        iconBlack.image = 'http://labs.google.com/ridefinder/images/mm_20_black.png';
        iconBlack.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
        iconBlack.iconSize = new GSize(12, 20);
        iconBlack.shadowSize = new GSize(22, 20);
        iconBlack.iconAnchor = new GPoint(6, 20);
        iconBlack.infoWindowAnchor = new GPoint(5, 1);

        var iconOrange = new GIcon();
        iconOrange.image = 'http://labs.google.com/ridefinder/images/mm_20_orange.png';
        iconOrange.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
        iconOrange.iconSize = new GSize(12, 20);
        iconOrange.shadowSize = new GSize(22, 20);
        iconOrange.iconAnchor = new GPoint(6, 20);
        iconOrange.infoWindowAnchor = new GPoint(5, 1);

        var iconGray = new GIcon();
        iconGray.image = 'http://labs.google.com/ridefinder/images/mm_20_gray.png';
        iconGray.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
        iconGray.iconSize = new GSize(12, 20);
        iconGray.shadowSize = new GSize(22, 20);
        iconGray.iconAnchor = new GPoint(6, 20);
        iconGray.infoWindowAnchor = new GPoint(5, 1);

        var customIcons = [];
        customIcons["Arson"] = iconOrange;
        customIcons["Assault"] = iconYellow;
        customIcons["Autotheft"] = iconGreen;
        customIcons["Burglary"] = iconGray;
        customIcons["Homicide"] = iconBlack;
        customIcons["Rape"] = iconRed;
        customIcons["Robbery"] = iconBlue;

