﻿	function usePointFromPostcode(postcode,html,propID) {
	var localSearch = new GlocalSearch();
		localSearch.setSearchCompleteCallback(null, 
			function() {
				
				if (localSearch.results[0])
				{	
				    var map = new GMap2(document.getElementById("map"));
				    map.addControl(new GSmallMapControl());
                    map.addControl(new GMapTypeControl());
					var resultLat = localSearch.results[0].lat;
					var resultLng = localSearch.results[0].lng;
					var point = new GLatLng(resultLat,resultLng);
					map.setCenter(point, 12);
					map.addOverlay(createMarker(point,html,propID));
					map.openInfoWindow(map.getCenter(),html);
				}
			});	
			
		localSearch.execute(postcode + ", UK");
	}
	
	function usePointFromPostcode2(postcode,html,propID) {
	var localSearch = new GlocalSearch();
		localSearch.setSearchCompleteCallback(null, 
			function() {
				
				if (localSearch.results[0])
				{	
					var resultLat = localSearch.results[0].lat;
					var resultLng = localSearch.results[0].lng;
					var point = new GLatLng(resultLat,resultLng);
					map.addOverlay(createMarker(point,html,propID));
				}
			});	
			
		localSearch.execute(postcode + ", UK");
	}
	
	function createMarker(point,html,propID) {	
          // Create a lettered icon for this point using our icon class
          var baseIcon = new GIcon();
          baseIcon.image = "http://www.eastfifeletting.co.uk/images/map_icon.png";
	      baseIcon.iconSize = new GSize(20, 21);
	      baseIcon.iconAnchor = new GPoint(4, 20);
	      baseIcon.infoWindowAnchor = new GPoint(9, 2);
          var mapIcon = new GIcon(baseIcon);

          // Set up our GMarker object
          var marker = new GMarker(point,mapIcon);
          GEvent.addListener(marker, "click", function() {
          location.href = "property-details.aspx?propID="+propID+"";
          });
          
          GEvent.addListener(marker, "mouseover", function() {
          marker.openInfoWindowHtml(html);
          OnClickMapIcon(propID);
          });
          return marker;
        }
        
    function initMap(){
          var map = new GMap2(document.getElementById("map"));
          map.setCenter(new GLatLng(56.235718, -2.804947), 11);
          map.addControl(new GSmallMapControl());
          map.addControl(new GMapTypeControl());
		  var baseIcon = new GIcon();
          baseIcon.image = "http://www.eastfifeletting.co.uk/images/map_icon.png";
	      baseIcon.iconSize = new GSize(20, 21);
	      baseIcon.iconAnchor = new GPoint(4, 20);
	      baseIcon.infoWindowAnchor = new GPoint(9, 2);
	      }