function numFormat(n, d, s) 
{
        if (arguments.length == 2) { s = "'"; }
        if (arguments.length == 1) { s = "'"; d = "."; }
        n = n.toString();
        a = n.split(d);
        x = a[0];
        y = a[1];
        z = "";
        if (typeof(x) != "undefined") {
        for (i=x.length-1;i>=0;i--)
                z += x.charAt(i);
        z = z.replace(/(\d{3})/g, "$1" + s);
        if (z.slice(-s.length) == s)
                z = z.slice(0, -s.length);
        x = "";
        for (i=z.length-1;i>=0;i--)
                x += z.charAt(i);
        if (typeof(y) != "undefined" && y.length > 0)
                x += d + y;
        }
        return x;
}

