// JavaScript Document copyright 2007 divine-creations.com ltd all rights reserved
 
function validatePayment()
{
    var amount = document.getElementById("amount").value;
    var giftaid = document.getElementById("chkgiftaid").checked;	
	var txtDescription = document.getElementById("item_name");
	
	if (amount<=0.00) 
	{
		alert("Please enter an amount you would like to donate and then click Submit.");
		return false;
	}
	
	if (giftaid)
	{ 
		txtDescription.value += " with UK Gift Aid";
		
	}

	return true;
}

function validateDonation()
{
	var amount = document.getElementById("amount").value;
	
     
	if (amount<=0.00) 
	{
		alert("Please enter a value you would like to donate to the memorial fund, and then click Submit.");
		return false;
	}
	
	var giftaid = document.getElementById("chkgiftaid").checked;	
	var txtDescription = document.getElementById("item_name");
	
	if (giftaid)
	{ 
		txtDescription.value += " with UK Gift Aid";
	}
	
	return true;
}

function validateDonations()
{
	/*
	  <input type="hidden" name="cmd" value="_xclick-subscriptions">
	  <input type="hidden" name="cmd" value="_xclick" />
	*/
	var amount = document.getElementById("amount");
	var name = document.getElementById("item_number").value;
	var item_name = document.getElementById("item_name");
     
	if (amount.value<=0.00) 
	{
		alert("Please enter a value you would like to donate to the "+name+" memorial fund, and then click Submit.");
		return false;
	}
	
	var giftaid = document.getElementById("chkgiftaid").checked;	
	var txtDescription = document.getElementById("item_name");
	
	
	
 
	var subscription_duration = document.getElementById("p3");
	var subscription_period = document.getElementById("t3");
	var subscription_value = document.getElementById("a3");
	var paypal_command = document.getElementById("cmd");
	 
	switch (amount.selectedIndex)
	{
		case 0:
			paypal_command.value = "_xclick";
			item_name.value = "Friends of the Mills Archive Trust : One-Off Donation";
			break;
			
		case 1:
			paypal_command.value = "_xclick";
			item_name.value = "Friends of the Mills Archive Trust : One-Off Donation";
			break;

		case 2:
			paypal_command.value = "_xclick-subscriptions";
			item_name.value = "Friends of the Mills Archive Trust : Recurring Donation";
			subscription_duration.value = "3";
			subscription_period.value = "M";
			subscription_value.value = amount.value;
			break;
	
		case 3:
			paypal_command.value = "_xclick-subscriptions";
			item_name.value = "Friends of the Mills Archive Trust : Recurring Donation";
			subscription_duration.value = "1";
			subscription_period.value = "Y";
			subscription_value.value = amount.value;
			break;

		case 4:
			paypal_command.value = "_xclick-subscriptions";
			item_name.value = "Friends of the Mills Archive Trust : Recurring Donation";
			subscription_duration.value = "1";
			subscription_period.value = "D";
			subscription_value.value = amount.value;
			break;			
	}
	
	if (giftaid)
	{ 
		txtDescription.value += " with UK Gift Aid";
	}
	
	
		
	
	return true;
}
 
