function formatNumber(num,cent,isThousand){
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
if(isNaN(cent))
cent = 0;
cent = parseInt(cent);
cent = Math.abs(cent);
if(isNaN(isThousand))
isThousand = 0;
isThousand = parseInt(isThousand);
if(isThousand < 0)
isThousand = 0;
if(isThousand >=1)
isThousand = 1;
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*Math.pow(10,cent)+0.50000000001);
cents = num%Math.pow(10,cent);
num = Math.floor(num/Math.pow(10,cent)).toString();
cents = cents.toString();
while(cents.length<cent){
cents = "0" + cents;
}
if(isThousand == 0)
return (((sign)?'':'-') + num + '.' + cents);
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
if(cents != 0){
return (((sign)?'':'-') + num + '.' + cents);
} else {
return (((sign)?'':'-') + num + '.00');
}
}