// JavaScript Document
function valid(f) {
!(/^[A-z0-9]*$/i).test(f.value)?f.value = f.value.replace(/[^A-z0-9]/ig,''):null;
} 

function ValidateForm()

{

	var BuyOrSellFlag = getRadioValue (document.Chiromart.BuyOrSellFlag);	// See which Transaction Type they chose

	if (document.Chiromart.Equipment.value == "") {					// If no equipment details
		alert ("Please specify equipment details");
		return false;
	}

	if (BuyOrSellFlag == "Sell") {							// If they want to Sell

		if ((document.Chiromart.MakeAndModel.value == "")
		||  (document.Chiromart.EquipmentDescription.value == "")) {	// If no equipment details for "Sell"

			alert ("Please specify full details of equipment you wish to sell");
			return false;
		}

	} else {											// If they want to Buy

		if ((document.Chiromart.BuyUsedFlag.checked == false)			// If "buy used" isn't checked
		&&  (document.Chiromart.BuyNewFlag.checked == false)) {		// ...and "buy new" isn't checked

			alert ("Please specify Quality Used or New equipment (or both)");
			return false;
		}

	}

	if ((document.Chiromart.Price.value == "")) {					// If no price

		alert ("Please specify price");
		return false;

	}

	if (document.Chiromart.ContactName.value == "") {				// If no Contact Name given

		alert ("Please specify a Contact Name");
		return false;

	}

	if ((document.Chiromart.Telephone.value == "")) {				// If no telephone number

		alert ("Please specify telephone number");
		return false;

	}

	if ((document.Chiromart.Email.value == "")) {					// If no email address

		alert ("Please specify email address");
		return false;

	}

}
function getRadioValue(radioObject)
{

	var value = null;

	for (var i=0; i < radioObject.length; i++) {

		if (radioObject[i].checked) {
			value = radioObject[i].value;
			break;
		}
	}

	return value;

}

function showCheckboxes(type)
{
	if (type == "Buy") {
		document.Chiromart.BuyUsedFlag.disabled=false;
		document.Chiromart.BuyNewFlag.disabled=false;
	} else {
		document.Chiromart.BuyUsedFlag.disabled=true;
		document.Chiromart.BuyNewFlag.disabled=true;
	}
}
