function formatCurrency(amount, signPositive, hideZero, isJavaScript) {
  amount = amount.toString().replace(',','.');

  if(isNaN(amount))
    return "&nbsp;";

  if (hideZero && amount == 0)
    return "&nbsp;";

  if (amount > 0 && signPositive) {
    sign = (isJavaScript) ? "+ " : "+&nbsp;";
  } else if (amount < 0) {
    sign = (isJavaScript) ? "- " : "-&nbsp;";
  } else {
    sign = "";
  }

  amount = Math.abs(amount);
  amount = Math.floor(amount*100+0.50000000001);
  cents = amount%100;
  amount = Math.floor(amount/100).toString();

  if(cents<10)
    cents = "0" + cents;

  for (var i = 0; i < Math.floor((amount.length-(1+i))/3); i++)
    amount = amount.substring(0,amount.length-(4*i+3))+'.'+
          amount.substring(amount.length-(4*i+3));

  return sign + ((isJavaScript) ? "€ " : "&euro;&nbsp;") + amount + ',' + cents;
}

function formatPercentage(amount) {
  amount = amount.toString().replace(',','.');

  if(isNaN(amount))
    return "&nbsp;";

  return Math.round(amount * 1000) / 10 + "%";
}

function hideAutoFillWatermarks () {
  // Hide watermarks for fields that are filled by browser autofill
  $("[watermark]").each(function(num,el) {
    if ($(el).val()) {
      $(el).siblings("label").fadeOut(500);
    }
  });
}
