﻿var totalHeight = 0;
var BrkH = 310;

jQuery(document).ready(function () {
    ColH();
});

function ColH() {
    jQuery(".region_tab").append("<div class='region_col' ref='0' style='padding-left: 20px;'></div>");
    jQuery(".region_tab").css({ position: "relative", height: 1, opacity: 0 });
    jQuery(".region_tab .region_row").each(function () {
        var thisHTML = jQuery(this).html();
        var index = jQuery(".region_row").index(this);
        var region_index = index + 1;
        var region_row_h = jQuery(this).height();
        totalHeight = totalHeight + region_row_h;
        var thisBrk = Math.floor((Math.round((totalHeight / BrkH) * 100) / 100));
        jQuery(this).attr({ "ref": thisBrk });
        var prevRef;
        if ((index - 1) <= 0) {
            prevRef = 0;
        } else {
            prevRef = jQuery(".region_row").eq(index - 1).attr("ref");
        }
        if (prevRef != jQuery(this).attr("ref")) {
            if (jQuery(".region_col[ref=" + thisBrk + "]").size() == 0) {
                jQuery("#holder").append("<div class='region_col' ref='" + thisBrk + "'></div>");
            }
        }
        jQuery(this).remove();
        jQuery(".region_col[ref=" + thisBrk + "]").append("<div class='region_row'><div class='padd'>" + thisHTML + "</div></div>");
    });
    jQuery(".region_tab").animate({ height: 450, opacity: 1 }, 300);

}
