jQuery(document).ready(function(){

jQuery("#registro_exitoso").css("display","none");
jQuery("#loading").css("display","none");

jQuery("#invAmigo").validate({
        rules: {
			nombre: {
				required: true,
				minlength: 3,
				maxlength: 100
			},
			mailPart: {
			     required: true,
			     email: true,
			     minlength: 3,
			     maxlength: 100
			},
			apellidPatPart: {
				required: true,
				minlength: 3,
				maxlength: 100
			},
			mailAmigo: {
			     required: true,
			     email: true,
			     minlength: 3,
			     maxlength: 100
			},
			telAmigo: {
				required: true,
				minlength: 3,
				maxlength: 20
			},
			comment: {
			     minlength: 3,
			     required: false
			}
        },
	messages: {
		nombre: "",
		mailPart: "",
		apellidoPatPart: "",
		mailAmigo: "",
		telAmigo: "",
		comment: ""
	},
	submitHandler: function() {
		jQuery("#invAmigo").ajaxSubmit({
			beforeSubmit:  showRequest,  // pre-submit callback 
			success:       showResponse  // post-submit callback
		});
	
	},
	highlight: function(element, errorClass) {
	    //jQuery(element).addClass('error');
	},
	unhighlight: function(element, errorClass){
	  //jQuery(element).removeClass('error');
	}
    });

	jQuery("#loading").ajaxStart(function(){
	   jQuery(this).show();
	 });

	function showRequest(formData, jqForm, options) { 
		jQuery("#loading").hide("slow");
	}

	// post-submit callback 
	function showResponse(responseText, statusText)  { 
		jQuery("#loading").hide("slow");
		jQuery("#registro_exitoso").empty();
		jQuery("#registro_exitoso").show("slow").append(responseText).fadeTo(3000, 1).fadeOut(2000);
		//jQuery("#enviar").removeAttr("disabled");
		//jQuery('#borrar').click();
		//jQuery('#resetInscInc').click();
		//alert("Gracias por su Inscripción");
		//jQuery('#gracias').show();
		jQuery('form')[1].reset();
	}
});