$(document).ready(function(){

                jQuery("#centruj-na-stred").center();
 
                $("#contactLink").click(function(){
                    if ($("#contactForm").is(":hidden")){
              
                        $("#contactForm").show('slide', {direction: 'left'}, 1000);
                        $("#contactLink").animate({ left: '+=306'} , 1000, function() {
                            // Animation complete.
                          });
                        $("#contactLink").css('filter', 'none');

                        
                    }
                    else{
                   
                        $("#contactForm").hide('slide', {direction: 'left'}, 1000);
                        $("#contactLink").animate({ left: '-=306'} , 940, function() {
                            // Animation complete.
                          });
                        $("#contactLink").css('filter', 'none');
                    }
                });
                
                  $("#closeLink").click(function(){
                    if ($("#contactForm").is(":hidden")){
        
                        $("#contactForm").show('slide', {direction: 'left'}, 1000);
                        $("#contactLink").animate({ left: '+=306'} , 1000, function() {
                            // Animation complete.
                          });
                        $("#contactLink").css('filter', 'none');

                        
                    }
                    else{
             
                        $("#contactForm").hide('slide', {direction: 'left'}, 1000);
                        $("#contactLink").animate({ left: '-=306'} , 940, function() {
                            // Animation complete.
                          });
                        $("#contactLink").css('filter', 'none');
                    }
                });
                
                
                /* form validation */
                
                $(function() {
                    /* $('.error').hide(); */
                    $(".button").click(function() {
                      // validate and process form here
                
                       
                  	    var name = $("input#rkname").val();
                      		if (name == "") {
                                
                                $("#captcha-div").fadeOut(400);
                                $("#captchaimage").fadeOut(400);
                                $("#captcha").fadeOut(400);
                                $("#captcha-div-wrong-info").fadeIn(400);
                                
                                $("#submit_btn").fadeOut(400);
                                $(".button-zpet").fadeIn(400);
                                
                                
                                return false;
                            }
                  		var email = $("input#rkmail").val();
                      		if (email == "") {
                                
                                $("#captcha-div").fadeOut(400);
                                $("#captchaimage").fadeOut(400);
                                $("#captcha").fadeOut(400);
                                $("#captcha-div-wrong-info").fadeIn(400);
                                
                                $("#submit_btn").fadeOut(400);
                                $(".button-zpet").fadeIn(400);
                                
                               
                                return false;
                            }
                  		var phone = $("input#rkphone").val();
                      		if (phone == "") {
                                
                                phone = "nezadáno";
                                
                                
                            }
                            
                        var message = $("textarea#rkmessage").val();
                      		if (message == "") {
                                
                                $("#captcha-div").fadeOut(400);
                                $("#captchaimage").fadeOut(400);
                                $("#captcha").fadeOut(400);
                                $("#captcha-div-wrong-info").fadeIn(400);
                                
                                $("#submit_btn").fadeOut(400);
                                $(".button-zpet").fadeIn(400);
                                
                                
                                return false;
                            }
                
                        /* ************* */
                        /* captcha check */
                        /* ************* */
                
                        var captcha = $("input#captcha").val();
                        
                        $.ajax({
                                type: "GET",
                                url: "kf/includes/process.php",
                                data: "captcha=" + captcha,
                                success:function(data){
                                            if(data=='true') {
                                                
                                                var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&message=' + message;
                            
                                                  $.ajax({
                                                    type: "POST",
                                                    url: "kf/bin/process.php",
                                                    data: dataString,
                                                    success: function() {
                                                                              
                                                      $("#captcha-div").fadeOut(400);
                                                      $("#captchaimage").fadeOut(400);
                                                      $("#captcha").fadeOut(400);
                                                      $("#captcha-div-good-info").fadeIn(400);
                                                      $("#submit_btn").fadeOut(400);
                                                      $(".button-zpet").fadeIn(400);
                                                      
                                                    }
                                                  });
                                                  return false;
                                           
                                              }
                                              else {
                                                
                                                      $("#captcha-div").fadeOut(400);
                                                      $("#captchaimage").fadeOut(400);
                                                      $("#captcha").fadeOut(400);
                                                      $("#captcha-div-wrong-info").fadeIn(400);
                                                      $("#submit_btn").fadeOut(400);
                                                      $(".button-zpet").fadeIn(400);
                                                  return false;
                                              }
                                                
                                        }
                              });
                
                       

                              return false;
                       
                            
                    
                    
                    });
                    
                       /* /form validation */
                
                        $("#zpet_btn").click(function() {
                        
                             /* reset form */
                                         
                                          $(':input','#myform')
                                         .not(':button, :submit, :reset, :hidden')
                                         .val('')
                                         .removeAttr('checked')
                                         .removeAttr('selected');
                                         
                                         $('#captcha').val('');
                                         
                                         $.post('kf/php/newsession.php');
                
                                         $("#captchaimage").load('kf/php/image_req.php?_o='+ escape(new Date()));  /* fixing explorer cache problem */                                       
                                       
                                         $("#captcha-div-good-info").fadeOut(400);
                                         $("#captcha-div-wrong-info").fadeOut(400);
                                         
                                         $("#captcha-div").fadeIn(400);
                                         $("#captchaimage").fadeIn(400);
                                         $('#captcha').fadeIn(400);
                                         
                                         
                                         $("#submit_btn").fadeIn(400);
                                         $(".button-zpet").hide();
                                         return false;  
                                         
                                         
                                         
                                          
                        });
                        return false;
                    
                  });
  
             
                return false;
                
            });
            
            function closeForm(){
                $("#messageSent").show("slow");
                setTimeout('$("#messageSent").hide();$("#contactForm").slideUp("slow")', 2000);
           }
           
         
            
            function refreshformu() {
                
                alert('refresh');
                return false;
                
            }
            

