// JavaScript Document
function validar_contacta_columna()//Validación del formulario contacta
{
	var Ok=false;
	if (document.getElementById("txtnombre").value=="" || document.getElementById("txtnombre").value=="nombre" || document.getElementById("txtapellidos").value=="" || document.getElementById("txtapellidos").value=="apellidos" || document.getElementById("txtemail").value=="email" || document.getElementById("txtemail").value=="") 
	{
		MensajeShadow("* campos obligatorios.");
		return false;
	}
	else
	{
		document.formcontacta.f_llegada.value = document.formcontacta.f_ini.value;
		document.formcontacta.f_salida.value = document.formcontacta.f_fin.value;
/*		
		//Valido que fecha de llegada y fecha de salida no sean iguales:
		if((document.formcontacta.f_llegada.value == document.formcontacta.f_salida.value) && (document.getElementById("f_ini").value != "Desde" && document.getElementById("f_fin").value != "Hasta"))
		{
			MensajeShadow("Para hacer la consulta la fecha de salida no puede ser igual a la fecha de llegada, como mínimo una noche.");
			return false;
		}
*/		
		if(document.getElementById("txtemail").value != '' && document.getElementById("txtemail").value != 'email') Ok=esMail(document.getElementById("txtemail"));
		
		if(Ok == true && document.getElementById("txttelefono").value != "" && document.getElementById("txttelefono").value != "telefono")
		{
			if(document.getElementById("txttelefono").value.length<9 || document.getElementById("txttelefono").value.length>9)
			{
				MensajeShadow("El Tel\u00e9fono de contacto debe tener 9 d\u00edgitos.");
				document.getElementById("txttelefono").focus();
				return false;
			}
			else if(document.getElementById("txttelefono").value.length==9)
			{
				Ok=esTelefono(document.getElementById("txttelefono"));
				if(!Ok) return false;
			}
		}
		
		
		
		if(Ok == true)
		{
			Procesar_Shadow('img',URL()+'modulos/img/procesando.gif','70','70');
			document.formcontacta.submit();
		}
	}
}

function comprobar_fechas()
{
	var fecha_llegada, ok;
	
	ok=false;
	fecha_llegada = document.getElementById("f_ini").value;
	ok = (fecha_llegada == "Llegada") ? false : true;
	
	return ok;
}

$(function(){
	$("#f_ini,#f_fin").datepicker({ 
		showButtonPanel: true,
		changeMonth: true,
		changeYear: true,
		beforeShow: customRange, 
		showOn: "both", 
		buttonImage: URL()+"includes/calendario-jquery/images/calendar.gif", 
		buttonImageOnly: true 
	});
});

function customRange(input) 
{ 
	switch(input.id)
	{
		case "f_ini":
			if(input.value!="Desde")
			{
				if(document.getElementById("f_fin").value!="Hasta")
					return {maxDate: $("#f_fin").datepicker("getDate")};
			
			}
			
			if(input.value == "Desde")
			{
				if(document.getElementById("f_fin").value!="Hasta")
					return {maxDate: $("#f_fin").datepicker("getDate"),minDate: $("#f_ini").datepicker("getDate")};
				else
					return {minDate: $("#f_ini").datepicker("getDate")};
			}
			break;
	
		case "f_fin":
			return {minDate: $("#f_ini").datepicker("getDate")};
			break;
	}//switch(input.id)
}//function customRange(input)
