/*
Functions used to switch currency values in donation pages
Requires previous definition of acctGBP and acctEUR.
*/
function validate(obj){

	if (obj.currency.value == "none"){
		alert("Please select your currency");
		return false;
	}

	if (obj.amount.value > 0){
		//urchinTracker('/external/donatenow');
		return true;
	}else{
		alert("Please enter your amount");
		return false;
	}
}

function updateCurrencySymbol(oSelect){
	var oTarget = document.getElementById("spanCurrency");
	var oInst = document.getElementById("instId");
	var oAcct = document.getElementById("accId");
	var oCountry = document.getElementById("country");
	if (oSelect && oTarget && oInst && oAcct && acctGBP && acctEUR){
		switch (oSelect.value){
			case "GBP":
				oTarget.firstChild.nodeValue="GB Pounds (GBP)";
				oInst.value = "42693";
				oAcct.value = acctGBP;
				if (oCountry) oCountry.value = "GB";
				break;
			case "EUR":
				oTarget.firstChild.nodeValue="Euros (EUR)";
				oInst.value = "141435";
				oAcct.value = acctEUR;
				if (oCountry) oCountry.value = "";
				break;
			case "USD":
				oTarget.firstChild.nodeValue="US Dollars";
				oInst.value = "141435";
				oAcct.value = acctEUR;
				if (oCountry) oCountry.value = "";
				break;
			default:
				return false;
		}
		return true;
	}else {
		alert("Sorry, unable to change currency");
		return false;
	}
}

//quick hack for 2nd form on donation page (i.e. quick donate) - updateCurrencySymbol updates the main form only
function updateQuickCurrencySymbol(oSelect){
	var oTarget = document.getElementById("quickSpanCurrency");
	var oInst = document.getElementById("quickInstId");
	var oAcct = document.getElementById("quickAccId");
	var oCountry = document.getElementById("quickCountry");
	if (oSelect && oTarget && oInst && oAcct && acctGBP && acctEUR){
		switch (oSelect.value){
			case "GBP":
				oTarget.firstChild.nodeValue="GB Pounds (GBP)";
				oInst.value = "42693";
				oAcct.value = acctGBP;
				if (oCountry) oCountry.value = "GB";
				break;
			case "EUR":
				oTarget.firstChild.nodeValue="Euros (EUR)";
				oInst.value = "141435";
				oAcct.value = acctEUR;
				if (oCountry) oCountry.value = "";
				break;
			case "USD":
				oTarget.firstChild.nodeValue="US Dollars";
				oInst.value = "141435";
				oAcct.value = acctEUR;
				if (oCountry) oCountry.value = "";
				break;
			default:
				return false;
		}
		return true;
	}else {
		alert("Sorry, unable to change currency");
		return false;
	}
}
