$(document).ready(function() {

	// Hide Filter
	$('#in_filter').hide();
	$('#thankyou').hide();
	$('#loader').hide();
	
	// Setup Form2Email Options
	var options = {
		beforeSubmit: function() {
		$('#loader').fadeIn(50);
		},
		dataType: 'json',
		success: processJson
		}
		
	// Form Functions
	function processJson(data) {
		var status = data.status;
		$('#loader').fadeOut(300);
				
		// If Fields are Empty
		if(status == 1) {$('#alert').append("<p>You must fill in all required fields.</p>");}
		
		// If Name is Wrong
		if(status == 2) {$('#alert').append("<p>Your name must be between 3 and 30 characters.</p>");}								
		
		// If Spam Bot
		if(status == 3) {$('#alert').append("<p>Leave the spam field blank please.</p>");}
		
		// If Fields are Empty
		if(status == 4) {$('#alert').append("<p>Your email address was not valid.</p>");}
		
		// If Probems
		if(status == 6) {$('#alert').append("<p>There was a problem sending the form.</p>");}
		
		// If Message Sent
		if(status == 5) {
												
			$('#main-form form').fadeOut(600);
			$('#thankyou').fadeIn(900);
			$('#quick-alert').hide();										
			$('#loader').fadeOut(500);
			return false;						
		
		}// End of Status 5
		
		$('#alert p').animate({opacity: 1.0}, 2000).slideUp(600);
		
	} 
	// End of processJson
	


	$('#main-form form').ajaxForm(options);


});