// This is a function that will look for all radio buttons that start with "regex" and set them all to unchecked, except for the "current" one.  It is referenced by B Black and Sons on includes/modules/attributes.php when putting out radio buttons\
function SingleSelect(regex,current) {
	re = new RegExp(regex);
	for(i = 0; i < document.forms['cart_quantity'].elements.length; i++) {
 		elm = document.forms['cart_quantity'].elements[i];
 		if (elm.type == 'radio') {
 			if (re.test(elm.id)) {
 				elm.checked = false;
			}
		}
	} 
current.checked = true;
}


//This function goes through all the radio buttons matching "regex (like the above function), but makes sure to just check the first one.  this functions should be run after pageload.
function SingleSelectOnLoad(regex) {
	re = new RegExp(regex);
	checkedFirst = false;
	for(i = 0; i < document.forms['cart_quantity'].elements.length; i++) {
 		elm = document.forms['cart_quantity'].elements[i];
 		if (elm.type == 'radio') {
 			if (re.test(elm.id)) {
				if (!checkedFirst) {  // if the first one hasn't been checked yet, then this is it.  check it, and no more.
					elm.checked = true;
					checkedFirst = true;
				} else {
					elm.checked = false;
				}
			}
		}
	} 
}
