﻿$(document).ready(function () {

    // Fix FundNets naming
    $('#nav li a').each(function () {
        $(this).text($(this).text().replace('/PLC', ''));
    });

    // Attach correct classes
    $('#nav ul ul').addClass('subNav');
    $('#nav > ul > li > a').wrap('<strong />');

    // Get link which points to current Url
    var currentURL = location.href.split('/');
    var currPage = currentURL[currentURL.length - 1].toLowerCase();
    
	// If there's no page id, redirect to first link 
	if (currPage.indexOf('id=0') != -1){
		currPage = $('#nav li:first a').attr('href').toLowerCase();
		$('#boxText h1').text('Modern investment thinking for over 140 years');
	}
	
	var currLink = $('#nav a').filter(function () {
        return $(this).attr('href').toLowerCase() == currPage;
    }).parent();

    // If it's top level, just highlight and show submenu
    if (currLink.is('strong')) {
        currLink.parent().addClass('active');
        currLink.parent().find('li').addClass('subNavActive');
    }
    // If it's subnav, open parent and highlight
    else {
        currLink.parents('li').addClass('active');
        currLink.parent().children().addClass('subNavActive');
        $('a', currLink).addClass('active');
    }

    // Initiate tabs
    $('.tabs').accessibleTabs({
        tabhead: 'h2',
        fx: 'fadeIn'
    });

    // Initiate carousel
    $('#mycarousel').jcarousel({
        scroll: 2,
        vertical: false
    });

});
function ct(obj) {
obj.target = '_blank';
}
