
var vresponse=false;var formtoggle=false;function checkImie(imie){if(imie.val()==""){imie.parent().addClass('ramka_blad');imie.parent().find('p:first').find('span').show();return false;}
imie.parent().removeClass('ramka_blad');imie.parent().find('p:first').find('span').hide();return true;}
function checkNazwisko(nazwisko){if(nazwisko.val()==""){nazwisko.parent().addClass('ramka_blad');nazwisko.parent().find('p:first').find('span').show();return false;}
nazwisko.parent().removeClass('ramka_blad');nazwisko.parent().find('p:first').find('span').hide();return true;}
function checkFirma(firma){if(firma.val()==""){firma.parent().addClass('ramka_blad');firma.parent().find('p:first').find('span').show();return false;}
firma.parent().removeClass('ramka_blad');firma.parent().find('p:first').find('span').hide();return true;}
function checkEmail(email){var a=email.val();var filter=/^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+\.[a-z]{2,4}$/;if(a==""){email.parent().addClass('ramka_blad');email.parent().find('p:first').find('span').text('Pole nie moze byc puste');email.parent().find('p:first').find('span').show();return false;}else if(!filter.test(a)){email.parent().addClass('ramka_blad');email.parent().find('p:first').find('span').text('Podany email jest nieprawidlowy');email.parent().find('p:first').find('span').show();return false;}
email.parent().removeClass('ramka_blad');email.parent().find('p:first').find('span').hide();return true;}
function checkTelefon(telefon){var a=telefon.val();var filter=/^[0-9 +\-()]+$/;if(a==""){telefon.parent().addClass('ramka_blad');telefon.parent().find('p:first').find('span').text('Pole nie moze byc puste');telefon.parent().find('p:first').find('span').show();return false;}else if(!filter.test(a)){telefon.parent().addClass('ramka_blad');telefon.parent().find('p:first').find('span').text('Format telefonu jest nieprawidlowy');telefon.parent().find('p:first').find('span').show();return false;}
telefon.parent().removeClass('ramka_blad');telefon.parent().find('p:first').find('span').hide();return true;}
function checkUwagi(uwagi){if(uwagi.val()==""){uwagi.parent().addClass('ramka_blad');uwagi.parent().find('p:first').find('span').show();return false;}
uwagi.parent().removeClass('ramka_blad');uwagi.parent().find('p:first').find('span').hide();return true;}
function slidecallback(){formtoggle=true;$.scrollTo("#footer_content",500);$("#imie").focus();}
$(function(){$('#formularz').find('input[type=text]').each(function(){$(this).focus(function(){$(this).parent().addClass('ramka2');})
$(this).blur(function(){$(this).parent().removeClass('ramka2');})});$("#form_unwrap").click(function(){$("#footer_hidden").toggle();if($("#footer_hidden").is(":visible")){if($("#formularz").is(":visible")){$.scrollTo("#footer_content",500);$("#imie").focus();}
$('#form_unwrap').css({backgroundPosition:"-234px 0"});}
else
$('#form_unwrap').css({backgroundPosition:"0px 0px"});return false;});$("#form_wrap").click(function(){$('#form_unwrap').css({backgroundPosition:"0 0"})
$("#footer_hidden").hide();return false;});
$('#formularz').submit(function(){var imie=$(this).find('input[type=text][name=imie]');var nazwisko=$(this).find('input[type=text][name=nazwisko]');var firma=$(this).find('input[type=text][name=nazwa_firmy]');var email=$(this).find('input[type=text][name=email]');var telefon=$(this).find('input[type=text][name=telefon]');var uwagi=$(this).find('textarea[name=dodatkowe]');var vimie=checkImie(imie);var vnazwisko=checkNazwisko(nazwisko);var vfirma=checkFirma(firma);var vemail=checkEmail(email);var vtelefon=checkTelefon(telefon);if(vimie&&vnazwisko&&vfirma&&vemail&&vtelefon){$.ajax({type:"POST",url:"http://afilo.pl/webapps/front/html/javascript/sendmail.php",async:true,data:"imie="+imie.val()+"&nazwisko="+nazwisko.val()+"&firma="+firma.val()+"&email="+email.val()+"&telefon="+telefon.val()+"&uwagi="+uwagi.val(),success:function(html){vresponse=true;},error:function(XMLHttpRequest,textStatus,errorThrown){$("#response").html(textStatus);}});$("#footer").hide();$('#response').show();return false;}
return false;})})

$(function(){$('#formularz2').find('input[type=text]').each(function(){$(this).focus(function(){$(this).parent().addClass('ramka3');})
$(this).blur(function(){$(this).parent().removeClass('ramka3');})});
$('#formularz2').submit(function(){var imie=$(this).find('input[type=text][name=imie]');var nazwisko=$(this).find('input[type=text][name=nazwisko]');var firma=$(this).find('input[type=text][name=nazwa_firmy]');var email=$(this).find('input[type=text][name=email]');var telefon=$(this).find('input[type=text][name=telefon]');var uwagi=$(this).find('textarea[name=dodatkowe]');var vimie=checkImie(imie);var vnazwisko=checkNazwisko(nazwisko);var vfirma=checkFirma(firma);var vemail=checkEmail(email);var vtelefon=checkTelefon(telefon);if(vimie&&vnazwisko&&vfirma&&vemail&&vtelefon){$.ajax({type:"POST",url:"http://afilo.pl/webapps/front/html/javascript/sendmail.php",async:true,data:"imie="+imie.val()+"&nazwisko="+nazwisko.val()+"&firma="+firma.val()+"&email="+email.val()+"&telefon="+telefon.val()+"&uwagi="+uwagi.val(),success:function(html){vresponse=true;},error:function(XMLHttpRequest,textStatus,errorThrown){$("#response").html(textStatus);}});$("#formularz2").hide();$('#response2').show();return false;}
return false;})})