jQuery(function($) {

	$(".widget .jCarouselLite").jCarouselLite({

	    btnNext: ".widget .next",

	    btnPrev: ".widget .prev",

	    visible: 4,

	    vertical: true

	});

	$(".widget a").click(function() {

		$(".widget .foto_details img").attr("src", $(this).attr("href"));

		return false;

	});

	calendarioEvento();

});



function calendarioEvento() {

	$(".details table.calendario td.disponible").click(function() {	

		var tipo = $("#inputEntrada").attr("value")!="" ? "inputSalida" : "inputEntrada";

		$("#"+tipo).attr("value", $(this).attr("title"));

		$("#d"+tipo).attr("html", $(this).attr("title"));

		enviarForm();

	});

	$("td.entrada, td.salida, td.tramo, #calReiniciar").click(function() {

		$("#inputEntrada, #inputSalida").attr("value", "");

		enviarForm();

	});

}



function enviarForm() {

	var gets = $("#frmReserva").serialize();

	$("#calendarioEvento .tEvento").fadeOut("fast", function() {

		$("#calendarioEvento .tEvento").html("<div id=\"cargando\">Cargando fechas de salida, por favor, espere</div>");

		$("#calendarioEvento .tEvento").load("ajax/calendario.php?"+gets, function() {

			calendarioEvento();

			$("#calendarioEvento .tEvento").fadeIn("fast");

		});	

	});

	return false;

}

