"Interactive Dollarizer"

 

function fix(total) {
     // var dollars = parseInt(total);
     var dollars = Math.floor(total);
     // var cents = total - dollars;
     var cents = (total * 100) - (dollars * 100); // browsers sometimes have rounding errors
     

     cents = Math.round( cents);

     if (cents < 10) cents = "0" + cents;
     if (cents == 100) dollars++;
     if (dollars == total || dollars == Math.floor(total) + 1) cents = "00";

     total = dollars + "." + cents;
     return total;
}