﻿function showEvent(c, d)
{
    if(c.checked==true)
    {
        document.getElementById(d).style.display="block";
    }
    else
    {
        document.getElementById(d).style.display="none";
    }
    
}

function toggleHonor() {
	var check=document.getElementById("honor");
	var checked=check.checked;
	
	document.getElementById("honorOf").style.display=checked?"block":"none";
	
	if (!checked) {
		document.getElementById("ackNOAH").value="";
		document.getElementById("ackAddress1").value="";
		document.getElementById("ackAddress2").value="";
		document.getElementById("ackCity").value="";
		document.getElementById("ackStates").selectedIndex=0;
		document.getElementById("ackZip").value="";
		document.getElementById("ackRelationship").value="";
		document.getElementById("ackTribute").value="";
		document.getElementById("ackComment").value="";
	}
	
	enableDonorValidators();
}

function purpose() {
    var value="";
	var donateEvent=document.getElementById("donateEvent");
	var radios=donateEvent.getElementsByTagName("INPUT");
	for (var i=0; i<radios.length; i++) {
	    if (radios[i].checked) value=radios[i].value;
	}
	return value;
}

function setOtherAmount(value) {
	var divOtherAmount=document.getElementById("divOtherAmount");
	divOtherAmount.style.display="none";
	divOtherAmount.getElementsByTagName("input")[0].value=value;
	
	Page_ClientValidate();
}

function setOtherPurpose(value) {
	var divOtherPurpose=document.getElementById("divOtherPurpose");
	divOtherPurpose.style.display="none";
	divOtherPurpose.getElementsByTagName("input")[0].value=value;
	
	Page_ClientValidate();
}

function onChangePurpose(list) {
	var donateOther=document.getElementById("donateOther");
	var divOtherPurpose=document.getElementById("divOtherPurpose");
	
	if (purpose()=="Specific Event") {
		donateOther.value="";
		divOtherPurpose.style.display="block";
	} else {
		donateOther.value=purpose();
		divOtherPurpose.style.display="none";
	}
	
	document.getElementById("donateEventValue").value=purpose();
	
	Page_ClientValidate();
}

function enableDonorValidators() {
	var enabled=document.getElementById("honor").checked;
	var donateEventDiv=document.getElementById("honorOf");
	var spans=donateEventDiv.getElementsByTagName("span");
	for (var i=0; i<spans.length; i++) {
		if (spans[i].innerHTML.match(/required/i)) {
			ValidatorEnable(spans[i],enabled);
		}
	}
}

function enableOtherPurposeValidator() {
	var enabled=purpose()=="Specific Event";
	
	ValidatorEnable(document.getElementById("donateOtherValidator"),enabled);
}