Change latin number to persian number and add commas by jQuery function
<p>I want change latin number to persian number and add commas, but it don't work true for me. what do i do?</p>

<p><a href="http://jsfiddle.net/39rKM/3/" rel="nofollow"><strong>Demo:</strong></a><br>
Please see my demo, output is <code>&amp;#1,782;&amp;#1,783;&amp;#1,783;&amp;#1,782;&amp;#1,781;&amp;#1,781;&amp;#1,782;&amp;#1,783;&amp;#1,783;&amp;#1,784;&amp;#1,784;&amp;#1,785;&amp;#1,785;&amp;#1,784;&amp;#1,783;&amp;#1,784;&amp;#1,780;&amp;#1,776;&amp;#1,784;&amp;#1,776;</code> not a right number.</p>

<pre><code>function numentofa(n) {
var digits = [],
    r;
do {
    r = n % 10;
    n = (n - r) / 10;
    digits.unshift(['&amp;#', r + 1776, ';'].join(''));
} while (n &gt; 0);
return digits.join('');
}
function addCommas(nStr) {
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length &gt; 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}
var oooook = addCommas(numentofa(67765567788998776676));
//$('.numbers').append(oooook);
    alert(oooook);​
</code></pre>
