function recogeDatos(){
 	  $('#formu').fadeOut(function(){
	   $('#formu').html('Insertando...')							 
	  }).fadeIn('slow')
      $.ajax({
         type: "POST",
         url: "inserta_visitas.php",
         data: 	"&nombre="+($("#nombre").val())+
		 		"&ciudad="+($("#ciudad").val())+
		 		"&edad="+($("#edad").val())+
		 		"&email="+($("#email").val())+
		 		"&conocistepor="+($("#conocistepor").val())+
		 		"&opinion="+($("#opinion").val())+
		 		"&mensaje="+($("#descripcion").val()),
         success: function(msg){
			test = msg+'x'
			if (test == 'x' ){
				$('#formu').fadeOut(function (){
		 			$('#formuGracias').append(msg).fadeIn('slow')											  
				})
	  		} else {
				$('#formu').fadeOut(function (){
		 			$('#formuError').append(msg).fadeIn('slow')											  
				})
			}
         }
      });
}


$().ready(function() {
	$("#formulario").validate({			
		event: "keyup",
		submitHandler: function() {
			recogeDatos();
	 		return (false);
		},
		rules: {
			nombre: { required: true, minLength: 1},
			//apellido: { required: true, minLength: 1},
			//telefono: { required: true, number: true, minLength: 1},
			email: { required: true, email: true},
			//direccion: { required: true, minLength: 1},
			//localidad: { required: true, minLength: 1},
			//provincia: { required: true, minLength: 1},
			//cp: { required: true, number: true, minLength: 5},
			descripcion: { required: true, minLength: 1}
		},
		messages: {
			nombre: " ",
			apellido: " ",
			telefono: " ",
			email: " ",
			direccion: " ",
			localidad: " ",
			provincia: " ",
			cp: " ",
			descripcion: " "
		}
	});	
});