﻿(function($) {
    $.fn.tab = function(o) {
        o = $.extend({
            first: 0
        }, o || {});
        this.each(function() {
            var tabs = $(this).children("ul").children("li");
            var divs = $(this).children("div");

            tabs.each(function(i) {
                $(this).mouseover(function() {
                    var index = tabs.index(this);
                    //var index = $.inArray(this, tabs);
                    _click(index);
                });
                var _click = function(n) {
                    tabs.removeClass("selected");
                    tabs.eq(n).addClass("selected");
                    divs.hide();
                    divs.eq(n).show();
                }
                var _init = function() {
                    tabs.addClass("tabs_tab");
                    divs.addClass("tabs_panel");
                    _click(o.first);
                }
                _init();
            });
        });
    }
})(jQuery);