// JavaScript for the Product Category Pages

$('.categoryImage img').each(function() {
    if ($(this).attr('src') == 'https://store.missfitzinc.com/' || $(this).attr('src') == 'https://store.missfitzinc.com/Images/System/NoImageAvailable.gif') {
        $(this).parent().hide();
    }
});

$(document).ready(function() {
    if ($('div.productsCategory div.item').length) {
        $('div.productsCategory div.item:nth-child(4n+4)').css('border-right','0px');
        
        var columns = 4;
        var items = $('div.productsCategory div.item').size();
        var remainingItems = items%columns;
        
        var lastItems
        if (remainingItems == 0) {
            lastItems = items - 4;
            $('div.productsCategory div.item').slice(lastItems, items).css('border-bottom','0px')
        } else {
            lastItems = items - remainingItems;
            $('div.productsCategory div.item').slice(lastItems, items).css('border-bottom','0px')
        }
        
        // Set the corners
        $('.productsCategory').bullNose(
            options = {
                pathToImages:    '/',
                topLeftImg:        'category-container-corner-top-left.gif',
                topRightImg:    'category-container-corner-top-right.gif',
                bottomLeftImg:    'category-container-corner-bottom-left.gif',
                bottomRightImg:    'category-container-corner-bottom-right.gif',
                imageWidth:        '10',
                imageHeight:    '10',
                imageIdPrefix:    'prodCorner',
                positionCornerAbsolute:    true
            }
        );
    } else {
        $('div.productsCategory')
            .css('width','0px')
            .css('height','0px')
            .css('border','0px')
            .css('margin','0px')
            .css('padding','0px')
            .css('background','transparent');
    }
    
});