$(document).ready(function() {
    
    // homepage tooltips
    $('.trigger').tooltip({
        position: ['center', 'center'],
        offset: [0, 100],
        relative: true,
        effect: 'fade',
        events: {
            def: "click, mouseout"
        }
    });

    // if user doesn't have javascript enabled they can still see the nav.
    $pane = $('.productlist .pane');
    $pane.css('display', 'none');
    
    // get the initial index.
    var $initidx = $('.productlist h3').index($('h3.initcat'));
    if ($initidx >= 0)
    {
        $pane.eq($initidx).css('display', 'block');
    }
    else
    {
        $initidx = -1;
    }
    
    // set up the tabs.
    $productlist = $(".productlist");
    if ($productlist.find('h3:not(.nochildren)').length > 0)
    {
        $productlist.tabs(".productlist div.pane", {
            tabs: "h3:not('.nochildren')",
            initialIndex: $initidx,
            effect: 'slide' 
        });
    }
    
    // open links to other sites in a new window
    $("._blank").click(function() { return ! window.open($(this).attr("href")); });
    
});