//----------------------------------------------------------------------------
// format a dutch number to the format 1.000.000,00 etc
//----------------------------------------------------------------------------

function FormatNumber( v, decimals) {
  // remove all non-number characters
  v = v.replace( /[^\d\.,]/g, ''); 
  if (v.search( /\d/) >= 0) {
    // replace dot if used as decimal-sign i.s.o comma
    v = v.replace( /\.(\d\d?)$/, ',$1'); 
    // remove thousands dots (if any)
    v = v.replace( /\./g, '');
    if (decimals >= 0) {
      // replace comma by dot, so we can convert
      v = v.replace( /,/, '.');
      // round in wanted decimals
      f = parseFloat( v);
      f = Math.round( f * Math.pow( 10, decimals)) / Math.pow( 10, decimals);
      d = (Math.floor( f) + "").length;
      v = String( f);
      // replace dot by comma
      v = v.replace( /\./, ',');
    } else {
      d = v.indexOf( ',');
      if (d == -1)
        d = v.length;
    }
    // add thousands points
    for( i = d; i > 3; i -= 3)
      v = v.substr( 0, i-3) + "." + v.substr( i-3);
  }
  return v;
}

function FI( inp) {
  inp.value = FormatNumber( inp.value, 0);
}

function FD2( inp) {
  inp.value = FormatNumber( inp.value, 2);
}

function FN( inp) {
  inp.value = FormatNumber( inp.value, -1);
}



