
//Filtros para validar formulario
var filters = {
    requerido: function(el) {return ($(el).val() != '' && $(el).val() != -1);},
    email: function(el) {return /^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/.test($(el).val());},
    telefono: function(el){return /^[0-9]*$/.test($(el).val());}};
// Extensiones
$.extend({
	stop: function(e){
        if (e.preventDefault) e.preventDefault();
        if (e.stopPropagation) e.stopPropagation();
    }
});


$(document).ready(Iniciar);

function Iniciar(){
	ocultarPantalla(0);
	$("#bServicios").click(function(){location.href="servicios.php"});
	$("#bHabitaciones").click(function(){location.href="habitaciones.php"});
	$("#bPiscina").click(function(){location.href="piscina.php"});
	$("#bEntorno").click(function(){location.href="entorno.php"});
	$("#bubicacion").click(function(){location.href="ubicacion.php"});
	$("#Contacto").click(function(){location.href="contacto.php"});
	$("form.validable").bind("submit",function(e){
		// Validar Formulario
	    if (typeof filters == 'undefined') return;
	    $(this).find("input, textarea, select").each(function(x,el){
	        if ($(el).attr("className") != 'undefined') {
	             $.each(new String($(el).attr("className")).split(" "), function(x, klass){
	                   if ($.isFunction(filters[klass]))
	                   if (!filters[klass](el))  {
						   $(el).addClass("error");
					   } else {
						   $(el).removeClass("error");
					   }
	             });
	        }
	    });
		if ($(this).find(".error").size() > 0) {
			$.stop(e || window.event);
			return false;
		}
	    $.ajax({
            type: 'POST',
            url: $(this).attr('action'),
            data: $(this).serialize(),
            success: function(data) {
                // Imprimimos la respuesta en el div result
                $('#texto').html(data);

            }
        });
		$.stop(e || window.event);
		return false;
	});
}


function Verfoto(idfoto,ancho,alto){
	var margenx;
	var margeny;
	var foto;
	
	alto=alto+15;
	margenx=parseInt(ancho/2);
	margeny=parseInt(alto/2);
	foto="./img/" + idfoto;
	$("#pantalla2").css("width", ancho + "px");
	$("#pantalla2").css("height", alto + "px");
	$("#pantalla2").css("margin-top","-"+margeny+"px");
	$("#pantalla2").css("margin-left","-"+margenx+"px");
	$("#pantalla").show();
	$("#pantalla2").show("slow");
	$("#pantalla2").html('<img src="' + foto + '" alt="a"/><h5 onclick="ocultarPantalla(1);" style="cursor: pointer;">[ Cerrar ]</h5>');
}

function ocultarPantalla(velo){
	$("#pantalla").hide();
	if (velo==1) {
		$("#pantalla2").hide("slow");
	} else {
		$("#pantalla2").hide();
	};
}

function ComoLlegar(mobil){
		if (mobil=='avion'){
			$("#texto").html('<h4>Como llegar en avión.</h4><p>Vuelos de cabotaje al Aeropuerto San Luis por las siguientes compañías: Aerolíneas Argentinas, Andes Líneas Aéreas, Austral Líneas Aéreas, LADE (Líneas Aéreas del Estado), Lan Argentina y Sol Líneas Aéreas.</p><p>Luego en omnibus a la ciudad de Merlo.</p>');
		};
		if (mobil=='colectivo'){
			$("#texto").html('<h4>Como llegar en omnibus.</h4><p>Desde la ciudad de Buenos Aires y otros puntos del país por las siguientes empresas: 20 de Junio, Autotransporte San Juan, Central Argentino, Chevallier, Dumas, El Rápido, El Turista, Expreso Jocolí, La Estrella, El Cóndor S.R.L., TAC y Uspallata.</p><p>Desde otros puntos del país por las siguientes empresas: Andesmar, Autotransporte Socasa, Expreso Uspallata, Sur y Media Agua, Transporte Villa María</p>');
		};
		if (mobil=='auto'){
			$("#texto").html('<h4>Como llegar en auto.</h4><ul><li>Desde San Francisco del Monte de Oro (San Luis):RN 146</li><li>Desde Villa Mercedes, La Toma, Concarán y Santa Rosa de Conlara (San Luis): RN 148, RP 20 (San Luis) y RN 7</li><li>Desde Merlo (San Luis):RP 5 (San Luis), RN 148, RP 20 (San Luis) y RN 7</li><li>Desde la Provincia de Buenos Aires:RN 7</li><li>Desde las Provincias de Salta, Jujuy, Tucumán, Santiago del Estero:RN 9, RN 20 y RN 146</li><li>Desde las Provincias de Formosa, Chaco y Santa Fe:RN 11, RN 19, RN 20 y RN 146</li><li>Desde las Provincias de Misiones, Corrientes y Entre Ríos:RN 12, RN 168, RN 19, RN 20 y RN 146</li><li>Desde las Provincias de Catamarca y La Rioja:RN 38, RP 15 (Córdoba), RN 20 y RN 146</li><li>Desde la Provincia de Mendoza:RN 7</li><li>Desde la Provincia de San Juan:RN 20 y RN 147</li><li>Desde la Provincia de Córdoba:RN 20 y RN 146</li><li>Desde la Provincia de la Pampa:RN 35 y RN 7</li><li>Desde la Patagonia Andina:RN 40, RN 258, RN 237, RN 22, RN 151, RN 143, RP 153 (Mendoza) y RN 146</li><li>Desde la Patagonia Atlántica:RN 3, RN 35 y RN 7</li></ul>');
		};
		if (mobil=='alta'){
			$("#texto").html('<h4>Tarífa Temporada Alta</h4><p>Consultar</p>');
		};
		if (mobil=='media'){
			$("#texto").html('<h4>Tarífa Temporada media</h4><p>Consultar</p>');
		};
		if (mobil=='baja'){
			$("#texto").html('<h4>Tarífa Temporada baja</h4><p>Consultar</p>');
		};
}
