/**
 * Format a number as currency.
 */
function formatAsCurrency(amount, currency) {
	var period, ret;
	
	if (!currency) currency = "£";
	amount = parseFloat(amount);
	
	if (isNaN(amount)) {
		ret = "0.00";
	} else {
		amount = Math.round(amount * 100) / 100;		// Round to two decimal places

		// Pad out as required
		ret = new String(amount);
		period = ret.indexOf(".");
		if (period < 0) {
			ret += ".00";
		} else {
			if (ret.length - 2 == period) ret += "0";		// In case there's only one decimal place
		} // if - else
	} // if - else
	
	return (currency + ret);
} // formatAsCurrency
