﻿function prepare_feature() {
    if (!window.feature) { return; }

    var count = $('div.feature_box').length;
    var random = count - 1;

    setInterval(function() {
        if (window.feature) {
            random = random - 1;
            if (random < 0) { random = count - 1; }
            change_feature($('div.tab')[random]);
        }
    }, 10000);
}

function stop_feature() {
    window.feature = false;
}

function change_feature(el) {
    var tar_id = $(el).attr('rel');
    var target = $('div#' + tar_id);

    $('div.feature_box').hide();
    $(target).show();

    $('div.tab.selected').removeClass('selected');
    $(el).addClass('selected');
}
