var map;
var gdir;
	function PlaneIcon() {
	}
	PlaneIcon.prototype = new GControl();
	PlaneIcon.prototype.initialize = function(map) {
	var container = document.createElement("div");
	this.setButtonStyle_(container);
	var img=document.createElement("IMG");
	img.src="../images/icon.png";
	if(window.ActiveXObject){
		img.attachEvent('onclick',function(){setDirections("上海街555号", "hong kong airport", "zh-CN")});
	}else{
		img.addEventListener('click',function(){setDirections("上海街555号", "hong kong airport", "zh-CN")}, false);
	 }
	container.appendChild(img);
	 map.getContainer().appendChild(container);
	 return container;
	 }
	 PlaneIcon.prototype.getDefaultPosition = function() {
		 return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(225, 0));
	 }
	 PlaneIcon.prototype.setButtonStyle_ = function(button) {  
	 button.style.backgroundColor = "transparent"; 
	 button.style.textAlign = "center";
	 button.style.cursor = "pointer";
	 button.style.border = "0";
	 }
	  function load() {
	 if (GBrowserIsCompatible()) {
	 map = new GMap2(document.getElementById("content"));
	 gdir = new GDirections(map, document.getElementById("directions"));
	 GEvent.addListener(gdir, "load", onGDirectionsLoad);
	 GEvent.addListener(gdir, "error", handleErrors);
	 map.addControl(new GSmallMapControl());
	 map.addControl(new GMapTypeControl());
	 map.setCenter(new GLatLng(22.318150305935045, 114.1681382060051),14);
	 var hotelicon = new GIcon(G_DEFAULT_ICON);
	 hotelicon.image = "../images/langham_logo.png";
	 iOptions = { icon:hotelicon};
	 var aIcon = new GIcon(G_DEFAULT_ICON);
	 aIcon.image = "../images/a_icon.png";
	 aOptions = { icon:aIcon};
	 var bIcon = new GIcon(G_DEFAULT_ICON);
	 bIcon.image = "../images/b_icon.png";
	 bOptions = { icon:bIcon};
	 var cIcon = new GIcon(G_DEFAULT_ICON);
	 cIcon.image = "../images/c_icon.png";
	 cOptions = { icon:cIcon};
	 var dIcon = new GIcon(G_DEFAULT_ICON);
	 dIcon.image = "../images/d_icon.png";
	 dOptions = { icon:dIcon};
	 var eIcon = new GIcon(G_DEFAULT_ICON);
	 eIcon.image = "../images/e_icon.png";
	 eOptions = { icon:eIcon};
	 var fIcon = new GIcon(G_DEFAULT_ICON);
	 fIcon.image = "../images/f_icon.png";
	 fOptions = { icon:fIcon};
	 var gIcon = new GIcon(G_DEFAULT_ICON);
	 gIcon.image = "../images/g_icon.png";
	 gOptions = { icon:gIcon};
	 var hIcon = new GIcon(G_DEFAULT_ICON);
	 hIcon.image = "../images/h_icon.png";
	 hOptions = { icon:hIcon};
	 var transportationIcon = new GIcon(G_DEFAULT_ICON);
	 transportationIcon.image = "../images/transportation_icon.png";
	 markerOptionsTransportation = { icon:transportationIcon };
	 var point = new GLatLng(22.318150305935045, 114.1681382060051);
	 map.addOverlay(createMarker(point, iOptions,0));
	 var point1 = new GLatLng(22.318328958218867,114.16799873113632);
map.addOverlay(createMarker(point1, bOptions,1));

	 var point2 = new GLatLng(22.31818008133157,114.16811406612396);
map.addOverlay(createMarker(point2, bOptions,2));

	 var pointDefault = new GLatLng(22.318150305935045, 114.1681382060051);

	 var mark = new GMarker(pointDefault,iOptions);
	 map.addOverlay(mark);
	 mark.openInfoWindowHtml("<div style=\"font:Arial, Helvetica, sans-serif;font-size:10px;color:#3F454F;text-autospace : ideograph-alpha;width:300px\"><table border=\"0\"><tr><td><b>香港旺角朗豪酒店<br>Address: 上海街555号<br>Tel: (852) 3552 3388</b></td><td><img src=\"../images/hotel.jpg\"></td></tr></table></div>");
	 map.addOverlay(createMarker(pointDefault, iOptions,0));
	 map.addControl(new PlaneIcon());

	 }
	 }
 function createMarker(point, number,index) {
	 var marker = new GMarker(point,number);

	 switch (index)
	 {

case 0:	 GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("<div style=\"font:Arial, Helvetica, sans-serif;font-size:10px;color:#3F454F;text-autospace : ideograph-alpha;width:350px\"><table border=\"0\"><tr><td><b>香港旺角朗豪酒店<br>Address: 上海街555号<br>Tel: ((852) 3552 3388</b></td><td><img src=\"../images/hotel.jpg\"></td></tr></table></div>");		 });
		 break; 

		 case 1:
		 GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("<div style=\"font:Arial, Helvetica, sans-serif;font-size:10px;color:#3F454F;text-autospace : ideograph-alpha;width:350px\"><table border=\"0\"><tr><td><b>The Backyard - Langham Place, Mongkok, Hong Kong</b><br> A beautiful al fresco terrace with sweet-scented mango trees under the glittering stars awaits you... A truly delightful discovery in the middle of Mongkok. Enjoy a balmy evening  of five star barbeques sizzle with sirloin steaks, beef short ribs, veal and pork sausages, lamb chops, salmon steaks and barramundi.</td></tr></table></div>");
	 });
	 break;

		 case 2:
		 GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("<div style=\"font:Arial, Helvetica, sans-serif;font-size:10px;color:#3F454F;text-autospace : ideograph-alpha;width:350px\"><table border=\"0\"><tr><td><b>Portal - Work & Play - Langham Place, Mongkok, Hong Kong</b><br> Spend the afternoon here and see just how effortlessly, a productive working day can segue into a lively and relaxing evening.</td></tr></table></div>");
	 });
	 break;

	 default : 
	 break;
 }
	 return marker;
}
	 function setDirections(fromAddress, toAddress, locale) {
	 if(fromAddress=="香港旺角朗豪酒店")
	 fromAddress = "上海街555号";
	 if(toAddress=="")return;	 gdir.load("from: " + fromAddress + " Hong Kong to: " + toAddress + " Hong Kong",{locale:"zh-CN"});
	 }

	 function handleErrors(){
	 if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	 else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	 alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	 else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	 alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
	 else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	 alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
	 else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	 alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	 else alert("An unknown error occurred.");
}
function onGDirectionsLoad(){
 }