﻿$.tabs = function(containerId, start) {
    var ON_CLASS = 'current';
    var id = '#' + containerId;
    var i = (typeof start != "number") ? 1 : start;
    $(id + ' #section-' + i).show();
    $(id + ' .tab-hd ul>li:nth-child(' + i + ')').addClass(ON_CLASS);
    //切换tab的显示方法
    //$(id + ' .tab-hd ul>li>a').click(function() {
    $(id + ' .tab-hd ul>li>a').mouseover(function() {
        if (!$(this.parentNode).is('.' + ON_CLASS))
        {
            var re = /([_\-\w]+$)/i;
            var target = $('#' + re.exec(this.href)[1]);
            if (target.size() > 0) {
                $(id + ' .tab-bd >div:visible').css({display:"none"});
                target.css({display:"block"});
                $(id + ' .tab-hd >ul>li').removeClass(ON_CLASS);
                $(this.parentNode).addClass(ON_CLASS);
            }
            else {
                alert('There is no such container.');
            }
        }
        return false;
    });
};
