  
  // ------------------------------------------ review secion
  $(function() {
    $("#addVote  li").click(function () { 
        showAddVoteButton(this); 
    });
    
    $("#addVote li a").attr("href", "javascript:void(0)");
    
    $("#addVoteButton").click(function () { 
        addVoteByAjax(); 
    });
  });
  
  var vote;
  function showAddVoteButton(temp){
    vote = temp.id.substring(5,6)
    $("#addVoteButton").show();
  }
  
  function addVoteByAjax(){
    $.get('ajaxResponse.php?action=addVote&vote='+vote+'&id_movie='+movieId, '', function(data){
      $(".reviewInfo").html(data);
    });
  }
  
  // ------------------------------------------ comment secion
  $(function() {
    $(".commentToMovie").click(function () { 
      
      if($("#commentToMovieContent").css("display")=="block"){
        $("#commentToMovieContent").hide(); 
      }
      else{
	  
	          $("#commentToMovieContent").show(); 
        
        $.get('ajaxResponse.php?action=showComment&id_movie='+movieId, '', function(data){
          $("#commentToMovieContent").html(data);
        });
      }
      
    });
  });
  
  function sendNewComment(){
   var formNewComment = $("#formNewComment").val();
   var formNewCommentAuthor = $("#formNewCommentAuthor").val();
    
    $.get('ajaxResponse.php?action=addComment&author='+formNewCommentAuthor+'&comment='+formNewComment+'&id_movie='+movieId, '', function(data){
      $("#commentToMovieContent").html(data);
    });
    
    return false;
  }  
  
  function getCommmentList(from){
    $.get('ajaxResponse.php?action=showComment&id_movie='+movieId+'&from='+from, '', function(data){
      $("#commentToMovieContent").html(data);
    });
    return false;
  }
    
  // ------------------------------------------ newsletter secion
  $(function() {
    $(".addToNewsletter").click(function (){ 
      addToNewsletter(this); 
    });
    $(".delFromNewsletter").click(function (){ 
      delFromNewsletter(this); 
    });
  });
  
  function addToNewsletter(ele){
    var dobryEmail = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    var email = $(".newsletterEmail").val();
      
    if(dobryEmail.test(email)){
      $.get('ajaxResponse.php?action=addEmailToNewslleter&email='+email, '', function(data){
        $(".newsletterEmail").val(data);
      });
    }
    else{
      $(".newsletterEmail").val("Niepoprawny adres e-mail !");
    }
  }
  
  function delFromNewsletter(ele){
    var dobryEmail = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    var email = $(".newsletterEmail").val();
      
    if (dobryEmail.test(email)){
      $.get('ajaxResponse.php?action=delEmailToNewslleter&email='+email, '', function(data){
        $(".newsletterEmail").val(data);
      });
    }
    else{
      $(".newsletterEmail").val("Niepoprawny adres e-mail !");
    }
  }
  
