function ThousandSeparator(decimalDigits,Value) {
  var separatorLength = 3;
  var OriginalValue=Value;
  var TempValue = "" + OriginalValue;
  var NewValue = "";
  var pStr;
  var dStr;
 
  if (TempValue.indexOf(".")==-1){TempValue+="."} dStr=TempValue.substr(0,TempValue.indexOf("."));
  pStr=TempValue.substr(TempValue.indexOf("."))    
  while (pStr.length-1< decimalDigits){pStr+="0"}
  if(pStr =='.') pStr ='';
  if(dStr.length > separatorLength) {
    while( dStr.length > separatorLength) {
      NewValue = " " + dStr.substr(dStr.length - separatorLength) + NewValue;
      dStr = dStr.substr(0,dStr.length - separatorLength);
    }
    NewValue = dStr + NewValue;
  } else {
    NewValue = dStr;
  } 
  NewValue = NewValue + pStr; 
  return NewValue;
}

function spocti() {
  var najem = Math.round(parseInt(document.FV_kalkulator.plocha.value)/25*887*13.46*0.015);
  var vykon = Math.round(parseInt(document.FV_kalkulator.plocha.value)/25);
  var sp = document.getElementById("sp");
  sp.firstChild.nodeValue=ThousandSeparator (0, najem);
  var sp = document.getElementById("sp20");
  sp.firstChild.nodeValue=ThousandSeparator (0, najem*20);
  var sp = document.getElementById("vykon");
  sp.firstChild.nodeValue=ThousandSeparator (0, vykon);
}

spocti();

