(function($) {

    // Render New Column Heights when page loads
    $(window).load(function() {
        $('*').ReWriteAgeTabColHeight();
        $('*').ReWriteSectionHeight();
    });

    // Find Longest AgeTab Column
    // Add difference to other columns via padding-top
    $.fn.ReWriteAgeTabColHeight = function() {
        var v25 = $('#2to5').offset();
        var v58 = $('#5to8').offset();
        var v812 = $('#8to12').offset();

        if (v25.top >= v58.top) {
            var newTop = v25.top - v58.top + "px";
            $('#5to8').css('paddingTop', newTop);
        }
        if (v25.top >= v812.top) {
            var newTop = v25.top - v812.top + "px";
            $('#8to12').css('paddingTop', newTop);
        }
        if (v58.top >= v25.top) {
            var newTop = v58.top - v25.top + "px";
            $('#2to5').css('paddingTop', newTop);
        }
        if (v58.top >= v812.top) {
            var newTop = v58.top - v812.top + "px";
            $('#8to12').css('paddingTop', newTop);
        }
        if (v812.top >= v25.top) {
            var newTop = v812.top - v25.top + "px";
            $('#2to5').css('paddingTop', newTop);
        }
        if (v812.top >= v58.top) {
            var newTop = v812.top - v58.top + "px";
            $('#5to8').css('paddingTop', newTop);
        }
    };

    // Find Longest Section
    // Add difference to shorter extension via height
    $.fn.ReWriteSectionHeight = function() {
        var KidsProducts = $('#PL_KidsProducts').height();
        var Featured = $('#PL_FeaturedOffers').height();
        var SectionDiff = 0;

        if (KidsProducts >= Featured) {
            SectionDiff = KidsProducts - Featured;
            $('#FeaturedOffers_Extension').css('height', SectionDiff);
        } else if (Featured >= KidsProducts) {
            SectionDiff = Featured - KidsProducts;
            $('#KidsProducts_Extension').css('height', SectionDiff);
        }
    };

}) (jQuery);