/**
 * Filename: googlemap.js
 * Purpose:  Provides Google Map functions
 * Author:   Andrew Hennessy http://www.andrewhennessy.com.au
 * 			 Last Modified 24 April 2010
 *			 Copyright (c) Andrew Hennessy 2007-2010.
 */

   //<![CDATA[

	var map        = null;
	var mapmode    = G_NORMAL_MAP;   //G_NORMAL_MAP, G_SATELLITE_MAP or G_HYBRID_MAP           
	var brunylat   = -43.29519939210697;
	var brunylng   = 147.26348876953125;
	var brunyzoom  = 11;
	var showLatLng = false;
	
	function Property() {
		this.name = "";
		this.description = "";
		this.imgurl = "";
		this.url = "";
		this.lat = 0;
		this.lng = 0;
	}
	
	function Property(name, lat, lng, description, url, imgurl) {
		this.name = name;
		this.description = description;
		this.imgurl = imgurl;
		this.url = url;
		this.lat = lat;
		this.lng = lng;
	}
	
	var explorers    = new Property("Explorers Cottages", -43.36515692789438, 147.22314834594727, "2 bedroom Explorers Cottages offer 3&frac12; star comfort and sleep up to 4 guests. Each has a private balcony and cosy log fire. ", "../accommodation/explorers.php", "../images/accom_home_explorers.jpg");
	var expvilla     = new Property("Explorers Villa", -43.36515692789438, 147.22314834594727, "This self contained, self catering villa is fitted out with a gourmet kitchen, HD LCD DVD TV, iPod dock and private Laundry facilities. Ideal for 1 or 2 couples to relax and enjoy the island.  ", "../accommodation/explorers-villa.php", "../images/accom_home_explorers_villa.jpg");
	var apollobay    = new Property("292 Apollo Bay", -43.15950369710293, 147.28840112686157, "This private waterfront retreat offers stunning views of Apollo Bay from almost every room! 3 bedroom, sleeping up to 6 guests.", "../accommodation/apollobay.php", "../images/accom_home_apollo.jpg");
	var maxys        = new Property("Maxy's By The Sea", -43.330047755144584, 147.23973512649536, "Absolute waterfront 3 bedroom retreat looking over Sunset Bay and Satellite Island. Sleeps up to 5 guests. ", "../accommodation/maxys.php", "../images/accom_home_maxys.jpg");
	var oystercatch  = new Property("Oyster Catcher Villa", -43.30289054518355, 147.25147247314453, "Perched up on a small hill in the township of Alonnah, the property takes in amazing views of the D'Entrecasteaux Channel, Satellite Island, The Hartz Mountain Ranges and beyond. Sleeps up to 2 guests. ", "../accommodation/oystercatcher.php", "../images/accom_home_oystercatcher.jpg");
	var sandpiper    = new Property("Sand Piper Studio", -43.30057158929237, 147.25988388061523, "Situated in Bruny Island's main township of Alonnah, this property takes in amazing views of the D'Entrecasteaux Channel, Satellite Island, The Hartz Mountain ranges and beyond. Sleeps up to 2 guests. ", "../accommodation/sandpiper.php", "../images/accom_home_sandpiper.jpg");
    var beachfront   = new Property("Beachfront On Bruny", -43.206, 147.383, "This unique accommodation offers stunning views of Great Bay. With a cosy log fire, it is ideal for a relaxing break for two. ", "../accommodation/beachfront-on-bruny.php", "../images/accom_home_beachfront.jpg");
	var aquarius     = new Property("Aquarius Retreat", -43.433, 147.182, "This two bedroom, architect designed home boasts direct access to the beach front and sits on a 100 acres with spectacular views out over Mickey's Bay. ", "../accommodation/aquarius-retreat.php", "../images/accom_home_aquarius.jpg");
	var allangels    = new Property("All Angels Church House", -43.358, 147.233, "Built in 1912, the church overlooks peaceful Daniels Bay. It includes the original cathedral ceilings and a cosy log fire. ", "../accommodation/allangels.php", "../images/accom_home_allangels.jpg");
	var umbrella     = new Property("Umbrella Point Retreat", -43.148, 147.304, "Just 10 minutes from the ferry, this private waterfront retreat sits on a large private block with direct access to the water. 3 bedrooms and huge living areas. ", "../accommodation/umbrella-point-retreat.php", "../images/accom_home_umbrella_point.jpg");
	

	function loadMap() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
		//map.addControl(new GSmallMapControl());
		
		if (showLatLng == true) {
			map.addControl(new GMapTypeControl());
			GEvent.addListener(map, "moveend", function() {
			  var center = map.getCenter();
			  document.getElementById("message").innerHTML = center.toString();
			});
		}
		
		map.setCenter(new GLatLng(brunylat, brunylng), brunyzoom, mapmode);
		
		map.addOverlay(newDualHouseMarker(explorers, expvilla));
		//map.addOverlay(newHouseMarker(apollobay));
		map.addOverlay(newHouseMarker(maxys));
		map.addOverlay(newHouseMarker(beachfront));
		map.addOverlay(newHouseMarker(aquarius));
		map.addOverlay(newHouseMarker(allangels));
		map.addOverlay(newHouseMarker(umbrella));
		map.addOverlay(newDualHouseMarker(oystercatch, sandpiper));
	
      }
    }
	
	function newIcon(imageName) {
		var icon        	  = new GIcon();
		icon.image      	  = "../images/" + imageName + ".png";
		icon.shadow     	  = "../images/" + imageName + "-shadow.png";
		icon.iconSize   	  = new GSize(32.0, 32.0);
		icon.shadowSize 	  = new GSize(49.0, 32.0);
		icon.iconAnchor 	  = new GPoint(16.0, 16.0);
		icon.infoWindowAnchor = new GPoint(16.0, 16.0);
		return icon;
	}
	
	function newHouseMarker(property) {
		var icon   = newIcon("house");
		var marker = new GMarker(new GLatLng(property.lat, property.lng), icon);
		
		var html = '<div class="MapInfoWindow">';
		html += '<p><strong>' + property.name + '</strong></p>';
		if (property.imgurl.length > 0) {
			html += '<img src="' + property.imgurl + '" height="75" width="100" alt="' + property.name + '" class="MapInfoWindowPic" />';
		}
		html += '<p>' + property.description + '</p>';
		html += '<p><small><a href="' + property.url + '">More information</a></small></p>';
		html += '</div>';
		
		GEvent.addListener(marker, 'click', function(){marker.openInfoWindowHtml(html);} );
		return marker;
	}
	
	function newDualHouseMarker(property, property2) {
		var icon   = newIcon("houses");
		var marker = new GMarker(new GLatLng(property.lat, property.lng), icon);
		
		var height = 120;
		if (property2 != null) {
			height = 250;
		}
		
		var html = '<div class="MapInfoWindow" style="height: ' + height + 'px; ">';
		html += '<p><strong>' + property.name + '</strong></p>';
		if (property.imgurl.length > 0) {
			html += '<img src="' + property.imgurl + '" height="75" width="100" alt="' + property.name + '" class="MapInfoWindowPic" />';
		}
		html += '<p>' + property.description + '</p>';
		html += '<p><small><a href="' + property.url + '">More information</a></small></p>';
		if (property2 != null) {
			html += '<p>&nbsp;</p>';
			html += '<p><strong>' + property2.name + '</strong></p>';
			if (property.imgurl.length > 0) {
				html += '<img src="' + property2.imgurl + '" height="75" width="100" alt="' + property.name + '" class="MapInfoWindowPic" />';
			}
			html += '<p>' + property2.description + '</p>';
			html += '<p><small><a href="' + property2.url + '">More information</a></small></p>';
		}
		html += '</div>';
		
		GEvent.addListener(marker, 'click', function(){marker.openInfoWindowHtml(html);} );
		return marker;
	}

    //]]>