// FORM CONTROLS

// Check to see if a value has been entered that should clear the radio set
// value = fieldvalue
// radioID = id of radioset
function clearRadioset(value, radioID)
{
   if(value.length >= 1){
   		//alert(value);
   		var count = radioID.length;
   		var i = 0;
   		//alert(count);
   		for(i = 0; i < count; i++ ) {
      		radioID[i].checked = false;
   		}
   	}
} // EMD clearRadioset -------------------------------------------------------


// Clear credit card fields if alternative payment option checkbox is selected
// value = checkbox selection  yes or no
function clearCreditCard(value)
{
	if(value==true){
		//alert('Clear credit card');
		document.getElementById('card_type').options[0].selected=true;
		document.getElementById('card_number').value='';
		document.getElementById('expiry_date').value='';
		document.getElementById('name_on_card').value='';
	}
}

// fieldID = ID of field
function clearField(fieldID){
	// alert ('Clear:' + fieldID);
	document.getElementById(fieldID).value='';
}


// value = field value (onBlur)
// selectID = ID of select menu
function clearSelect(value,selectID){
	if(value.length >= 1){
		document.getElementById(selectID).options[0].selected=true;
	}
}

// value = value of element selected
// radioID = *name* of radio set (no quote marks in Javascript call)
// index = position of radio option to be selected 0 is first item

function setRadio(value,radioID,index)
{
	// alert('Set radio: ' + value + ' ' + radioID + ' ' + index);
	if(value.length >= 1){
		var count = radioID.length;
   		//alert(count);
   		var i = 0;
   		for(i = 0; i < count; i++ ) {
      		if(i == index) {
      		   radioID[i].checked = true;
      		} else {
      			radioID[i].checked = false;
      		}
   		}
	}

}
