function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

<!-- Begin
function round(num) {
amount = Math.round(num*Math.pow(10,2))/Math.pow(10,2);
amount -= 0;
// .99 cent format courtsey of Martin Webb
return (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function stocks(form) {
visitors = form.visitors.value * 1;
opendays = form.opendays.value * 1;
targetmarket = form.targetmarket.value / 100;
rrp = form.rrp.value * 1;
onlinebooking = form.onlinebooking.value / 100;
visitorperday = visitors / opendays;

revenue = round(parseFloat(visitors * targetmarket * onlinebooking * rrp)); // Total Potential Revenue
cost = round(parseFloat((visitorperday * targetmarket * onlinebooking * 60 * 12) + 25000)); // Cost
profit = round(revenue * 0.5);

form.revenue.value  = addCommas(revenue);
form.totalcosts.value = addCommas(cost);
form.grossprofit.value = addCommas(profit);
}
//  End -->

