function formatMoney(p) /* Code used by all JS to format the money stuff, inserts the primary price, potentially compensated for the regular price */
{
        p = p * curRate; // Calculate the right value
        price = formatNum(p);

        if(curName == 'USD') // Pre/postfix with currencyname
            price = "$"+price;
        else
            price = price + " " + curName;
        return price;
}

function formatNum(p) // Format the number as price without currency stuff added
{
                var price = (p*1).toFixed( (p % 1 >= 0.01) ? 2 : 0); // Check whether or not to use digits
                var sRegExp = new RegExp('(-?[0-9]+)([0-9]{3})'), price = price+''; // Build the regexp

                while(sRegExp.test(price)) { // Fix the comma's
                    price = price.replace(sRegExp, '$1'+','+'$2');
                }
        return price;
}


