  $(document).ready( function()
  {

    function ucfirst( str ) {
        str += '';
        var f = str.charAt(0).toUpperCase();
        return f + str.substr(1);
    }
  
    $("a.addFavorite").click( function()
    {
      var img = $(this).find('img');
      var btn = $(this);

      $.post("/scripts/php/fav.php", { type: btn.attr("rev"), id: btn.attr("rel") }, function (data)
      {
        if ( data == "true" )
        {
          alertMsg("faved");
          $(this).removeClass('addFavorite');
          img.attr('src', '/img/fav_heart.png');
          
          btn.unbind();
        }
        else if ( data == "nonlogged" )
        {
          alertMsg("nonLogged");
        }
        else
        {
          alert("Film jest już w ulubionych.");
        }
      });
    }).mouseover( function()
    {
      $(this).find('img').attr('src', '/img/serce.png');
    }).mouseout( function()
    {
      $(this).find('img').attr('src', '/img/serce_.png');
    });
    
    $('a.report').click( function()
    {
      id = $(this).attr("rel");
      type = $(this).attr("rev");
      $.get("/scripts/php/reportForm.php", { 'id' : id, 'type' : type }, function(answer)
      {
        $.blockUI({ css: { borderColor: '#7C9C1F' }, message : $(answer) });
      });

    }).mouseover( function()
    {
      $(this).find('img').attr('src', '/img/wykrzyknik.png');
    }).mouseout( function()
    {
      $(this).find('img').attr('src', '/img/wykrzyknik_.png');
    });    
    
  });
