/* --- SmartEdit --- */
//--- Foundation Page RedDot Menu 
function toggleFDRM(subMenu) {
    var subDivs = document.getElementById(subMenu).getElementsByTagName('div');
    var divImg = subDivs[0].getElementsByTagName('img');
                
    if (subDivs[1].style.display == "block") {
        subDivs[1].style.display = "none";
        divImg[0].src = "/images/interface/widget_plus.gif";
    }
    else {
        subDivs[1].style.display = "block";
        divImg[0].src = "/images/interface/widget_minus.gif";
    }
}
//--- Footer Redirects
$(document).ready(function() {
    $('div.se-redirects li:odd').css('background-color','#F5F5F5');
    var redirectHeight = $('div.se-redirects ul').height();
    if(redirectHeight<200) $('div.se-redirects').css('height',redirectHeight).css('overflow','auto');
 });
/* --- End --- */
// Provides all variables passed via URL
var urlParams = {};
(function () {
    var e,
        a = /\+/g,
        r = /([^&=]+)=?([^&]*)/g,
        d = function (s) { return decodeURIComponent(s.replace(a, ' ')); },
        q = window.location.search.substring(1);
    while (e = r.exec(q))
       urlParams[d(e[1])] = d(e[2]);
})();
/*--------------------------------------------------
 * Eaton Vance
 */
 
var EV;
if (!EV) EV = {};
EV.PrintMode = (typeof urlParams['print'] != 'undefined') ? true : false;
/*--------------------------------------------------
 * EV.ToolModal
 * -  Create a modal using simplemodal jQuery plugin, based on the URL and assigns the title of the title attribute.
 */
EV.ToolModal = function(e) {
    e.preventDefault();
    // custom ladder muni tool modal
    if( $('#ladder_modal').length ){
        shareLadder();
        $('#ladder_modal').modal();
    } else {
        var modalObject =  $( $(this).attr('href') );
        if( modalObject ) {
            
            // If Modal Header has not been created yet create one.
            if( modalObject.children('.simplemodal-header').length < 1 )
                modalObject.prepend('<div class="simplemodal-header"><span class="close">&nbsp;</span><h4 class="simplemodal-title">&nbsp;</h4></div>');
            
            if( $(this).attr('title') )
                $('.simplemodal-title').html( $(this).attr('title') );
            
            modalObject.modal({overlayClose: true, opacity: 30, closeClass: 'close', minWidth: 300, maxWidth: 950});
        }
    }
}
/*--------------------------------------------------
 * EV.PortfolioFit
 * -  Create a modal using simplemodal jQuery plugin, based on the URL and assigns the title of the title attribute.
 */
 
EV.PortfolioFit = {};
EV.PortfolioFit.filterPortfolioFit = function( filter ) {
    $("#fund_list table").find("tbody tr td:nth-child(" + filter + ")").each(function (e) {
        var td = $(this).addClass("selected");
        
        if (td.html() === "&nbsp;")
            td.parents("tr").hide();
        
    });
        
    $("#fund_list table").each(function(){
        if( $(this).find("tr:visible").length === 0)
            $(this).hide();
    });
}
EV.PortfolioFit.resetFiltersPortfolioFit = function() {
    $("#portfolio-fit-filters a").removeClass("selected");
    $("#fund_list table td").removeClass("selected");
    $("#fund_list table tr").show();
    $("#fund_list table").show();
}
/*--------------------------------------------------
 * EV.updatePickList()
 */
EV.updatePickList = function(o) {
    var action = null;
    var symbol = null;
    
    if( $(o).hasClass("add-picklist") )
        action = "1";
    else if( $(o).hasClass("remove-picklist") )
        action = "0";
    else {
        alert( "Error: no action specified for fund [" + $(o).attr("rel") + "]" );
        return;
    }
    
    if( $(o).attr("rel").length > 3 )
        symbol = $(o).attr("rel");
    else
        alert( "Error: no fund symbol specified in the related attribute [" + $(o).attr("rel") + "]" );
    
    if( !$(o).hasClass('check') ) {
        $(o).removeClass();
        $(o).text("Sending...");
    }
    
    $.ajax({
      type: 'POST',
      url: "Access-PickList.php",
      data: {"fund-symbol":symbol, "action":action},
      success: function(data) {
        
        if( data.indexOf( "0" ) ) {
        
            if( action == 1 ) {
                $(o).removeClass("add-picklist");
                $(o).addClass("remove-picklist");
                
                if( !$(o).hasClass('check') ) {
                    $(o).text("Remove from Pick List");
                    $(o).addClass("checked");
                }
                
            } else {
                $(o).removeClass("remove-picklist");
                $(o).addClass("add-picklist");
                
                if( !$(o).hasClass('check') ) {
                    $(o).text("Add to Pick List");
                    $(o).removeClass("checked");                      
                }
                
            }  
          
        } else
            alert("Error: Could not add to pick list. [" + data + "][" + data.indexOf( "0" ) + "]" );
        
      }
      
    });
}    
   
/*--------------------------------------------------
 * EV Main
 */
 
$(document).ready(function () {
    //--- Global Init Functions
    if(!EV.PrintMode) $('body').removeClass('no-js'); // Allows for controlled styles if JS is disabled or broken.
    isHome = ($('body.home').length == 1);     // Bool for testing home page specific scripts.
    if(EV.PrintMode) {
        var printStylesClone = $('link[media="print"]').clone().appendTo('head');
        printStylesClone.attr('media','screen');
    }
    
    //$('#tools-export').click(EV.ToolModal);
    //$('#tools-print').click(EV.ToolModal);
    $('.pop-modal').click(EV.ToolModal);
    $('a[rel=ev-modal]').click(EV.ToolModal);
    
    // END: Global Init
    
    $('.fund-table').each(function() {
        var tableFrame = $(this);
        var tableButtonFrame = $(this).find('.fund-table-buttons');
        var tableFrameDate = $(this).find('caption .date');
        $(this).find('tbody tr.table-view').each(function(){
            
            if( $(this).hasClass('table-view-chart') )
                tableButtonFrame.append( '<a href="#" class="icon"><span class="icon-chart">&nbsp;</span></a>' );
            else if( $(this).hasClass('table-view-graph') )
                tableButtonFrame.append( '<a href="#" class="icon"><span class="icon-graph">&nbsp;</span></a>' );
            else
                tableButtonFrame.append( '<a href="#">' + $(this).find('.table-view-name').text() + '</a>' );
            
        });
        
        tableButtonFrame.children('a').click(function(e){
        
            tableFrame.find('tbody').hide();
            var currentTableBody = tableFrame.children('tbody:eq(' + $(this).index() + ')');
            currentTableBody.show();
            
            tableFrameDate.html( currentTableBody.find( '.table-view .table-view-date' ).text() );
            
            e.preventDefault();
            
            $(this).addClass('active').siblings().removeClass('active');
            
        });
        
        tableButtonFrame.children('a:first').trigger('click');
        
    });
    
    
    /*--------------------------------------------------
    * Portfolio Fit : Filtering
    */
    $('#portfolio-fit-reset a.reset').click(function (e) {
        e.preventDefault();
        EV.PortfolioFit.resetFiltersPortfolioFit();
    });
    $('#portfolio-fit-filters a').click(function (e) {
        var column = $('#portfolio-fit-filters a').index(this) + 2;
        EV.PortfolioFit.resetFiltersPortfolioFit();
        EV.PortfolioFit.filterPortfolioFit(column);
        
        $(this).addClass('selected');
        e.preventDefault();
    });
    // Filter via URL
    if (typeof (urlParams['filter']) != 'undefined') {
        var typeName = urlParams['filter'];
        $('#portfolio-fit-filters .' + urlParams['filter']).parent().trigger('click');
    }
    /*--------------------------------------------------
    * Header : Site Listing 
    */
    var sitesListing = $('#sites-listing');
    if(sitesListing.length){
        var sitesListingActive = $('.active',sitesListing);
        $('li',sitesListing).hover(
            function(){
                $(this).children('ul.active').fadeIn('fast');
            },
            function(){
                $(this).children('ul.active').fadeOut('fast');
            }
        );
        $('li',sitesListingActive).hover(function(){
            $(this).toggleClass('hover');
        });
    }
    /*--------------------------------------------------
    * Navigation : Fund Finder : Search 
    */
    //--- Top Navigation Items assign hover states 
    $('#navigation > ul > li').not('body.home #fund-finder-nav').hover(
        function () {
            var _this = $(this);
            _this.addClass('hover');
            $('.arw',_this).show();
            _this.children('ul').stop(true, true).slideToggle('slow');
        },
        function () {
            var _this = $(this);
            $('.arw',_this).hide();
            _this.children('ul').stop(true, true).slideToggle('slow');
            _this.removeClass('hover');
            // If Search Box is focused assign hiding when unfocuses.
            /*
            if( $('#fund-search:focus').length < 1 ) {
            _this.children('ul').stop(true, true).slideToggle('slow');
            _this.removeClass('hover');
            } else {
            $('#fund-search:focus').blur(function(){
            _this.children('ul').stop(true, true).slideToggle('slow');
            _this.removeClass('hover');
            });
            }
            */
        }
    );
    function FindLargestNumber(someArray){
        var biggest = 0;
        for ( x=0; x<someArray.length; x++ ){
            if (someArray[x] > biggest) {
                biggest = someArray[x];
            }
        }
        return biggest;
    }
    
    // Fund Finder
    if($('#fund-finder-nav').length){
        
        // Initialize which levels need to be displayed wide.
        $('#fund-finder-nav ul ul ul ul > li').each(function (event) {
            var _this = $(this);
            var fourthLevelFunds = _this.children("ul").children('li');
            var fourthLevelFundsCount = fourthLevelFunds.length;
            if (fourthLevelFundsCount > 10){
                _this.addClass("wide");
                var upperHalf = Math.round((fourthLevelFundsCount/2))-1;
                var splitItem = $(fourthLevelFunds[upperHalf]);
                var originalUL = splitItem.parent();
                var newUL = $('<ul>').addClass('col2');
                newUL.append( splitItem.nextAll() );
                originalUL.addClass('col1').after(newUL);
            }
        });
        // Level 1: Initialize basic accordion effect.
        $('#fund-finder-nav > ul > li > ul > li > ul').hide();
        var fundFinderActiveObject = $("#fund-finder-nav > ul > li > ul > li > a:first");
        $(fundFinderActiveObject).parent('li').addClass('active');
        $(fundFinderActiveObject).parent('li').children('ul').show();
        // Initialize height and display of fly out navs, accomodate for difference when on home
        var fundFinderBaseHeight = $('#fund-finder-nav ul:first li:first').height();
        $("#fund-finder-nav > ul > li > ul > li > a").hover(function (event) {
            fundFinderBaseHeight = $('#fund-finder-nav ul:first li:first').height();
        });
        
        // For only first level of the fund finder creating accordion effect
        $("#fund-finder-nav > ul > li > ul > li > a").click(function (event) {
            event.preventDefault();
        
            if (fundFinderActiveObject == this)
                return false;
            
            fundFinderBaseHeight = $('#fund-finder-nav ul:first li:first').height();
            $(fundFinderActiveObject).parent().removeClass('active');
            $(fundFinderActiveObject).parent().children('ul').slideToggle('medium');
            $(this).parent().addClass('active');
            $(this).parent().children('ul').slideToggle('medium',function(){
                fundFinderBaseHeight = $('#fund-finder-nav ul:first li:first').height();
                $(this).parents('#fund-finder-nav > ul').animate({'height': fundFinderBaseHeight });
            });
            fundFinderActiveObject = this;
        });
        // Simulate n-th child CSS selector for the 2nd item of 4th level list, first-child is used in CSS.
        //$('body.home #fund-finder-nav ul ul ul ul ul.wide > li:nth-child(2)').addClass('second-child');
            
        /* Level 2: Active states/animations */
        $('#fund-finder-nav ul ul ul > li').hover(function () {        
        
            var liHeight = $(this).height();
            $(this).addClass('active');
            
            if ($(this).children("ul").length){
                $(this).addClass('children');
                var level3_ulHeight = $(this).children("ul").first().height();
                var height = (level3_ulHeight > fundFinderBaseHeight) ? level3_ulHeight : fundFinderBaseHeight;
                $(this).addClass('active').height(liHeight).parents('#fund-finder-nav > ul').stop().animate({ 'width': 339, 'height': height });
                $(this).children("ul").height(height);
                $(this).children("ul").children("li").each(function(){
                    var _height = $(this).height();
                    $(this).height(_height);
                });
            }
            
        }, function () {
            $(this).removeClass('active children').parents('#fund-finder-nav > ul').stop().animate({ 'width': 170, 'height': fundFinderBaseHeight });
        });
        
        var globalHeightLvl3 = 0;
        
        /* Level 3: Active states/animations */
        $('#fund-finder-nav ul ul ul ul > li').hover(function () {
    
            var liHeight = $(this).height();
            $(this).addClass('active');
            var level4_ulHeight = $(this).children("ul").first().height();
            var level3_ulHeight = $(this).parent().height();
            var level2_ulHeight = $(this).parent().parent().height();
 
            var heightArray = new Array(fundFinderBaseHeight,level4_ulHeight,level3_ulHeight,level2_ulHeight);
            
            var height = FindLargestNumber(heightArray);
            var width = 669;
            globalHeightLvl3 = height;
            if ($(this).hasClass('wide')) width = 989;
            if($(this).children("ul").length){
                $(this).addClass('children').height(liHeight).parents('#fund-finder-nav > ul').stop().animate({ 'width': width, 'height': height });
                $(this).children("ul").height(globalHeightLvl3);
            }
        
        }, function () {
            $(this).removeClass('active children').parents('#fund-finder-nav > ul').stop().animate({ 'width': 339, 'height': globalHeightLvl3 });
        
        });
        var globalHeightLvl4 = 0;
        var globalWidthLvl4 = 0;
        
        /* Level 4: Maintain Hover State on 4th Level funds */
        $('#fund-finder-nav ul ul ul ul ul > li').hover(function () {
            var width = 669;
            if ($(this).parent().parent().hasClass('wide')) width = 989;
            
            var level4_ulHeight = $(this).parent().height();
            var level3_ulHeight = $(this).parent().parent().parent().height();
            var heightArray = new Array(fundFinderBaseHeight,level4_ulHeight,level3_ulHeight);
            var height = FindLargestNumber(heightArray);
            globalHeightLvl4 = height;
            globalWidthLvl4 = width;
            
            $(this).addClass('active').parents('#fund-finder-nav > ul').stop().animate({ 'width': width, 'height': height });
        }, function () {
            $(this).removeClass('active').parents('#fund-finder-nav > ul').stop().animate({ 'width': globalWidthLvl4, 'height': globalHeightLvl4 });
        });
    } // end Fund Finder
    // Search Box Focus Simulation Effects for older browsers (IE7 & IE8)
    $('#search').hover(function () {
        if (!$('#search-query').is(':focus') && ($('#search-query').val() === "" || $('#search-query').val() == "Search")) {
            $('#search-query').stop().animate({ 'border-color': '#b3b3b3' });
        }
    }, function () {
        if (!$('#search-query').is(':focus') && ($('#search-query').val() === "" || $('#search-query').val() == "Search")) {
            $('#search-query').stop().animate({ 'border-color': '#fff' }, 'slow');
        }
    });
    $('#search-query').focus(function () {
        $(this).css({ 'border-color': '#b3b3b3' });
        if ($(this).val() == "Search") {
            $(this).val('');
        }
    });
    $('#search-query').blur(function () {
        var val = $(this).val();
        if (val == '') {
            $(this).val("Search");
            $(this).animate({ 'border-color': '#fff' });
        }
    });
    // END: Navigation Drop Downs
    // Topics page expandable fund list
    if ($('.topics_dropdown').length) {
        $('.topics_dropdown .listholder').hide();
        $('.topics_dropdown h4').click(function (e) {
            e.preventDefault();
            var container = $(this).parent(),
            _this = $(this);
            if (_this.hasClass('open')) {
                container.children('.listholder').hide();
                _this.toggleClass('open');
            } else {
                container.children('.listholder').show();
                _this.toggleClass('open');
            }
        });
    }
    
    /*--------------------------------------------------
     * Tabs
     */
    //--- Fund Details Sub Banner
    var fundTabBanner = function () {
    
        $('#banner_overview').hide();
        
        var activePane = $('.fund_pane:visible');
        
        if ($('.tab-text',activePane).attr('id') == 'overview') $('#banner_overview').css('display', 'inline-block');
        
        // IE7 (IE8 compat) Table Caption display bug
        if ( $.browser.msie && parseInt( $.browser.version ) == 7 ) $('table.fund-table > caption',activePane).css('zoom','1');
        
    }
    if ($('.tabs-teaser-funds').length && !EV.PrintMode) Enthink.Tabs.InitTabs('.tabs-teaser-funds', '.tab-text', true, 'eFundsTabs', 'button-tabs', '', 'active', '', '', EV.SmartEdit);
    if ($('.tabs-topic').length > 1 && !EV.PrintMode) Enthink.Tabs.InitTabs('.tabs-topic', '.tab-text', true, 'eTopicTabs', 'button-tabs', '', 'active', '', '', EV.SmartEdit);
    if ($('.fund_pane').length && !EV.PrintMode) Enthink.Tabs.InitTabs('.fund_pane', '.tab-text', true, 'eFundPaneTabs', '', '', 'active', '#fund_main_tabs', fundTabBanner, '', '', EV.SmartEdit);
    if ($('.fund_subpane').length && !EV.PrintMode) Enthink.Tabs.InitTabs('.fund_subpane', '.tab-text', true, 'eFundSubPaneTabs', 'button-tabs', '', 'active', '', '', EV.SmartEdit);

    /* Accordions */
    $( '.teaser-funds-accordion' ).each(function(){
    
        var $accordion = $(this);
        
        $('.teaser-funds-accordion-pane', $accordion).each(function(){
        
            var $pane = $(this),
                $handle = $('.handle-text', $pane),
                $ul = $('ul', $pane).first(),
                count = $('li', $ul).length,
                countSpan = $('<span>').addClass('count').text(' (' + count + ')');
            
            $handle.append( countSpan );
            
            ( $pane.index() != 0 || $accordion.hasClass('closed') ) ? $ul.hide() : $ul.show() ;
            $handle.css('cursor','pointer').click(function(){
            
                var $activeUL = $('ul:visible', $accordion);
                
                ( $activeUL[0] === $ul[0] ) ? (
                    $ul.hide() 
                ) : (
                    $activeUL.hide(),
                    $ul.show()
                );
                
            });
        });
    });        

    /*--------------------------------------------------
     * Carousels
     */
    //--- Topics Carousel
    if ($('.carousel-topics').length) {
    
        $('.carousel-topics').each(function(){
            
            var carousel = $(this);
            var carouselID = carousel.attr('id');
            var controls = $('.controls',carousel);
            var controlCount = $('li',controls).length;
            var content = $('.content',carousel); 
       
            if ( controlCount > 1 ){
                controls.css('display', 'inline-block');
                $('li',controls).hover(function () {
                    $(this).css('cursor', 'pointer');
                }, function () {
                    $(this).css('cursor', 'auto');
                });
                
                var autoplay = ( carousel.hasClass('Disabled') || EV.SmartEdit ) ? false : true;
        
                if(autoplay) {
                    var feature = new Ev.Carousel(content, controls, 7000);
                } else {
                    $('li',controls).bind('click',function(){
                        var listIndex = $('li',controls).index(this);
                        var activeControl = $('li.active',controls);
                        var activePane = $('li.active',content);
                        var targetPane = $('.content li',carousel).eq(listIndex);
                        
                        activeControl.toggleClass('active')
                        $(this).toggleClass('active');
                        activePane.toggleClass('active');
                        targetPane.toggleClass('active');
                        Enthink.Utils.SetCookie('evcarouseltopics_'+ carouselID,listIndex,'1');
                    });
                    var topicsCookieID = Enthink.Utils.GetCookie('evcarouseltopics_'+ carouselID);
                    if(topicsCookieID) $('li',controls).eq(topicsCookieID).click();
                }
            }
        }); // each
    }
    //--- Home Page Carousel
    if ($('.carousel-home').length) {
    
        var carousel = $('.carousel-home');
        var content = $('.content', carousel);
        var controls = $('ul.controls', carousel);
        var controlCount = $('li',controls).length;
        var cookieID = Enthink.Utils.GetCookie('evherocarousel');
        var isHomePage = ( $('body').hasClass('home') ) ? true : false;
        // Styling does depend on JS
        //$('#mask', carousel).css('border-right-width', '0');
        if ( isHomePage ) $('div.carousel-text',content).css('width','739px').css('padding-left','250px');
        if ( EV.SmartEdit ) { 
            if(carousel.hasClass('carousel-home-se')){ 
                carousel.css('margin-top','-58px'); 
            } else {
                carousel.css('margin-top','-25px'); 
            }
            $('.carousel-home-se .content').css('height','390px'); 
            $('.carousel-home-se').css('height','425px');   
        }
        
        var autoplay = ( carousel.hasClass('Disabled') || EV.SmartEdit ) ? false : true;
        if(controlCount==3 || controlCount>=5) {
            
            switch(controlCount){
                case 3:
                    var itemWidth = 332;
                break;
                default:
                    var itemWidth = 198;
            }
            var carouselScroll = new Scroll.Carousel('.carousel-home #mask',itemWidth);
        } else {
            $('#mask',carousel).css('text-align','left').css('border-right','1px dotted #ccc');
            if( isHomePage && EV.SmartEdit ) {
               $('.rdMenu, .rdMenuOpen',carousel).css('width','489px');
            } else {
               $('.rdMenu, .rdMenuOpen',carousel).css('width','989px');
            }
        }        
        $('.item', controls).bind('click', function (e) {
            e.preventDefault();
            
            if(!EV.SmartEdit && autoplay) {
                window.clearTimeout(carouselInterval);
                    carouselInterval = setInterval(function () { 
                        if($('.center', controls).next().length){
                            $('.center', controls).next().trigger('click'); 
                        } else {
                            $('li', controls).first().trigger('click');
                        }
                    }, 9000);
            }   
         
            if($(e.target).attr('href')) clearInterval(carouselInterval);
            var targetAnchor = $(this).find('a');
            var targetID = targetAnchor.attr('rel');
            var parentControl = $(this);
            var targetPane = $('#' + targetID, content);
            var activePane = $('li:visible', content);
            var speed = ($.browser.msie) ? 'slow' : 'slow';
                       
            if(controlCount==4 || controlCount==2) {
                $('li',controls).removeClass('center active');
                parentControl.toggleClass('center');
            }
                       
            if(!EV.SmartEdit) {
            
                targetPane.find('*').hide(); // ensure content is hidden
                if($.support.opacity){
                
                    activePane.fadeOut(speed, function () {
                        if ($.browser.msie) _IECarouselGradient(targetPane); // IE friendly gradient filter
                        targetPane.fadeIn(speed, function () {
                            $('.carousel-item, .carousel-img, .carousel-text',targetPane).show();
                            if($('.carousel-img',targetPane).children().size() > 0){
                                $('.carousel-img *',targetPane).fadeIn(speed, function () {
                                    $('.carousel-text *',targetPane).fadeIn(speed);
                                });
                            } else {
                                if($('.carousel-text',targetPane).children().size() > 0){
                                    $('.carousel-text *',targetPane).fadeIn(speed);
                                }
                            }
                        });
                    });
                    
                } else { // IE7/IE8
                
                    activePane.hide();
                    targetPane.find('*').show();
                    targetPane.show();                
                
                }
            } else { // SmartEdit
                
                activePane.hide();
                targetPane.find('*').show();
                targetPane.show();                
                Enthink.Utils.SetCookie('evherocarousel',targetID,'1');
            }
        });
        if(!EV.SmartEdit && autoplay) {
            $('.carousel-home ul.content li.active *').show();
            if(controlCount>1) var carouselInterval = setInterval(function () { $('.center', controls).next().trigger('click'); }, 9000);
        } else {
        
            if(controlCount<3) {
                //$('li',controls).removeClass('center');
                $('li',controls).first().show();
            }
        
            if(cookieID!=null){
                $('a[rel='+cookieID+']',controls).closest('li').click();
            } else {
                var activeContent = $('.carousel-home ul.content li.active');
                if(activeContent.length){
                    $('.carousel-home ul.content li.active *').show();
                } else {
                    $('.carousel-home ul.controls li').filter(':first').click();
                }
            }
        }
        
    } // End Home Carousel
    
    function _IECarouselGradient(targetPane) {
        var paneClasses = targetPane.attr('class');
        if(paneClasses){
            var classArray = paneClasses.split(' ');
            for (i=0; i<classArray.length; i++) {
                if (classArray[i].substr(0, 9) == 'carousel-'){
                    var paneClass=classArray[i]; // one class to rule them all
                }        
            }    
        }
        var paneGradient = _IECarouselGradientColors(paneClass);
        if( paneClass && paneGradient ) targetPane.css('filter', "progid:DXImageTransform.Microsoft.gradient(" + paneGradient + ");");
    }
    function _IECarouselGradientColors(classString) {
        switch(classString) {
        case 'carousel-blue':
            return "startColorstr='#86BDDC', endColorstr='#E7EEF4'";
        default:
            return false;
        }    
    }
    /*--------------------------------------------------
     * Fund Performance Table
     */
    // ie7 randomly hiding table.performance th span.arw on #header_buttons a:hover
    if( $('#header_buttons').length && !($.browser.msie && $.browser.version.substr(0,1)==7) ) {
        $('#header_buttons ul li a').hover(function(){ $(this).toggleClass('hover'); }, function(){ $(this).toggleClass('hover'); });
    }
    if ($('table.performance').length) {
        //index array for the sortable solution
        var sortable = {};
        sortable.headers = {};
        var counter = 0;
        //run through the thead elements to apply appropriate styling classes to them
        $("table.performance thead tr th").each(function () {
            var th = $(this);
            var classArray = getClasses(th);
            if ($.inArray("sortable", classArray) != -1) {
                th.addClass("sortable");
            }
            else {
                index = th.index();
                sortable.headers[index] = {};
                sortable.headers[index].sorter = false;
            }
            counter++;
        });
        // Include addtional tablesorter options if defined in the page
        if (typeof EV.tablesorterOptions != 'undefined') {
            $.extend(sortable, EV.tablesorterOptions)
        }
        var performanceTable = $('table.performance');
        performanceTable.tablesorter(sortable);  // apply sorting to table col.sortable
        var performanceTableBody = $('tbody',performanceTable);
        performanceTableBody.delegate('.check','click',function(){
            var _this = $(this);
            _this.toggleClass('checked');
            _this.parent().parent().toggleClass('picklist');
        });
        var browserCheck = ($.browser.msie && parseInt($.browser.version) < 8);
        performanceTableBody.delegate('tr','mouseover mouseleave', function(e) {
            var _row = $(this);
            if ( e.type == 'mouseover' ) {
                if(!browserCheck) _row.addClass('hover');
                _row.find(".download_wrapper").show();
            } else {
                if(!browserCheck) _row.removeClass('hover');
                _row.find(".download_wrapper").hide();
            }
        });
        if(!browserCheck) {
            performanceTableBody.delegate('td','mouseover mouseleave', function(e) {
                var _cell = $(this);
                var _col = $('col',performanceTable).eq(_cell.index());
                if( !_col.hasClass('no_hover') ){
                    if ( e.type == 'mouseover' ) {
                        _cell.addClass('hover');
                        /*if(!browserCheck)*/ _col.addClass('hover');
                    } else {
                        _cell.removeClass('hover');
                        /*if(!browserCheck)*/ _col.removeClass('hover');
                    }
                }
            });
        }     
    }
    //show the share list if it is selected
    $("div.shares a").click(function (e) {
        e.preventDefault();
        $(this).parent().find("ul").slideToggle();
    });
    if ($('#performance-table').length) {
        //check to make sure rows are visible on initial page load
        checkTable();
        //check to see if a filter variable is passed via the url
        if (typeof (urlParams['filter']) != "undefined") {
            var typeName = urlParams['filter'];
            
            //retrieve the anchor associated with this filter
            var anchor = $("#performance-table div.links a." + typeName);
            
            // clear active class if filter variable is passed
            if(typeName.search("share") == -1){
                $("#performance-table ul.type li").removeClass("active");
            } else {
                $("#performance-table ul.shares li").removeClass("active");
            }
            
            //add this anchor as the active filter
            anchor.parents("li").addClass("active");
            //get the text of the element selected
            var text = anchor.text();
            //find the parent object holding the element selected
            var slider = anchor.parents("div.funds, div.shares");
            //change the text in its respective dropdown
            slider.find("a span").html(text);
            //get the column index we will be comparing data against
            var index = $("#performance-table table col.symbol").index() + 1;
            filterTable(index, typeName, anchor);
        }
        //show the fund list if it is selected
        $("#performance-table div.links div.funds a").click(function (e) {
            e.preventDefault();
            $(this).parent().find("div.fund_list").slideToggle();
        });
        //do the following when a link in the dropdowns is selected
        $("#performance-table div.links ul li a").click(function () {
            var a = $(this);
            //get the text of the element selected
            var text = a.text();
            //find the parent object holding the element selected
            var slider = a.parents("div.funds, div.shares");
            //change the text in its respective dropdown
            slider.find("a span").html(text);
            //slide the element back up
            if (slider.is(".funds")) {
                slider.find("div").slideToggle();
            }
            else {
                slider.find("ul").slideToggle();
            }
        });
        $("#performance-table div.links ul li:has(a)").hover(function () {
            var ul = $(this);
            ul.addClass("hover");
        },
        function () {
            var ul = $(this);
            ul.removeClass("hover");
        });
        //do the following if any of the fit selection options is selected
        $("#performance-table ul a").each(function () {
            var anchor = $(this);
            anchor.click(function () {
                // Deactivate previous filter on same side (left/right)
                anchor.parent().parent().parent().find('li').each(function () {
                    $(this).removeClass("active");
                });
                anchor.parents("li").addClass("active");
                //get the classname of the fund filter selected
                var typeName = anchor.attr("class");
                //get the column index we will be comparing data against
                var index = $("#performance-table table col.symbol").index() + 1;
                filterTable(index, typeName, anchor);
            });
        });
    }
   
    /*--------------------------------------------------
     * Join Tooltip
     */
 
    var joinButton = $('#ev-join');
    var joinTemplate = $('#ev-tooltip-join-template');
    if( joinTemplate.length ){
        var fadeSpeed = ($.support.opacity) ? 'normal' : 0;
        joinButton.hover(function(){
            var _this = $(this);
            if( $('.ev-tooltip',_this).length < 1 ) joinTemplate.clone(false).removeAttr('id').appendTo(_this);
            var clonedTooltip = $('.ev-tooltip',_this);
            
            // Tooltip Display
            $('.ev-tooltip-download',clonedTooltip).show();
            $('.ev-tooltip-body',clonedTooltip).show();
            clonedTooltip.stop(true, true).fadeIn(fadeSpeed);
            
            // Tooltip Position
            clonedTooltip.position({
                    my: 'left',
                    at: 'right',
                    of: _this,
                    offset: '25 0',
                    collision: 'flip fit'    
                });
            
                $('.ev-tooltip-arw-left',clonedTooltip).position({
                    my: 'left',
                    at: 'right',
                    of: _this,
                    collision: 'flip fit'    
                });
            
                $('.ev-tooltip-arw-border-left',clonedTooltip).position({
                    my: 'left',
                    at: 'right',
                    of: _this,
                    collision: 'flip fit'    
                });
            
                if (_this.offset().left > clonedTooltip.offset().left) {
                $('div.ev-tooltip-arw-left',clonedTooltip).attr('class','ev-tooltip-arw-right');
                $('div.ev-tooltip-arw-border-left',clonedTooltip).attr('class','ev-tooltip-arw-border-right');
                } else {
                $('div.ev-tooltip-arw-right',clonedTooltip).attr('class','ev-tooltip-arw-left');
                $('div.ev-tooltip-arw-border-right',clonedTooltip).attr('class','ev-tooltip-arw-border-left');
                }
            },
            function(){
                var _this = $(this);
                var clonedTooltip = $('.ev-tooltip',_this);
                clonedTooltip.stop(true, true).fadeOut(fadeSpeed);
            }
        );
    }


    /*--------------------------------------------------
     * Export/Sign In Button
     */
    if( !EV.PrintMode ) {
    
        // Ensure subscribe.js is present
        if( typeof window.EV.LoginModal == 'function' ) {
        
            $('#tools-export').click(function(e){
                e.preventDefault();
                EV.LoginModal(this,'gated-export',true);
            });
            
            $('#ev-login, .ev-login').live('click', function(e){
                    e.preventDefault();
                    EV.LoginModal(this,'login',false);
            });
        }
    }
    /*--------------------------------------------------
     * Gated Content / Un-gated Content / Subscribe Links
     */
    if( !EV.PrintMode ) {
    // Don't run without SelfServe
    if( typeof(EV_SDATA)!=='undefined' && EV_SDATA !== false ){
    
    // Ensure subscribe.js is present
    if( typeof window.EV.GatedContent == 'function' ) {
                           
    // Don't run with empty subscription data
    if( !$.isEmptyObject(EV_SDATA) ){
                        
                        var updatedAnchorCount = 0;
                        
                        // Update anchors
                        $('a[href]').each(function(){
                        
                            var anc = $(this);
                            var pathname = anc.attr('href').toLowerCase();
                            //var pathnameTrim = ( pathname.charAt(pathname.length-1) == ';') ? pathname.substr(0, pathname.length-1 ) : false;
                            // Exception Class
                            if ( anc.hasClass('acctbutton') || anc.hasClass('no_padlock') || pathname.charAt(0) == "#" || anc.parents('ul.controls').length )
                                return true;
                            
                            var itemData = EV_SDATA[pathname];
                            // var itemData = ( EV_SDATA[pathname] ) ? EV_SDATA[pathname] : ( EV_SDATA[pathnameTrim] ) ? EV_SDATA[pathnameTrim] : false ;
                            if (itemData) {
                                anc.wrapInner('<span />');
                                
                                // check access controls
                                /*var accessArr = itemData.access;
                                for( var key in accessArr ) {
                                    if(accessArr[key]=="1") { 
                                        anc.addClass('sac_'+key);
                                    }
                                }*/
                                
                                /* Custom behaviour */
                                
                                    // show/hides
                                    var showIcons = true;
                                    if ( anc.parents('div.carousel-item').length ) showIcons = false;
                                    
                                    // custom targets
                                    var parentEvent = false;
                                    var target = false;
                                    if ( anc.parents('div.event').length ) {
                                        parentEvent = anc.closest('div.event');
                                        target = $('p.title',parentEvent);
                                    }
                                    
                                    // additional styling
                                    var buttonWrapper = anc.parents('div.buttons');
                                    if ( buttonWrapper.length ) {
                                        buttonWrapper.addClass('padlock');
                                    }
                                
                                /* Add new hooks */                                  
                                if ( itemData.tags.locked_content==true && itemData.tags.BRD_SUBSCRIBE==true ) {   
                              
                                    updatedAnchorCount++;
                                    anc.addClass('ev-gated-subscription');
                                    anc.addClass('sid_' + itemData.printcode); 
                                    
                                    if ( showIcons ) {
                                        // subscribe icon
                                        var elementSubscribe = document.createElement('img');
                                        elementSubscribe.setAttribute('class', 'subscribe');
                                        elementSubscribe.setAttribute('alt','(subscribe)');
                                        elementSubscribe.setAttribute('src', '/images/interface/widget_plus.gif');
                                        
                                        // gated icon
                                        var elementPadlock = document.createElement('img');
                                        elementPadlock.setAttribute('class', 'padlock');
                                        elementPadlock.setAttribute('alt','Content for Financial Advisors only');
                                        elementPadlock.setAttribute('src', '/images/interface/padlock.gif');
                                        
                                        if ( target ) { 
                                            if ( !target.children('img').length ) target.append( elementPadlock );
                                            if ( !target.children('img').length ) target.append( elementSubscribe );
                                        } else { 
                                            if ( !anc.children('img').length ) anc.append( elementPadlock );
                                            if ( !anc.children('img').length ) anc.append( elementSubscribe );
                                        }
                                    }
                                } else if ( itemData.tags.BRD_SUBSCRIBE==true ) { 
                                    
                                    updatedAnchorCount++;
                                    anc.addClass('ev-subscription');
                                    anc.addClass('sid_' + itemData.printcode); 
                                    
                                    if ( showIcons ) {
                                        var elementSubscribe = document.createElement('img');
                                        elementSubscribe.setAttribute('class', 'subscribe');
                                        elementSubscribe.setAttribute('alt','(subscribe)');
                                        elementSubscribe.setAttribute('src', '/images/interface/widget_plus.gif');
                                                               
                                        if ( target ) { 
                                            if ( !$(target).children('img').length ) target.append( elementSubscribe );
                                        } else { 
                                            if ( !$(target).children('img').length ) anc.append( elementSubscribe );
                                        }
                                    }     
                           
                                } else if ( itemData.tags.locked_content==true ) {                                 
                                   
                                    updatedAnchorCount++;
                                    anc.addClass('ev-gated');
                                    
                                    if ( showIcons ) {
                                        
                                        var elementPadlock = document.createElement('img');
                                        elementPadlock.setAttribute('class', 'padlock');
                                        elementPadlock.setAttribute('alt','Content for Financial Advisors only');
                                        elementPadlock.setAttribute('src', '/images/interface/padlock.gif');
                                        
                                        if ( target ) { 
                                            if ( !target.children('img').length ) target.append( elementPadlock );
                                        } else { 
                                            if ( !anc.children('img').length ) anc.append( elementPadlock );
                                        }
                                        
                                    }
                                }
                            }
                        });
                        // Update Register and Forgot Password links for login modal
                        if(typeof(EV_URL_REG)!='undefined') $('#btn-register').attr('href',EV_URL_REG);
                        if(typeof(EV_URL_FGT)!='undefined') $('#btn-forgot').attr('href',EV_URL_FGT);                        
                        // Initialize Gated/Subscription Flow
                        if( updatedAnchorCount > 0 ){
                        
                            // Update Subscribe HTML with SelfServe links
                            if(typeof(EV_URL_PRF)!='undefined') {
                                $('#btn-manage').attr('href',EV_URL_PRF);
                                $('li.s_already a.manage').attr('href',EV_URL_PRF); 
                            }
                            EV.GatedContent();
                            
                            // Fix stacking order for tooltip in IE7
                            if($.browser.msie && $.browser.version.substr(0,1)<8){
                                $(function(){
                                    var zIndexNumber = 900;
                                    $('div').not('#banner .fund_details, #tools, #banner, #body-gradient, #ev-tooltip, #banner_overview .downloads, #main, #navigation, .widget-gradient').each(function(){
                                        $(this).css('zIndex',zIndexNumber);
                                        zIndexNumber -= 2;
                                    });
                                });
                            }
                        }
                        
                        // Profile Maintenance
                        var form = $('#sub-maintenance');
                        
                        if(form.length){
                        
                            form.show(); // JS enabled only
                            EV.ProfileMaintenance(form);
                            
                        }
        
    } } } } // checks
    /*--------------------------------------------------
     * Tooltip Funds
     */
    if(!EV.PrintMode){
        
        $(".fund").each(function () {
            var fundID = parseID(this.className,'fid_');
            if (!fundID || !ev_FundData[fundID])
                return;
            var fund = ev_FundData[fundID];
            var fadeSpeed = ($.support.opacity) ? 'normal' : 0;
            var _this = $(this);
            if( _this.hasClass('ev-tooltip') ){ // tooltip content class widget
                // Set the fund modal details to the current fund.
                $(".date", _this).html(ev_FundData["market-date"]);
                var fundBody = $(".ev-tooltip-body-fund",_this);
                
                fundBody.addClass(("cid_" + fund["class"]));
                
                $("h5", fundBody).html(fund["name"]);
                $(".description", fundBody).html(fund["description"]);
                $(".value", fundBody).html(((fund["domicile"]=="US")?"$":"") + fund["price"].toFixed(2));
                $(".price .change", fundBody).html('<span class="arw"></span>' + fund["change"].toFixed(2));
                $(".price .change", fundBody).removeClass("up");
                $(".price .change", fundBody).removeClass("down");
                if (fund["change"] > 0)
                    $(".price .change", fundBody).addClass("up");
                else if( fund["change"] < 0 )
                    $(".price .change", fundBody).addClass("down");
                $(".symbol span", fundBody).html(fundID);
                
                    // Filter Portfolio Fit Items
                    $(".recommended dd", fundBody).hide().each(function () {
                        if ($.inArray(this.className, fund["fit"]) > -1)
                            $(this).show();
                    });
            } else { // tooltip hover anchor
                $(this).mouseleave(function () {
                    $("#ev-tooltip").fadeOut(fadeSpeed);
                });
    
                $(this).mouseenter(function () {
    
                    // Set the fund modal details to the current fund.
                    $("#ev-tooltip-body-fund .date").html(ev_FundData["market-date"]);
                    $("#ev-tooltip-body-fund").removeClass();
                    $("#ev-tooltip-body-fund").addClass(("cid_" + fund["class"]));
                    $("#ev-tooltip-body-fund h5").html(fund["name"]);
                    $("#ev-tooltip-body-fund .description").html(fund["description"]);
                    $("#ev-tooltip-body-fund .value").html(((fund["domicile"]=="US")?"$":"") + fund["price"].toFixed(2));
                    $("#ev-tooltip-body-fund .price .change").html('<span class="arw"></span>' + fund["change"].toFixed(2));
                    $("#ev-tooltip-body-fund .price .change").removeClass("up");
                    $("#ev-tooltip-body-fund .price .change").removeClass("down");
    
                    if (fund["change"] > 0)
                        $("#ev-tooltip-body-fund .price .change").addClass("up");
                    else if( fund["change"] < 0 )
                        $("#ev-tooltip-body-fund .price .change").addClass("down");
    
                    $("#ev-tooltip-body-fund .symbol span").html(fundID);
    
                    // Filter Portfolio Fit Items
                    $("#ev-tooltip-body-fund .recommended dd").hide().each(function () {
                        if ($.inArray(this.className, fund["fit"]) > -1)
                            $(this).show();
                    });
    
                    // Show hide tooltip types
                    $("#ev-tooltip-body-portfolio").hide();
                    $("#ev-tooltip-body-fund").show();
                    $("#ev-tooltip").stop(true, true).show();
                    // Position Tooltip
                    $("#ev-tooltip").position({
                        my: "left",
                        at: "right",
                        of: $(this),
                        offset: "25 0",
                        collision: "flip fit"
                    });
                    $("#ev-tooltip-arw").position({
                        my: "left",
                        at: "right",
                        of: $(this),
                        collision: "flip fit"
                    });
                    $("#ev-tooltip-arw-border").position({
                        my: "left",
                        at: "right",
                        of: $(this),
                        collision: "flip fit"
                    });
    
                    if ($(this).offset().left > $("#ev-tooltip").offset().left) {
                        $("#ev-tooltip-arw, #ev-tooltip-arw-border").removeClass("arw-left");
                        $("#ev-tooltip-arw, #ev-tooltip-arw-border").addClass("arw-right");
                    } else {
                        $("#ev-tooltip-arw, #ev-tooltip-arw-border").removeClass("arw-right");
                        $("#ev-tooltip-arw, #ev-tooltip-arw-border").addClass("arw-left");
                    }
                });
            } // Widget or Tooltip Check
        }); // Each Fund Assignment
        // Tooltip Portfolio
        $(".fund-types > li > a").each(function () {
            var fadeSpeed = ($.support.opacity) ? 'normal' : 0;
            $(this).mouseleave(function () {
                $("#ev-tooltip").fadeOut(fadeSpeed);
            });
            $(this).mouseenter(function () {
                // Assign Portfolio Fit Data
                $('#ev-tooltip-body-portfolio .description').html($(this).siblings('p').html());
                $("#ev-tooltip-body-portfolio h5").removeClass();
                $("#ev-tooltip-body-portfolio h5").addClass($(this).attr('class'));
                $("#ev-tooltip-body-portfolio h5").html($(this).html());
                // Show hide tooltip types
                $("#ev-tooltip-body-portfolio").show();
                $("#ev-tooltip-body-fund").hide();
                $("#ev-tooltip").stop(true, true).fadeIn(fadeSpeed);
                // Position Tooltip
                $("#ev-tooltip").position({
                    my: "left center",
                    at: "right center",
                    of: $(this),
                    offset: "25 0",
                    collision: "flip fit"
                });
                $("#ev-tooltip-arw").position({
                    my: "left center",
                    at: "right center",
                    of: $(this),
                    collision: "flip fit"
                });
                $("#ev-tooltip-arw-border").position({
                    my: "left center",
                    at: "right center",
                    of: $(this),
                    collision: "flip fit"
                });
                if ($(this).offset().left > $("#ev-tooltip").offset().left) {
                    $("#ev-tooltip-arw, #ev-tooltip-arw-border").removeClass("arw-left");
                    $("#ev-tooltip-arw, #ev-tooltip-arw-border").addClass("arw-right");
                } else {
                    $("#ev-tooltip-arw, #ev-tooltip-arw-border").removeClass("arw-right");
                    $("#ev-tooltip-arw, #ev-tooltip-arw-border").addClass("arw-left");
                }
            });
        }); // Each Portfolio
        
    }
    
    /*--------------------------------------------------
     * Banner Teaser Rollover Dropdowns
     */
     $('.widgets .teaser.insight').each(function(){
        var initialY = $('h3',this).height() + 26; // 14px padding less rounded corners
        var buttons = $('.buttons',this);
        var buttonsHeight = buttons.height();
        buttons.hide().css('top', initialY+'px');
        $(this).hover(function(){
            $.support.opacity ? (
                buttons.css('opacity', 0).show().animate({opacity: 1}, 500)
            ) : (
                buttons.show()
            )
        },
        function(){
            $.support.opacity ? (
                buttons.animate({opacity: 0}, 500).hide()
            ) : (
                buttons.hide()
            )
        });
     });
    
    /* Widget Heights */
    $('.widgets').each(function(){
        var tallest = 0;
        var widgets = $(this).children();
        var seBool = false;
        widgets.each(function(){
            if( !$(this).hasClass('widgetOpen') ){
                var widgetHeight = $(this).height();
                tallest = ( widgetHeight > tallest ) ? widgetHeight : tallest;
            }
        });
        widgets.each(function(){
            if( !$(this).hasClass('widgetOpen') ){
                if($(this).hasClass('ev-tooltip')){
                    $(this).css('height', tallest + 8 + 'px'); // 8px padding 
                } else if($('.teaser',this).hasClass('insight')) {
                    $('.teaser',this).css('height', tallest - 10 + 'px');
                } else {
                    $('.teaser',this).css('height', tallest + 'px');
                }
            }        
        });
    });  
  
    $('.carousel-topics-wide').each(function(){
        var carousel = $(this);
        var tallest = 0;
        $('ul.content li',carousel).each(function(){
            var paneHeight = $(this).height();
            tallest = ( paneHeight > tallest ) ? paneHeight : tallest;
        });
        $('ul.content',carousel).css('height',tallest+35+'px');
        
        if($.support.opacity){     
            $('ul.content li',carousel).css('height',tallest+10+'px');
        } else {
            $('ul.content li',carousel).css('height',tallest+'px');
        }
    });
    
}); // END: Document Ready
/*--------------------------------------------------
 * EV Public Methods
 */
$(document).ready(function(){
    $('input#fund-search').autocomplete({source:'http://'+window.location.hostname+'/js/autocomplete.json.php'}, {dataType:'json', minLength:3});
    $("input#fund-search'").bind("autocompleteselect", function(event, ui) { 
        document.location.href =  ui.item.value;
        event.preventDefault; 
        } );
}); 
// KnowledgeVision Modals
var webPresentation = function (url, width, height){
    if( typeof url == 'undefined' || typeof url != 'string' || typeof jQuery == 'undefined' )
        return false;
    // Clean URL
    url = ( url.charAt(0) == '/' ) ? url.substring(1) : url;
    
    // Sizing
    var windowWidth = Math.floor( $(window).width() * .9 ),
        windowHeight = Math.floor( $(window).height() * .9 ) - 42;
    typeof width == 'undefined' ? (
        width = windowWidth
    ) : (
        width = ( typeof width == 'string' ) ? parseInt(width) : width,
        width = ( width > windowWidth ) ? windowWidth : width        
    );
    
    typeof height == 'undefined' ? (
        height = windowHeight
    ) : (
        height = ( typeof height == 'string' ) ? parseInt(height) : height,
        height = ( height > windowHeight ) ? windowHeight : height
    );
    // Modal HTML
    if( !$('#presentation-template-html').length )
        $('body').append( $('<div />').attr('id','presentation-template-html').css('width',width+'px').css('height',height+42+'px') );
    
    // If Modal Header has not been created yet create one.
    if( $('#presentation-template-html').children('.simplemodal-header').length < 1 )
        $('#presentation-template-html').prepend('<div class="simplemodal-header" style="margin-bottom:5px;"><span class="close">&nbsp;</span><h4 class="simplemodal-title">&nbsp;</h4></div>');
        
    // Modal
    var modalOptions = {
        overlayClose: true, 
        opacity: 30,
        closeClass: 'close',
        onShow: function(){
            $('#presentation-template-html').append('<iframe id="presentationFrame" src="/includes/presentation.php?config=' + url + '&width=' + width + '&height=' + height + '" frameborder="no" scrolling="no" width="' + width + '" height="' + height + '"></iframe>');
        }
    }
    // Launch
    $('#presentation-template-html').modal(modalOptions);
}




// Looks for prefix_SYMBOL in the class attribute and extracts the SYMBOL
function parseID(classString,prefix) {
    if (typeof (classString) == "string" && typeof (prefix) == "string") {
    var classArray = classString.split(" ");
    for (i=0; i<classArray.length; i++) {
        if (classArray[i].substr(0, 4) == prefix)
        return(classArray[i].substring(4));
    }
    }
    return null;
}
//This function just finds the classes in a passed in element and returns it as an array
function getClasses(element) {
    classArray = element.parents("table").find("col").eq(element.index()).attr("class").split(" ");
    return classArray;
}
function filterTable(index, typeName, anchor) {
    var parts=typeName.split("-");
    var leftFilter=$("#performance-table div.fund_list li.active a").attr("class")||'all-left';
    var rightFilter=$("#performance-table ul.shares li.active a").attr("class")||'all-right';
    if(parts[0]=='share'||typeName=='all-right')rightFilter=typeName;else leftFilter=typeName;
    
    $("#performance-table table tbody tr").each(function () {                                                                                                                                                             
        var tr = $(this);
        if(leftFilter=="all-left" && rightFilter=="all-right"){
            tr.removeClass('hide');
        }else{
            tr.addClass('hide');
            if(leftFilter=='all-left'){//show only matching right filter
                if(tr.hasClass(rightFilter))tr.removeClass('hide');
            }//if left all only
            else{
                if(rightFilter=='all-right'){ //show only matching left filter
                    if(tr.hasClass(leftFilter))tr.removeClass('hide');
                }else{//neither left nor right filters are 'all', show only rows matching both filters.
                    if(tr.hasClass(leftFilter)&&tr.hasClass(rightFilter)){
                        tr.removeClass('hide');
                    }//if neither all
                }//else: neither filter is on all
            }//else left all
        }//not both all
    });//Q(tr).each(fn{})
}//filterTable
//This function checks if any rows are visible in the table, and if not, shows the tfoot element
function checkTable() {
    var hiddenRows = $("#performance-table table tbody").find("tr:visible").length;
    if (hiddenRows === 0) {
        $("#performance-table table thead").hide();
        $("#performance-table table tbody").hide();
        $("#performance-table table tfoot").show();
    }
    else {
        $("#performance-table table thead").show();
        $("#performance-table table tbody").show();
        $("#performance-table table tfoot").hide();
    }
}






 
// Set the focus to the initial field 
function SetInitialFocus()
{
    document.getElementById("txtFirstName").focus();
}
   
 // Force a click of the Login button when the Enter Key is pressed
function SetKeyPress(e)
{
   if(e.keyCode == 13)
   {
      e.returnValue = false;
      document.getElementById("btnSubmit").click();
   }
}
function aShareFilter(){
    $(function(){
        
        $("#performance-table ul.shares li").removeClass("active");
        
        //add this anchor as the active filter
        $("#performance-table div.links a.share-A").parents("li").addClass("active");
        //get the text of the element selected
        var text = $("#performance-table div.links a.share-A").text();
        //find the parent object holding the element selected
        var slider = $("#performance-table div.links a.share-A").parents("div.funds, div.shares");
        //change the text in its respective dropdown
        slider.find("a span").html(text);
        //get the column index we will be comparing data against
        var index = $("#performance-table table col.symbol").index() + 1;
        
        filterTable(3,'share-A',$("#performance-table div.links a.share-A"));
    });
}
function meetManager(){
     $("ul.tabs > li.tab > span:contains('Management')").click();
}
