﻿(
    function ($) {
        $.fn.extend(
            {
                documentation: function () {
                    var list = $('ul.list-items', this).hide();
                    var titles = $('span.tabtitle', list).slice(0,2);
                    var bodies = $('div.body', list).clone();
                    var tabs = $('<ul/>').addClass('tabs').insertAfter(list);
                    bodies.insertAfter(tabs).hide();
                    titles.each(
                        function () {
                            $('<li/>').html($(this).text()).appendTo(tabs).click(
                                function () {
                                    var tab = $(this);
                                    bodies.hide().eq(tab.index()).show();
                                    tabs.children().removeClass('active');
                                    tab.addClass('active');
                                }
                            );
                        }
                    );
                    tabs.children().first().click();
                }
            }
        );
    }
)(jQuery);

$(document).ready(
    function () {
        $('article.documentation-container-').documentation();
    }
);
