/*
     $Revision$
     $Id$
*/
function num2curr(s) {
//    debugger;
  if( !isNaN(s) ) {
    s = s.toFixed(2);
  }
  return s;
}

// Met eventueel gewenste decimaalscheider (punt of komma) maar
// nooit 1000-scheiders
function num2currEditable(fnum, decimals)
{
    if (fnum == null)
        return "";

    if (typeof decimals == "undefined")
        decimals = 2;
    fnum = fnum.toFixed(decimals);

    var waarde2 = (1.5).toLocaleString(); // Eventueel gewenste komma.
    fnum = fnum.substring(0, fnum.length - decimals - 1) + waarde2.substring(2, 1) + fnum.substring(fnum.length - decimals);

    return fnum;
}

function isGoodNumber(str, intOnly, posOnly, numLen, numDec)
{
    var posOnlyStr = (posOnly ? "" : "\\-?");
    var numLenStr  = (numLen == -1 ? "" : (numDec == -1 ? numLen : (intOnly ? numLen : numLen - numDec)));
    var numDecStr  = (numDec == -1 ? "" : numDec);

    var intOnlyStr = "\\d{1," + numLenStr + "}[.,]?";
    var dblOnlyStr = "\\d{0," + numLenStr + "}[.,]\\d{1," + numDecStr + "}" + "|"
                   + "\\d{1," + numLenStr + "}[.,]\\d{0," + numDecStr + "}" ;

    var anum = "^"
             + posOnlyStr + "(" + intOnlyStr
                                + (intOnly ? "" : "[.,]?" + "|" + dblOnlyStr)
                          + ")"
             + "$";

    var patt = new RegExp(anum);
    return patt.test(str);
}
