﻿///<reference path="/_js/jQuery/1.4.1/jquery-1.4.1-vsdoc.js"/>

(function ($) {

    $.fn.WSoBCenterTabs = function () {

        //perform these actions on each element
        return this.each(function () {

            var centerTabsWrapper = $(this); //get itself

            //add the click event
            $("ul.tabs li", centerTabsWrapper).click(function () {
                //what one was clicked?
                var pos = $("ul.tabs li", centerTabsWrapper).index(this);
                var tab = $(this);
                var tabContent = $("div.contentWrapper div.content", centerTabsWrapper).eq(pos);

                //if its already selected, dont do anything
                if (tab.hasClass("selected"))
                    return;

                //otherwise just hide everything else and show the new one
                $("div.contentWrapper div.content", centerTabsWrapper).hide();

                //show the one we want
                $("div.contentWrapper div.content", centerTabsWrapper).eq(pos).show();

                //remove other selected tabs
                $("ul.tabs li", centerTabsWrapper).removeClass("selected");

                //update our tab
                tab.addClass("selected");
            });

            //show the first one!
            $("ul.tabs li", centerTabsWrapper).eq(0).click();
        });

    };

})(jQuery);
