function enableAllInputsInElement(elementName, enabled)
{
	if (elem = document.getElementById(elementName))
	{
		inputs = elem.getElementsByTagName("input");

		for (i=0; i<inputs.length; i++)
		{
			inputs[i].disabled = !enabled;
		}

		inputs = elem.getElementsByTagName("select");

		for (i=0; i<inputs.length; i++)
		{
			inputs[i].disabled = !enabled;
		}
	}
}

function createPopUpFromElement(elem)
{
	newwindow = window.open('','name','height=300,width=250,screenX=200,screenY=200,resizable,status=no');

	if (window.focus) {newwindow.focus()}

	newwindow.document.write(elem.innerHTML);

	return false;
}

function moneyFormat(num, nogroup)
{
	num = num.toString().replace(/\$|\,/g,'');

	if (isNaN(num))
	{
		znum = "0";
	}

	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();

	if (cents<10)
	{
		cents = "0" + cents;
	}

	if (!nogroup)
	{
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		{
			num = num.substring(0,num.length-(4*i+3))+','+
				num.substring(num.length-(4*i+3));
		}
	}

	// TODO localise this

	return (((sign)?'':'-') + num + '.' + cents);
}

function redirectToSecureSelf()
{
	if (window.location.protocol == 'http:' && window.location.pathname != '/' && !disableSecureSiteRedirect)
	{
		window.location = 'https:' + '//' + window.location.host + window.location.pathname + window.location.search;
	}
}
