﻿// JavaScript Document
$.fn.tabList = function() {
    var $container = $(this);
    var $contents = $container.find('.tab_container');
    var $tabs = $container.find('.tabs a');

    //Hide content
    $tabs.filter(':first').addClass('selected');
    $contents.hide().filter(':first').show();
    $contents.each(function() {
        if (!(jQuery.trim($(this).html()))) {
           $tabs.filter("[href='#" + $(this).detach().attr("id") + "']").parent().remove();
        }
    });

    //On clicks
    $tabs.click(function() {
        $tabs.removeClass('selected');
        $(this).addClass('selected');
        $contents.hide().filter(this.hash).show();
        return false;
    });
    if (window.location.hash != "") {
        $contents.hide().filter(window.location.hash).show();
        $tabs.removeClass('selected');
        $('[href="' + window.location.hash + '"]').addClass('selected');
    }
}
