﻿$(document).ready(function(){
    
    // Tabbed biew
    $('#tabs li a').live('click', function(){
        if (!$(this).is('.open')){
            $('#tabs li.open').removeClass('open');
            $(this).parent().addClass('open').fadeTo(10,1); 
            
            $('.tab.open').removeClass('open').hide();
            var link = $(this).attr('rel') ? $(this).attr('rel') : $(this).attr('href');
            $(link).addClass('open').show();
        }
        
        if (typeof editTab == 'function'){
            editTab();
        }
        return false;
    });

    // Fix fund links 
    $('.tab tbody a[href^=www]').each(function(){
        $(this).attr('href', 'http://' + $(this).attr('href'));
    });
    $('.tab tbody a:not([target])').attr('target','_top');

    // Fix for 2nd col width
    $('.tab tbody td:nth-child(2):not(.nowrap)').addClass('nowrap');

    // Fade tabs and buttons on mouseover
    $('#tabs li, td.first, .buttonbar img').hover(
        function(){
            if (!$(this).is('.open') && !$(this).is('.edit')) $(this).fadeTo(200, 0.5);  
        },
        function(){
            if (!$(this).is('.open') && !$(this).is('.edit')) $(this).fadeTo(10, 1);  
        });

    // Start with first tab
    $('#tabs li:first-child a').trigger('click'); 

});
