//<![CDATA[

	jQuery(document).ready(function()
	{
		var ajaxProxy = "http://www.yupe.co.uk/ajax-proxy.php";
		var listUrl = "https://lists.york.ac.uk/mailman/subscribe/pole-exercise-club";
		var signupUrl = "https://lists.york.ac.uk/mailman/listinfo/pole-exercise-club";
		
		jQuery("form.SubscribeForm").submit(function()
		{
			jQuery("#ajaxBusy").show();
			// Google Analytics
			pageTracker._trackPageview("/outbound/ajaxform/lists.york.ac.uk/mailman/subscribe/pole-exercise-club");
			
			jQuery.post(ajaxProxy, 
			{ 
				csurl: escape(listUrl),
				fullname: jQuery("#name").val(),
				email: jQuery("#email").val(),
				pw: "",
				digest: "0"
			},
			function(data)
			{
				jQuery("#ajaxBusy").hide();
				
				// Remove HTML guff.  Interesting bit is between </h1> and <hr>.
				data = data.replace(/(^(.|\n)*<\/h1>|<hr>(.|\n)*$)/gi, "");
				
				// Failed
				if (data.search("Your subscription request has been received, and will soon be acted upon.") == -1)
				{
					jQuery("#ajaxResult").html("<h4>Ooh dear.  Something went wrong.</h4><p>" + data + "</p><p>Keeps going wrong?  <a href=\"" + signupUrl + "\">Try signing up on the mailing list server&nbsp&raquo;</a></p>").fadeIn("fast");
				}
				else
				{
					jQuery("#ajaxResult").html("<h4>Thanks!</h4><p>You should get an email from the list service we use to confirm your subscription.  Just click the link in that and you&rsquo;re done.</p>").fadeIn("fast");
				}
			});
			
			return false;
		});
	});

//]]>
