/*function initialize() 
{
	var latlng = new google.maps.LatLng(52.2144507595, -0.0486260836934);
	var myOptions = {
	zoom: 11,
	center: latlng,
	mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById("map"), myOptions);
	
	var html = "<div class=\"bubble\"><p><strong>Filcris Ltd.</strong><br>The Old Fire Station<br>Broadway<br>Bourn<br>Cambridge<br>CB3 7TE</p></div>";
	var infowindow = new google.maps.InfoWindow({
		content: html
	});
	
	var marker = new google.maps.Marker({
      position: latlng, 
      map: map, 
      title:"Filcris Ltd"
  });
	
	google.maps.event.addListener(marker, 'click', function() {
	  infowindow.open(map,marker);
	});
}*/


var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var location_map;
	
function initialize() {
	
	directionsDisplay = new google.maps.DirectionsRenderer();

	var location = new google.maps.LatLng(52.2144507595, -0.0486260836934);
	var centrepoint = new google.maps.LatLng(52.2144507595, -0.0486260836934);
	var location_options = {
		zoom: 11,
		center: centrepoint,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		mapTypeControl: true,
		navigationControl: true
	};

	location_map = new google.maps.Map(document.getElementById("map"), location_options);
	
	directionsDisplay.setMap(location_map);
	directionsDisplay.setPanel(document.getElementById("panel"));

	
	var location_marker = new google.maps.Marker({
		position: location, 
		map: location_map,
		title:"Realnet Limited"
	});
	
	var location_info_html = "<div style=\"width: 275px; height: 150px;\"><h3 style=\"width: 275px\">Filcris Ltd.</h3><p style=\"width: 100px;\">The Old Fire Station<br>Broadway<br>Bourn<br>Cambridge<br>CB3 7TE</p></div>";
	
	var location_info = new google.maps.InfoWindow({
		content: location_info_html
	});

	google.maps.event.addListener(location_marker, 'click', function() {
		location_info.open(location_map,location_marker);
	});
}

function overlayDirections()
{
	var start = document.getElementById("postcode").value;
	var end = new google.maps.LatLng(52.2144507595, -0.0486260836934);
	var request = {
		origin:start, 
		destination:end,
		travelMode: google.maps.DirectionsTravelMode.DRIVING,
		unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL,
		region: "GB"
	};
	directionsService.route(request, function(response, status) {
	if (status == google.maps.DirectionsStatus.OK) {
	  directionsDisplay.setDirections(response);
	}
	else
	{
		alert(status);	
	}
	});

	
}
