//arrays of related questions to be activated/deactivated if chosen //contains question text for each question var questionTitlesArray = new Array(); var messages = new Array(); var formSubmitted = false; //heating fuel options var heatingFuelArray = new Array( new Option("Not Present","106"), new Option("Anthracite grains","114"), new Option("Anthracite nuts","113"), new Option("Bottled gas (cylinders)","109"), new Option("Bulk LPG","108"), new Option("Electricity","116"), new Option("House coal","111"), new Option("Mains Gas","107"), new Option("Oil","110"), new Option("Smokeless fuel","112"), new Option("Wood","115") ); //boiler types var boilerTypes = new Array( new Option("Normal","123"), new Option("Combination boiler (This has no hot water cylinder)","124"), new Option("Condensing boiler","125"), new Option("Condensing combination boiler (This has no hot water cylinder)","126"), new Option("Back boiler (Behind a fireplace)","127") ); //room heater types var roomHeaterTypes = new Array( new Option("Standard gas fire","132"), new Option("Gas fire + back boiler (hot water cylinder only, no radiators)","133"), new Option("Gas coal effect heater in an open fireplace","134"), new Option("Open fire","135"), new Option("Open fire with + boiler (hot water only, no radiators)","136"), new Option("Closed room heater","137"), new Option("Closed room heater + back boiler (hot water cylinder, no radiators)","138"), new Option("Electric heaters","139") ); //secondary room heaters var secondaryRoomHeaters = new Array( new Option("Closed room heater","190"), new Option("Closed room heater with back boiler","191"), new Option("Electric heaters","192"), new Option("Gas coal effect heater in an open fireplace","187"), new Option("Gas fire + back boiler (supplying hot water cylinder, no radiators)","186"), new Option("Open fire","188"), new Option("Open fire + back boiler (supplying hot water, no radiators)","189"), new Option("Standard gas fire","185") ); var secondaryHeatingFuel = new Array( new Option("Secondary heating system not present","174"), new Option("Mains Gas","175"), new Option("Bulk LPG","176"), new Option("Bottled gas (cylinders)","177"), new Option("House coal","179"), new Option("Smokeless fuel","180"), new Option("Anthracite nuts","181"), new Option("Anthracite grains","182"), new Option("Wood","183"), new Option("Electricity","184") ); var hotWaterHeatingMethods = new Array( new Option("From main heating","149"), new Option("From secondary heating","150"), new Option("Electric immersion heater","151"), new Option("Instant electric water heater","152"), new Option("Gas water heater over single sink (single-point)","153"), new Option("Gas water heater to more than one sink (multi-point)","154") ); var storeyOptions = new Array( new Option("1", "36"), new Option("2", "37"), new Option("3", "38"), new Option("4", "39") ); var convertedHouseStoreyOptions = new Array( new Option("1", "36"), new Option("2", "37") ); var bungalowStoreyOptions = new Array( new Option("1", "36") ); var bungalowRoomOptions = new Array( new Option("3", "28"), new Option("4", "29"), new Option("5", "30"), new Option("6", "31"), new Option("7", "32"), new Option("8", "33"), new Option("9", "34"), new Option("10", "35") ); var flatRoomOptions = new Array( new Option("2", "27"), new Option("3", "28"), new Option("4", "29"), new Option("5", "30"), new Option("6", "31"), new Option("7", "32"), new Option("8", "33"), new Option("9", "34"), new Option("10", "35") ); var bungalowRoomIntegralOptions = new Array( new Option("4", "29"), new Option("5", "30"), new Option("6", "31"), new Option("7", "32"), new Option("8", "33"), new Option("9", "34"), new Option("10", "35") ); var offPeakOptions = new Array( new Option("Unknown", "168"), new Option("No", "169"), new Option("Yes", "170") ); //intialises page and sets question visibilities if HEC has already been answered function initPage() { toggleQuestionList(new Array(4,8,9,10,11,21,22,23,24,25,26,33,36,37,36),false); flatSelected(document.getElementById('answer[0].answerId').selectedIndex,3,false); toggleQuestionCheck(4,document.getElementById('answer[3].answerId').selectedIndex,2,false); toggleQuestionCheck(8,document.getElementById('answer[7].answerId').selectedIndex,2,false); mainHeatingSet() changeSecondaryRoomHeaters(document.getElementById('answer[32].answerId').value,false); hotWaterCylinderSelected(document.getElementById('answer[35].answerId').selectedIndex,2,false); if(document.getElementById('answer[36].answerId').selectedIndex == 2){ noAccessHotWaterCylinderSelected(document.getElementById('answer[36].answerId').selectedIndex,2,false); } if(document.getElementById('answer[36].answerId').selectedIndex == 0){ noAccessHotWaterCylinderSelected(document.getElementById('answer[36].answerId').selectedIndex,0,false); } // Q14 is "how much of the property is double-glazed?". If the user answers less than 100% then // they have to answer Q15: Are the single glazed windows draught-stripped? If the user answers // 100% then Q15 is hidden. The checkDoubleGlazing method is the onChange event for Q14; I've // added it here so that, after reloading someone's filled-in HEC questionnaire Q15 is displayed // as appropriate. checkDoubleGlazing(document.getElementById('answer[14].answerId').selectedIndex); } //intialises page 1 and sets question visibilities if HEC has already been answered function initPage1() { toggleQuestionList(new Array(4,8,9,10,11),false); flatSelected(document.getElementById('answer[0].answerId').selectedIndex,3,false); toggleQuestionCheck(4,document.getElementById('answer[3].answerId').selectedIndex,2,false); toggleQuestionCheck(8,document.getElementById('answer[7].answerId').selectedIndex,2,false); } //intialises page and sets question visibilities if HEC has already been answered function initPage2() { // Q14 is "how much of the property is double-glazed?". If the user answers less than 100% then // they have to answer Q15: Are the single glazed windows draught-stripped? If the user answers // 100% then Q15 is hidden. The checkDoubleGlazing method is the onChange event for Q14; I've // added it here so that, after reloading someone's filled-in HEC questionnaire Q15 is displayed // as appropriate. checkDoubleGlazing(document.getElementById('answer[14].answerId').selectedIndex); } //intialises page and sets question visibilities if HEC has already been answered function initPage3() { toggleQuestionList(new Array(21,22,23,24,25,26,33,36,37,36),false); mainHeatingSet() changeSecondaryRoomHeaters(document.getElementById('answer[32].answerId').value,false); hotWaterCylinderSelected(document.getElementById('answer[35].answerId').selectedIndex,2,false); if(document.getElementById('answer[36].answerId').selectedIndex == 2){ noAccessHotWaterCylinderSelected(document.getElementById('answer[36].answerId').selectedIndex,2,false); } if(document.getElementById('answer[36].answerId').selectedIndex == 0){ noAccessHotWaterCylinderSelected(document.getElementById('answer[36].answerId').selectedIndex,0,false); } } //goes to next page or submits form for HEC processing function nextPage(page) { if (page !=4) { if (validate(page-1)) { // TK move the buttons down a bit on page 2 //if (page==2) // document.getElementById("flibble"+page).height=30; document.getElementById("page"+(page-1)).style.display = 'none'; document.getElementById("page"+page).style.display = 'block'; //resizeSpacerTable(page); window.scrollTo(0,0); } } else { //validate last page and submit form if ((validate(page-1)) && (!formSubmitted)) { //stops form being submitted more than once formSubmitted = true; document.answersForm.submit(); } } } // blah: /* function resizeSpacerTable(page) { return; alert(page); var height=0; if (page == 1) height = 700; else if (page == 2) height = 5; else if (page == 3) height = 1500 else alert('unknown page'); alert('before:'+document.getElementById('spacerImage').height); document.getElementById('spacerImage').height=height; alert('after:'+document.getElementById('spacerImage').height); } */ //go back to previous page function previousPage(page) { document.getElementById("page"+(page-1)).style.display = 'none'; document.getElementById("page"+(page-2)).style.display = 'block'; window.scrollTo(0,0); } //if flat/maisonette toggled, hide Q2 and show Q9-11 function flatSelected(valueToCheck,setToZero) { var flatQuestions = new Array(9,10,11); var activateFlag = false; //switch off Q2 and toggle flat questions if flat or not chosen if ((valueToCheck == 3) || (valueToCheck ==4)) { activateFlag = true; toggleQuestion(1,false,true); flatTypeSelected(document.getElementById("answer[9].answerId").selectedIndex); } else { if (valueToCheck != 4) toggleQuestion(1,true,true); if (valueToCheck == 2) { swapOptions(6, bungalowStoreyOptions, document.getElementById("answer[6].answerId")); } } integralGarage(document.getElementById("answer[7].answerId").selectedIndex); toggleQuestionList(flatQuestions,activateFlag,setToZero); } function isBungalowSelected() { return document.getElementById("answer[0].answerId").selectedIndex == 2; } function integralGarage(value) { toggleQuestionCheck(8,document.getElementById('answer[7].answerId').selectedIndex,2,false); if (isBungalowSelected() && value == 2) { swapOptions(5, bungalowRoomIntegralOptions, document.getElementById("answer[5].answerId")); } else if (isBungalowSelected() || document.getElementById("answer[0].answerId").selectedIndex == 1){ swapOptions(5, bungalowRoomOptions, document.getElementById("answer[5].answerId")); } else { swapOptions(5, flatRoomOptions, document.getElementById("answer[5].answerId")); } } function flatTypeSelected(value) { flat = document.getElementById("answer[0].answerId").selectedIndex == 3; // if converted house if (value == 1 && flat) { swapOptions(6, convertedHouseStoreyOptions, document.getElementById("answer[6].answerId")); } else { swapOptions(6, storeyOptions, document.getElementById("answer[6].answerId")); } } //if hot water cylinder toggled, switch on/off Q36-38 function hotWaterCylinderSelected(valueToCheck,value,setToZero) { var cylinderQuestions = new Array(36,37,38); var activateFlag = true; if (valueToCheck != value) { activateFlag = false; } toggleQuestionList(cylinderQuestions,activateFlag,setToZero); } //if main heating selected, toggle correct questions and fuel types //depending whether it is a boiler, storage heater, room heater etc. function mainHeatingSelected(valueToCheck,setToZero) { toggleQuestionList(new Array(21,22,23,24,25,26),false,setToZero); if (setToZero) { changeHeatingFuel(valueToCheck); } //switch off main question 28 if no heating controls at all... if (valueToCheck == 2) { document.getElementById("questionTextId28").className = "textOff"; } else { document.getElementById("questionTextId28").className = "textOn"; } //toggle checkboxes switch (valueToCheck) { //boiler case 1: toggleQuestionList(new Array(21,22,23,24),true,setToZero); checkboxToggle(28,true); checkboxToggle(29,true); checkboxToggle(30,true); checkboxToggle(31,true); swapOptions(39,offPeakOptions, document.getElementById("answer[39].answerId")); if (setToZero) toggleSecondaryHeatingOption(true); break; //storage heater case 2: toggleQuestion(25,true); swapOptions(39,new Array(new Option("Yes", "170")), document.getElementById("answer[39].answerId")); setQuestionAnswerByIndex(40,1); checkboxToggle(28,false); checkboxToggle(29,false); checkboxToggle(30,false); checkboxToggle(31,false); if (setToZero) toggleSecondaryHeatingOption(false); break; //room heater case 3: toggleQuestion(26,true); checkboxToggle(28,true); checkboxToggle(29,true); checkboxToggle(30,true); checkboxToggle(31,false); swapOptions(39,offPeakOptions, document.getElementById("answer[39].answerId")); if (setToZero) toggleSecondaryHeatingOption(false); break; //Warm air case 4: checkboxToggle(28,true); checkboxToggle(29,true); checkboxToggle(30,true); checkboxToggle(31,false); swapOptions(39,offPeakOptions, document.getElementById("answer[39].answerId")); if (setToZero) toggleSecondaryHeatingOption(false); break; //Community heating case 5: checkboxToggle(28,true); checkboxToggle(29,true); checkboxToggle(30,true); checkboxToggle(31,true); swapOptions(39,offPeakOptions, document.getElementById("answer[39].answerId")); if (setToZero) toggleSecondaryHeatingOption(false); break; //Ceiling heating case 6: checkboxToggle(28,true); checkboxToggle(29,true); checkboxToggle(30,true); checkboxToggle(31,false); swapOptions(39,offPeakOptions, document.getElementById("answer[39].answerId")); if (setToZero) toggleSecondaryHeatingOption(false); break; } } //set main heating visibilities (checboxes and questions) depending on //if the questionnaire has been answered already and you are coming //through to update it. function mainHeatingSet() { var valueToCheck = document.getElementById('answer[19].answerId').selectedIndex; toggleQuestionList(new Array(21,22,23,24,25,26),false,false); //switch off main question 28 if no heating controls at all... if (valueToCheck == 2) { document.getElementById("questionTextId28").className = "textOff"; } else { document.getElementById("questionTextId28").className = "textOn"; } //toggle checkboxes switch (valueToCheck) { //boiler case 1: toggleQuestionList(new Array(21,22,23,24),true,false); break; //storage heater case 2: toggleQuestion(25,true); swapOptions(39,new Array(new Option("Yes", "170")), document.getElementById("answer[39].answerId")); setQuestionAnswerByIndex(40,1); checkboxToggle(28,false); checkboxToggle(29,false); checkboxToggle(30,false); checkboxToggle(31,false); removeNoSecondaryHeatingOption(); break; //room heater case 3: toggleQuestion(26,true); checkboxToggle(31,false); break; //Warm air case 4: checkboxToggle(31,false); break; //Community heating case 5: break; //Ceiling heating case 6: checkboxToggle(31,false); break; } } //checks whether all double glazing, in which case, turn off following question function checkDoubleGlazing(glazingOption) { if (glazingOption == 5) { toggleQuestion(15,false,true); } else { toggleQuestion(15,true,true); } } //removed 'NOT PRESENT' from secondary heating fuel if Storage heaters chosen //fix as part of sense on public site work: removed 11th option: secondaryHeatingFuel[10] //since the array doesn't have an 11th option! function toggleSecondaryHeatingOption(flag) { var optionsList = document.getElementById('answer[32].answerId').options; if (!flag) { toggleQuestion(32,true,true); toggleQuestion(33,true,true); swapOptions(32,new Array(secondaryHeatingFuel[1],secondaryHeatingFuel[2],secondaryHeatingFuel[3],secondaryHeatingFuel[4],secondaryHeatingFuel[5],secondaryHeatingFuel[6],secondaryHeatingFuel[7],secondaryHeatingFuel[8],secondaryHeatingFuel[9])); } else { toggleQuestion(32,true,true); toggleQuestion(33,false,true); swapOptions(32,new Array(secondaryHeatingFuel[0],secondaryHeatingFuel[1],secondaryHeatingFuel[2],secondaryHeatingFuel[3],secondaryHeatingFuel[4],secondaryHeatingFuel[5],secondaryHeatingFuel[6],secondaryHeatingFuel[7],secondaryHeatingFuel[8],secondaryHeatingFuel[9])); } } function removeNoSecondaryHeatingOption() { var select = document.getElementById('answer[32].answerId'); select.remove(1); toggleQuestion(32,true,true); toggleQuestion(33,false,true); } //if you select heating controls selected, toggle on or off the //heating control function heatingControlsSelected(valueToCheck,value,setToZero) { var heatingControlQuestions = new Array(29,30,31); var activateFlag = true; if (valueToCheck != value) { activateFlag = false; } if (!setToZero) { toggleQuestionList(heatingControlQuestions,activateFlag,setToZero); } } //If 'no access' is selected for hot water cylinder (Q37, then turn off Q38 and 39 function noAccessHotWaterCylinderSelected(valueToCheck,value,setToZero) { var cylinderQuestions = new Array(37,38); var activateFlag = false; if (valueToCheck != value) { activateFlag = true; } toggleQuestionList(cylinderQuestions,activateFlag,setToZero); } //change heating fuel type depending on heating mechanism (boiler/storage heater/room heater etc) function changeHeatingFuel(heatingType) { switch (heatingType) { case 1: swapOptions(20,new Array(heatingFuelArray[1],heatingFuelArray[2],heatingFuelArray[4],heatingFuelArray[5],heatingFuelArray[6],heatingFuelArray[7],heatingFuelArray[8],heatingFuelArray[9],heatingFuelArray[10])); break; case 2: swapOptions(20,new Array(heatingFuelArray[5])); break; case 3: swapOptions(20,new Array(heatingFuelArray[1],heatingFuelArray[2],heatingFuelArray[3],heatingFuelArray[4],heatingFuelArray[5],heatingFuelArray[6],heatingFuelArray[7],heatingFuelArray[9],heatingFuelArray[10])); break; case 4: swapOptions(20,new Array(heatingFuelArray[5],heatingFuelArray[7],heatingFuelArray[8])); break; case 5: swapOptions(20,new Array(heatingFuelArray[4],heatingFuelArray[5],heatingFuelArray[6],heatingFuelArray[7],heatingFuelArray[8],heatingFuelArray[9],heatingFuelArray[10])); break; case 6: swapOptions(20,new Array(heatingFuelArray[5])); break; } //switch heating fuel question to new document.getElementById("answer[20].answerId").selectedIndex = 0; } //change boiler or room heater type if boiler/room heater and certain fuel type selected function changeHeaterType(heatingFuel) { //boiler if (document.getElementById('answer[19].answerId').selectedIndex ==1) { swapBoilerTypes(heatingFuel); } //room heater if (document.getElementById('answer[19].answerId').selectedIndex == 3) { swapRoomHeaterTypes(heatingFuel); } } //change the room heater type depending on fuel selected function swapRoomHeaterTypes(heatingFuel) { switch (heatingFuel) { //Bottled gas case 3: swapOptions(26,new Array(roomHeaterTypes[0],roomHeaterTypes[1],roomHeaterTypes[2])); break; //LPG case 4: swapOptions(26,new Array(roomHeaterTypes[0],roomHeaterTypes[1],roomHeaterTypes[2])); break; //Mains Gas case 7: swapOptions(26,new Array(roomHeaterTypes[0],roomHeaterTypes[1],roomHeaterTypes[2])); break; //Electricity case 5: swapOptions(26,new Array(roomHeaterTypes[7])); break; //Anthracite grains case 1: swapOptions(26,new Array(roomHeaterTypes[3],roomHeaterTypes[4],roomHeaterTypes[5],roomHeaterTypes[6])); break; //Anthracite nuts case 2: swapOptions(26,new Array(roomHeaterTypes[3],roomHeaterTypes[4],roomHeaterTypes[5],roomHeaterTypes[6])); break; //House coal case 6: swapOptions(26,new Array(roomHeaterTypes[3],roomHeaterTypes[4],roomHeaterTypes[5],roomHeaterTypes[6])); break; //Smokeless fuel case 8: swapOptions(26,new Array(roomHeaterTypes[3],roomHeaterTypes[4],roomHeaterTypes[5],roomHeaterTypes[6])); break; //Wood case 9: swapOptions(26,new Array(roomHeaterTypes[3],roomHeaterTypes[4],roomHeaterTypes[5],roomHeaterTypes[6])); break; } } //change the boiler type depending on fuel selected (if boiler selected as main heating method) function swapBoilerTypes(heatingFuel) { switch (heatingFuel) { //LPG case 3: swapOptions(24,new Array(boilerTypes[0],boilerTypes[1],boilerTypes[2],boilerTypes[3],boilerTypes[4])); break; //Mains Gas case 6: swapOptions(24,new Array(boilerTypes[0],boilerTypes[1],boilerTypes[2],boilerTypes[3],boilerTypes[4])); break; //Oil case 7: swapOptions(24,new Array(boilerTypes[0],boilerTypes[1],boilerTypes[2],boilerTypes[3])); break; //Electricity case 4: swapOptions(24,new Array(boilerTypes[0],boilerTypes[1])); break; //Anthracite grains case 1: swapOptions(24,new Array(boilerTypes[0],boilerTypes[4])); break; //Anthracite nuts case 2: swapOptions(24,new Array(boilerTypes[0],boilerTypes[4])); break; //House coal case 5: swapOptions(24,new Array(boilerTypes[0],boilerTypes[4])); break; //Smokeless fuel case 8: swapOptions(24,new Array(boilerTypes[0],boilerTypes[4])); break; //Wood case 9: swapOptions(24,new Array(boilerTypes[0],boilerTypes[4])); break; } } //change secondary room heaters type depending on the heating fuel value selected function changeSecondaryRoomHeaters(heatingFuelValue, switchFuelHeaters) { if (heatingFuelValue == 174) { toggleQuestion(33,false,true); //change back hot water heating method setHotWaterHeatingMethod(); } else { toggleQuestion(33,true,true); } //grabbed if coming back into questionnaire after completion, as code below //will remove the question's selected index var secondaryRoomHeaterType = document.getElementById('answer[33].answerId').value; switch (heatingFuelValue) { case "175": swapOptions(33,new Array(secondaryRoomHeaters[3],secondaryRoomHeaters[4],secondaryRoomHeaters[7])); break; case "176": swapOptions(33,new Array(secondaryRoomHeaters[3],secondaryRoomHeaters[4],secondaryRoomHeaters[7])); break; case "177": swapOptions(33,new Array(secondaryRoomHeaters[3],secondaryRoomHeaters[4],secondaryRoomHeaters[7])); break; case "178": swapOptions(33,new Array(secondaryRoomHeaters[0],secondaryRoomHeaters[1],secondaryRoomHeaters[5],secondaryRoomHeaters[6])); break; case "179": swapOptions(33,new Array(secondaryRoomHeaters[0],secondaryRoomHeaters[1],secondaryRoomHeaters[5],secondaryRoomHeaters[6])); break; case "180": swapOptions(33,new Array(secondaryRoomHeaters[0],secondaryRoomHeaters[1],secondaryRoomHeaters[5],secondaryRoomHeaters[6])); break; case "181": swapOptions(33,new Array(secondaryRoomHeaters[0],secondaryRoomHeaters[1],secondaryRoomHeaters[5],secondaryRoomHeaters[6])); break; case "182": swapOptions(33,new Array(secondaryRoomHeaters[0],secondaryRoomHeaters[1],secondaryRoomHeaters[5],secondaryRoomHeaters[6])); break; case "183": swapOptions(33,new Array(secondaryRoomHeaters[0],secondaryRoomHeaters[1],secondaryRoomHeaters[5],secondaryRoomHeaters[6])); break; case "184": swapOptions(33,new Array(secondaryRoomHeaters[2])); break; } //if coming back from an already entered HEC, set the Secondary heating method correctly if (!switchFuelHeaters) { setQuestionAnswerByValue(34,secondaryRoomHeaterType); } } function boilerTypeSelected(boilerType) { setQuestionAnswerByIndex if (boilerType>=124 && boilerType<=126) { //switch off hot water cylinder questions setQuestionAnswerByIndex(35,2); setQuestionAnswerByIndex(36,1); hotWaterCylinderSelected(1,2,true); } else { setQuestionAnswerByIndex(35,0); setQuestionAnswerByIndex(36,0); hotWaterCylinderSelected(1,2,true); } } //changes hot water heating method depending on main and secondary heating chosen function setHotWaterHeatingMethod() { var mainHeating = document.getElementById("answer[19].answerId").value; var secondaryHeating = document.getElementById("answer[33].answerId").value; var roomHeaterMain = document.getElementById("answer[26].answerId").value; var roomHeaterSecondary = document.getElementById("answer[33].answerId").value; var heatingMethodsArray = new Array(); heatingMethodsArray.push(hotWaterHeatingMethods[4]); heatingMethodsArray.push(hotWaterHeatingMethods[5]); heatingMethodsArray.push(hotWaterHeatingMethods[2]); heatingMethodsArray.push(hotWaterHeatingMethods[3]); //if main heating is boiler, warm air or community: if ((mainHeating == 100) || (mainHeating == 103) || (mainHeating == 104)) { heatingMethodsArray.push(hotWaterHeatingMethods[0]); } //if main heating is storage or ceiling if ((mainHeating == 101) || (mainHeating == 105)) { //do nothing } //room heater if (mainHeating == 102) { if ((roomHeaterMain == 133) || (roomHeaterMain == 138)) { heatingMethodsArray.push(hotWaterHeatingMethods[0]); } } if (roomHeaterSecondary == 191) { heatingMethodsArray.push(hotWaterHeatingMethods[1]); } if ((secondaryHeating == 186) || (secondaryHeating == 189) || (secondaryHeating == 191)) { heatingMethodsArray.push(hotWaterHeatingMethods[1]); } swapOptions(34,heatingMethodsArray, document.getElementById("answer[34].answerId")); } //change the options list for a question with a new set of options function swapOptions(questionNumber,optionsList, previousAnswer) { var prevAns = null; if (previousAnswer && previousAnswer.value) prevAns = previousAnswer.value; var question = document.getElementById("answer["+questionNumber+"].answerId"); question.options.length = 1; for (i=0;i= no of storeys if (document.getElementById("answer[5].answerId").value < document.getElementById("answer[6].answerId").value - 10) { messages.push('The number of storeys cannot be greater than the number of rooms.'); } validation = checkErrorMessages(); break; //page two case 2: setMessageAfterValidate(13); setMessageAfterValidate(14); if (!(validateAnswer(14,81))) { setMessageAfterValidate(15); } setMessageAfterValidate(16); setMessageAfterValidate(17); validation = checkErrorMessages(); break; //page three case 3: setMessageAfterValidate(18); setMessageAfterValidate(19); //check main heating if (validateAnswer(19,100)) { //boiler setMessageAfterValidate(21); setMessageAfterValidate(22); setMessageAfterValidate(23); setMessageAfterValidate(24); //check heating controls validateHeatingControls(4); } if (validateAnswer(19,101)) { //storage heater setMessageAfterValidate(25); //NO CHECKING OF HEATING CONTROLS AS ALL DISABLED } if (validateAnswer(19,102)) { //room heater setMessageAfterValidate(26); validateHeatingControls(3); } //ceiling heating if (validateAnswer(19,105)) { validateHeatingControls(3); } //community heating if (validateAnswer(19,104)) { validateHeatingControls(4); } //warm air if (validateAnswer(19,103)) { validateHeatingControls(3); } setMessageAfterValidate(20); //check that secondary heating system has been selected setMessageAfterValidate(32); if (!validateAnswer(32,174)) { setMessageAfterValidate(33); } //check hot water heating method setMessageAfterValidate(34); //check hot water cylinder setMessageAfterValidate(35); if (validateAnswer(35,156)) { setMessageAfterValidate(36); if (!validateAnswer(36,158)) { setMessageAfterValidate(37); setMessageAfterValidate(38); } } //check Q39 - Off peak electricity if (validateAnswer(19,101)) { if (!validateAnswer(39,170)) { setQuestionAnswerByIndex(40,3); } } else { setMessageAfterValidate(39); } validation = checkErrorMessages(); break; } return validation; } //launch error pop up if validation unsuccessful function checkErrorMessages() { if (messages.length >0) { var messageString = "Please correct the following:\n\n"; for (i =0;i=lowerRange) && (value <=upperRange)); } //ensure that a question has been selected with some value from the dropdown function validateNotNull(questionNumber) { var validate = true; var questionValue = document.getElementById("answer["+questionNumber+"].answerId").value; if (questionValue == 0) {validate = false;} if (questionValue == -1) {validate = false;} return validate; } //add error message to errors array if failed validation function setMessageAfterValidate(questionNumber) { if (!validateNotNull(questionNumber)) {messages.push(questionTitlesArray[questionNumber+1]);} } //check that at least one heating control has been selected function validateHeatingControls(numberOfChecks) { var heatingControlsArray = new Array(28,29,30,31); var validate = false; for (i=0;i