﻿// ==================================================================================================
// =                                                                                                =
// =                                INFTABS - Easy Tabs by InfVent                                  =
// =                                                                                                =
// = Created  by: Robert Larsson at Infvent AB, www.infvent.com                                     =
// = Created  at: 2001-03-23                                                                        =
// = Last Change: 2001-03-23                                                                        =
// ==================================================================================================


/* Init all tabs that has 'inftab' as class */

$(document).ready(function () {
    $('ul.inftab').each(function () {
        $('div#' + $(this).attr('id')).show();
        var selectedTab = $('#' + $(this).attr('id') + ' li.selected').attr('tab');
        inftab_init('#' + $(this).attr('id'), selectedTab);
    });
});



function inftab_init(ul_id, selectedTab) {
    $('ul' + ul_id + ' li').each(function (index) {
        //alert('div' + ul_id + ' ' + $(this).attr('tab') + ' ' + $(this).text());//.hide();
        $(this).click(function () {
            inftab_select_tab(ul_id, index)
        });

        if ($(this).attr('tab') == selectedTab) {
            inftab_select_tab(ul_id, index);
        }
    });
}

function inftab_select_tab(ul_id, selectIndex) {
    $(ul_id + ' li').each(function (index) {
        if (index == selectIndex) {
            $(this).removeClass("selected");
            $(this).addClass("selected");
            $('div' + ul_id + ' ' + $(this).attr('tab')).show();
        }
        else {
            $(this).removeClass("selected");
            $('div' + ul_id + ' ' + $(this).attr('tab')).hide();
        }
    })
}

