
  $.ajaxSetup({global: true, async: false});
  $(document).ready( function()
  {
  
    $('.rating .plus, .rating .minus').click( function()
    {
        var parent = $(this).parent();
        
        var cId = $(this).attr('cid');
        var number = ( $(this).hasClass('plus') ) ? +1 : -1;
        var type = parent.attr('rel');

        $.get("./scripts/php/isLogged.php", function(data)
        {
          data = parseInt( data );
          if ( data > 0 )
          {
              $.get("./scripts/php/crate.php", { "id" : cId, "ocena" : number, "type" : type }, function(dane)
              {
                parent.find('b').html( dane );
                if ( parseInt(dane) < 0 )
                {
                  parent.find('b').css('color', 'red');
                }
                else
                {
                  parent.find('b').css('color', 'inherit');
                }
              });     
          }
          else
            alertMsg("nonLogged");
        });
      
    });
    
  });
