if (!EatonVance) var EatonVance = {};
if (!EatonVance.UI) EatonVance.UI = {};

// EatonVance.UI namespace
new function() {
    // namespace short hand
    var ME = EatonVance.UI;

    ME.accessList = {
'/Whats-Your-Number.php': 1,
'/PIF-Performance-Reports.php': 1,
'/Investment-Professional-Webinars.php': 1,
'/Latin-America-Documents.php': 1,
'/Cayman-Latin-America-Documents.php': 1,
'/SecureDoc-4895.php': 1,
'/LoadDocument.php': 1,
'/LoadDocument.php': 1,
'/LoadDocument.php': 1,
'/LoadDocument.php': 1,
'/LoadDocument.php': 1,
'/SecureDoc-4504.php': 1,
'/SecureDoc-4503.php': 1,
'/SecureDoc-3501.php': 1,
'/SecureDoc-3149.php': 1,
'/SecureDoc-3148.php': 1,
'/SecureDoc-1616.php': 1,
'/SecureDoc-1615.php': 1,
'/SecureDoc-1608.php': 1,
'/SecureDoc-1607.php': 1,
'/SecureDoc-5394.php': 1,
'/SecureDoc-q411ccflyer.php': 1,
'/SecureDoc-5354.php': 1,
'/SecureDoc-3927.php': 1,
'/SecureDoc-CCSVOL0911.php': 1,
'/SecureDoc-5142-7-11j.php': 1,
'/SecureDoc-5142-7-11f.php': 1,
'/SecureDoc-5142-7-11e.php': 1,
'/SecureDoc-5142-7-11a.php': 1,
'/SecureDoc-5142-7-11b.php': 1,
'/SecureDoc-5142-7-11c.php': 1,
'/SecureDoc-5142-7-11d.php': 1,
'/SecureDoc-5142-7-11g.php': 1,
'/SecureDoc-5142-7-11i.php': 1,
'/SecureDoc-5142-7-11h.php': 1,
'/SecureDoc-5287.php': 1,
'/SecureDoc-5266.php': 1,
'/SecureDoc-5256.php': 1,
'/SecureDoc-5169.php': 1,
'/SecureDoc-4963.php': 1,
'/SecureDoc-4155.php': 1,
'/SecureDoc-3893.php': 1,
'/SecureDoc-3684.php': 1,
'/SecureDoc-3266.php': 1,
'/SecureDoc-5147.php': 1,
'/SecureDoc-5146.php': 1,
'/SecureDoc-5140.php': 1,
'/SecureDoc-5136.php': 1,
'/SecureDoc-5133.php': 1,
'/SecureDoc-5124.php': 1,
'/SecureDoc-5123.php': 1,
'/SecureDoc-5122.php': 1,
'/SecureDoc-5108.php': 1,
'/SecureDoc-5105.php': 1,
'/SecureDoc-5103.php': 1,
'/SecureDoc-5101.php': 1,
'/SecureDoc-5044.php': 1,
'/SecureDoc-4898.php': 1,
'/SecureDoc-4882.php': 1,
'/SecureDoc-4625.php': 1,
'/SecureDoc-4603.php': 1,
'/SecureDoc-4519.php': 1,
'/SecureDoc-4484.php': 1,
'/SecureDoc-3968.php': 1,
'/SecureDoc-3698.php': 1,
'/SecureDoc-366.php': 1,
'/SecureDoc-NAA.php': 1,
'/Advisor-Institute.php': 1,
'/Performance-Reports.php': 1,
'/Business-Development-Tips.php': 1,
'/Business-Development-Tips.php': 1,
'/Getting-Started-DAF.php': 1,
'/Investment-Professional-Benefits-DAF.php': 1,
'/Investment-Professional-Benefits-PIF.php': 1,
'/Getting-Started-PIF.php': 1,
'/Estimate-Income-Tax-Deduction.php': 1,
'/EVI-CI-Floating-Rate-Income-Fund-EFRNT.php': 1,
'/EVI-CI-Strategic-Income-Fund-ECMSX.php': 1,
'/Ireland-Funds-Sales-Charges-and-Commissions.php': 1,
'/EVI-CI-Strategic-Income-Fund-ESINN.php': 1,
'/Cayman-and-Ireland-Price-Chart.php': 1,
'/EVI-CI-Floating-Rate-Income-Fund-EFRAT.php': 1,
'/EVI-CI-Floating-Rate-Income-Fund-EFRAX.php': 1,
'/EVI-CI-Strategic-Income-Fund-EAMSX.php': 1,
'/Cayman-Funds-Sales-Charges-and-Commissions.php': 1,
'/EVI-CI-Floating-Rate-Income-Fund-ERFIX.php': 1,
'/EVI-CI-Strategic-Income-Fund-ESINT.php': 1,
'/EVI-CI-Strategic-Income-Fund-ESIAX.php': 1,
'/EVI-CI-Floating-Rate-Income-Fund-ECFIX.php': 1,
'/EVI-CI-Emerging-Markets-Local-Income-Fund-EEMAA.php': 1,
'/EVI-CI-Floating-Rate-Income-Fund-EMFRX.php': 1,
'/EVI-CI-Emerging-Markets-Local-Income-Fund-EEMCT.php': 1,
'/EVI-CI-Emerging-Markets-Local-Income-Fund-EEMNN.php': 1,
'/EVI-CI-Strategic-Income-Fund-ERMSX.php': 1,
'/EVI-CI-Emerging-Markets-Local-Income-Fund-EEMCC.php': 1,
'/EVI-CI-Strategic-Income-Fund-ESIAT.php': 1,
'/EVI-CI-Emerging-Markets-Local-Income-Fund-EEMAT.php': 1,
'/EVI-CI-Floating-Rate-Income-Fund-EOFIX.php': 1,
'/Cayman-Funds-EU-Asia-Middle-East-Documents.php': 1,
'/EVI-CI-Emerging-Markets-Local-Income-Fund-EEMNT.php': 1,
'/DC-SA-Professional-Materials.php': 1,
'/Investment-Professional-Media-Library.php': 1,

// Call a function to generate all Media Manager locked items in the same format as the above list.
'theend': 1
    };
   
    ME.PadlockRestricted = function (src) {

        // Should be abstracted
        $('a[href]').not('#navigation a, .carousel-home a').each(function(){
            var anc = $(this);
            var pathname = anc.attr('href');
            // Exception Class
            if (anc.hasClass('acctbutton') || anc.hasClass('no_padlock') || pathname.charAt(0) == "#")
                return true;
            
            if (pathname.charAt(0) != '/') {
                pathname = '/' + pathname;
            }
            if (ME.accessList[pathname]) {
                
                // Add Icon
                var elementPadlock = document.createElement('img');
                elementPadlock.setAttribute('class', 'padlock');
                elementPadlock.setAttribute('src', '/images/interface/padlock.gif');

                if ( !anc.children('img').length ) {
                    if( anc.parents('span.button').length || anc.parents('.documents-vert').length ){
                        anc.append( elementPadlock );
                    } else {
                        anc.after( elementPadlock );
                    }  
                }    
                
                // Trigger Login Modal
                if( typeof window.EV.LoginModal == 'function' && EV_BYPASS!=1 ) {
                    anc.bind('click',function(e){
                        e.preventDefault();
                        EV.LoginModal(anc,'redirect',false);
                    });
                }
          
            }
        });

        // Should be abstracted
        $('#navigation a').each(function(){

            var anc = $(this);
            var pathname = anc.attr('href');

            // Exception Class
            if (anc.hasClass('acctbutton') || anc.hasClass('no_padlock') || pathname.charAt(0) == "#")
                return true;
            
            if (pathname.charAt(0) != '/') {
                pathname = '/' + pathname;
            }
            if (ME.accessList[pathname]) {
                
                var elementPadlock = document.createElement('img');
                elementPadlock.setAttribute('class', 'padlock');
                elementPadlock.setAttribute('src', '/images/interface/padlock.gif');
                $(anc).append( elementPadlock );
                
            }
        });

    };

    if (window.attachEvent) {
        window.attachEvent('onload', ME.PadlockRestricted);
    }
    else if (window.addEventListener) {
      window.addEventListener('load', ME.PadlockRestricted, false);
    }
    else {
        window.onload = ME.PadlockRestricted;
    }
};
