﻿function calc_btu(){
	var btu = 0;
	var northFacingAddition    = 0;
	var frenchWindowsAddition  = 0;
	var doubleGlazingDeduction = 0;
	
	var roomHeight = document.getElementById("btu_height").value;
	var roomWidth  = document.getElementById("btu_width").value;
	var roomLength = document.getElementById("btu_length").value;
	
	btu = roomHeight * roomWidth * roomLength;
	
	var isLounge = document.getElementById("btu_roomtype_lounge").checked;
	var isBedroom = document.getElementById("btu_roomtype_bedroom").checked;
	var isKitchen = document.getElementById("btu_roomtype_kitchen").checked;
	
	if (isLounge) {
		btu = btu * 5;
	} else if (isBedroom) {
		btu = btu * 4;
	} else if (isKitchen) {
		btu = btu * 3;
	}
	
	var roomIsNorthFacing    = document.getElementById("btu_isNorthFacing").checked;
	var roomHasFrenchWindows = document.getElementById("btu_hasFrenchWindows").checked;
	var roomHasDoubleGlazing = document.getElementById("btu_hasDoubleGlazing").checked;
	
	if (roomIsNorthFacing) {
		northFacingAddition = btu * 0.15;
	}
	if (roomHasFrenchWindows) {
		frenchWindowsAddition = btu * 0.2;
	}
	if (roomHasDoubleGlazing) {
		doubleGlazingDeduction = btu * 0.1;
	}
	btu = btu + northFacingAddition + frenchWindowsAddition - doubleGlazingDeduction;
	
	document.getElementById("btu_result").innerHTML = Math.round(btu*100)/100;
	
	Set_Cookie("btu_height",roomHeight);
	Set_Cookie("btu_width",roomWidth);
	Set_Cookie("btu_length",roomLength);
	Set_Cookie("btu_lounge",isLounge);
	Set_Cookie("btu_bedroom",isBedroom);
	Set_Cookie("btu_kitchen",isKitchen);
	Set_Cookie("btu_north",roomIsNorthFacing);
	Set_Cookie("btu_french",roomHasFrenchWindows);
	Set_Cookie("btu_glazing",roomHasDoubleGlazing);
}
