/**
* Load and control one-click area
*/
$.ajax({
	url:'_oneclick_signup.php',
	type: 'GET',
	dataType: 'html',
	success: function(html)
	{
		$('#mailing_signup').html(html);

		$('#mailing_signup a').bind('click', function()
		{
			if (!this.href.match('update.php')) { return true; }

			// disable after the first click
			var me = $(this);
			me.unbind();
			me.bind('click', function() { return false; });
			me.css('cursor', 'default');
			me.html('Hang on a sec...');

			$.ajax({
				url: '/www2/user_profile/site_bar/oneClickHandler.php',
				type: 'POST',
				dataType: 'json',
				data: {campaign: this.href.match(/precheck\[\]=(\d+)/)[1]},
				success: function(response)
				{
					if (response.type == 'success') {
						$('#mailing_signup').html("<a>You're on the " + response.campaignTypeName + " mailing list</a>");
					} else {
						alert(response.text);
					}
				}
			});

			return false;
		});
	}
});
