/**
 * Inicializuje Truncator
 * Elementy ktere chceme skryvat musi mit prirazrnu tridu "hide_me".
 * Elementy ovladani musi mit prirazeny triny "more" a "less".
 *
 * @param string truncatorId ID boxu s elementy ktere chceme skryvat.
 * @param integer showCount Pocet elementu ktere jsou v zakladu odkryty.
 */
function initTruncator(truncatorId, showCount)
{
    $('#'+truncatorId+' > .more').click(function(){
        $('#'+truncatorId+' > .hide_me').show();
        toggleControls(truncatorId);
        return false;
    });

    $('#'+truncatorId+' > .less').click(function(){
        truncateTruncatorBox(truncatorId, showCount);
        toggleControls(truncatorId);
        return false;
    });

    truncateTruncatorBox(truncatorId, showCount);
    $('#'+truncatorId+' > .less').hide();
}

function truncateTruncatorBox(truncatorId, showCount)
{
    $('#'+truncatorId+' > .hide_me:gt('+(showCount-1)+')').hide();
}

function toggleControls(truncatorId)
{
    $('#'+truncatorId+' > .less').toggle();
    $('#'+truncatorId+' > .more').toggle();
}
