$(function(){
	
	var j = jQuery.noConflict();
	
	j("#cf_main form").validate({
    rules: {
      imie: "required",
      nazwisko: "required",
      telefon: {
				required: true,
				minlength: 9,
				digits: true
			},
      email: {
        required: true,
        email: true
      },
      ulica: "required",
      miasto: "required",
      kod_pocztowy_1: {
				required: true,
				minlength: 2,
				digits: true
			},
      kod_pocztowy_2: {
				required: true,
				minlength: 3,
				digits: true
			},
      zgoda: "required"
    },
		highlight: function(el, errorClass) {
			j(el).parents("p:first").find("span.error").show();
		},
		unhighlight: function(el, errorClass) {
			if ((el.name === "kod_pocztowy_1" || el.name === "kod_pocztowy_2") && (j(":text[name=kod_pocztowy_1]").val().match(/[^0-9]/) || j(":text[name=kod_pocztowy_2]").val().match(/[^0-9]/) || j(":text[name=kod_pocztowy_1]").val().length !== 2 || j(":text[name=kod_pocztowy_2]").val().length !== 3)) {
				j(el).parents("p:first").find("span.error").show();
			} else {
				j(el).parents("p:first").find("span.error").hide();
			}
			
		},
		errorPlacement:	function() {
			return false;
		}
  });
  
  

});

