/**
 * Debugging
 */
var debug = false;

/**
 * Animation speeds (ms)
 */
var animSpeed = 300;

/**
 * Console logging (for debugging)
 */
function log(msg)
{
	if (debug)
		console.log(msg);
}

/**
 * Formats the given number
 * @param String num
 * @param Object options - places (number), currencySymbol (e.g. $), percentage (boolean), unformat
 */
function format(num, options)
{
	// Defaults
	if (options == undefined) options = {};
	if (options.places == undefined) options.places = 0;
	
	var newNum = new NumberFormat();
	newNum.setPlaces(options.places);
	newNum.setNumber(num);
	
	// Currency
	if (options.currencySymbol !== undefined)
	{
		newNum.setCurrency(true);
		newNum.setCurrencyPrefix(options.currencySymbol);
		newNum.setPlaces(2);
	}
	
	// Percentages
	if (options.percentage !== undefined)
	{
		// log('Formatted: ' + newNum.toPercentage());
		return newNum.toPercentage();
	}
	// Unformat
	else if (options.unformat !== undefined)
	{
		// log('Formatted: ' + newNum.toUnformatted());
		return newNum.toUnformatted();
	}
	else
	{
		// log('Formatted: ' + newNum.toFormatted());
		return newNum.toFormatted();
	}
}

$(function() {
	/**
	 * App Messages
	 */
	if ($('#msg').length > 0)
		$('#msg').slideDown(animSpeed);
	
	$('#closeMsg').click(function() {
		$('#msg').slideUp(animSpeed);
	});
});
