﻿/*
* tabs.js
* Simple jQuery tab function for UR Play
*/
(function($) {
    $.fn.tabs = function(settings) {
        if (settings) $.extend(config, settings);

        this.each(function() {
            var obj = $(this);

            $("div.tab-content:not(div.tab-content:first)", obj).css("display", "none");
            $("li.tab:first", obj).addClass("tab-selected");

            //Add click event top all the tabs
            $("li.tab a", obj).click(function(event) {

                //Dont follow the link
                event.preventDefault();

                //Get tab-content div id from link href
                var strContainerId = $(this).attr('href');
                strContainerId = strContainerId.substring(strContainerId.lastIndexOf("#"), strContainerId.length);

                //Add selected class to the tab, remove from others
                $(this).parent().addClass("tab-selected");
                $(this).parent().parent().find("li.tab").not($(this).parent()).removeClass("tab-selected");

                //Show current tab-content, hide others
                $("div.tab-content:visible:not(" + strContainerId + ")", obj).fadeOut(150, function() {
                    $(strContainerId).fadeIn(250);
                });
            })
        });

        return this;
    };
})(jQuery);
