$(document).ready(function(){
		
        //Thickbox

 		//$("#frmReservar").validate();

        $('#frmReservar').submit(function(){
		
		$('#campo_fecha').removeClass("error");
		$('#campo_fecha2').removeClass("error");
		$('#habitaciones').removeClass("error");
		$("#msg_error").slideUp();
		if(!(($('#habitaciones').val() != '' && $('').val('#habitaciones') != -1  )
			&& /^[0-9]*$/.test($('#habitaciones').val())
		))
		{
			$('#habitaciones').addClass("error");
			
		}
		else{
			
			if (!(($('#campo_fecha').val() != '' && $('').val('#campo_fecha') != -1))) {
				$('#campo_fecha').addClass("error");
				
			}
			else {
				
				if (!(($('#campo_fecha2').val() != '' && $('').val('#campo_fecha2') != -1))) {
					$('#campo_fecha2').addClass("error");
					
				}
				else {
				
				
					$("p#lbl_fecha_entrada").html($("input#campo_fecha").val());
					$("#c_reservacion_fecha_ingreso").attr("value",$("input#campo_fecha").val());
					
					$("p#lbl_fecha_salida").html($("input#campo_fecha2").val());
					$("#c_reservacion_fecha_salida").attr("value",$("input#campo_fecha2").val());
					
					$("p#lbl_no_habitaciones").html($("input#habitaciones").val()+" habitaci&oacute;n(es)");
					$("#c_reservacion_no_habitaciones").attr("value",$("input#habitaciones").val());
					
					$("p#lbl_tipo_habitacion").html($("select#tipo_habitacion").val());
					$("#c_reservacion_tipo_habitacion").attr("value",$("select#tipo_habitacion").val());
					
					tb_show('Reservacion', 'TB_inline?height=500&width=600&inlineId=TBcontent');
					
					return false;
				}
			}	
		}
		$("#msg_error").html( "Rellene correctamente todos los campos");
		$("#msg_error").slideDown();
		return false;
        });
		
		
		
		$('#frmCompletarReservacion').submit(function(){
		
		$('#c_reservacion_nombre').removeClass("error");
		$('#c_reservacion_email').removeClass("error");
		$('#c_reservacion_telefono').removeClass("error");
		$('#c_reservacion_acepto').removeClass("error");
		$("#msg_error2").slideUp();
		if(!(($('#c_reservacion_nombre').val() != '' && $('').val('#c_reservacion_nombre') != -1  )
			
		))
		{
			$('#c_reservacion_nombre').addClass("error");
			$("#msg_error2").html( "El campo de Nombre es requerido");
		}
		else{
			
			if (!(($('#c_reservacion_email').val() != '' && $('').val('#c_reservacion_email') != -1)
			&& /^[A-Za-z\.][A-Za-z0-9_\.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/.test($('#c_reservacion_email').val())
			)) {
				$('#c_reservacion_email').addClass("error");
				$("#msg_error2").html( "Introduzca un email v&aacute;lido");	
			}
			else {
				
				if (!(($('#c_reservacion_telefono').val() != '' && $('').val('#c_reservacion_telefono') != -1)
				&& /^[0-9]*$/.test($('#habitaciones').val()) )) {
					$('#c_reservacion_telefono').addClass("error");
					$("#msg_error2").html( "Introduzca un n&uacute;mero telef&oacute;nico (solo caracteres num&eacute;ricos");
					
				}
				else {
					
					if (!($('#c_reservacion_acepto').attr('checked'))) {
						$('#acepto_leyenda').addClass("letras_error");
						$("#msg_error2").html("Debe aceptar que la informaci&oacute;n proporcionada es verdadera");
					}
					else {
					
						$('#frmCompletarReservacion').submit();
						
					}	
				}
			}	
		}
		
		$("#msg_error2").slideDown();
		return false;
        });

				
		 
        $('input#TBcancel').click(function(){

            tb_remove();

        });

 

        $('input#TBsubmit').click(function(){

            document.testconfirmTB.submit();

        });
		
		

});
