featured = {
    cash: {},
    
    vote_for: function(obj) {
        var $obj = $(obj);
        var url = $obj.attr('href');
        var attrs = url.split('/');
        attrs.pop();
        var id = attrs.pop();
        
        this.cash[id] = null;
        
        $.getJSON(url, function(data) {
            //$obj.next().find('span').html(data.count);
            $('#ivote_'+id).html(data.count);
            $('#vote_'+id).html(data.count);
            if(data.can_go) {
                $obj.html('Мне интересно');
                $('#vote_link_'+id).html('Мне интересно');
            } else {
                $obj.html('Я передумал');
                $('#vote_link_'+id).html('Я передумал');
            }
        });
        return false;
    },

    get_info: function(obj) {
        var $obj = $(obj);
        var id = $obj.attr('href').split('/')[2];
        
        $('li.active_man').find('span').hide().end().find('a').show().end().removeClass('active_man');
        $obj.parent().append('<span>'+$obj.html()+'</span>').addClass('active_man');
        $obj.hide();
        
        if (!this.cash[id]) {
            var that = this;
            $('td.description_men').html('<div class="top_bc"><div class="corner_men"></div></div><div class="text_men" style="height: 128px;"><p><img src="/img/bullets/indicator.gif" alt="Загрузка"/> Загрузка...</p></div>');
            $.get('/get_info/'+id+'/', function(data) {
                that.cash[id] = data;
                $('td.description_men').html(data);
            });
        } else {
            $('td.description_men').html(this.cash[id]);
        }
        return false;
    }
}

fresh = {
    speed: 10400,
    start: function() {
        setTimeout(fresh.rotate, fresh.speed);
    },
    rotate: function() {
        var fr = $('#fresh_reports');
        var obj = $(fr.find('.program')[0]);
        obj.animate({marginTop: '-245px'}, 'slow', function() {
            var n = obj.next();
            fr.append(obj);
            obj.css('margin-top', 0);
            setTimeout(fresh.rotate, fresh.speed);
        });
    }
}

$(document).ready(function() {
    fresh.start();
});
