<!-- Google Map // Display Homes -->

var dMichigan;
var dStanford;
var dLexington;
var dWestmont;
var dAlkimos;


    function CreateMarker(lattitude, longitude, infoWindowHtml)
	{
	    var center = new GLatLng(lattitude,longitude);
	  	var dLocalObj = new GMarker(center, {draggable: false});
	  	GEvent.addListener(dLocalObj, "click", function() {
        	dLocalObj.openInfoWindowHtml(infoWindowHtml);
        });
		
		return dLocalObj;
	}

	function initialize() {
      if (GBrowserIsCompatible()) {
	  	
		//Establish Canvas
        map = new GMap2(document.getElementById("map_canvas"));
		
		//Set map center and zoom level
		//map.setCenter(new GLatLng(-31.94284,115.85495), 9); Perth
		//map.setCenter(new GLatLng(-31.886886525780806,115.8233642578125), 9); Joondalup
		map.setCenter(new GLatLng(-32.00807595929104,115.850830078125), 9);
		
		//Michigan Marker and Information
		dMichigan = CreateMarker(-32.109447,115.951695, "<div class='markerInfo'><h2>The Michigan</h2><img src='images/display_homes/michigan.jpg' alt='The Michigan' class='markerThumb' /><h3>Location</h3><p>Aldenham Dr,<br /> Southern River 6110</p><div><a href='display_homes_michigan.aspx'>More information</a>&nbsp;|&nbsp;<a href='http://maps.google.com.au/maps?f=q&source=s_q&hl=en&q=Aldenham+Dr,+Southern+River+WA+6110&sll=-32.474609,115.759456&sspn=0.012925,0.01929&gl=au&g=28+Jasper+Way,+Lakelands+WA+6210&ie=UTF8&cd=1&geocode=FaMOFv4dZ0bpBg&split=0&hq=&hnear=Aldenham+Dr,+Southern+River+WA+6110&ll=-32.10497,115.948656&spn=0.012978,0.01929&z=16&iwloc=A' target='_blank'>Get directions</a></div></div>");
		
		//Stanford Marker and Information
		dStanford = CreateMarker(-31.886323,115.818354, "<div class='markerInfo'><h2>The Stanford</h2><img src='images/display_homes/stanford.jpg' alt='The Stanford' class='markerThumb' /><h3>Location</h3><p>25 Lycium Quays,<br />Roslea Estate<br />Stirling 6021</p><div><a href='display_homes_stanford.aspx'>More information</a>&nbsp;|&nbsp;<a href='http://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=25+Lycium+Quays,+Stirling+WA+6021&sll=-31.885866,115.81903&sspn=0.001635,0.002411&gl=au&ie=UTF8&hq=&hnear=25+Lycium+Quays,+Stirling+WA+6021&z=17' target='_blank'>Get directions</a></div></div>");
		
	//http://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=Cobaki+Brace,+Lakelands,+Western+Australia&aq=0&sll=-25.335448,135.745076&sspn=52.292103,75.058594&ie=UTF8&hq=&hnear=Cobaki+Brace,+Lakelands+Western+Australia+6180&z=16
		//
		dLexington = CreateMarker(-32.475457, 115.758424, "<div class='markerInfo'><h2>The Lexington</h2><img src='images/display_homes/lexington.jpg' alt='The Lexington' class='markerThumb' /><h3>Location</h3><p>Cobaki Place, Lakelands</p><div><a href='display_homes_lexington.aspx'>More information</a>&nbsp;|&nbsp;<a href='http://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=Cobaki+Place,+Lakelands,+WA&aq=&sll=-32.593106,117.553711&sspn=6.89374,9.876709&ie=UTF8&hq=&hnear=Cobaki+Brace,+Lakelands+Western+Australia+6180&z=17' target='_blank'>Get directions</a></div></div>");
		
		//http://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=Romano+Crescent,+Iluka,+Western+Australia&aq=0&sll=-32.475457,115.758424&sspn=0.012255,0.018325&ie=UTF8&hq=&hnear=Romano+Crescent,+Iluka+Western+Australia+6028&z=16
		dWestmont = CreateMarker(-32.475457,115.758424, "<div class='markerInfo'><h2>The Westmont</h2><img src='images/display_homes/westmont.jpg' alt='The Westmont' class='markerThumb' /><h3>Location</h3><p>Romano Crescent, Iluka</p><div><a href='display_homes_Westmont.aspx'>More information</a>&nbsp;|&nbsp;<a href='http://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=Romano+Crescent,+Iluka,+Western+Australia&aq=0&sll=-32.475457,115.758424&sspn=0.012255,0.018325&ie=UTF8&hq=&hnear=Romano+Crescent,+Iluka+Western+Australia+6028&z=16' target='_blank'>Get directions</a></div></div>");
		//http://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=Alkimos,+Western+Australia&aq=&sll=-31.629322,115.687931&sspn=0.049476,0.073299&ie=UTF8&hq=&hnear=Alkimos+Western+Australia&z=14
		dAlkimos = CreateMarker(-31.629322,115.687931, "<div class='markerInfo'><h2>The Alkimos</h2><img src='images/telethon/telethon_2010.jpg' alt='The Alkimos' class='markerThumb' /><h3>Location</h3><p>Shipmaster Avenue, Alkimos</p><div><a href='display_homes_alkimos.aspx'>More information</a>&nbsp;|&nbsp;<a href='http://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=Alkimos,+Western+Australia&aq=&sll=-31.629322,115.687931&sspn=0.049476,0.073299&ie=UTF8&hq=&hnear=Alkimos+Western+Australia&z=14' target='_blank'>Get directions</a></div></div>");

		//Add markers
		map.addOverlay(dMichigan);
		map.addOverlay(dStanford);
		map.addOverlay(dLexington);
		map.addOverlay(dWestmont);
		map.addOverlay(dAlkimos);
		  
		//Add Controls, remove Scale
		var customUI = map.getDefaultUI();
		customUI.controls.scalecontrol = false;
		map.setUI(customUI);

      }
    }
	
	//Go to the Michigan when this function is called
    function gotoMichigan() {    
	  closeAll();
	  
      var center = new GLatLng(-32.109447,115.951695);
	  map.panTo(center);
	  GEvent.trigger(dMichigan, "click");
	}
	
	
	//Go to the Stanford when this function is called
    function gotoStanford() {    
	  closeAll();

      var center = new GLatLng(-31.886323,115.818354);
	  map.panTo(center);
	  GEvent.trigger(dStanford, "click");
	}
	function gotoLexington(){
	closeAll();
	      var center = new GLatLng(-25.335448,135.745076);
	  map.panTo(center);
	  GEvent.trigger(dLexington, "click");
	}
	function gotoAlkimos(){
	closeAll();
	      var center = new GLatLng(0,0);
	  map.panTo(center);
	  GEvent.trigger(dAlkimos, "click");
	}
	function gotoWestmont(){
	closeAll();
	      var center = new GLatLng(0,0);
	  map.panTo(center);
	  GEvent.trigger(dWestmont, "click");
	}
	
	
	function closeAll(){
        dMichigan.closeInfoWindow();
        dStanford.closeInfoWindow();
        dLexington.closeInfoWindow();
        dWestmont.closeInfoWindow();
        dAlkimos.closeInfoWindow();
	}
