
/* Prototype to the rescue */

Event.observe(window, 'load', function() {
  Event.observe('donation_type_amt', 'click', clearGiftRadios);
  Event.observe('donation_type_dorothy', 'click', clearGiftRadios);
  Event.observe('donation_type_monthly', 'click', clearGiftRadios);
	for (i=0; i<$$('#gifts input.radio').length; i++) {
	 Event.observe($$('#gifts input.radio')[i].id, 'click', clearDonationGroups);
	}
        for (i=0; i<$$('#gifts2 input.radio').length; i++) {
	 Event.observe($$('#gifts2 input.radio')[i].id, 'click', clearDonationGroups);
	}
	Event.observe('donation_amt_selector_one_time', 'change', selectAmt);
	Event.observe('donation_amt_selector_dorothy', 'change', selectAmtForDorothy);
	Event.observe('donation_amt_selector_monthly', 'change', selectMonthly);
});

function selectAmt() {
	$('donation_type_amt').checked = true;
	clearMonthlyGroup();
	clearCharterGroup();
    clearGiftRadios();
    clearDorothyGroup();
}

function selectAmtForDorothy() {
	$('donation_type_dorothy').checked = true;
	clearMonthlyGroup();
	clearCharterGroup();
    clearGiftRadios();
    clearAmtGroup();
}

function selectMonthly() {
	$('donation_type_monthly').checked = true;
 	clearGiftRadios();	
	clearCharterGroup();
 	clearAmtGroup();
    clearDorothyGroup();

} 

function clearGiftRadios() {
	for (i=0; i<$$('#gifts input.radio').length; i++) {
		$$('#gifts input.radio')[i].checked = false;
                  };
	for (i=0; i<$$('#gifts2 input.radio').length; i++) {
		$$('#gifts2 input.radio')[i].checked = false;
                }
}

function clearDonationGroups() {
	clearMonthlyGroup();
	clearCharterGroup();
	clearAmtGroup();
    clearDorothyGroup();
}

function clearMonthlyGroup() {
	$('donation_amt_selector_monthly').value = 0;
	$('donation_type_monthly').checked = false;	
}

function clearCharterGroup() {
//	$('donation_amt_selector_charter').value = 0;
//	$('donation_type_charter').checked = false;	
}

function clearAmtGroup() {
	$('donation_amt_selector_one_time').value = 0;
	$('donation_type_amt').checked = false;	
}

function clearDorothyGroup() {
	$('donation_amt_selector_dorothy').value = 0;
	$('donation_type_dorothy').checked = false;
}

