function morelesstext (divSelector, showChar, moretext, lesstext)
{
  if(jQuery(divSelector).length)
  {
    var showChar = showChar;
    var ellipsestext = "...";
    //var moretext = "celý popis";
    //var lesstext = "skrýt";
    jQuery(divSelector).each(function() {
        var content = jQuery(this).html();
  
        if(content.length > showChar) {
  
            var c = content.substr(0, showChar);
            var h = content.substr(showChar/*-1*/, content.length - showChar);
  
            var html = c + '<span class="moreellipses">' + ellipsestext+ ' </span><span class="morecontent"><span>' + h + '</span>  <a href="" class="morelink">' + moretext + '</a></span>';
  
            jQuery(this).html(html);
        }
  
    });
  
    jQuery(divSelector + " .morelink").click(function(){
        if(jQuery(this).hasClass("less")) {
            jQuery(this).removeClass("less");
            jQuery(this).html(moretext);
        } else {
            jQuery(this).addClass("less");
            jQuery(this).html(lesstext);
        }
        jQuery(this).parent().prev().toggle();
        jQuery(this).prev().toggle();
        return false;
    });
  }
}

function secondsToTime(secs)
{
    secs = Math.round(secs);
    var hours = Math.floor(secs / (60 * 60));

    var divisor_for_minutes = secs % (60 * 60);
    var minutes = Math.floor(divisor_for_minutes / 60);

    var divisor_for_seconds = divisor_for_minutes % 60;
    var seconds = Math.ceil(divisor_for_seconds);

    var obj = {
        "h": hours,
        "m": minutes,
        "s": seconds
    };
    return obj;
}

function seconds2time (seconds) {
    var time_default = "00 m";
    
    var hours   = Math.floor(seconds / 3600);
    var minutes = Math.floor((seconds - (hours * 3600)) / 60);
    var seconds = seconds - (hours * 3600) - (minutes * 60);
    var time = time_default;
    

    if (hours != 0) {
      //time = hours+":";
      time = hours+" h ";
    }
    if (minutes != 0 || time !== time_default) {
      minutes = (minutes < 10 && time !== "") ? "0"+minutes : String(minutes);
      //time += minutes+":";
      time += minutes+" m";
    }
    
    /*
    if (time === "") {
      time = seconds+"s";
    }
    else {
      time += (seconds < 10) ? "0"+seconds : String(seconds);
    }
    */
    return time;
}