
// Clears all checkboxes on the page, except for the calling element. Useful for "None of the above" type answers.
//	Usage: 	<input type="checkbox" id="checkbox42" name="foo42" value="1" onclick="ClearAll(checkbox42, this.form);">
//				Clears all checkboxes on the form, except for id="checkbox42"
function ClearAll(me, form){
	if( me.checked == true )
		for(i = 0; i < form.elements.length; i++)
			if(form.elements[i].type == "checkbox" && form.elements[i].name != me.name)
				form.elements[i].checked = false;
}

// Clears one checkbox.  Useful for clearing out the "None..." answer when selecting something else.
// Usage: 	<input type="checkbox" id="checkbox1" name="foo1" value="1" onclick="ClearOne(checkbox42);">
//				Clears id="checkbox42"
function ClearOne(control){
	control.checked = false;    // the 'None' control
}

// Clears the contents of one textbox.  When clearing out a series of radios/checks, clear out the textbox
// attached to the "other"" response as well.
// Usage: 	<input type="checkbox" id="checkbox1" name="foo1" value="1" onclick="ClearAll('checkbox42', this.form); ClearText('text2');">
//				Clears all checkboxes on the page, and the textbox with id="text2"
function ClearText(control){
	document.getElementById(control).value = '';    // the 'None' control
}

// Clears a range of checkboxes.  Useful when you need to clear a few checkboxes, but not all of them!
// Usage: 	<input type="checkbox" id="checkbox1" name="foo1" value="1" onclick="ClearRange(2, 10);">
//				Clears id="checkbox2", id="checkbox3" ... id="checkbox9", id="checkbox10"
function ClearRange(start, end){
	var foo;
	for(i = start; i <= end; i++) {
		foo = 'checkbox' + i;
		document.getElementById(foo).checked = false;
	}
}

