(function($) {
    $.fn.panelSwitcher = function (psId) {
        $(".panel").hide();
        if (psId === undefined || psId == '') {
            psId = '#panelswitcher';
        }
        $(psId).ready(function() {
            var href = location.href;
            if (href.lastIndexOf("#") != -1) {
                target = href.substr(href.lastIndexOf("#"));
                $(target).show();
                $(psId + " a").each(function() {
                    if (target == $(this).attr("href")) {
                        $(this).addClass("active");
                    }
                });
            }
        });

        $(psId + " a").click(function () {
            // switch all tabs off
            $(psId + " a.active").removeClass("active");

            // switch this tab on
            $(this).addClass("active");

            // slide all elements with the class 'panel' up
            $(".panel").hide();

            // Now figure out what the 'href' attribute value is and find the
            // element with that id.  Then slide that down.
            var content_show = $(this).attr("href");
            $(content_show).show();

            return true;
        });
    };
})(jQuery);
