$(document).ready(function() {

    var read_only = true,
        item_id = $('#user_rating').attr('data-user_rating_id');

	// AdBlock Blocker
    if(($('.ad').height() == $('.ad').height()*2) || ($('.ad').height() == 0))
    {
        $("#link").html('Please <strong>do not block the ads on my site</strong>. Their view is the only way I could maintain it.<br>Select <strong>Disable Adblock on downlibrary.com blocking</strong>. Thank you.');
    }

    if($.cookie('user_rating_' + item_id) == null)
    {
        read_only = false;
    }

    $('#user_rating').raty({
        readOnly: read_only,
        half: true,
        space: false,
        start: function() {
            return $(this).attr('data-user_rating');
        },
        click: function(score, evt) {
            $('#user_rating').raty('readOnly', true);

            $.cookie('user_rating_' + item_id, 1, { expires: 365 });

            $.post('/files/user_vote', {
                id: item_id,
                vote: score
            });
        }
    });

	// prettyPhoto - galeria programu
    $("a[rel^='prettyPhoto']").prettyPhoto({
        show_title: false,
        autoplay: false,
        modal: true,
        keyboard_shortcuts: false,
        social_tools: ''
    });
	
    // Rozwijanie menu kategorii
    $('.expandable').each(function(){

        var elements = $('li', this).has('ul');

        $('> a', elements).click(function(e){
            e.preventDefault();
            $(this).parent().toggleClass('active');
        });

    });

});
