﻿   
  
   // Declare variables for later use
        var map;
        var geocoder;
        var marker;

        function loadMap() {
            // loadMap: initialize the API and load the map onto the page

            // Get the map container div
            var mapDiv = document.getElementById('map');
            


            // Confirm browser compatibility with the Maps API
            if (!GBrowserIsCompatible())
                mapDiv.innerHTML = 'Sorry, your browser isn\'t compatible with Google Maps.';
            else {
                // Initialize the core map object
                map = new GMap2(mapDiv,
      { mapTypes: [G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP] });

      // Set the starting map viewport

      var coordinates = new GLatLng(52.634570, -1.1294438);
      map.setCenter(coordinates, 6, G_NORMAL_MAP);
              

                // Add the standard map controls
                map.addControl(new GSmallMapControl());
                map.addControl(new GScaleControl(),
                   new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(6, 18)));
                map.addControl(new GMapTypeControl(true));

                // Initialize the geocoder object
                geocoder = new GClientGeocoder();
                document.getElementById('ctl00_ContentPlaceHolder1_Button2').style.display = 'none';
            }
           
        };

        function loadJamMap() {
            // loadMap: initialize the API and load the map onto the page

            // Get the map container div
            var mapDiv = document.getElementById('map');
            document.getElementById('ctl00_ContentPlaceHolder1_Button2').style.display = 'none';


            // Confirm browser compatibility with the Maps API
            if (!GBrowserIsCompatible())
                mapDiv.innerHTML = 'Sorry, your browser isn\'t compatible with Google Maps.';
            else {
                // Initialize the core map object
                map = new GMap2(mapDiv,
      { mapTypes: [G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP] });

                // Set the starting map viewport

      var coordinates = new GLatLng(18.048642, -77.505173);
                map.setCenter(coordinates, 9, G_NORMAL_MAP);


                // Add the standard map controls
                map.addControl(new GSmallMapControl());
                map.addControl(new GScaleControl(),
                   new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(6, 18)));
                map.addControl(new GMapTypeControl(true));

                // Initialize the geocoder object
                geocoder = new GClientGeocoder();
            }
        };

        function geocode() {
            // geocode: Call the Google geocoder with the address supplied by the user
            var address = document.getElementById('address').value;

            geocoder.getLatLng(address, afterGeocode);

            document.getElementById('ctl00_ContentPlaceHolder1_Button2').style.setAttribute('display', '')
            document.getElementById('ctl00_ContentPlaceHolder1_Button2').focus();

        };

        function afterGeocode(coordinates) {
            // afterGeocode: Callback function for the geocoder, showing the coords on the map
            if (coordinates == null)
                alert('Address not found. Please try again.');
            else {
                // Address was found
                if (marker == null) {

                    marker = new GMarker(coordinates, { draggable: true });
                    map.addOverlay(marker);


                    //                     var iconOptions = { width: 34, height: 34, primaryColor: "#fffc1b" };
                    //                    var myIcon = MapIconMaker.createMarkerIcon(iconOptions);
                    //                    marker = new GMarker(coordinates, { icon: myIcon, draggable: true });
                    //                    map.addOverlay(marker);
                    //                  


                    GEvent.addListener(marker, 'dragend', markerDragEnd);
                    GEvent.addListener(marker, 'dragstart', markerDragStart);
                }
                else {
                    // The marker already exists, just move it to the new coordinates
                    marker.setPoint(coordinates);
                }

                map.setCenter(coordinates, 16);

                marker.openInfoWindowHtml('Drag marker to exact location, then click Next.');
                saveCoordinates();
            }
        };

        function markerDragStart() {
            // markerDragStart: Close the infowindow when the marker is being dragged
            map.closeInfoWindow();
        };

        function markerDragEnd() {
            // markerDragEnd: Update the form coordinates and show more instructions

            saveCoordinates();

            var content = '<a href="#" onclick="map.zoomIn(); return false">Zoom in</a>' +
                ' if needed to place marker<br />exactly, or then click Next when done.';
            marker.openInfoWindow(content);
        };

        function saveCoordinates() {
            // saveCoordinates: Copy the current marker coordinates into the form fields
            var coordinates = marker.getPoint();
            document.getElementById('Hidden1').value = coordinates.lat().toFixed(6);
            document.getElementById('Hidden2').value = coordinates.lng().toFixed(6);
            
        };


 