//Equality Plugin
    $.fn.equality = function(options){
        var height,elements;
        
        elements = $(this);
        options = $.extend({},$.equality.defaults, options);
        height = options.height;
        
        $(this).each(function() {
            $(this).height() > height && (height = $(this).height() + options.addOn)
        });
        options.minHeight == true ? elements.css({
            minHeight: height,
            height: 'auto'
        }) : elements.css({
            height: height,
            minHeight: ''
        });
        return $(this);
    };
    $.equality = {
        defaults : {
            height: 0,
            minHeight : 0,
            addOn : 0
        }
    };
//End Equality

$(document).ready(function() {
//Fix numbering of lists that span more than 1 paginated column
var i = 0;
$("ol.countList li").each(function() {
    if ($(this).hasClass("listReset")) {
        i = 0;
    }
    i = i + 1;
    $(this).prepend('<span class="itemNum">' + i + ". </span>");
});

    var activePage = new FS.queryString();

    // Setting menu item active based on url or contentPageID
    if (typeof contentPageID == 'undefined') {
        if (typeof activePage.params['page'] == 'undefined') {
            activePage.params['page'] = ''; /*page param MUST be defined to avoid error at 38 on pages where page= isn't set in navbar.*/
        }

        if(FS.dom.body.hasClass('investorRelations')){
            var activeId = activePage.params['page'].replace(/investorRelations_/i,"#").toLowerCase();
        }
        else if(FS.dom.body.hasClass('customerCare')){
            var activeId = activePage.params['page'].replace(/customerCare_/i,"#").toLowerCase();
        }
        else {
            var activeId = '';
        }

        if (typeof activeId == 'undefined') {
            return false;
        }
        else {
            $(activeId).addClass('selected cCareActive');
        }
    }
    else {
        $('#breadCrumb').remove();
        $('#'+contentPageID.toLowerCase()).addClass('selected cCareActive');
    }


    if(FS.dom.body.hasClass('investorRelations') || FS.dom.body.hasClass('customerCare')) {
        if($('#leftNav ul ul ul > li').hasClass('selected')) {
            $('#leftNav ul ul ul > li.selected').parent('ul').parent('li').addClass('selected');
        }
    }
    
    //TODO: temp fix: appending 日 character to date dropdown for user birthday 
    if(FS.langId === -10) {
        $('#userBirthday option').next().append('日');
        $('#userGender').parent('div').addClass('genderWrap');
    }
    
    // Colorbox calls for TOC and Sec/Privacy modals
    $('.TOCmodal').colorbox({iframe:true, width:"620px", scrolling:false, height:"710px",  title:'<p>'+FS.local_lang.labels.TOCmodal+'</p>' + FS.button({buttonName: "closeButton", buttonClass: "closeButton", buttonId: "closeButton", buttonLabel: FS.local_lang.labels.close})});
    $('.SPmodal').colorbox({iframe:true, width:"720px", scrolling:false, height:"710px",  title:'<p>'+FS.local_lang.labels.SPmodal+'</p>' + FS.button({buttonName: "closeButton", buttonClass: "closeButton", buttonId: "closeButton", buttonLabel: FS.local_lang.labels.close})});

    
    if (typeof activePage.params['page'] !== "undefined" || typeof contentPageID !== 'undefined') {
        if (typeof activePage.params['page'] !== "undefined" && activePage.params['page'].match(/flsApp|_landing/)) {
            return false;
        } else {
            if (FS.dom.secondaryContent.length && !$('#contentPadding .paginated').length && !$('.watch_c_table').length) {
                $('#primaryContent,#secondaryContent,#columnContainer,#leftNavContainer,.paginated,#leftNav ul:first,#columnSinglePrivacy,#columnSingle').equality({height: true, addOn: 140});
            }
        }
    }
});
