/**
 * Created by SonicK.
 * User: vadim.lyahovic
 * Date: 5/16/11
 * Time: 5:29 PM
 * To change this template use File | Settings | File Templates.
 */
(function($) {
    function TabBox(obj) {
        this.obj = obj;
        this.opts = {
            sels : {
                tab          : "li",
                tabs         : ".tabs li",
                content_item : ".contentItem"
            },
            css : {
                selected : "selected"
            }
        };
        this.init();
    }

    TabBox.prototype.init = function() {
        var instance = this;
        $(this.obj).find(this.opts.sels.tabs).click(function() {
            $(instance.obj)
                    .find(instance.opts.sels.tab)
                    .removeClass(instance.opts.css.selected);
            $(this).addClass(instance.opts.css.selected);

            $(instance.obj)
                    .find(instance.opts.sels.content_item)
                    .removeClass(instance.opts.css.selected)
                    .eq($(this).parent().children().index($(this))) //jQuery 1.3.2
                    .addClass(instance.opts.css.selected);
        });
    };

    $.fn.extend({
        TabBox : function() {
            return this.each(function() {
                this.tabBox = new TabBox(this);
            });
        }
    });
})(jQuery);

