function validaFormulario(form) {
 	
	jQuery.validator.addMethod("password", function( value, element ) {
		var result = this.optional(element) || value.length >= 4;
		if (!result) {
			element.value = "";
			var validator = this;
			setTimeout(function() {
				validator.blockFocusCleanup = true;
				element.focus();
				validator.blockFocusCleanup = false;
			}, 1);
		}
		return result;
	}, "Password short. Please, input four or more characters.");
	
	// a custom method making the default value for companyurl ("http://") invalid, without displaying the "invalid url" message
	jQuery.validator.addMethod("defaultInvalid", function(value, element) {
		return value != element.defaultValue;
	}, "");
	
	jQuery.validator.messages.required = "";
	
	
		$('#'+form).bind("invalid-form.validate", function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = errors == 1
					? 'Field was found not completed. Check the Red mark.'
					: 'Fields were found not met. Check the marking Red.';
				
				$('#'+form+" div.error span").html(message);
				alert('Fields were found not met. Check the marking Red.');
				$('#'+form+" div.error").show();
			} else {
				$('#'+form+" div.error").hide();
			}
		}).validate({
			//focusInvalid: false,
			//focusCleanup: true,
			onkeyup: false,
			messages: {
				password2: {
					required: " ",
					equalTo: "Re-type Password"	
				},
				email: {
					required: " ",
					email: "Invalid e-mail."
				}
			},
			debug:false
		});

	
  $(".resize").vjustify();
  $("div.buttonSubmit").hoverClass("buttonSubmitHover");

  if ($.browser.safari) {
    $("body").addClass("safari");
  }
  
  $('#'+form+" input.phone").mask("(99)9999-9999");
  $('#'+form+" input.zipcode").mask("99.999-99");
  $('#'+form+" input.cpf").mask("999.999.999-99");
  $('#'+form+" input.cnpj").mask("99.999.999/9999-99");
  
};

$.fn.vjustify = function() {
    var maxHeight=0;
    $(".resize").css("height","auto");
    this.each(function(){
        if (this.offsetHeight > maxHeight) {
          maxHeight = this.offsetHeight;
        }
    });
    this.each(function(){
        $(this).height(maxHeight);
        if (this.offsetHeight > maxHeight) {
            $(this).height((maxHeight-(this.offsetHeight-maxHeight)));
        }
    });
};

$.fn.hoverClass = function(classname) {
	return this.hover(function() {
		$(this).addClass(classname);
	}, function() {
		$(this).removeClass(classname);
	});
};