/*///////////////////////////////////////////////////////////////////////
Ported to jquery from prototype by Joel Lisenby (joel.lisenby@gmail.com)
http://joellisenby.com

original prototype code by Aarron Walter (aarron@buildingfindablewebsites.com)
http://buildingfindablewebsites.com

Distrbuted under Creative Commons license
http://creativecommons.org/licenses/by-sa/3.0/us/
///////////////////////////////////////////////////////////////////////*/

$(document).ready(function() {
	$('#signup').submit(function() {
		// update user interface
		$('#response').html('Adding email address...');
		
		// Prepare query string and send AJAX request
		$.ajax({
			url: '/common/store-address.php',
			data: 'ajax=true&email=' + escape($('#email').val()) + '&listid=' + escape($('#listid').val()) ,
			success: function(msg) {
				$('#response').html(msg);
				
				if (('Success!' == msg) && $('#newsletter-form').length) {
					$('#newsletter-form').delay('1500').hide('slow', function(){
						$('#response').html('');
						$('#email').val('');
					});
				}
			}
		});
	
		return false;
	});
});
