$(document).ready(function(){
	$('#sendContactForm').submit(function() {
		$('#phone').each(function() {
			this.value = this.value.toString().split(" ").join("").split("-").join("").split("+").join("00");
		});
	});

	$.validator.addMethod(
		"regex",
		function(value, element, regexp) {
			var check = false;
			var re = new RegExp(regexp);
			return this.optional(element) || re.test(value);
		},
		"pole musi zawierać tylko litery"
	);
		
	$('#sendContactForm').validate({
		rules: {
			name : {
				required: true
			},
			company : {
				required: true
			},
			email : {
				required: true,
				email: true
			},
			captcha : {
				required: true,
				minlength: 5,
				maxlength: 5,
				//remote: mainUrl + "check/captcha.html"
			},
			fax : {
				number: true
			},
			content : {
				required: true
			},
			subject : {
				required: true
			}
		},
		messages: {
			name: {
				required: translate('required_name')
			},
			company : {
				required: translate('required_company')
			},
			email: {
				required: translate('required_email'),
				email: translate('invalid_email')
			},
			content: {
				required: translate('required_message')
			},
			captcha: {
				required: translate('required_captcha'),
				minlength: translate('too_short_captcha'),
				maxlength: translate('too_long_captcha'),
				//remote: translate('incorrect_captcha')
			},
			subject: {
				required: translate('required_subject')
			}
		},
		errorElement: "p",
		errorClass: "warning"
	});
	
	
});