var tour1AdultPrice = 7.50;
var tour1ChildPrice = 5.00;
var tour1ConcessionPrice = 6.00;
var tour1FamilyPrice = 19.00;

var tour2AdultPrice = 8.00;
var tour2ChildPrice = 5.00;
var tour2ConcessionPrice = 6.50;
var tour2FamilyPrice = 21.00;

var tour3AdultPrice = 8.50;
var tour3ChildPrice = 5.00;
var tour3ConcessionPrice = 7.00;
var tour3FamilyPrice = 21.00;


function updateButtons() {
	var tour = document.getElementById("tour").value;
	
	if(tour == 1) {
		document.getElementById("tour-name").value = "Unknown Tour";
		document.getElementById("tour-amount").value =
			calculateTourTotals(tour1AdultPrice,tour1ChildPrice,tour1ConcessionPrice,tour1FamilyPrice);
	}
	
	if(tour == 2) {
		document.getElementById("tour-name").value = "Gallows to Grave Tour Booking";
		document.getElementById("tour-amount").value =
			calculateTourTotals(tour2AdultPrice,tour2ChildPrice,tour2ConcessionPrice,tour2FamilyPrice);
	}
	
	if(tour == 3) {
		document.getElementById("tour-name").value = "Ghost Hunt Tour Booking";
		document.getElementById("tour-amount").value =
			calculateTourTotals(tour3AdultPrice,tour3ChildPrice,tour3ConcessionPrice,tour3FamilyPrice);
	}
}



function updateDate() {
	document.getElementById("date-value").value = document.getElementById("day-picker").value+" "+document.getElementById("month-picker").value;
}


function calculateTourTotals(adultPrice,childPrice,concessionPrice,familyPrice) {	
	var total =	(adultPrice * document.getElementById("adults").value) +
				(childPrice * document.getElementById("children").value) +
				(concessionPrice * document.getElementById("concessions").value) +
				(familyPrice * document.getElementById("families").value);
	
	document.getElementById("amount-output").innerHTML = formatAsCurrency("\u00A3",total);
	return total;
}


function formatAsCurrency(currency,amount) {
   digits = amount.toFixed(2).split(".");
   digits[0] = digits[0].split("").reverse().join("").replace(/(\d{3})(?=\d)/g, "$1,").split("").reverse().join("");
   return currency+digits.join(".");
}
