/*
 *
 * jquery.jackrabbit.js
 *
 * Author: Frederick King
 * 
 *
 */
(function ($) {
    //////////////////////////////////////////////////////////////////////////////
    // Expand Collapse
    //////////////////////////////////////////////////////////////////////////////
    $(document).ready(function () {
        $('.expandCollapse h3').click(function () {
            $(this).next().slideToggle();
            return false;
        });
        $('.expandAll').click(function () {
            $(this).nextAll('.tabContent').slideDown();
            return false;
        });
    });
    //////////////////////////////////////////////////////////////////////////////
    // Tabs
    //////////////////////////////////////////////////////////////////////////////
    var tabs = $('.tabs'),
		tabLinks = tabs.children('ul').children('li')
    contentDivs = tabs.children('.tabsContentWrap').children('.tabContent');
    tabLinks.bind('click', function () {
        var elem = $(this),
        //Find the href attribute value to identify the active tab + content
			activeTab = elem.find("a").attr("href");
        //Remove any "active" class
        tabLinks.removeClass("active");
        //Add "active" class to selected tab
        elem.addClass("active");
        //Hide all tab content
        contentDivs.hide();
        //Fade in the active ID content
        $(activeTab).fadeIn();
        return false;
    });
    $(document).ready(function () {
        var avail = tabs.width() - (tabLinks.size() * 2);
        tabLinks.width(avail / tabLinks.size());
        //Activate first tab
        tabLinks.eq(0).addClass("active").show();
        //Show first tab content
        contentDivs.eq(0).show();
    });
    //////////////////////////////////////////////////////////////////////////////
    // Search
    //////////////////////////////////////////////////////////////////////////////
    var searchLabel = $('#formSearch label'),
        searchInput = $('#search');
    // event bindings
    searchLabel.bind('click', function () {
        var elem = $(this).hide();
    });
    searchInput.bind('focusin', function () {
        searchLabel.trigger('click');
    });
    searchInput.bind('blur', function () {
        var elem = $(this);
        if (elem.val() == "") {
            searchLabel.show();
        }
    });
    /////////////////////////////////////////////////////////////////////////////
} (window.jQuery))    
