(function($) {

	$('#email').click(function() {
		$(this).css({color: '#000000'})
	});

	// jQuery Form Example Plugin
	$(function(){
		$('#email').example('Your Email');
	});


	// validate signup form on keyup and submit
	$("#email_signup").validate({
		rules: {
			email: {
				required: true,
				email: true
			}
			
		},
		messages: {
			email: {
				required: "Please enter a valid email address"
			}
		},
		submitHandler: function() {

			var email = $("input#email").val();


			var dataString = 'email=' + email;
			//alert (dataString);return false;

			$.ajax({
				type: "POST",
				url: "/ajax/process_email.php",
				data: dataString,
				success: function(msg) {
					if(msg == 'success') {
						$('#message').html("");
						$('#email_signup').html("<h3>Check Your Email Now</h3>").append("<p>We need to verify your address. Please check your email and click the confirmation link.</p>");
					} else {
						$('#message').html("<p>Error: "+msg+"</p>");
					}
				}
			});

			return false;

		}

	});
	
})(jQuery);
