//<![CDATA[	
	$(document).ready(function(){
		var regexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
		
		$('#donateNowButton').click(function(){
			var error = false;
			
			if($('#firstname').val().replace(/\s+/g,"").length == 0){
				error = true;
			}
			
			if($('#lastname').val().replace(/\s+/g,"").length == 0){
				error = true;
			}
			
			if($('#address').val().replace(/\s+/g,"").length == 0){
				error = true;
			}
			
			if($('#town').val().replace(/\s+/g,"").length == 0){
				error = true;
			}
			
			if($('#state').val().replace(/\s+/g,"").length == 0){
				error = true;
			}
			
			if($('#zip').val().replace(/\s+/g,"").length == 0){
				error = true;
			}
			
			if($('#email').val().replace(/\s+/g,"").length == 0){
				error = true;
			}
			else if($('#email').val().search(regexp) == -1){
				error = true;
			}
			
			if($('#phone').val().replace(/\s+/g,"").length == 0){
				error = true;
			}
			
			if($('#totalAmount').val().replace(/\s+/g,"").length == 0){
				error = true;
			}
			
			if(!$('#period1').attr('checked') && !$('#period2').attr('checked') && !$('#period3').attr('checked')){
				error = true;
			}
			
			if(!$('#year-period1').attr('checked') && !$('#year-period2').attr('checked')){
				error = true;
			}
			
			if(error){
				$('#processBox').html('Please fill out all required fields. Form will not process unless all required fields (<span class="mandatory">*</span>) are complete and valid.');
			}
			else{
				$('#donateNowButton').attr('disabled', 'true');
				$('#processBox').html('Processing... please wait. ');
				
				var formData = 'firstname=' + encodeURIComponent($('#firstname').val()) + '&lastname=' + encodeURIComponent($('#lastname').val()) + '&town=' + encodeURIComponent($('#town').val()) + '&address=' + encodeURIComponent($('#address').val()) + '&state=' + encodeURIComponent($('#state').val()) + '&zip=' + encodeURIComponent($('#zip').val())+ '&email=' + encodeURIComponent($('#email').val()) + '&phone=' + encodeURIComponent($('#phone').val()) + '&total_amount=' + encodeURIComponent($('#totalAmount').val());
				
				var radios = new Array('period1', 'period2', 'period3', 'year-period1', 'year-period2');
				for(var i in radios){
					if($('#'+radios[i]).attr('checked')){
						if(i<2){
							formData += '&period=' + encodeURIComponent($('#'+radios[i]).val())
						}
						else{
							formData += '&period_year=' + encodeURIComponent($('#'+radios[i]).val())
						}
					}
				}
				
				$.ajax({
					type: 'POST',
					url: 'includes/php/contact-donate.php',
					cache: false,
					data: formData,
					dataType: "xml",
					timeout: 10000,
					error: function(ob, status){
						$('#donateNowButton').attr('disabled', '');
						$('#processBox').html('Error: ' + status + '. Please try again.');
					},
					success: function(xml){
						$('#donateNowButton').attr('disabled', '');
						var root = xml.getElementsByTagName('root')[0];
						if(root.getElementsByTagName("error")[0].firstChild.nodeValue == 'false'){
							$('#donateForm')[0].reset();
							$('#domateFormContent').html('<span id="confirm">Thank you! Your message has been successfully sent.</span><br/><br/>');
						}
						else{
							$('#processBox').html('Error. Please try again.');
						}
					}
				});
			}
		});
	});
//]]>
