// Validate PayPal Form

// Ensure the user of this form has entered the required fields.
function validateData() {
	var bRequirementsMet = true;
	var txtOccupation = getElementById("occupation");
	var txtEmployer = getElementById("employer");
	var btnEligibility = getElementById("eligibility");

	if ( ( document.paypal_form.amount[0].checked == false )
    && ( document.paypal_form.amount[1].checked == false )
	&& ( document.paypal_form.amount[2].checked == false )
	&& ( document.paypal_form.amount[3].checked == false )
	&& ( document.paypal_form.amount[4].checked == false )
	&& ( document.paypal_form.amount[5].checked == false ) )
    {
        bRequirementsMet = false;
		window.alert( "You have not chosen an amount to donate. \nThis is a required field." );
    }


	// Verify the occupation field is not empty
	if( bRequirementsMet && (txtOccupation.value.length == 0 ) ) {
		bRequirementsMet = false;
		window.alert( "You have left the occupation field blank. \nThis is a required field. \nPlease enter a correct value." );
		txtOccupation.focus();
	}

	// Verify the employer field is not empty
	if( bRequirementsMet && ( txtEmployer.value.length == 0 ) ) {
		bRequirementsMet = false;
		window.alert( "You have left the employer field blank. \nThis is a required field. \nPlease enter a correct value." );
		txtEmployer.focus();
	}

	// Verify the eligibility field is checked
	if( bRequirementsMet && ( btnEligibility.checked == false ) ) {
		bRequirementsMet = false;
		window.alert( "You have left the elibigility field unchecked. \nThis is a required field." );
		btnEligibility.focus();
	}

	return bRequirementsMet;
}


// Retrieve an element by its ID attribute
// NOTE: This function is used in place of
//	document.getElementById() to support
//	Internet Explorer 4.01.
function getElementById( id ) {
	if( typeof( document.getElementById ) == "undefined" ) {
		for( var i = 0; i < document.all.length; i++ ) {
			var el = document.all( i );
			if( el.id == id ) {
				return el;
			}
		}
	}
	else {
		return document.getElementById( id );
	}
}

function Submit() {
	if( validateData() ) {
		getElementById( "SUBMIT" ).disabled = true;
		var pForm = getElementById( "paypal_form" );
		pForm.submit();
	}
}