    //<![CDATA[
    
    // create the map
    var map = null;
    var geocoder = null;
    var marker = null;
    var curAddress = null;

    function load() {

      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        geocoder = new GClientGeocoder();

        curAddress = getURLParams('address');

        //map.setCenter(new GLatLng(32.89,-97.52), 13);
        if (curAddress) {
          setMapCenter(curAddress);
        }
        else {
         map.setCenter(new GLatLng(37.0625,-95.677068000000006),3);
        }

        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());

        if (curAddress) {
          //setupMarkers();
          window.setTimeout(setupMarkers, 0);
        }
      }
    }

    function setMapCenter(address) {
      curAddress = address;
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point && address) {
              //alert("Address \"" + address + "\" not found");
            } else {
              map.setCenter(point, 12);
            }
          }
        );
      }
    }

    function getLatLong(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point && address) {
              //alert("Address \"" + address + "\" not found");
            } else {
              return point;
            }
          }
        );
      }
    }

    // Creates a marker at the given point with the given number label
    function createMarker(point, number) {
      marker = new GMarker(point);
      GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml("Marker #<b>" + number + "</b>");
      });
      return marker;
    }

    function getIcon(num) {
      var icon = null;
      icon = new GIcon();
      icon.image = "images/stars/star"+(num*1+1)+".png";
      icon.iconSize = new GSize(26, 26);
      icon.iconAnchor = new GPoint(0, 0);
      icon.infoWindowAnchor = new GPoint(20, 10);
      //icon.shadow = "images/star_shadow.png";
      //icon.shadowSize = new GSize(35, 26);
      return icon;
    }

    function setupMarkers() {      
      for (var j in theaters) {
        var place = theaters[j];
        
        addMarker(place, j);
      }
    }
    function addMarker(place, num) {
        if (geocoder) {
          geocoder.getLatLng( place["street"] + ", " + place["zip"],  //place["address"],
            function(point) {
              if (!point) {
                //alert(place["address"] + " not found");
              } else {
                var icon = getIcon(num);
                //var lat_long = new GLatLng(place["lat"],place["long"]);
                var marker = new GMarker(point, { title: place["name"], icon: icon });
                
                GEvent.addListener(marker, "click", function() {
                  marker.openInfoWindowHtml("<b>" + place["name"] + "</b><br />" + place["company"] + "<br />" +
                                            place["address"] + "<br />" + place["phone"]);  });
                
                map.addOverlay(marker);
              }
            }
          );  
        }
    }

    function getURLParams(name)
    {
      name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regexS = "[\\?&]"+name+"=([^&#]*)";      
      var regex = new RegExp( regexS );
      var results = regex.exec( window.location.href );
      if( results == null )
        return "";
      else
      {
        // replace "+" with spaces
        results[1] = results[1].replace("+", " ");
        // replace "%2C with commas
        results[1] = results[1].replace(/%2C/i,",");
        return results[1];
      }
    }
    
    function setMapToTheater(i)
    {
      var address = theaters[i]['street'] + " " + theaters[i]['zip'];
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point && address) {
              //alert("Address \"" + address + "\" not found");
            } else {
              map.panTo(point);
            }
          }
        );
      }
    }

    //]]>

