$(function(){var msg_comment='TREŚĆ WIADOMOŚCI';var msg_email='TWÓJ ADRES E-MAIL';var msg_name='TWOJE IMIĘ I NAZWISKO';var fading=false;$('a.modal').click(function(){if(fading)return;fading=true;$('html, body').animate({scrollTop:0},'fast');$('.success, .error').hide();$('form#contactForm').show();$('#name').val(msg_name);$('#email').val(msg_email);$('#comment').val(msg_comment);$('#mask').css({'opacity':0.0}).show().fadeTo('',0.7);$('div#contact').fadeIn('fast',function(){fading=false});return false});$('div#close, div#mask').click(function(){if(fading)return;fading=true;$('div#contact, div#mask').stop().fadeOut('slow',function(){fading=false})});$('#contactForm input').focus(function(){if(($(this).val()==msg_email)||($(this).val()==msg_name))$(this).val('')});$('#contactForm #name').blur(function(){if(($(this).val()==""))$(this).val(msg_name)});$('#contactForm #email').blur(function(){if(($(this).val()==""))$(this).val(msg_email)});$('#contactForm textarea').focus(function(){if($(this).val()==msg_comment)$(this).val('')});$('#contactForm textarea').blur(function(){if(($(this).val()==""))$(this).val(msg_comment)});$('input#submit').click(function(){$('.error').hide().remove();var username=$('#name').val(),email=$('#email').val(),comment=$('#comment').val();var error_count=0;var username_regex=/^[a-z0-9_-]{3,16}$/,email_regex=/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;if(username.length<3){$('#contact_header').after('<p class=error>Wpisz imię i nazwisko!</p>');error_count+=1}if(!email_regex.test(email)){$('#contact_header').after('<p class=error>Nieprawidłowy adres e-mail!</p>');error_count+=1}if(comment==''){$('#contact_header').after('<p class=error>Nie wpisałeś wiadomości!</p>');error_count+=1}if(error_count==0){$.ajax({type:"post",url:"/action/contact/",data:"name="+encodeURIComponent(username)+"&email="+encodeURIComponent(email)+"&comment="+encodeURIComponent(comment),datatype:"text",success:function(resp){$('.error').hide();$('.success').slideDown('slow');$('form#contactForm').slideUp('slow')},error:function(){$('.error').hide();$('#sendError').slideDown('slow')}})}else{$('.error').show()}return false})});
