jQuery(function(){
      jQuery('.error').hide();
      jQuery('.text-input').css({backgroundColor:"#FFFFFF"});
      jQuery('.text-input').focus(function(){
        jQuery(this).css({backgroundColor:"#FFDDAA"});
      });
      jQuery('.text-input').blur(function(){
        jQuery(this).css({backgroundColor:"#FFFFFF"});
      });

      jQuery("#PartnerRequest").submit(function() {
        jQuery('.error').hide();
            var company_name = jQuery("#company_name").val();
            company_name = jQuery.trim(company_name)
            if (company_name == "") {
              jQuery("#company_name_error").show();
              jQuery("#company_name").focus();
              return false;
            }
            var phone = jQuery("#phone").val();
            phone = jQuery.trim(phone)
            if (phone == "") {
              jQuery("#phone_error").show();
              jQuery("#phone").focus();
              return false;
            }
            var mail = jQuery("#mail").val();
            mail = jQuery.trim(mail)
            if (mail == "") {
              jQuery("#mail_error").show();
              jQuery("#mail").focus();
              return false;
            }
            var person_contact = jQuery("#person_contact").val();
            person_contact = jQuery.trim(person_contact)
            if (person_contact == "") {
              jQuery("#person_contact_error").show();
              jQuery("#person_contact").focus();
              return false;
            }
            
            var address = jQuery("#address").val();
            var www = jQuery("#www").val();
            var trade = jQuery("#trade").val();
            var clients = jQuery("#clients").val();
            var territory = jQuery("#territory").val();
            var resources = jQuery("#resources").val();
            var cooperation = jQuery("#cooperation").val();
            var cooperation_other = jQuery("#cooperation_other").val();
            
            var dataString = 'company_name='+ company_name + 
                '&phone=' + phone + 
                '&address=' + address + 
                '&www=' + www + 
                '&mail=' + mail + 
                '&person_contact=' + person_contact + 
                '&trade=' + trade + 
                '&clients=' + clients + 
                '&territory=' + territory + 
                '&resources=' + resources + 
                '&cooperation=' + cooperation +
                '&cooperation_other=' + cooperation_other;
            jQuery.ajax({
              type: "POST",
              url: "http://www.primesoft.pl/script/partner_request.php",
              data: dataString,
              success: function() {
                jQuery('#PartnerRequestForm').html("<div id='message'></div>");
                jQuery('#message').html("<h2>Formularz został wysłany! </h2>")
                .append("<p>Odpowiemy w możliwie najkrótszym czasie.</p>")
                .hide()
                .fadeIn(1500, function() {
                  jQuery('#message').append("<p>Dziękujemy.</p>");
                });
              }
         });
        return false;
            });
    });
