function initialize() {
    var latlng = new google.maps.LatLng(51.435534,-0.506192);
    var myOptions = { zoom: 15, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU }};
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);	
	var image = new google.maps.MarkerImage('img/icons/gmap.png', new google.maps.Size(50, 37), new google.maps.Point(0,0), new google.maps.Point(0, 37));
 	var shadow = new google.maps.MarkerImage('img/icons/shadow-gmap.png', new google.maps.Size(69, 37), new google.maps.Point(0,0), new google.maps.Point(0, 32));
	var shape = { coord: [1,36,28,1,50,0,45,24], type: 'poly'};
	var marker = new google.maps.Marker({ position: latlng, map: map, title: "Staines Central", zIndex: 2 });
}
function convert_postcode(postcode_in) {
	var postcode_out = "";
	for (i = 0; i < postcode_in.length; i++) { if (postcode_in.charAt(i) != " ") { postcode_out += postcode_in.charAt(i); } else { postcode_out += "+"; } }
	return postcode_out;
}	
function get_directions() {
	var chosen_postcode = "TW18 4EX";
	var entered_postcode = document.directions.enterpostcode.value;
	var converted_chosen_postcode = convert_postcode(chosen_postcode);
	var converted_entered_postcode = convert_postcode(entered_postcode);
	if (converted_entered_postcode == "" || converted_chosen_postcode == converted_entered_postcode || entered_postcode == "Enter postcode") {
		var oWin = window.open("http://maps.google.co.uk/maps?q="+converted_chosen_postcode, "_blank");
		if (oWin) { if (oWin.focus) oWin.focus(); return false; }
		oWin = null;	
	} else {	
		var oWin = window.open("http://maps.google.com/maps?saddr="+ converted_entered_postcode + "&daddr="+ converted_chosen_postcode +"&hl=en", "_blank");
		if (oWin) { if (oWin.focus) oWin.focus(); return false; }
		oWin = null;
	}		
}

$(document).ready(function() {
	$.fn.search = function() {
		return this.focus(function() { if( this.value == this.defaultValue ) { this.value = ""; } }).blur(function() { if( !this.value.length ) { this.value = this.defaultValue; } });
	};	
	if ($('#enterpostcode').length) { $('#enterpostcode').search();	}
});
	
	
