
    //<![CDATA[

    if (GBrowserIsCompatible()) {
      var gmarkers = [];
      var htmls = [];
      var i = 0;
      // arrays to hold variants of the info window html with get direction forms open
      var to_htmls = [];
      var from_htmls = [];
    
	
			var mP = {
			
			
				init: function() {
					if(!document.getElementById('map')) {
						return;
					}
				
		      // create the map
		      mP.map = new GMap2(document.getElementById("map"));
		      mP.map.addControl(new GLargeMapControl());
		      mP.map.addControl(new GMapTypeControl());
		      mP.map.setCenter(new GLatLng(55.94915,-3.21500), 15);
		
		      // === create a GDirections Object ===
		      mP.gdir=new GDirections(mP.map, document.getElementById("directions"));
		
		      // === Array for decoding the failure codes ===
		      var reasons=[];
		      reasons[G_GEO_SUCCESS]            = "Success";
		      reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
		      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
		      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
		      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
		      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
		      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
		      reasons[G_GEO_BAD_REQUEST]        = "A directions request could not be successfully parsed.";
		      reasons[G_GEO_MISSING_QUERY]      = "No query was specified in the input.";
		      reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";
		
		      // === catch Directions errors ===
		      GEvent.addListener(mP.gdir, "error", function() {
		        var code = mP.gdir.getStatus().code;
		        var reason="Code "+code;
		        if (reasons[code]) {
		          reason = reasons[code]
		        } 
		
		        alert("Failed to obtain directions, "+reason);
		      });
		
		
		
		      // obtain the attribues of each marker
	        var point = new GLatLng(55.94915,-3.21500);
	        var html = "<strong>Colpitts World Travel Ltd</strong><br />50 Melville Street,<br />Edinburgh<br />EH3 7HF";
	        var label = "Marker One";
	        // create the marker
	        var marker = mP.createMarker(point,label,html);
	        mP.map.addOverlay(marker);
				
		     
				
				
				},
			
			

					// A function to create the marker and set up the event window
	      createMarker: function(point,name,html) {
	        var marker = new GMarker(point);
	
	        // The info window version with the "to here" form open
	        to_htmls[i] = html + '<br>Directions: <b>To here</b> - <a href="javascript:mP.fromhere(' + i + ')">From here</a>' +
	           '<br>Start address:<form action="javascript:mP.getDirections()">' +
	           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
	           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
	           '<input type="hidden" id="daddr" value="'+name+"@"+ point.lat() + ',' + point.lng() + 
	           '"/>';
	        // The info window version with the "to here" form open
	        from_htmls[i] = html + '<br>Directions: <a href="javascript:mP.tohere(' + i + ')">To here</a> - <b>From here</b>' +
	           '<br>End address:<form action="javascript:mP.getDirections()">' +
	           '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
	           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
	           '<input type="hidden" id="saddr" value="'+name+"@"+ point.lat() + ',' + point.lng() +
	           '"/>';
	        // The inactive version of the direction info
	        html = html + '<br>Directions: <a href="javascript:mP.tohere('+i+')">To here</a> - <a href="javascript:mP.fromhere('+i+')">From here</a>';
	
	        GEvent.addListener(marker, "click", function() {
	          marker.openInfoWindowHtml(html);
	        });
	
	        gmarkers[i] = marker;
	        htmls[i] = html;
	
	        i++;
	        return marker;
	      },
	
	      // ===== request the directions =====
	      getDirections: function() {
	        var saddr = document.getElementById("saddr").value
	        var daddr = document.getElementById("daddr").value
	        mP.gdir.load("from: "+saddr+" to: "+daddr);
	        document.getElementById("directions").style.height = "200px";
	      },
	
	
	      // This function picks up the click and opens the corresponding info window
	      myclick: function(i) {
	        gmarkers[i].openInfoWindowHtml(htmls[i]);
	      },
	
	      // functions that open the directions forms
	      tohere: function(i) {
	        gmarkers[i].openInfoWindowHtml(to_htmls[i]);
	      },
	      fromhere: function(i) {
	        gmarkers[i].openInfoWindowHtml(from_htmls[i]);
	      }



			
      
	      
	    }
    
    
			window.addEvent('domready', mP.init);
			window.addEvent('unload', GUnload);
    
    } else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

    // This Javascript is based on code provided by the
    // Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/   
    // http://econym.googlepages.com/index.htm

    //]]>