﻿$(document).ready(function(){ 
    $(".tablecarro").each(function(){
        var total = 0;
        var i = 0;
        var s = "";
        var tabcarro = $(this);
        
        tabcarro.find(".grupohora").each(function(){
            var g1 = $(this);
            s = g1.text();

            if (g1.text() != "")
            {
                total = 0;
                tabcarro.find(".grupohora").each(function(){
                    var g2 = $(this);
                    if(g1[0].id != g2[0].id &&
                        g1.text() == g2.text())
                    {
                        g2.remove();
                        total++;
                    }
                });
                
                if(total >= 1)
                    g1.attr("rowspan", total + 1);
                g1.text(s + " ");
            }
        });
    });
});