// Calculate Coffee Break Costs

	function calculate(){
		form = document.forms['breakcalc'];
		daysPerWeek = 5;
		weeksPerYear = 52;
		e = form['employees'].value;
		b = form['breaks'].value;
		m = form['mins'].value;
		r = form['rate'].value;
		
		perweek = e*b*(m/60)*r*daysPerWeek;
		perannum = perweek*weeksPerYear;

		document.getElementById('perweekspan').innerHTML = currencyFormat(perweek);
		document.getElementById('perannumspan').innerHTML = currencyFormat(perannum);		
	}

	function currencyFormat(num){
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
			num = "0";
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
			cents = "0" + cents;
		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));
		return (num + '.' + cents);
	}
	
	function init(){
		form = document.forms['breakcalc'];
		for (i=0; i<form.length; i++)
			form[i].onchange = calculate;
	}
