function PluralTimeValue(iValue, sValueSingle, sValuePlural) {
  if (iValue == 1)
     {
     return iValue + " " + sValueSingle;
     }
  else
     {
     return iValue + " " + sValuePlural;
     }
}

function Difference(tDestination, sInTimePrefix, sInTimeSuffix, sOutOfTimeText) {
var  tNow = new Date();

  var tDifference = Math.floor(tDestination.getTime() / 1000 - tNow.getTime() / 1000);

  var sDifference;

  var tDays = Math.floor(tDifference / 86400);
  tDifference -= Math.floor(tDifference / 86400) * 86400;

  var tHours = Math.floor(tDifference / 3600);
  tDifference -= Math.floor(tDifference / 3600) * 3600;

  var tMins = Math.floor(tDifference / 60);
  tDifference -= Math.floor(tDifference / 60) * 60;

  var tSecs = tDifference;

  if (tDays == 0)
     { // HEUTE
     sDifference = sInTimePrefix +
                   PluralTimeValue(Math.abs(tHours), "Std., ", "Std., ") +
                   PluralTimeValue(Math.abs(tMins), "Min.", "Min.") /*+
                   " und " +
                   PluralTimeValue(Math.abs(tSecs), "Sekunde", "Sekunden") +
                   sInTimeSuffix*/;
     }
  else
     { // IN x TAGEN
     if (tDays > 0)
        {
        //sDifference = sInTimePrefix + PluralTimeValue(Math.abs(tDays), "Tag", "Tagen") + sInTimeSuffix;
        sDifference = sInTimePrefix +
                      PluralTimeValue(Math.abs(tDays), "Tag <br />", "Tagen <br />") +
                      PluralTimeValue(Math.abs(tHours), "Std., ", "Std., ") +
                      PluralTimeValue(Math.abs(tMins), "Min.", "Min.");
        }
     else
        { // DIE ZEIT IST KOMPLETT ABGELAUFEN
        sDifference = sOutOfTimeText;
        }
     }
  return sDifference;
}

function SinceDate(tDestination, sPrefix, sSuffix) {
var tNow = new Date();

  var tDifference = Math.floor(tNow.getTime() / 1000 - tDestination.getTime() / 1000);

  var sDifference;

  var tDays = Math.floor(tDifference / 86400);
  tDifference -= Math.floor(tDifference / 86400) * 86400;

  var tHours = Math.floor(tDifference / 3600);
  tDifference -= Math.floor(tDifference / 3600) * 3600;

  var tMins = Math.floor(tDifference / 60);
  tDifference -= Math.floor(tDifference / 60) * 60;

  var tSecs = tDifference;

     sDifference = sPrefix +
                   PluralTimeValue(Math.abs(tDays), "Tag, ", "Tagen, ") +
                   PluralTimeValue(Math.abs(tHours), "Std., ", "Std., ") +
                   PluralTimeValue(Math.abs(tMins), "Min.", "Min.") +
                   sSuffix;
  return sDifference;
}