var map;
var point;
var marker;
var html = '<b>Abbey Lodge Hotel</b>';
html += '<br>62 Kirkgate, Shipley, BD18 3EL<br>01274 583 854';
html += '<br>';
var new_html;
/*var abbeyIcon = new GIcon();
abbeyIcon.image = "/images/abbey_logo.png";
abbeyIcon.shadow = "/images/abbey_logo_shadow.png";
abbeyIcon.iconSize = new GSize(30, 15);
abbeyIcon.shadowSize = new GSize(40, 17);
abbeyIcon.iconAnchor = new GPoint(6, 20);
abbeyIcon.infoWindowAnchor = new GPoint(15, 0);
markerOptions = { icon:abbeyIcon };*/

function map_init(map_id) {
	var new_html = html+'<div id="google_marker_swap"><span style="font-size: 0.9em;"><a href="javascript: to_here(\'resize\');">Get Directions</a></span></div>';
	if (map_id != undefined)
	{
		map = new GMap2(document.getElementById(map_id));

		map.setCenter(new GLatLng(53.833531,-1.782101), 14);
		//map.setMapType(G_HYBRID_MAP);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());

		point = map.getCenter();
		//marker =  new GMarker(point, markerOptions);
		marker =  new GMarker(point);
		map.addOverlay(marker);

		var new_html = '<div id="google_marker">'+new_html+'</div>';

		marker.openInfoWindowHtml(new_html);

		GEvent.addListener(marker, 'click', function() {
	  		marker.openInfoWindowHtml(new_html);
		});
	}
	else
	{
		map.updateInfoWindow([new GInfoWindowTab('', new_html)]);
	}
}

function to_here(resize)
{
	var new_html = '<span style="font-size: 0.9em;">Get Directions: <b>To here</b> - <a href="javascript: from_here();">From here</a></span><br>';
	new_html += '<span style="font-size: 0.8em;">Start address</span>';
	new_html += '<form action="http://maps.google.co.uk" method="get" target="_blank" style="padding: 0px; margin: 0px;">';
	new_html += '<input type="hidden" name="daddr" value="BD18 3EL">';
	new_html += '<input type="text" size="20" maxlength="40" name="saddr" id="saddr" value="">&nbsp;<input type="submit" value="Go"><br>';
	new_html += '<a href="javascript: map_init();" style="font-size: 0.8em;">&laquo; Back</a>';
	new_html += '</form>';

	map.updateInfoWindow([new GInfoWindowTab('', html+new_html)]);
}

function from_here(resize)
{
	var new_html = '<span style="font-size: 0.9em;">Get Directions: <a href="javascript: to_here();">To here</a> - <b>From here</b></span><br>';
	new_html += '<span style="font-size: 0.8em;">End address</span>';
	new_html += '<form action="http://maps.google.co.uk" method="get" target="_blank" style="padding: 0px; margin: 0px;">';
	new_html += '<input type="hidden" name="saddr" value="BD18 3EL">';
	new_html += '<input type="text" size="20" maxlength="40" name="daddr" id="daddr" value="">&nbsp;<input type="submit" value="Go"><br>';
	new_html += '<a href="javascript: map_init();" style="font-size: 0.8em;">&laquo; Back</a>';
	new_html += '</form>';

	map.updateInfoWindow([new GInfoWindowTab('', html+new_html)]);
}
