// JavaScript Document
var maps;
	var directionsService = new google.maps.DirectionsService();
	var directionsDisplay = new google.maps.DirectionsRenderer();
	var infoWindow = new google.maps.InfoWindow({maxWidth: 150});
	
	var markerOffice = new google.maps.Marker({
		title: 'Hotel Orange',
		icon: 'img/marcador.png', // esta é uma imagem local
		position: new google.maps.LatLng('-7.809917', '-34.839854')
	});
	
	function initialize() {
		var options = {
				zoom: 15,
				center: markerOffice.position,
				mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		
		map = new google.maps.Map(document.getElementById("map_content"), options);
		
		markerOffice.setMap(map);
		
		
		google.maps.event.addListener(markerOffice, 'click', function() {
			infoWindow.setContent('Rua Srg. do Silvino Macêdo, 35 - Imbiribeira - Recife - PE, 51160-060, Brasil');
			infoWindow.open(map, markerOffice);
		}); 
	}
	
	$(document).ready(function() {
		$('#form_route').submit(function() {
			infoWindow.close();
			markerOffice.setMap(null);
			directionsDisplay.setMap(null);
			//directionsDisplay = new google.maps.DirectionsRenderer();
			
			var request = {
					origin: $("#route_from").val(),
					destination: markerOffice.position,
					travelMode: google.maps.DirectionsTravelMode.DRIVING
			};
			
			directionsService.route(request, function(response, status) {
					if (status == google.maps.DirectionsStatus.OK) {
						directionsDisplay.setDirections(response);
						directionsDisplay.setMap(map);
					}
			});
			
			return false;
		});
	});
