$(document).ready(function() {

	// Hide Loader & Other Stuff
	$('#loader').hide();
	$('#thankyou').hide();
	$('#in_filter').hide();
	//$('#quick-contact form').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-contact form').hide(1500);					
			$('#thankyou').slideDown(1800);			
			$('#loader').fadeOut(500);
			return false;						
		}// End of Status 5
		
		$('#alert p').animate({opacity: 1.0}, 2000).slideUp(600);
		
	} 
	// End of processJson
	
	$('#main-contact form').ajaxForm(options);	

}); 