$(document).ready(function(){ 
	
	/*
	 * Northie Courier
	 */
	$('#newsletter').submit(function() { 
		$('#error').html('Loading...');
		$.post(this.action, $('#newsletter').serialize(),
			function(data) {
				if(data.success == 1) {
					$('#newsletter').html(data.result).hide().fadeIn('slow');
				} else {
					$('#error').html(data.result).hide().fadeIn('slow');
				}
			}, 'json'
		);
		return false;
	});
	
	$('#email_address').focus(function() { 
		if($('#email_address').val() == 'Email Address') {
			$('#email_address').val('');
		}		
	});
	
	$('#email_address').blur(function() { 
		if($('#email_address').val() == '') {
			$('#email_address').val('Email Address');
		}
	});
	
	/*
	 * Testimonials
	 */
	$('a.nextTestimonial').live('click', function() {
		$.getJSON(this.href, function(data) {
			$('#testimonialBody').html(data.body).hide().fadeIn('slow');
			$('#testimonialLink').html(data.link).hide().fadeIn('slow');
		});		
		return false;
	});
	
	/*
	 * Contact Us
	 */
	$('#contact').submit(function() { 
		$('#error').html('Loading...');
		$.post(this.action, $('#contact').serialize(),
			function(data) {
				if(data.success == 1) {
					$('#contact').html(data.result).hide().fadeIn('slow');
				} else {
					$('#error').html(data.result).hide().fadeIn('slow');
				}
			}, 'json'
		);
		return false;
	});
	
	$('#recaptcha_response_field').val('Enter the two words above');
	
	$('#recaptcha_response_field').focus(function() { 
		if($('#recaptcha_response_field').val() == 'Enter the two words above') {
			$('#recaptcha_response_field').val('');
		}		
	});
	
	$('#recaptcha_response_field').blur(function() { 
		if($('#recaptcha_response_field').val() == '') {
			$('#recaptcha_response_field').val('Enter the two words above');
		}
	});
	
	/*
	 * Frequently Asked Questions
	 */
	$('a.helpful').live('click', function() {
		$.getJSON(this.href, function(data) {
			$('#' + data.id).addClass('helpfulAnswer');
			$('#' + data.id).html(data.response).hide().fadeIn('slow');
		});		
		return false;
	});
	
});