
$(document).ready(function(){
$("#campoFormulario").validate({
        rules: {
            name: {
                required: true,
                minLength: 3,
                maxLength: 25
            },
            email: {
                required: true,
				email: true
            },
            company: {
                required: true,
                minLength: 3,
                maxLength: 200
            },
            phoneNumber: {
                required: true
            },
            comment: {
                required: true,
                minLength: 3,
                maxLength: 300
            }
        
        },
		messages: {
            name: "<img src='assets/images/bad-field.jpg' alt='x'>",
            email: {
                required: "<img src='assets/images/bad-field.jpg' alt='x'>",
				email: "<img src='assets/images/bad-field.jpg' alt='x'>",
				minlength: "<img src='assets/images/bad-field.jpg' alt='x'>"
            },
            phoneNumber: "<img src='assets/images/bad-field.jpg' alt='x'>",
            comment: "<img src='assets/images/bad-field.jpg' alt='x'>",
			company: "<img src='assets/images/bad-field.jpg' alt='x'>" 
        },
		submitHandler: function() {
			$("#campoFormulario").ajaxSubmit({
				beforeSubmit:  showRequest,  // pre-submit callback 
				success:       showResponse  // post-submit callback
				});
		
		},
		highlight: function(element, errorClass) {
	     $(element).addClass('errorClass');
		},
		unhighlight: function(element, errorClass){
		$(element).removeClass('errorClass');
		}
    });

	$("#loading").ajaxStart(function(){
	$("#contactSend").attr("disable","true");
	   $(this).show();
	 });
	

	function showRequest(formData, jqForm, options) { 

	} 

	// post-submit callback 
	function showResponse(responseText, statusText)  { 
		$("#loading").hide("slow");
		$("#response").show("slow").append(responseText).fadeTo(3000, 1).fadeOut(2000);
		$("#contactSend").attr("disable","false");
		$('#col1Form').find('input').each(function(){
			$(this).val('');
		});
		$('#col2Form').find('textarea').each(function(){
			$(this).val('');
		});
	}
});