function run_highlights() {
//turn off all highlights
	var highlightsoff = document.getElementsByClassNameBE3("prod_box");
	x = highlightsoff.length;
	while(x--){
		highlightsoff[x].className = highlightsoff[x].className.replace("highlight_yes_on", "highlight_yes");
		highlightsoff[x].className = highlightsoff[x].className.replace("highlight_no_on", "highlight_no");
		highlightsoff[x].className = highlightsoff[x].className.replace("highlight_pc_on", "highlight_pc");
		highlightsoff[x].className = highlightsoff[x].className.replace("highlight_mac_on", "highlight_mac");
		highlightsoff[x].className = highlightsoff[x].className.replace("highlight_left_on", "highlight_left");
		highlightsoff[x].className = highlightsoff[x].className.replace("highlight_right_on", "highlight_right");
		highlightsoff[x].className = highlightsoff[x].className.replace("prod_box prod_box_shadeoff", "prod_box");
	}
	//

	//check to see what should be filtered
	var checkpcon = document.getElementsByClassNameBE3("pc_hl", "choosercbon");
	var checkmacon = document.getElementsByClassNameBE3("mac_hl", "choosercbon");
	var checkyeson = document.getElementsByClassNameBE3("yes_hl", "choosercbon");
	var checknoon = document.getElementsByClassNameBE3("no_hl", "choosercbon");
	var checklefton = document.getElementsByClassNameBE3("left_hl", "choosercbon");
	var checkrighton = document.getElementsByClassNameBE3("right_hl", "choosercbon");
	//if(checkpcon.length > 0) { alert('pc'); }
	
	var filters = [];
	if(checkpcon.length > 0) { filters.push('highlight_pc'); }
	if(checkmacon.length > 0) { filters.push('highlight_mac'); }
	if(checkyeson.length > 0) { filters.push('highlight_yes'); }
	if(checknoon.length > 0) { filters.push('highlight_no'); }
	if(checklefton.length > 0) { filters.push('highlight_left'); }
	if(checkrighton.length > 0) { filters.push('highlight_right'); }
	//alert(filters.length);

	if(filters.length == 3) {
		var highlights = document.getElementsByClassNameBE3(filters[0], filters[1], filters[2]);
	}
	if(filters.length == 2) {
		var highlights = document.getElementsByClassNameBE3(filters[0], filters[1]);
	}
	if(filters.length == 1) {
		var highlights = document.getElementsByClassNameBE3(filters[0]);
	}

	if(filters.length == 0) {
		//unhighlight all then return
			var highlights = document.getElementsByClassNameBE3("prod_box");
			x = highlights.length; 
			if(x) {
				while(x--){
					highlights[x].className = highlights[x].className.replace("prod_box", "prod_box prod_box_shadeoff");
				}
			}
			return;
	}

	x = highlights.length; 
	//alert(x);
	if(x) {
		while(x--){
			
			if(filters.length == 3) {
				highlights[x].className = highlights[x].className.replace(filters[2], filters[2]+'_on');
				highlights[x].className = highlights[x].className.replace(filters[1], filters[1]+'_on');
				highlights[x].className = highlights[x].className.replace(filters[0], filters[0]+'_on');
			}
			if(filters.length == 2) {
				highlights[x].className = highlights[x].className.replace(filters[1], filters[1]+'_on');
				highlights[x].className = highlights[x].className.replace(filters[0], filters[0]+'_on');
			}
			if(filters.length == 1) {
				highlights[x].className = highlights[x].className.replace(filters[0], filters[0]+'_on');
			}
		}
	}

				
}

window.addEvent('domready', function(){
run_highlights();

if($('precheckoutform')) {	
	$('precheckoutform').addEvent('submit', function(e) {
	    new Event(e).stop();

		if(confirm('Checking out confirms that you have read and agree to the policies and terms of use')) {
			this.send({
				onComplete: function() {
					document.paypalform.submit();
				}
			});
		}
	});
}

	var chairinputs_w = document.getElementsByClassNameBE("chooser_chair-w");
	i = chairinputs_w.length; 
	
	while(i--){
		chairinputs_w[i].onclick = function(){ 
			itwo = chairinputs_w.length;
			if(this.className.match("choosercbon")) {
				var checkbox_on = "1";
			}
				if(this.className.match("lt250")) {
					document.chform.chweight.value = 'lt250';
				}
				else if(this.className.match("gt250")) {
					document.chform.chweight.value = 'gt250';
				}
			//clears both
			while(itwo--){
				chairinputs_w[itwo].className = chairinputs_w[itwo].className.replace(" choosercbon", "");
			}
			//if it wasn't on for this checkbox, turn it on
			if(checkbox_on != "1") {
				this.className += " choosercbon";
			}
				
			//If not, the checkbox was already on
			else {
				this.className = this.className.replace(" choosercbon", "");
				document.chform.chweight.value = '';
			}
			//set the input field value
			
		};
	};
	
	var chairinputs_cu = document.getElementsByClassNameBE("chooser_chair-cu");
	i = chairinputs_cu.length; 
	
	while(i--){
		chairinputs_cu[i].onclick = function(){ 
			itwo = chairinputs_cu.length;
			if(this.className.match("choosercbon")) {
				var checkbox_on = "1";
			}
				if(this.className.match("ch_heavy")) {
					document.chform.chcompuse.value = 'heavy';
				}
				else if(this.className.match("ch_exec")) {
					document.chform.chcompuse.value = 'exec';
				}
				else if(this.className.match("ch_multi")) {
					document.chform.chcompuse.value = 'multi';
				}
			//clears both
			while(itwo--){
				chairinputs_cu[itwo].className = chairinputs_cu[itwo].className.replace(" choosercbon", "");
			}
			//if it wasn't on for this checkbox, turn it on
			if(checkbox_on != "1") {
				this.className += " choosercbon";
			}
				
			//If not, the checkbox was already on
			else {
				this.className = this.className.replace(" choosercbon", "");
				document.chform.chcompuse.value = '';
			}
		};
	};
	
	var chairinputs_p = document.getElementsByClassNameBE("chooser_chair-p");
	i = chairinputs_p.length; 
	
	while(i--){
		chairinputs_p[i].onclick = function(){ 
			itwo = chairinputs_p.length;
			ithree = itwo;
			if(this.className.match("choosercbon")) {
				var checkbox_on = "1";
			}
	
				document.chform.pain_none.value = '';
				while(ithree--){
					if(chairinputs_p[ithree].className.match('ch_none')) {
						chairinputs_p[ithree].className = chairinputs_p[ithree].className.replace(" choosercbon", "");
					}
				}

				if(this.className.match("ch_neck")) {
					document.chform.chpain.value = 'neckshoulder';
					if(checkbox_on == '1') { document.chform.pain_neck.value = '';	} else { document.chform.pain_neck.value = '1'; }
				}
				else if(this.className.match("ch_midback")) {
					document.chform.chpain.value = 'midback';
					if(checkbox_on == '1') { document.chform.pain_backmid.value = '';	} else { document.chform.pain_backmid.value = '1'; }
				}
				else if(this.className.match("ch_lowback")) {
					document.chform.chpain.value = 'lowback';
					if(checkbox_on == '1') { document.chform.pain_backlow.value = '';	} else { document.chform.pain_backlow.value = '1'; }
				}
				else if(this.className.match("ch_legs")) {
					document.chform.chpain.value = 'legs';
					if(checkbox_on == '1') { document.chform.pain_legs.value = '';	} else { document.chform.pain_legs.value = '1'; }
				}
				else if(this.className.match("ch_hands")) {
					document.chform.chpain.value = 'handswrists';
					if(checkbox_on == '1') { document.chform.pain_hands.value = '';	} else { document.chform.pain_hands.value = '1'; }
				}
				else if(this.className.match("ch_none")) {
					document.chform.chpain.value = 'nopain';
					if(checkbox_on == '1') { document.chform.pain_none.value = '';	} 
					else { 
						document.chform.pain_none.value = '1'; 
						
						//clears all others
						while(itwo--){
							chairinputs_p[itwo].className = chairinputs_p[itwo].className.replace(" choosercbon", "");
						}
						document.chform.pain_hands.value = '';
						document.chform.pain_legs.value = '';
						document.chform.pain_neck.value = '';
						document.chform.pain_backmid.value = '';
						document.chform.pain_backlow.value = '';
						// end clear
					}
				}



			//if it wasn't on for this checkbox, turn it on
			if(checkbox_on != "1") {
				this.className += " choosercbon";
			}
				
			//If not, the checkbox was already on
			else {
				this.className = this.className.replace(" choosercbon", "");
			}
		};
	};

//var testvar = document.getElementsByClassNameBE3("highlight_yes", "highlight_pc");
//alert(testvar.length);

	var inputs = document.getElementsByClassNameBE("chooser_wristtwist");
	i = inputs.length; 
	
	while(i--){
		inputs[i].onclick = function(){ 
			itwo = inputs.length;
			if(this.className.match("choosercbon")) {
				var checkbox_on = "1";
			}
			//clears both
			while(itwo--){
				inputs[itwo].className = inputs[itwo].className.replace(" choosercbon", "");
			}
			//if it wasn't on for this checkbox, turn it on
			if(checkbox_on != "1") {
				this.className += " choosercbon";
				run_highlights();
			}
				
			//If not, the checkbox was already on
			else {
				this.className = this.className.replace(" choosercbon", "");
				run_highlights();
			}
		};
	};


	var inputs2 = document.getElementsByClassNameBE("chooser_platform");
	i = inputs2.length; 
	
	while(i--){
		inputs2[i].onclick = function(){ 
			itwo = inputs2.length;
			if(this.className.match("choosercbon")) {
				var checkbox_on = "1";
			}
			//clears both
			while(itwo--){
				inputs2[itwo].className = inputs2[itwo].className.replace(" choosercbon", "");
			}
			//if it wasn't on for this checkbox, turn it on
			if(checkbox_on != "1") {
				this.className += " choosercbon";
				run_highlights();
			}
				
			//If not, the checkbox was already on
			else {
				this.className = this.className.replace(" choosercbon", "");
				run_highlights();
			}
		};
	};

	var inputs3 = document.getElementsByClassNameBE("chooser_mouseside");
	i = inputs3.length; 
	
	while(i--){
		inputs3[i].onclick = function(){ 
			itwo = inputs3.length;
			if(this.className.match("choosercbon")) {
				var checkbox_on = "1";
			}
			//clears both
			while(itwo--){
				inputs3[itwo].className = inputs3[itwo].className.replace(" choosercbon", "");
			}
			//if it wasn't on for this checkbox, turn it on
			if(checkbox_on != "1") {
				this.className += " choosercbon";
				run_highlights();
			}
				
			//If not, the checkbox was already on
			else {
				this.className = this.className.replace(" choosercbon", "");
				run_highlights();
			}
		};
	};

	

});
