function showKnown()
{
	document.getElementById('blockUnknown').style.display = 'none';
	document.getElementById('blockKnown').style.display = 'block';
	document.getElementById('systemTabFiller').innerHTML = '&nbsp;&nbsp;<a href="http://www.prothermostats.com/find_thermostat.php?reset=1">Start Over</a>';	
	document.getElementById('tabKnown').className = 'tabSelected';
	document.getElementById('systemTabUnknown').className = 'tabNotSelected';
	document.getElementById('systemTabSpacer1').className = 'tabFiller';
	document.getElementById('systemTabSpacer2').className = 'tabFiller';
	document.getElementById('systemTabFiller').className = 'tabFiller';
}

function showUnknown()
{
	document.getElementById('blockKnown').style.display = 'none';
	document.getElementById('blockUnknown').style.display = 'block';
	document.getElementById('systemTabFiller').innerHTML = '&nbsp;&nbsp;<a href="http://www.prothermostats.com/find_thermostat.php?reset=1">Start Over</a>';	
	document.getElementById('tabKnown').className = 'tabNotSelected';
	document.getElementById('systemTabUnknown').className = 'tabSelected';
	document.getElementById('systemTabSpacer1').className = 'tabFiller';
	document.getElementById('systemTabSpacer2').className = 'tabFiller';
	document.getElementById('systemTabFiller').className = 'tabFiller';
}

function showBasic()
{
	/*document.getElementById('blockAdvanced').className = 'hide';*/
	document.getElementById('blockBasic').className = 'featuresBlock';
	document.getElementById('tabBasic').className = 'tabSelected';
	/*document.getElementById('tabAdvanced').className = 'tabNotSelected';	*/
}

function showAdvanced()
{
	document.getElementById('blockBasic').className = 'hide';
	/*document.getElementById('blockAdvanced').className = 'featuresBlock';*/
	/*document.getElementById('tabAdvanced').className = 'tabSelected';*/
	document.getElementById('tabBasic').className = 'tabNotSelected';	
}

function setSystemType(s)
{
	document.finder.stages.value = s;
}

function setPowerType(s)
{
	document.finder.power.value = s;
}

function setProgrammable(s)
{
	document.finder.programmable.value = s;
}

function setAutochangeover(s)
{
	document.finder.autochangeover.value = s;
}

function setTouchscreen(s)
{
	document.finder.touchscreen.value = s;
}

function setBacklight(s)
{
	document.finder.backlight.value = s;
}

function setProgrammableFan(s)
{
	document.finder.programmable_fan.value = s;
}

function setVacationHold(s)
{
	document.finder.vacation_hold.value = s;
}

function setTempLimits(s)
{
	document.finder.temp_limit.value = s;
}

function setKeypadLockout(s)
{
	document.finder.keypad_lockout.value = s;
}

function updateStep1()
{
	if(document.finder.stages.value != '') {
		document.getElementById('howPowered').className = 'visible';
	} else {
		document.getElementById('howPowered').className = 'hide';
	}
	if(document.finder.stages.value != '' && document.finder.power.value != '') {
		document.getElementById('continue1').className = 'visible';
		document.getElementById('continue1button').disabled = false;
	} else {
		document.getElementById('continue1').className = 'visible';
		document.getElementById('continue1button').disabled = true;
	}
}

function gotoStep2()
{
	document.getElementById('step1').className = 'hide';
	document.getElementById('step2').className = 'visible';
}

function gotoStep1()
{
	document.getElementById('step2').className = 'hide';
	document.getElementById('step1').className = 'visible';
}

function checkTerminals()
{
	/*var tR = false;
	var tC = false;
	var tW1 = false;
	var tW2 = false;
	var tY1 = false
	var tY2 = false;
	var tG = false;
	var tOB = false;
	var tE = false;*/
			
	var tAUX = false;
	var tB = false;
	var tC = false;
	var tE = false;
	var tG = false;
	var tL = false;
	var tO = false;
	var tOB = false;
	var tR = false;
	var tRc = false;
	var tRh = false;
	var tT = false;
	var tW = false;
	var tW1 = false;
	var tW2 = false;
	var tX = false;
	var tX2 = false;
	var tY = false;
	var tY1 = false;
	var tY2 = false;
	
	if(document.getElementById('terminalAUX').checked)
	{
		tAUX = true;
	}
	
	if(document.getElementById('terminalB').checked)
	{
		tB = true;
	}
	
	if(document.getElementById('terminalC').checked)
	{
		tC = true;	
	}
	
	if(document.getElementById('terminalE').checked)
	{
		tE = true;
	}
	
	if(document.getElementById('terminalG').checked)
	{
		tG = true;	
	}	
	
	if(document.getElementById('terminalL').checked)
	{
		tL = true;
	}
	
	if(document.getElementById('terminalO').checked)
	{
		tO = true;
	}
	
	if(document.getElementById('terminalOB').checked)
	{
		tOB = true;
	}
	
	if(document.getElementById('terminalR').checked)
	{
		tR = true;
	}
	
	if(document.getElementById('terminalRc').checked)
	{
		tRc = true;
	}
	if(document.getElementById('terminalRh').checked)
	{
		tRh = true;
	}
	if(document.getElementById('terminalT').checked)
	{
		tT = true;
	}
	if(document.getElementById('terminalW').checked)
	{
		tW = true;
	}
	if(document.getElementById('terminalW1').checked)
	{
		tW1 = true;
	}
	if(document.getElementById('terminalW2').checked)
	{
		tW2 = true;
	}
	if(document.getElementById('terminalX').checked)
	{
		tX = true;
	}
	if(document.getElementById('terminalX2').checked)
	{
		tX2 = true;
	}
	if(document.getElementById('terminalY').checked)
	{
		tY = true;
	}
	if(document.getElementById('terminalY1').checked)
	{
		tY1 = true;
	}
	if(document.getElementById('terminalY2').checked)
	{
		tY2 = true;
	}
	
	
	var output = '';
	
	s = '';
	p = '';
		
	if((tR == true || tRc == true || tRh == true) && !(tC == true || tX == true) && (tW1 == true || tW == true) && !(tW2 == true || tAUX == true) && !(tY1 == true || tY == true) && !(tY2 == true) && !(tG == true) && !(tOB == true || tO == true) && !(tE == true))
	{
		output = 'Heat Only, Battery Powered or Mechanical';
		s = 'HO';
		p = 'OTH';
	} else if((tR == true || tRc == true || tRh == true) && !(tC == true || tX == true) && (tW1 == true || tW == true) && !(tW2 == true || tAUX == true) && !(tY1 == true || tY == true) && !(tY2 == true) && (tG == true) && !(tOB == true || tO == true) && !(tE == true)) {
		output = 'Heat Only with Fan, Battery Powered or Mechanical';
		s = 'HO';
		p = 'OTH';
	} else if((tR == true || tRc == true || tRh == true) && !(tC == true || tX == true) && !(tW1 == true || tW == true) && !(tW2 == true || tAUX == true) && (tY1 == true || tY == true) && !(tY2 == true) && (tG == true) && !(tOB == true || tO == true) && !(tE == true)) {
		output = 'Cool Only (The Thermostat Finder Does Not Support Cooling Only)';
	} else if((tR == true || tRc == true || tRh == true) && !(tC == true || tX == true) && (tW1 == true || tW == true) && !(tW2 == true || tAUX == true) && (tY1 == true || tY == true) && !(tY2 == true) && (tG == true) && !(tOB == true || tO == true) && !(tE == true)) {
		output = '1 Heat/1 Cool, Battery Powered or Mechanical';
		s = 'SS';
		p = 'OTH';
	} else if((tR == true || tRc == true || tRh == true) && (tC == true || tX == true) && (tW1 == true || tW == true) && !(tW2 == true || tAUX == true) && (tY1 == true || tY == true) && !(tY2 == true) && (tG == true) && !(tOB == true || tO == true) && !(tE == true)) {
		output = '1 Heat/1 Cool, 24VAC Power';
		s = 'SS';
		p = 'HW';
	} else if((tR == true || tRc == true || tRh == true) && (tC == true || tX == true) && (tW1 == true || tW == true) && !(tW2 == true || tAUX == true) && (tY1 == true || tY == true) && !(tY2 == true) && (tG == true) && (tOB == true || tO == true) && !(tE == true)) {
		output = 'Heat Pump';
		s = 'HP';
		p = 'HW';
	} else if((tR == true || tRc == true || tRh == true) && (tC == true || tX == true) && (tY1 == true || tY == true) && !(tY2 == true) && (tG == true) && (tOB == true || tO == true)) {
		output = 'Heat Pump';
		s = 'HP';
		p = 'HW';
	} else if((tR == true || tRc == true || tRh == true) && (tC == true || tX == true) && !(tW1 == true || tW == true) && (tW2 == true || tAUX == true) && (tY1 == true || tY == true) && !(tY2 == true) && (tG == true) && (tOB == true || tO == true)) {
		output = 'Heat Pump';
		s = 'HP';
		p = 'HW';
	} else if((tR == true || tRc == true || tRh == true) && (tC == true || tX == true) && !(tW1 == true || tW == true) && (tW2 == true || tAUX == true) && (tY1 == true || tY == true) && !(tY2 == true) && (tG == true) && (tOB == true || tO == true) && (tE == true)) {
		output = 'Heat Pump with Backup Heat';
		s = 'HP';
		p = 'HW';
	} else if((tR == true || tRc == true || tRh == true) && (tC == true || tX == true) && (tW1 == true || tW == true) && !(tW2 == true || tAUX == true) && (tY1 == true || tY == true) && !(tY2 == true) && (tG == true) && (tOB == true || tO == true) && (tE == true)) {
		output = 'Heat Pump with Backup Heat';
		s = 'HP';
		p = 'HW';
	} else if((tR == true || tRc == true || tRh == true) && (tC == true || tX == true) && (tW1 == true || tW == true) && (tW2 == true || tAUX == true) && (tY1 == true || tY == true) && !(tY2 == true) && (tG == true) && !(tOB == true || tO == true) && !(tE == true)) {
		output = 'Multi-stage Furnace, Standard AC';
		s = 'MS';
		p = 'HW';
	} else if((tR == true || tRc == true || tRh == true) && (tC == true || tX == true) && (tW1 == true || tW == true) && (tW2 == true || tAUX == true) && (tY1 == true || tY == true) && (tY2 == true) && (tG == true) && !(tOB == true || tO == true) && !(tE == true)) {
		output = 'Multi-stage Furnace, Multi-stage AC';
		s = 'MS';
		p = 'HW';
	} else if((tR == true || tRc == true || tRh == true) && !(tC == true || tX == true) && (tW1 == true || tW == true) && (tW2 == true || tAUX == true) && (tY1 == true || tY == true) && (tY2 == true) && (tG == true) && !(tOB == true || tO == true) && !(tE == true)) {
		output = 'Multi-stage Furnace, Multi-stage AC, Battery Powered';
		s = 'MS';
		p = 'OTH';
	} else {
		output = 'Unknown - Call us at (866) 764-9900 for help selecting a thermostat.';
	}
		
	setSystemType(s);
	setPowerType(p);
	updateStep1();
	
	document.getElementById('resultSystem').innerHTML = output;
	
	return(false);	
}

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

function getProductCount()
{
	
	stages = document.finder.stages.value;
	power = document.finder.power.value;
	
	programmable = document.finder.programmable.value;
	autochangeover = document.finder.autochangeover.value;
	backlight = document.finder.backlight.value;
	programmable_fan = document.finder.programmable_fan.value;
	keypad_lockout = document.finder.keypad_lockout.value;
	vacation_hold = document.finder.vacation_hold.value;
	temp_limit = document.finder.temp_limit.value;
	touchscreen = document.finder.touchscreen.value;
		
	url = 'http://www.prothermostats.com/finder_count.php?stages=' + stages + '&power=' + power + '&programmable=' + programmable + '&autochangeover=' + autochangeover + '&backlight=' + backlight + '&programmable_fan=' + programmable_fan + '&keypad_lockout=' + keypad_lockout + '&vacation_hold=' + vacation_hold + '&temp_limit=' + temp_limit + '&touchscreen=' + touchscreen;
					
	httpRequest = createRequestObject();
	httpRequest.open('get', url);
	httpRequest.onreadystatechange = returnProductCount;
	httpRequest.send(null);
		
}

function returnProductCount()
{
	if(httpRequest.readyState == 4){ //Finished loading the response
		try
		{
			var response = httpRequest.responseXML;
			var prod = response.getElementsByTagName('products');

			if(prod.length > 0){
				/* this means I received a response from the server */

				var prod_count = parseFloat(unescape(prod[0].childNodes[0].firstChild.nodeValue));
				var min_price = parseFloat(unescape(prod[0].childNodes[1].firstChild.nodeValue));
				var max_price = parseFloat(unescape(prod[0].childNodes[2].firstChild.nodeValue));
				
				if(prod_count != 1){
					output = '<b>' + String(prod_count) + ' Thermostats Found</b>';
				} else {
					output = '<b>1 Thermostat Found</b>';
				}
				if(min_price > 0){
					output = output + ' ($' + addCommas(min_price.toFixed(2));
					if(max_price > min_price){
						output = output + ' to $' + addCommas(max_price.toFixed(2));	
					}	
					output += ')';
				}
				
				document.getElementById('matchResults').innerHTML = output;

			}
		}
		catch(e)
		{
		}
	}
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function storeSettings()
{
	_optKnown = document.getElementById('optKnown').checked;
	_optUnknown = document.getElementById('optUnknown').checked;
	_systemSS = document.getElementById('systemSS').checked;
	_systemHP = document.getElementById('systemHP').checked;
	_systemLV = document.getElementById('systemLV').checked;
	_systemMS = document.getElementById('systemMS').checked;
	_systemHO = document.getElementById('systemHO').checked;
	_systemMV = document.getElementById('systemMV').checked;
	_powerBattery = document.getElementById('powerBattery').checked;
	_powerHardwire = document.getElementById('powerHardwire').checked;
	_powerUnsure = document.getElementById('powerUnsure').checked;
	_terminalAUX = document.getElementById('terminalAUX').checked;
	_terminalB = document.getElementById('terminalB').checked;
	_terminalC = document.getElementById('terminalC').checked;
	_terminalE = document.getElementById('terminalE').checked;
	_terminalG = document.getElementById('terminalG').checked;
	_terminalL = document.getElementById('terminalL').checked;
	_terminalO = document.getElementById('terminalO').checked;
	_terminalOB = document.getElementById('terminalOB').checked;
	_terminalR = document.getElementById('terminalR').checked;
	_terminalRc = document.getElementById('terminalRc').checked;
	_terminalRh = document.getElementById('terminalRh').checked;
	_terminalT = document.getElementById('terminalT').checked;
	_terminalW = document.getElementById('terminalW').checked;
	_terminalW1 = document.getElementById('terminalW1').checked;
	_terminalW2 = document.getElementById('terminalW2').checked;
	_terminalX = document.getElementById('terminalX').checked;
	_terminalX2 = document.getElementById('terminalX2').checked;
	_terminalY = document.getElementById('terminalY').checked;
	_terminalY1 = document.getElementById('terminalY1').checked;
	_terminalY2 = document.getElementById('terminalY2').checked;
	
	_optBasic = document.getElementById('optBasic').checked;
	/*_optAdvanced = document.getElementById('optAdvanced').checked;*/
	_chkProgrammable = document.getElementById('chkProgrammable').checked;
	_chkAutochangeover = document.getElementById('chkAutochangeover').checked;
	_chkTouchscreen = document.getElementById('chkTouchscreen').checked;
	_chkBacklight = document.getElementById('chkBacklight').checked;
	_chkProgrammableFan = document.getElementById('chkProgrammableFan').checked;
	_chkVacationHold = document.getElementById('chkVacationHold').checked;
	_chkTempLimits = document.getElementById('chkTempLimits').checked;
	_chkLockout = document.getElementById('chkLockout').checked;
	if(document.getElementById('step2').className == 'visible') {
		_step = '2';
	} else {
		_step = '1';
	}
	
	/*url = 'http://www.prothermostats.com/store_settings.php?optKnown=' + _optKnown + '&optUnknown=' + _optUnknown + '&systemSS=' + _systemSS + '&systemHP=' + _systemHP + '&systemLV=' + _systemLV + '&systemMS=' + _systemMS + '&systemHO=' + _systemHO + '&systemMV=' + _systemMV + '&powerBattery=' + _powerBattery + '&powerHardwire=' + _powerHardwire + '&powerUnsure=' + _powerUnsure + '&terminalR=' + _terminalR + '&terminalC=' + _terminalC + '&terminalW=' + _terminalW + '&terminalW2=' + _terminalW2 + '&terminalY=' + _terminalY + '&terminalY2=' + _terminalY2 + '&terminalG=' + _terminalG + '&terminalO=' + _terminalO + '&terminalE=' + _terminalE + '&optBasic=' + _optBasic + '&optAdvanced=' + _optAdvanced + '&chkProgrammable=' + _chkProgrammable + '&chkAutochangeover=' + _chkAutochangeover + '&chkTouchscreen=' + _chkTouchscreen + '&chkBacklight=' + _chkBacklight + '&chkProgrammableFan=' + _chkProgrammableFan + '&chkVacationHold=' + _chkVacationHold + '&chkTempLimits=' + _chkTempLimits + '&chkLockout=' + _chkLockout + '&step=' + _step;*/
	url = 'http://www.prothermostats.com/store_settings.beta.php?optKnown=' + _optKnown + '&optUnknown=' + _optUnknown + '&systemSS=' + _systemSS + '&systemHP=' + _systemHP + '&systemLV=' + _systemLV + '&systemMS=' + _systemMS + '&systemHO=' + _systemHO + '&systemMV=' + _systemMV + '&powerBattery=' + _powerBattery + '&powerHardwire=' + _powerHardwire + '&powerUnsure=' + _powerUnsure + '&terminalAUX=' + _terminalAUX + '&terminalB=' + _terminalB + '&terminalC=' + _terminalC + '&terminalE=' + _terminalE + '&terminalG=' + _terminalG + '&terminalL=' + _terminalL + '&terminalO=' + _terminalO + '&terminalOB=' + _terminalOB + '&terminalR=' + _terminalR + '&terminalRc=' + _terminalRc + '&terminalRh=' + _terminalRh + '&terminalT=' + _terminalT + '&terminalW=' + _terminalW + '&terminalW1=' + _terminalW1 + '&terminalW2=' + _terminalW2 + '&terminalX=' + _terminalX + '&terminalX2=' + _terminalX2 + '&terminalY=' + _terminalY + '&terminalY1=' + _terminalY1 + '&terminalY2=' + _terminalY2 + '&optBasic=' + _optBasic + '&chkProgrammable=' + _chkProgrammable + '&chkAutochangeover=' + _chkAutochangeover + '&chkTouchscreen=' + _chkTouchscreen + '&chkBacklight=' + _chkBacklight + '&chkProgrammableFan=' + _chkProgrammableFan + '&chkVacationHold=' + _chkVacationHold + '&chkTempLimits=' + _chkTempLimits + '&chkLockout=' + _chkLockout + '&step=' + _step;
			
	httpStore = createRequestObject();
	httpStore.open('get', url);
	httpStore.send(null);
	
}

function loadSettings()
{
	
	url = 'http://www.prothermostats.com/get_settings.beta.php';	
					
	httpLoad = createRequestObject();
	httpLoad.open('get', url);
	httpLoad.onreadystatechange = returnSettings;
	httpLoad.send(null);
		
}

function returnSettings()
{
	if(httpLoad.readyState == 4){ //Finished loading the response
		try
		{
			var response = httpLoad.responseXML;
			
			var stg = response.getElementsByTagName('settings');

			if(stg.length > 0){
				/* this means I received a response from the server */

				_optKnown = stg[0].childNodes[0].firstChild.nodeValue.toString();
				_optUnknown = stg[0].childNodes[1].firstChild.nodeValue.toString();
				_systemSS = stg[0].childNodes[2].firstChild.nodeValue.toString();
				_systemHP = stg[0].childNodes[3].firstChild.nodeValue.toString();
				_systemLV = stg[0].childNodes[4].firstChild.nodeValue.toString();
				_systemMS = stg[0].childNodes[5].firstChild.nodeValue.toString();
				_systemHO = stg[0].childNodes[6].firstChild.nodeValue.toString();
				_systemMV = stg[0].childNodes[7].firstChild.nodeValue.toString();
				_powerBattery = stg[0].childNodes[8].firstChild.nodeValue.toString();
				_powerHardwire = stg[0].childNodes[9].firstChild.nodeValue.toString();
				_powerUnsure = stg[0].childNodes[10].firstChild.nodeValue.toString();
				_terminalAUX = stg[0].childNodes[11].firstChild.nodeValue.toString();
				_terminalB = stg[0].childNodes[12].firstChild.nodeValue.toString();
				_terminalC = stg[0].childNodes[13].firstChild.nodeValue.toString();
				_terminalE = stg[0].childNodes[14].firstChild.nodeValue.toString();
				_terminalG = stg[0].childNodes[15].firstChild.nodeValue.toString();
				_terminalL = stg[0].childNodes[16].firstChild.nodeValue.toString();
				_terminalO = stg[0].childNodes[17].firstChild.nodeValue.toString();
				_terminalOB = stg[0].childNodes[18].firstChild.nodeValue.toString();
				_terminalR = stg[0].childNodes[19].firstChild.nodeValue.toString();
				_terminalRc = stg[0].childNodes[20].firstChild.nodeValue.toString();
				_terminalRh = stg[0].childNodes[21].firstChild.nodeValue.toString();
				_terminalT = stg[0].childNodes[22].firstChild.nodeValue.toString();
				_terminalW = stg[0].childNodes[23].firstChild.nodeValue.toString();
				_terminalW1 = stg[0].childNodes[24].firstChild.nodeValue.toString();
				_terminalW2 = stg[0].childNodes[25].firstChild.nodeValue.toString();
				_terminalX = stg[0].childNodes[26].firstChild.nodeValue.toString();
				_terminalX2 = stg[0].childNodes[27].firstChild.nodeValue.toString();
				_terminalY = stg[0].childNodes[28].firstChild.nodeValue.toString();
				_terminalY1 = stg[0].childNodes[29].firstChild.nodeValue.toString();
				_terminalY2 = stg[0].childNodes[30].firstChild.nodeValue.toString();
				_optBasic = stg[0].childNodes[31].firstChild.nodeValue.toString();
				_chkProgrammable = stg[0].childNodes[33].firstChild.nodeValue.toString();
				_chkAutochangeover = stg[0].childNodes[33].firstChild.nodeValue.toString();
				_chkTouchscreen = stg[0].childNodes[35].firstChild.nodeValue.toString();
				_chkBacklight = stg[0].childNodes[36].firstChild.nodeValue.toString();
				_chkProgrammableFan = stg[0].childNodes[37].firstChild.nodeValue.toString();
				_chkVacationHold = stg[0].childNodes[38].firstChild.nodeValue.toString();
				_chkTempLimits = stg[0].childNodes[39].firstChild.nodeValue.toString();
				_chkLockout = stg[0].childNodes[40].firstChild.nodeValue.toString();
				_step = stg[0].childNodes[41].firstChild.nodeValue.toString();
				
				/* now I have to reset the form */
				
				if(B(_optKnown) == true) {
					document.getElementById('optKnown').checked = true;
					showKnown();
				} else if(B(_optUnknown) == true) {
					document.getElementById('optUnknown').checked = true;
					showUnknown();
				}
				
				if(B(_systemSS) == true) {
					document.getElementById('systemSS').checked = true;
					if(B(_optKnown) == true) {
						setSystemType('SS');
					}
				} else if (B(_systemHP) == true) {
					document.getElementById('systemHP').checked = true;
					if(B(_optKnown) == true) {
						setSystemType('HP');
					}
				} else if (B(_systemLV) == true) {
					document.getElementById('systemLV').checked = true;
					if(B(_optKnown) == true) {
						setSystemType('LV');
					}
				} else if (B(_systemMS) == true) {
					document.getElementById('systemMS').checked = true;
					if(B(_optKnown) == true) {
						setSystemType('MS');
					}
				} else if (B(_systemHO) == true) {
					document.getElementById('systemHO').checked = true;
					if(B(_optKnown) == true) {
						setSystemType('HO');
					}
				} else if (B(_systemMV) == true) {
					document.getElementById('systemMV').checked = true;
					if(B(_optKnown) == true) {
						setSystemType('MV');
					}
				}
				
				if(B(_powerBattery) == true) {
					document.getElementById('powerBattery').checked = true;
					if(B(_optKnown) == true) {
						setPowerType('OTH');
					}
				} else if (B(_powerHardwire) == true) {
					document.getElementById('powerHardwire').checked = true;
					if(B(_optKnown) == true) {
						setPowerType('HW');
					}
				} else if (B(_powerUnsure) == true) {
					document.getElementById('powerUnsure').checked = true;
					if(B(_optKnown) == true) {
						setPowerType('OTH');
					}
				}
				
				document.getElementById('terminalAUX').checked = B(_terminalAUX);
				document.getElementById('terminalB').checked = B(_terminalB);
				document.getElementById('terminalC').checked = B(_terminalC);
				document.getElementById('terminalE').checked = B(_terminalE);
				document.getElementById('terminalG').checked = B(_terminalG);
				document.getElementById('terminalL').checked = B(_terminalL);
				document.getElementById('terminalO').checked = B(_terminalO);
				document.getElementById('terminalOB').checked = B(_terminalOB);
				document.getElementById('terminalR').checked = B(_terminalR);
				document.getElementById('terminalRc').checked = B(_terminalRc);
				document.getElementById('terminalRh').checked = B(_terminalRh);
				document.getElementById('terminalT').checked = B(_terminalT);
				document.getElementById('terminalW').checked = B(_terminalW);
				document.getElementById('terminalW1').checked = B(_terminalW1);
				document.getElementById('terminalW2').checked = B(_terminalW2);
				document.getElementById('terminalX').checked = B(_terminalX);
				document.getElementById('terminalX2').checked = B(_terminalX2);
				document.getElementById('terminalY').checked = B(_terminalY);
				document.getElementById('terminalY1').checked = B(_terminalY1);
				document.getElementById('terminalY2').checked = B(_terminalY2);
				
				/* set the system & power only if they are in the unknown tab */
				if(B(_optUnknown) == true) {
					checkTerminals();
				}
				
				if(B(_optBasic) == true) {
					document.getElementById('optBasic').checked = true;
					showBasic();
				} /*else if(B(_optAdvanced) == true) {
					document.getElementById('optAdvanced').checked = true;
					showAdvanced();
				}*/

				if(B(_chkProgrammable) == true) {
					document.getElementById('chkProgrammable').checked = B(_chkProgrammable);
					if(B(_optBasic) == true) {
						setProgrammable('Y');
					}
				}
				if(B(_chkAutochangeover) == true) {
					document.getElementById('chkAutochangeover').checked = B(_chkAutochangeover);
					if(B(_optBasic) == true) {
						setAutochangeover('Y');
					}
				}
				if(B(_chkTouchscreen) == true) {
					document.getElementById('chkTouchscreen').checked = B(_chkTouchscreen);
					if(B(_optBasic) == true) {
						setTouchscreen('Y');
					}
				}
				if(B(_chkBacklight) == true) {
					document.getElementById('chkBacklight').checked = B(_chkBacklight);
					if(B(_optBasic) == true) {
						setBacklight('Y');
					}
				}
				if(B(_chkProgrammableFan) == true) {
					document.getElementById('chkProgrammableFan').checked = B(_chkProgrammableFan);
					if(B(_optBasic) == true) {
						setProgrammableFan('Y');
					}
				}
				if(B(_chkVacationHold) == true) {
					document.getElementById('chkVacationHold').checked = B(_chkVacationHold);
					if(B(_optBasic) == true) {
						setVacationHold('Y');
					}
				}
				if(B(_chkTempLimits) == true) {
					document.getElementById('chkTempLimits').checked = B(_chkTempLimits);
					if(B(_optBasic) == true) {
						setTempLimits('Y');
					}
				}
				if(B(_chkLockout) == true) {
					document.getElementById('chkLockout').checked = B(_chkLockout);
					if(B(_optBasic) == true) {
						setKeypadLockout('Y');
					}
				}
				
				getProductCount();
				
				if(_step == '2') {
					gotoStep2();
				} else {
					updateStep1();
					gotoStep1();
				}
			}
		}
		catch(e)
		{
		}
	}
}

function B( objAny ){
	if(objAny.toString() == "true"){
		return(true);
	}
	if(objAny.toString() == "false"){
		return(false);
	}
}

function switchToBasic()
{
	/* here I need to set the features based on the basic tab */
	if(document.getElementById('chkProgrammable').checked == true) {
		setProgrammable('Y');
	} else {
		setProgrammable('');
	}	
	if(document.getElementById('chkAutochangeover').checked == true) {
		setAutochangeover('Y');
	} else {
		setAutochangeover('');
	}	
	if(document.getElementById('chkTouchscreen').checked == true) {
		setTouchscreen('Y');
	} else {
		setTouchscreen('');
	}	
	if(document.getElementById('chkBacklight').checked == true) {
		setBacklight('Y');
	} else {
		setBacklight('');
	}	
	if(document.getElementById('chkProgrammableFan').checked == true) {
		setProgrammableFan('Y');
	} else {
		setProgrammableFan('');
	}	
	if(document.getElementById('chkVacationHold').checked == true) {
		setVacationHold('Y');
	} else {
		setVacationHold('');
	}	
	if(document.getElementById('chkTempLimits').checked == true) {
		setTempLimits('Y');
	} else {
		setTempLimits('');
	}	
	if(document.getElementById('chkLockout').checked == true) {
		setKeypadLockout('Y');
	} else {
		setKeypadLockout('');
	}	
	getProductCount();
	
}

function switchToAdvanced()
{
	
}

function switchToKnown()
{
	
	if(document.getElementById('systemSS').checked == true) {
		setSystemType('SS');
	} else if(document.getElementById('systemHP').checked == true) {
		setSystemType('HP');
	} else if(document.getElementById('systemLV').checked == true) {
		setSystemType('LV');
	} else if(document.getElementById('systemMS').checked == true) {
		setSystemType('MS');
	} else if(document.getElementById('systemHO').checked == true) {
		setSystemType('HO');
	} else if(document.getElementById('systemMV').checked == true) {
		setSystemType('MV');
	} else {
		setSystemType('');
	}
	
	if(document.getElementById('powerBattery').checked == true) {
		setPowerType('OTH');
	} else if(document.getElementById('powerHardwire').checked == true) {
		setPowerType('HW');
	} else if(document.getElementById('powerUnsure').checked == true) {
		setPowerType('OTH');
	} else {
		setPowerType('');
	}
	
	updateStep1();
	
}

function switchToUnknown()
{
	checkTerminals();
	updateStep1();
}