// JavaScript Document
jQuery.noConflict();
jQuery(document).ready(function()
{
		validator();
		/*process_form();*/
}); 



function validator(){
	jQuery("#contact_form").validate({
		submitHandler: function(form) {
			process_form(form.nazwisko.value, form.company.value, form.mail.value, form.tel.value, form.contact_message.value);
		}
	}); 
}

function process_form(nazwisko,company,mail,tel,contact_message){
	//alert ('process_form (imie='+imie+'nazwisko'+nazwisko+'firma'+firma+'email'+email+'telefon'+telefon+'haslo'+haslo);
	jQuery.ajax({
		type: 'POST',
		url: '/php/modules/sendmail/send_contact_form.php',
		data: 'nazwisko='+nazwisko+'&company='+company+'&mail='+mail+'&tel='+tel+'&contact_message='+contact_message,
		success: function(response){
			setTimeout(function(){
			}, 1500, throw_error(response));
		},
		error:
			function(xhr) {
			alert("error "+xhr.status+" "+xhr.statusText);
		}
	});
}

function throw_error(response){
	jQuery('#response').html(response);
	jQuery("#contact_form").hide();
	
}
