	/*
	* Loads google map api
	*/
	google.load('search', '1');
	google.load('maps', '2');

	/*
	* Our global state variables
	*/
	
	var gLocalSearch;
	var gMap;
	var gSelectedResults = [];
	var gCurrentResults = [];
	var gSearchForm;	
	/*
	* Create our "tiny" marker icon
	*/
	var gSmallIcon = null;


	/*
	* Set up the map and the local searcher.
	* To load the map OnLoad funcation is being called
	*/
	
	function OnLoad() 
	{
	
	/*
	* Creates pink icon
	*/
	
	gSmallIcon = new google.maps.Icon();
	gSmallIcon.image = "../markers/mm_20_red.png";
	gSmallIcon.shadow = "../markers/mm_20_shadow.png";
	gSmallIcon.iconSize = new google.maps.Size(12, 20);
	gSmallIcon.shadowSize = new google.maps.Size(22, 20);
	gSmallIcon.iconAnchor = new google.maps.Point(6, 20);
	gSmallIcon.infoWindowAnchor = new google.maps.Point(5, 1);
		
	/*
	* Initialize the map Map conrols
	*/
	
	gMap = new GMap2(document.getElementById("map"));
	gMap.addControl(new GSmallMapControl());
	gMap.addControl(new GMapTypeControl());
	gMap.setCenter(new GLatLng(-31.929729,115.979748), 13);
	
	
	/*
	* Initialize the local searcher
	*/
	
	gLocalSearch = new google.search.LocalSearch();
	gLocalSearch.setCenterPoint(gMap);
	
	/*
	* Sets The number of result to display maximum 8 results 
	*/
	
	gLocalSearch.setResultSetSize(GSearch.LARGE_RESULTSET);
	
	/*
	* When search is being completed
	* Localsearch funcation will be called for further marker setting and all
	*/
	
	gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);
	
	/*
	*	Add addresses here to display it on map
	*/
	
    gLocalSearch.execute('Marmion & Whitfords Avenue, Hillary\'s, WA, 6025');		
	//gMap.setCenter(new GLatLng(-31.929729,115.979748), 9);
	
	
    }

   
    /*
	* Called when Local Search results are returned, we clear the old
    * results and load the new ones.
	*/

	function OnLocalSearch() 
	{
		
		/* 
		* Show results untill it founds matching result with our criteria
		* But with max search result length
		*/

		for (var i = 0; i < gLocalSearch.results.length; i++) 
		{
			gCurrentResults.push(new LocalResult(gLocalSearch.results[i]));		
		}
		

		/*
		* When search initially happens then only
		* move the map to the first result	
		*/
		
		var first = gLocalSearch.results[0];
		gMap.panTo(new google.maps.LatLng(first.lat, first.lng));

	}



  /*
	* A class representing a single Local Search result returned by the
	* Google AJAX Search API.
	*/
	
	function LocalResult(result) 
	{
	
		this.result_ = result; 
		//gMap.addOverlay(this.marker(G_DEFAULT_ICON));
		
		gMap.addOverlay(this.marker(gSmallIcon));	
		
	}

    // Returns the GMap marker for this result, creating it with the given
    // icon if it has not already been created.
    /*
	* Returns the GMap marker for this result, creating it with the given
    * icon if it has not already been created.		
	*/
	
    LocalResult.prototype.marker = function(opt_icon) 
	{
	
		if (this.marker_) return this.marker_;	    
		
		/*
		* Initialize marker variable 
		* Pass result lat and lang for marker point
		*/
		
		var marker = new google.maps.Marker
					(
						new google.maps.LatLng
						(
							parseFloat(this.result_.lat),
							parseFloat(this.result_.lng)
						),
						opt_icon
					);					   	   
					
						/*
						* Creates container div to show infowindow innerHTML
						*/

						var container = document.createElement("div");
							container.id = "divUnselected";
							container.className = "unselected";							
						
						/*
						* Get result innner HTML Passed from Google AJAX Search API.
						* Convert this value to lower case
						*/
						
			container.innerHTML = 'Marmion & Whitfords Avenue, Hillary\'s, WA, 6025';						
			container.innerHTML += '<br><a href="http://mayamasala.net/whitfords/whitfords.htm">Maya Masala Whitfords</a>';			
						
						/*
						* Binds marker Event which will be called on click of marker
						* And this event will open a infowindow
						* When info window is being opened this funcation also set
						* map pointer to that marker
						*/
						GEvent.bind
								(
									marker, 
									"click", 
									this, 
									function() 
									{		
										gMap.panTo
											(
												new google.maps.LatLng
													(
														this.result_.lat, 
														this.result_.lng
													)
											);
					
										marker.openInfoWindowHtml(container);
								}
								);
		
					this.marker_ = marker;
		
					return marker;
	}
   

   

    google.setOnLoadCallback(OnLoad, true);
	