$(document).ready(function() {
	
	$(".long, .short").focus(function() {
		var defaultValue = $(this).attr("name");
		var currentValue = $(this).val();
		if(currentValue == defaultValue) $(this).val('');
	});
	$(".long, .short").blur(function() {
		var defaultValue = $(this).attr("name");
		var currentValue = $(this).val();
		if(currentValue == '') $(this).val(defaultValue);
	});
	
	$("textarea.click").focus(function() {
		if($(this).html() == 'Please share the reasons why you support Rodney.') $(this).html('');
	});
	$("textarea.click").blur(function() {
		if($(this).html() == '') $(this).html('Please share the reasons why you support Rodney.');
	});
	
	$("#updatesbtn").click(function() {
		var rand = Math.round(Math.random() * 999999);
		$.ajax({
			type: "POST",
			url: "wp-content/themes/rodney/ajax/newsletter-signup.php",
			data: 'field_email=' + $("#field-email").val() + '&field_zipcode=' + $("#field-zipcode").val() + '&rand=' + rand,
			success: function(msg) {
				$("#field-email, #field-zipcode").val('').focus().blur();
				$("#newsletter-message").html(msg);
				setTimeout(function() {
					$("#newsletter-message").fadeOut("medium");
				}, 2500);
			}
		});
 	});
});
