var HotBar = {
    opts: {
        ce: 340,
        ma: 110,
        le: 150,
        ker: function () { return this.ce + this.ma }
    },
    nw: 340,
    cw: 110,
    as: 300,
    animating: false,
    activeIndex: 0,
    acCn: function () { return jQuery('#mrln-heading-hotbar').children('.ac:first') },
    anCn: function () { return jQuery('#mrln-heading-hotbar').children('.an:first') },
    activeNav: function () { return jQuery('.mrln-hotbar-nav-btn').filter('.sel:first') },
    indexedContainer: function (index) { return jQuery(jQuery('#mrln-heading-hotbar').children().get(index)) },
    indexedNav: function (index) { return jQuery(jQuery('.mrln-hotbar-nav-btn').get(index)) },
    elements: function () {
        return jQuery('#mrln-heading-hotbar').children();
    },
    init: function () {
        this.change(0);
        jQuery(this.elements()).bind('mouseenter', function () {
            HotBar.changeSelected(this);
        });
        return this;
    },
    change: function (index) {
        this.anCn().removeClass('an');
        this.indexedContainer(index).addClass('an');
        this.activeNav().removeClass('sel');
        this.indexedNav(index).addClass('sel');
        this.animate();
    },
    changeSelected: function (element) {
        index = jQuery(element).index('.mrln-hotbar-300');
        this.activeNav().removeClass('sel');
        this.indexedNav(index).addClass('sel');

        this.anCn().removeClass('an');
        jQuery(element).addClass('an');
        this.animate();
    },
    animate: function () {
        if (this.animating) return;
        if (!this.anCn()[0]) return;
        var anCn = this.anCn();
        var acCn = this.acCn();
        if (anCn.hasClass('ac')) return;
        this.animating = true;
        var opts = this.opts;
        anCn.children('.mrln-hotbar-300-content').hide();
        anCn.animate(
        { width: this.nw },
        {
            complete: function () {
                anCn.children('.mrln-hotbar-300-content').fadeIn();
                acCn.removeClass('ac');
                anCn.removeClass('an').addClass('ac');
                HotBar.animating = false;
                HotBar.animate();
            },
            step: function (now, o) {
                acCn.css({ width: (opts.ker() - now) + 'px' });
            },
            duration: opts.le
        });
    }
}.init();

var thumb_change_time = 10; // animasyon geçiş süreci, milisaniye bazında
var hotbar_thumbs = 6; // bu toplam thumbnail sayısı, dizayn değişmediği sürece değiştirmeyin
var selected_thumb = 0; // animasyonun başlayacağı thumbnail, 0'dan saymaya başlayarak
var hotbar_animation = true;
function change_hotbar() {
    if (hotbar_animation) {
        HotBar.change(selected_thumb)
        selected_thumb++;
        if (selected_thumb >= hotbar_thumbs) selected_thumb = 0;
        setTimeout("change_hotbar();", thumb_change_time);
    }
}
change_hotbar();
