	var groupTicketsCost = new Array(29.99,28.99,26.99,23.99);
	var regularTicketsCost = 48.99;
	function formatCurrency(num) {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "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;
		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 (((sign)?'':'-') + '$' + num + '.' + cents);
	}
	function colorRow(id) {
		var rowArray = new Array("people100","people1000","people2500","people5000","people10000");
		for (x in rowArray) {
			if(document.getElementById(rowArray[x]))
				document.getElementById(rowArray[x]).style.backgroundColor = "#fff2bf";
		}
		if (id) {
			document.getElementById(id).style.backgroundColor = "#ffe475";
		}
	}
	function calculateCost() {
		var newValue = document.calculator.group_size.value;
		if (!isNaN(newValue) && String(newValue).length >= 3) {
			if (newValue >= 100 && newValue < 1000) {		
				document.calculator.total_cost.value = formatCurrency(newValue * groupTicketsCost[0]);
				document.calculator.total_savings.value = formatCurrency((regularTicketsCost * newValue) - (groupTicketsCost[0] * newValue))+"!";
				colorRow("people100");
			} else if (newValue >= 1000 && newValue < 2500) {		
				document.calculator.total_cost.value = formatCurrency(newValue * groupTicketsCost[1]);
				document.calculator.total_savings.value = formatCurrency((regularTicketsCost * newValue) - (groupTicketsCost[1] * newValue))+"!";
				colorRow("people1000");
			} else if (newValue >= 2500 && newValue < 5000) {		
				document.calculator.total_cost.value = formatCurrency(newValue * groupTicketsCost[2]);
				document.calculator.total_savings.value = formatCurrency((regularTicketsCost * newValue) - (groupTicketsCost[2] * newValue))+"!";
				colorRow("people2500");
			} else if (newValue >= 5000 ) {		
				document.calculator.total_cost.value = formatCurrency(newValue * groupTicketsCost[3]);
				document.calculator.total_savings.value = formatCurrency((regularTicketsCost * newValue) - (groupTicketsCost[3] * newValue))+"!";
				colorRow("people5000");
			}
		} else {
			document.calculator.total_cost.value = "---";
			document.calculator.total_savings.value = "---";
			colorRow();
		}
	}
