Number.prototype.toDecimals = function(n)
{
	n = (isNaN(n))? 2 : n;
	var nT = Math.pow(10, n);

	function pad(s)
	{
		s = s || ".";
		return (s.length > n) ? s : pad(s + "0");
	}
	return (isNaN(this)) ? this : (new String(Math.round(this * nT)/nT)).replace(/(\.\d*)?$/, pad);
}

function clickById(id) {
	var el = $(id);
	if (el) {
		el.fireEvent('unselect');
		el.fireEvent('click');
	}
}

function showWin(url, args, width, height, params, center)
{
	if(!params) params = "";
	var w = width ? "width=" + width + "px, " : "";
	var h = height ? "height=" + height + "px, " : "";

	var win = window.open(url, args, w + h + "help=0, toolbar=0, personalbar=0, titlebar=0, location=0, scrollbars=0, resizable=1," + params);

	if(center)
	{
		win.moveTo((window.screen.width-width)/2, (window.screen.height-height)/2)
	}

	return win;
}

function numVal(val)
{
	return isNaN(val) ? 0 : Number(val);
}
