﻿var totalFloorArea, totalVolume, kitchenBoost, bathroomBoost, enSuiteBoost, enSuite2Boost, utilityBoost, wcBoost, ventilationRate, area, areaDB, infiltration, pressure, numberOfBedrooms;

function PopupDomestic() {
    popDomestic.Show();
}

function CalculateDomestic() {
    $.getJSON("datacallbacks.aspx?m=GetDomestic",
        { domesticArea: txtTotalFloorArea.GetValue() },
        function (data) {
            totalFloorArea = txtTotalFloorArea.GetValue();
            totalVolume = totalFloorArea * txtCeilingHeight.GetValue();
            kitchenBoost = data.KitchenBoost * txtKitchen.GetValue();
            bathroomBoost = data.BathroomBoost * txtBathroom.GetValue();
            enSuiteBoost = data.EnSuiteBoost * txtEnSuite.GetValue();
            enSuite2Boost = data.EnSuite2Boost * txtEnSuite2.GetValue();
            utilityBoost = data.UtilityBoost * txtUtility.GetValue();
            wcBoost = data.WCBoost * txtWC.GetValue();

            ventilationRate = data.VentilationRate;
            areaDB = data.TotalFloorArea * 0.3;
            area = txtTotalFloorArea.GetValue() * 0.3;
            infiltration = totalVolume * 0.04;
            pressure = ddlPressure.GetValue();
            numberOfBedrooms = lblBedrooms.GetValue();

            lblTotalVolume.SetValue(totalVolume + ' m<sup>3</sup>');
            lblBoost.SetValue((kitchenBoost + bathroomBoost + enSuiteBoost + enSuite2Boost + utilityBoost + wcBoost) + ' l/s');
            lblVentilation.SetValue(ventilationRate + ' l/s');
            lblArea.SetValue(area + ' l/s');
            lblInfiltration.SetValue(infiltration + ' l/s');

            if (areaDB > ventilationRate) {
                lblAP3.SetValue(areaDB + ' l/s');
                lblAP5.SetValue(areaDB - infiltration + ' l/s');
            } else {
                lblAP3.SetValue(ventilationRate + ' l/s');
                lblAP5.SetValue(ventilationRate - infiltration + ' l/s');
            }
            lblPressure.SetValue(pressure + ' Pa');
            lblBedrooms.SetValue(numberOfBedrooms);
        }
    );
}
