(function($){

    function getWidth(max, count, min){
        if (count < 1) {
            return max;
        } else if ((max/count) > min ) {
            return max/count;
        }
        return getWidth(max, count-1, min);
    }

    $(document).ready(function(){

        // Isotope
        var isotope = $('#isotope-container').isotope({
            itemSelector: '.isotope-item'
        });
        $('.pagination').hide();

        // Infinite Scroll
        $('#isotope-container').infinitescroll({
            navSelector  : ".pagination",
            nextSelector : ".pagination .next",
            itemSelector : ".blog-article",
            loading: {
                selector: '#infinite-scrolling-loading',
                finishedMsg: '',
                img: 'wp-content/themes/apperclass/assets/images/loader3.gif',
                msgText: ''
            }
        },function(elements){
            $(elements).imagesLoaded( function(){
                var width = $('#isotope-container').width();
                $(elements).css('width', getWidth(width, 5, 250) + 'px');
                isotope.isotope( 'appended', elements );
            });
        });

        // Switch category menu
        $('.category-list-menu').hide();
        $('.category-switch').change(function(e){
            window.location = $(this).val();
        });

        $(window).resize(function(){
            var width = $('#isotope-container').width();
            $('.isotope-item').css('width', getWidth(width, 5, 240) + 'px');
            setTimeout(function(){
                $('#isotope-container').data('isotope').layout();
            },50);
        });

        $(window).trigger('resize');
    });
})(jQuery);


@@ -229,16 +229,443 @@
 %0A    %7D%0A%0A
+    function updateSizes($elements)%7B%0A        var width = $('#isotope-container').width();%0A        var boxWidth =  getWidth(width, 5, 250);%0A        $elements.css('width', boxWidth + 'px');%0A        var imageWidth = boxWidth - 10 ;%0A        var imageHeight = imageWidth * 0.75;%0A        var $images = $elements.find('img');%0A        $images.css('width', imageWidth  + 'px');%0A        $images.css('height', imageHeight + 'px');%0A    %7D%0A%0A
     $(do
@@ -690,16 +690,16 @@
 tion()%7B%0A
-
 %0A       
@@ -1344,185 +1344,34 @@
     
-$(elements).imagesLoaded( function()%7B%0A                var width = $('#isotope-container').width();%0A                $(elements).css('width', getWidth(width, 5, 250) + 'px');%0A    
+updateSizes($(elements));%0A
     
@@ -1423,24 +1423,8 @@
  );%0A
-            %7D);%0A
     
@@ -1666,127 +1666,38 @@
     
-var width = $('#isotope-container').width();%0A            $('.isotope-item').css('width', getWidth(width, 5, 240) + 'px'
+updateSizes($('.isotope-item')
 );%0A 

fix image sizes