<!--

	//================================================================================================
	// VARIABLES DECLARATION
	//================================================================================================	

	
	//================================================================================================
	// AJAX FUNCTIONS
	//================================================================================================		
	function sendDonation(gift, otheramount, frequency, startdate, company, firstname, surname, email, phone, address, suburb, state, postcode, name_behalf, address_behalf, occasion, subscribe, listID)
	{
		var url = "process.asp";

		var data = "process=donation";
		data = data + "&listID=" + listID;
		data = data + "&gift=" + gift;
		data = data + "&otheramount=" + otheramount;
		//data = data + "&frequency=" + frequency;
		//data = data + "&startdate=" + startdate;
		data = data + "&company=" + company;
		data = data + "&firstname=" + firstname;
		data = data + "&surname=" + surname;
		data = data + "&email=" + email;
		data = data + "&phone=" + phone;
		data = data + "&address=" + address;
		data = data + "&suburb=" + suburb;
		data = data + "&state=" + state;
		data = data + "&postcode=" + postcode;
		data = data + "&name_behalf=" + name_behalf;
		data = data + "&address_behalf=" + escape(address_behalf);
		data = data + "&occasion=" + escape(occasion);
		data = data + "&subscribe=" + subscribe;
		data = data + "&sid=" + Math.random();		
		
		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {			
				//alert(txt);
				$('txtMessage').set('text', 'Success! Redirecting to Paymate.com...');
				
				window.location = txt;
				
				var form = document.donateform;
				form.gift[0].checked = true;
				form.giftOtherAmount.value = "";
				//form.frequency[0].checked = true;
				form.firstname.value = "";
				form.surname.value = "";
				form.email.value = "";
				form.phone.value = "";
				form.address.value = "";
				form.suburb.value = "";
				form.state.value = "";
				form.postcode.value = "";
				form.name_behalf.value = "";
				form.address_behalf.value = "";			
				form.occasion.value = "";			
				form.subscribe.value = "";			
			},

			onRequest: function() {
				$('txtMessage').set('text', 'Processing donation. Please wait...');
			},
			
			onFailure: function() {
				alert("Error connecting to server. Please refresh this page...");
			}
			
		}).send(data);
	}
	
	//================================================================================================
	// FORM FUNCTIONS
	//================================================================================================
	function submitDonation()
	{
		var i, c_frequency, c_startdate, c_gift;
		var form = document.donateform;

		var c_listID = form.listID.value;

		for (i = 0; i < form.gift.length; i++) {
			if (form.gift[i].checked) {
				c_gift = form.gift[i].value;
			}
		}

		var c_otheramount = form.giftOtherAmount.value;
		
		// for (i = 0; i < form.frequency.length; i++) {
			// if (form.frequency[i].checked) {
				// c_frequency = form.frequency[i].value;
			// }
		// }
		
		//c_startdate = form.startdate.value;
		
		var c_company = form.organisation.value;
		var c_firstname = form.firstname.value;
		var c_surname = form.surname.value;
		var c_email = form.email.value;
		var c_phone = form.phone.value;
		var c_address = form.address.value;
		var c_suburb = form.suburb.value;
		var c_state = form.state.value;
		var c_postcode = form.postcode.value;
		var c_name_behalf = form.name_behalf.value;
		var c_address_behalf = form.address_behalf.value;
		var c_occasion = form.occasion.value;
		var c_subscribe = form.subscribe.value;

		var valid = true;

		if (form.gift[5].checked && c_otheramount < 5)
		{
			valid = false;
			alert("Please make sure you have entered minimum of $5 for the donation amount.");
		}				
		else if (c_firstname == "")
		{
			valid = false;
			alert("Please make sure you have entered your first name.");
		}
		else if (c_surname == "")
		{
			valid = false;
			alert("Please make sure you have entered your last name.");
		}
		else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(c_email)))
		{
			valid = false;
			alert("Please make sure you have entered a valid e-mail address.");
		}
		else if (c_phone == "")
		{
			valid = false;
			alert("Please make sure you have entered your contact phone number.");
		}
		else if (c_address == "")
		{
			valid = false;
			alert("Please make sure you have entered your street address.");
		}
		else if (c_suburb == "")
		{
			valid = false;
			alert("Please make sure you have entered your suburb.");
		}
		else if (c_state == "")
		{
			valid = false;
			alert("Please make sure you have entered your state.");
		}
		else if (c_postcode == "")
		{
			valid = false;
			alert("Please make sure you have entered your postcode.");
		}

		if (valid == true)
		{
			sendDonation(c_gift, c_otheramount, c_frequency, c_startdate, c_company, c_firstname, c_surname, c_email, c_phone, c_address, c_suburb, c_state, c_postcode, c_name_behalf, c_address_behalf, c_occasion, c_subscribe, c_listID);
		}
	}

	//================================================================================================
	// LAYOUT FUNCTIONS 
	//================================================================================================			
	function frequencyChange(field)
	{
		if (field.checked && field.value == "Single Donation")
		{
			$('div_startdate').setStyle('display', 'none');
		}
		else
		{
			$('div_startdate').setStyle('display', 'block');
		}
	}
	
	//================================================================================================
	// EVENTS FUNCTIONS
	//================================================================================================		
	function setupSlideshows()
	{
		if ($chk($$('.rotating_images')[0]))
		{
			var imageShow = new SimpleSlideShow({
				startIndex: 0,
				slides: $$('.slide_image')
			});
			
			var play = function() 
			{
				imageShow.forward();
			}
			var timer = play.periodical(4000);			
		}	
		
		if ($chk($$('.rotating_captions')[0]))
		{
			var captionShow = new SimpleSlideShow({
				startIndex: 0,
				slides: $$('.slide_caption')
			});
			
			var play = function() 
			{
				captionShow.forward();
			}
			var timer = play.periodical(4000);			
		}			
	}	
	
	function setupActions()
	{
		
	}	
	
	//================================================================================================
	// START THIS WHEN PAGE DOM READY
	//================================================================================================		
	window.addEvents({
	
		'domready' : function(e) {
			setupSlideshows();
		},
		
		'resize' : function() {

		}
		
	});
	

//-->
