﻿function resizeColumns() {
    var containerDiv = $('div.featured');
    var subDivs = $('div.featuredProduct');
    //containerDiv.css({ 'width': '100%' });

    var totalWidth = containerDiv.width(); //Get the width of row
    var paddingBuffer = 15;
    var numPossCols = Math.floor(totalWidth / 180); //Find how many columns of 200px can fit per row / then round it down to a whole number
    var numActualCols = subDivs.size();
    var fixedWidth = Math.floor((totalWidth - (paddingBuffer*numActualCols*2)) / numPossCols); //Get the width of the row and divide it by the number of columns it can fit / then round it down to a whole number. This value will be the exact width of the re-adjusted column
    if (numActualCols < numPossCols) { // children don't fill container's width
        fixedWidth = Math.floor((totalWidth - (paddingBuffer * numActualCols * 2)) / numActualCols);
    }
    //alert(totalWidth + "-" + numPossCols + "-" + fixedWidth);
    containerDiv.css({ 'width': totalWidth }); //Set exact width of row in pixels instead of using % - Prevents cross-browser bugs that appear in certain view port resolutions.
    subDivs.css({ 'width': fixedWidth }); //Set exact width of the re-adjusted column	
}