jQuery(function($){
  
  $('#paszekContact_company_or_client_name').parents('form').validate({
    rules: {"paszekContact[company_or_client_name]":{"required":true},"paszekContact[email]":{"required":true,"email":true},"paszekContact[content]":{"required":true},"paszekContact[captcha]":{"required":true}},
    messages: {"paszekContact[company_or_client_name]":{"required":"Please enter yours name\/lastname or company name"},"paszekContact[email]":{"required":"Pease enter email address","email":"Please enter valid email address."},"paszekContact[content]":{"required":"Please enter message content"},"paszekContact[captcha]":{"required":"Please enter the image info","length":function(a, elem){ return '\\\"' + $(elem).val() + '\\\" must be %length% characters long.';}}},
    wrapper: 'ul class=error_list',
    errorElement: 'li',
    errorPlacement: function(error, element) 
    {
     if(element.parents('.radio_list').is('*') || element.parents('.checkbox_list').is('*'))
     {
       error.prependTo( element.parent().parent().parent() );
     }
     else
     {
       error.prependTo( element.parent() );
     }
   }
  
  });
  
  
});

/* for some reason the jQuery Validate plugin does not incluce a generic regex method */
jQuery.validator.addMethod(
  "regex",
  function(value, element, regexp) {
      if (regexp.constructor != RegExp)
          regexp = new RegExp(regexp);
      else if (regexp.global)
          regexp.lastIndex = 0;
      return this.optional(element) || regexp.test(value);
  },
  "Invalid."
);