function initialize() {
    //  check for map first
    var isMap = document.getElementById("showGmap")

    
    if (isMap) {
        showGmap = document.getElementById("showGmap").value
        hidMedia = document.getElementById("hidMedia").value
    }
    else { showGmap = ""; return; }

    //  Should we build the gmap
    if (showGmap == "" || hidMedia == 1 || hidMedia == 2 || hidMedia == 3 || hidMedia == 4 || hidMedia == 5) { return; }


    var latitude = document.getElementById("latitudex").value;
    var longitude = document.getElementById("longitudex").value
    var myPoint = new GLatLng(latitude, longitude);

    //alert(GBrowserIsCompatible)
    if (GBrowserIsCompatible()) {
        if (hidMedia == 7 || hidMedia == 6) {
            geocoder = new GClientGeocoder();
            map = new GMap2(document.getElementById("map_canvas"));
            //  Center the map
            // map.setCenter(new GLatLng(30.277952882891515, -97.79196739196777), 17);
            map.addControl(new GMapTypeControl());
            if (hidMedia == 6) {
                map.removeMapType(G_NORMAL_MAP);
                map.setMapType(G_SATELLITE_MAP)
                map.setCenter(new GLatLng(latitude, longitude), 18);
            }
            else {
                map.removeMapType(G_SATELLITE_MAP);
                map.setMapType(G_NORMAL_MAP)
                map.setCenter(new GLatLng(latitude, longitude), 13);
            }
            map.addControl(new GSmallMapControl());
            map.enableScrollWheelZoom();

            //	Add marker
            if (latitude != "0") { map.addOverlay(new GMarker(myPoint, { draggable: true })) }
            else { showAddress() }
        }

        if (hidMedia == 8) {
            panoClient = new GStreetviewClient();
            var POV = { yaw: 370.64659986187695, pitch: -5 }; //-20
            myPano = new GStreetviewPanorama(document.getElementById("map_canvas"));
            myPano.setLocationAndPOV(myPoint, POV);
            GEvent.addListener(myPano, "error", handleNoFlash);
            panoClient.getNearestPanorama(myPoint, showPanoData);
        }
    }
}


function initializeArea() {
    //  check for map first
    var isMap = document.getElementById("showGmap")

    if (isMap) {
        hidMedia = document.getElementById("hidMedia").value
    }
    else { showGmap = ""; return; }

    //  Should we build the gmap
    if (hidMedia != 1) { return; }

    var latitude = document.getElementById("latitudex").value;
    var longitude = document.getElementById("longitudex").value
    var myPoint = new GLatLng(latitude, longitude);

    if (GBrowserIsCompatible()) {
            geocoder = new GClientGeocoder();
            map = new GMap2(document.getElementById("map_canvas"));
            //  Center the map
            // map.setCenter(new GLatLng(30.277952882891515, -97.79196739196777), 17);
            map.addControl(new GMapTypeControl());
            map.removeMapType(G_SATELLITE_MAP);
            map.setMapType(G_NORMAL_MAP)
            map.setCenter(new GLatLng(latitude, longitude), 12);
            map.addControl(new GSmallMapControl());
            map.enableScrollWheelZoom();

            //	Add marker
            if (latitude != "0") { map.addOverlay(new GMarker(myPoint, { draggable: false })) }
            else { showAddress() }

    }
}


function handleNoFlash(errorCode) {
    if (errorCode == 603) {
        alert("Error: Flash doesn't appear to be supported by your browser");
        return;
    }
}

function showAddress() {
    //  Check to see if we need to geocode
    if (document.getElementById("geocodeAddress").value == "") { return; }
    address = document.getElementById("geocodeAddress").value;
    if (geocoder) {
        geocoder.getLatLng(
      address,
      function(point) {
          if (!point) {
              alert(address + " not found");
          } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              // marker.openInfoWindowHtml(address);
          }
      }
    );
    }
}