jQuery(function() {

    // Tabbed Nav
    $(".tabnav").idTabs(function(id) {
        if ($(id + '-side').length > 0) {
            $(id + '-side').show().siblings().hide();
        } else {
            $('.rightnarrow .block').hide();
        }
        return true;
    });

    // List filter
    $(".list-counts").show();
    $(".filter-count, .total-count").text($('.filtered li').length);
    $('#listfilter').keyup(function() {
        $('.list-empty').remove();
        var filter = $(this).val(), count = 0;
        $(".filtered:first li").each(function() {
            if ($(this).text().search(new RegExp(filter, "i")) < 0) {
                $(this).addClass("hidden");
            } else {
                $(this).removeClass("hidden");
                count++;
            }
        });
        if (count == 0) {
            $('.filtered').append('<li class="list-empty">No results for "' + filter + '"</li>');
        }
        $('.filter-count').text(count);
    });

    // Input example
    $('input[@title]').example(function() {
        return $(this).attr('title');
    });

});