$(document).ready(function(){
	
	
/* Formulario de contactenos */

$("#contactenos").submit(function(){
		$(".error").hide();
		var hasError = false;
		// campos del form
		
		/* Datos del usuario */
		var nameToVal = $('#name').val();
		var emailToVal = $('#email').val();
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var commentToVal = $('#comment').val();

		// validaciones   -------------------------------------------
		/* Datos del cliente */
		if(nameToVal == '')
		{
			/*$("input[name='name']").after('<span class="error"> *</span>');*/
			hasError = true;
		}

		/*if(telefonoToVal == '')
		{
			hasError = true;
		}*/
		
		if(emailToVal == '')
		{
			/*$("input[name='email']").after('<span class="error"> *</span>');*/
			hasError = true;
		} else if(!emailReg.test(emailToVal)) {
			$("input[name='email']").after('<span class="error"> ponga un correo v&aacute;lido</span>');
			hasError = true;
		}
		
		if(commentToVal == '')
		{
			/*$("input[name='comment']").after('<span class="error"> *</span>');*/
			hasError = true;
		}
		
		if(hasError == true)
		{
			alert('Debe llenar todos los campos');
			return false;		
		}
		else 
		{		
			return true;
		}
	});
	
	
	$("#sugerencias").submit(function(){
		$(".error").hide();
		var hasError = false;
		// campos del form
		
		/* Datos del usuario */
		
		var commentToVal = $('#comment').val();

		// validaciones   -------------------------------------------
		
		
		if(commentToVal == '')
		{
			hasError = true;
		}
		
		if(hasError == true)
		{
			alert('Debe poner un comentario');
			return false;		
		}
		else 
		{		
			return true;
		}
	});
	
	
	$("#cotizacion").submit(function(){
		$(".error").hide();
		var hasError = false;
		// campos del form
		
		/* Datos del usuario */
		
		var identificacionToVal = $('#identificacion').val();
		var nombreToVal = $('#nombre').val();
		var ciudadToVal = $('#ciudad').val();
		var telToVal = $('#tel').val();
		var celToVal = $('#cel').val();
		var emailToVal = $('#email').val();
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var qtyToVal = $('#qty').val();
		var datepickerToVal = $('#datepicker').val();
		
		// validaciones   -------------------------------------------
				
		if(identificacionToVal == '')
		{
			hasError = true;
			alert('Debe poner la su n&uacute;mero de usuario');
		}
		
		if(nombreToVal == '')
		{
			hasError = true;
			alert('Debe poner su nombre completo');
		}
		
		if(ciudadToVal == '')
		{
			/*hasError = true;*/
		}
		
		if(telToVal == '')
		{
			hasError = true;
			alert('Debe poner el telefono de habitacion');
		}
		
		if(celToVal == '')
		{
			/*hasError = true;*/
		}
		
		if(emailToVal == '')
		{
			/*$("input[name='email']").after('<span class="error"> *</span>');*/
			hasError = true;
		} else if(!emailReg.test(emailToVal)) {
			//$("input[name='email']").after('<span class="error"> ponga un correo v&aacute;lido</span>');
			alert('Ponga un correo valido');
			hasError = true;
		}
		
		if(qtyToVal == '')
		{
			hasError = true;
			alert('Debe poner la cantidad de personas');
		}
		
		if(datepickerToVal == '')
		{
			hasError = true;
			alert('Debe poner la fecha');
		}
		
		if(hasError == true)
		{
			return false;		
		}
		else
		{		
			return true;
		}
	});
	
	$('#categoria').change(function(){	
		switch($('#categoria').val())
		{
			case 'Socio':
				$("label[for='identificacion']").html('N&uacute;mero');
			break;
			case 'Accionista':
				$("label[for='identificacion']").html('N&uacute;mero');
			break;
			case 'Particular':
				$("label[for='identificacion']").html('C&eacute;dula');	
			break;
			default:
				alert('Error!');
		}
	});
	
	$('#zone_select').change(function(){	
		var zone = $('#zone_select').val();
		
		if(zone=='0'){
			$('.selectable_zones').show();
		}
		else{
			$('.selectable_zones').hide();
		}
		
		$("."+zone).show();
	});
	
	$("#zone_form").submit(function(){
		var datepickerToVal = $('#datepicker').val();
		var tel_contactoToVal = $('#tel_contacto').val();
		
		if(datepickerToVal == '')
		{
			alert('Debe seleccionar el dia');
			
			return false;
		}
		
		if(tel_contactoToVal == '')
		{
			alert('Debe poner un telefono');
			
			return false;
		}
	});
	
	$("#evento_form").submit(function(){
		var tel_contactoToVal = $('#tel_contacto').val();
		
		if(tel_contactoToVal == '')
		{
			alert('Debe poner un telefono');
			
			return false;
		}
	});
	
});