function convert(){
	//get the country, anchor, optional extras and amounts from the form select fields
	var fee = document.converter.ausCurrency.options[document.converter.ausCurrency.selectedIndex].value;
	var country = document.converter.countrySelect.options[document.converter.countrySelect.selectedIndex].value;
	var extras = document.converter.countrySelect.options[document.converter.countrySelect.selectedIndex].className;
	//split the country select field values into an array
	var countryDetail = country.split("***");
	//assign each array value to a variable
	var countryName = countryDetail[0];
	var denomination = countryDetail[1];
	//split the extras
	var extrasDetail = extras.split("***");
	//conversion rate + %5
	var rate = countryDetail[2]*extrasDetail[1];
	//get the anchor and optional field
	var anchor = extrasDetail[0];
	//document.getElementById("anchor").setAttribute("href", "/allforms/990i/methods-of-payment.htm#"+anchor);
	document.getElementById('paymentframe').src = anchor+".htm";
	var loading
	var note = "";
	if (extrasDetail[2]){var note = "\nNote: "+extrasDetail[2]}
	//calculate the fee x conversion rate
	var subTotalCalc = fee*rate;
	var subTotal = subTotalCalc/denomination;
	//for rounding UP to the nearest whole denomiation use the following
	//var total = Math.ceil(subTotal)*denomination;
	//otherwise for rounding UP or DOWN use the following
	var total = Math.round(subTotal)*denomination;
	var totalText = total+" "+countryName;
	//test for second currency
	var total2 = "";
	if (countryDetail[3]&&countryDetail[4]&&countryDetail[5]){
		
		var countryName2 = countryDetail[3];
		var denomination2 = countryDetail[4];
		//conversion rate + %5
		var rate2 = countryDetail[5]*extrasDetail[1];
		//calculate the fee x conversion rate
		var subTotalCalc2 = fee*rate2;
		var subTotal2 = subTotalCalc2/denomination2;
		//var total2 = Math.ceil(subTotal2)*denomination2;
		var total2 = Math.round(subTotal2)*denomination2;
		var total2Text = total2+" "+countryName2;
	}
	if (isNaN(fee)==true){
		window.document.converter.allowedCurrency.value = "Please select a fee";
	}
		else if (total2!=""){
		window.document.converter.allowedCurrency.value = totalText+"\nor\n"+total2Text+note;
		}
		else{
		window.document.converter.allowedCurrency.value = totalText+note;
		}
		

}

function clearForm(){

//clears the country dropdown and currency output box when a fee is selected
window.document.converter.countrySelect.options[0].selected=true;
window.document.converter.allowedCurrency.value = "";
}

