$(document).ready(function(){
	//Remove text from input box
	$("#newsletter-email").focus( function() {
		if ( $(this).val() == 'Enter email address...' ) {
			$(this).val('');
			$(this).removeClass('midgrey');
		}
		return false;
	});

	$("#newsletter-signup").submit( function() {
		newsletterSubscribe();
		return false;
	});
});

function newsletterSubscribe() {
	$.getJSON(
		'_gateway/newsletter.cfc',
		{ method: 'subscribe', email: $('#newsletter-email').val() },
		function(data) {
			//Set new value
			$( "#newsletter-dialog" ).html( data.MSG );
			$( "#newsletter-dialog" ).dialog({
				modal: true,
				title: 'Newsletter Signup',
				buttons: {
					OK: function() {
						$( this ).dialog( "close" );
					}
				}
			});
			
			if ( data.SUCCESS == 1 ) {
				$('#newsletter-email').val('');
			}
		}
	);
}

