(function ($) {
    "use strict";

    $(function () {

        var total_width = 214,
            range = 84,
            left_offset = Math.floor((total_width - range) / 2);

        $('#home-cover').fadeOut(500);

        $('#home-slides .slide')
            .each(function (i) {
                var slide = $(this),
                    card = $('> .slide-description', slide),
                    random_position = Math.floor(Math.random() * range) + left_offset,
                    height = card.outerHeight(true) + 1; // pixel line was visible
                card
                    .hide()
                    .css('background-position', random_position + 'px 0px');
                slide
                    .hover(function () {
                        card
                            .css('opacity', 1)
                            .clearQueue()
                            .fadeIn();
                    }, function () {
                        card
                            .clearQueue()
                            .fadeOut();
                    });
            });
    });

}(jQuery));

