/* Methods used to drive contents calculator. */
/* If editing calculator form, this JavaScript must be updated to keep input names synchronised. */
/* If the input names in the form and this JavaScript file don't match, the functions will not work. */

function lounge_family_room_onchange() {
with (document.getElementById("formCalculator"))
	{
		loungeSub.value = (lounge1.value * 1) + (lounge2.value * 1) + (lounge3.value * 1) + (lounge4.value * 1) + (lounge5.value * 1) + (lounge6.value * 1);
		return grand_total_onchange();
	}
}

function dining_room_room_onchange() {
with (document.getElementById("formCalculator"))
	{
		diningSub.value = (dining1.value * 1) + (dining2.value * 1);
		return grand_total_onchange();
	}
}

function bedroom1_onchange() {
with (document.getElementById("formCalculator"))
	{
		mainBedroomSub.value = (mainBedroom1.value * 1) + (mainBedroom2.value * 1);
		return grand_total_onchange();
	}
}

function bedroom_other_onchange() {
with (document.getElementById("formCalculator"))
	{
		otherBedroomsSub.value = (otherBedrooms1.value * 1) + (otherBedrooms2.value * 1) + (otherBedrooms3.value * 1);
		return grand_total_onchange();
	}
}

function kitchen_onchange() {
with (document.getElementById("formCalculator"))
	{
		kitchenSub.value = (kitchen1.value * 1) + (kitchen2.value * 1) +
			(kitchen3.value * 1) + (kitchen4.value * 1) + (kitchen5.value * 1) +
			(kitchen6.value * 1) + (kitchen7.value * 1) + (kitchen8.value * 1) +
			(kitchen9.value * 1) + (kitchen10.value * 1) + (kitchen11.value * 1);
		return grand_total_onchange();
	}
}

function general_onchange() {
with (document.getElementById("formCalculator"))
	{
		generalSub.value = (general1.value * 1) + (general2.value * 1) + (general3.value * 1) +
			(general4.value * 1) + (general5.value * 1) + (general6.value * 1) +
			(general7.value * 1) + (general8.value * 1) + (general9.value * 1) +
			(general10.value * 1) + (general11.value * 1) + (general12.value * 1) +
			(general13.value * 1) + (general14.value * 1) + (general15.value * 1) +
			(general16.value * 1) + (general17.value * 1) + (general18.value * 1) + (general19.value * 1) ;
		return grand_total_onchange();
	}
}

function laundry_onchange() {
with (document.getElementById("formCalculator"))
	{
		laundrySub.value = (laundry1.value * 1) + (laundry2.value * 1) + (laundry3.value * 1) + (laundry4.value * 1);
		return grand_total_onchange();
	}
}

function other_valuables_onchange() {
with (document.getElementById("formCalculator"))
	{
		otherSub.value = (other1.value * 1) + (other2.value * 1) + (other3.value * 1) + (other4.value * 1) + (other5.value * 1) + (other6.value * 1);
		return grand_total_onchange();
	}
}

function manchester_onchange() {
with (document.getElementById("formCalculator"))
	{
		manchesterSub.value = (manchester1.value * 1) + (floor1.value * 1) + (floor2.value * 1);
		return grand_total_onchange();
	}
}

function grand_total_onchange() {
with (document.getElementById("formCalculator"))
	{
		grandTotal.value = (loungeSub.value * 1) + (diningSub.value * 1) +
			(mainBedroomSub.value * 1) + (otherBedroomsSub.value * 1) + (kitchenSub.value * 1) +
			(generalSub.value * 1) + (laundrySub.value * 1) + (otherSub.value * 1) +
			(manchesterSub.value * 1) + (anyOtherSub.value * 1);
	}
}
