var map = null;
var latLng = null;

$(document).ready(function(){	
    $("#pictures").easySlider({
		controlsShow: false,
        auto: true,
		continuous: true,
        pause: 6000,
        speed: 2000
    });
    $("#slide-text").easySlider({
		controlsShow: false,
        auto: true, 
		continuous: true,
		vertical: true,
        pause: 6000,
        speed: 2000
    });			
});

/* Para el Div de info  y error*/
function mostrardiv(div) {
	div = document.getElementById(div);
	div.style.display ='';
}

function cerrardiv() {
	div = document.getElementById(div);
	div.style.display='none';
}

function inicializarMapa(lat, lng) {
	latLng = new google.maps.LatLng(lat, lng);
	var options = {
	  zoom: 17,
	  center: latLng,
	  mapTypeId: google.maps.MapTypeId.HYBRID
	};
	map = new google.maps.Map(document.getElementById("map_canvas"), options);
	var markerOpts = {
		map: map,
		position: latLng,
		title: "Hostería Aymará"
	}
	marker = new google.maps.Marker(markerOpts);
}

function trazarRuta(address) {
	inicializarMapa(latLng.lat(), latLng.lng());
	var directionRequest = {
		origin: address,
		destination: latLng,
		travelMode: google.maps.DirectionsTravelMode.DRIVING
	};
	
	var directionsService = new google.maps.DirectionsService();
	directionsService.route(directionRequest,
		function(directionsResult, directionsStatus) {
			var rendererOpts = {
				directions: directionsResult,
				map: map
			}
			directionsRenderer = new google.maps.DirectionsRenderer(rendererOpts);
		}
	);
}

function trazarRutaOnEnter(idAddress) {
	$(idAddress).keyup(function(e) {
		if(e.keyCode == 13) {
			trazarRuta($(idAddress).val());
		}
	});
}
