﻿var IndexState = {
    showedBlock: 'none',
    blockActive: 'none',
    activeSubmenu: 'none',
    timeoutID: 'none'
};



$(function initIndexMenu() {
    IndexState.selected = $("div.promo-tabs > div.sel");  //index menu
    IndexState.currentClass = "style-1";
    var promo = $(".promo-content > div")[0].children[1];
    if (promo != null) {
        IndexState.activePromoContent = $("#" + promo.id);
        IndexState.activePromoContent.show();
    }
});

function IndexMenuClick(id) {
    var pressed = $("#" + id);
    //change selected index
    var menuid = id.substring(id.length - 4, id.length);

    $(".promo-content > div > div").each(function () {
        if ($(this).attr('id').match("PromoContainer_" + menuid)) {
            if (IndexState.activePromoContent != 'none') {
                IndexState.activePromoContent.hide();
            }
            $(this).show();
            IndexState.activePromoContent = $(this);
        }
    });
   
    IndexState.selected.removeClass("sel");
    IndexState.selected = pressed.parent();
    pressed.parent().addClass("sel");

    //get selected class number from icon number
    $("#index-menu-container").removeClass(IndexState.currentClass);
    var iconame = pressed[0].children[0].className;

    //switch style for IndexMenu container
    $("#index-menu-container").removeClass(IndexState.currentClass);
    IndexState.currentClass = "style-" + iconame[iconame.length - 1];
    $("#index-menu-container").addClass(IndexState.currentClass);
}

