

// Mailing list form script

$(document).ready(function()
{
	// Default text box text
	var default_text = 'Sign up for email updates';
	
	// Clear text when user clicks into the text box
	$('#email-text').focus(function()
	{
		if($(this).attr('value') == default_text) $(this).attr('value','');
	});
	
	// Restore default text when users clicks away
	$('#email-text').blur(function()
	{
		if($(this).attr('value') == '') $(this).attr('value',default_text);
	});
	
	// form submission
	$('#mailer').submit(function()
	{
		var email = $('#email-text').attr('value'); // the value of the text box
		if(email != default_text) { // if it's not the default text, continue
		// fade out the text field
		$('#mail-show').fadeOut(700,function()
		{
			// send the data to PHP
			$.post("http://noncollective.com/wp-content/themes/noncollective/mail_signup.php",
				{email:email,fromJS:true},
				function(data)
				{
					$('#mail-show').html(data); // update the 'mail-show' div text
					$('#mail-show').fadeIn(700); // fade the updated text in
				});
		});
		}
		return false; // prevents the form from submitting to a new page
	});
});