/*
	Core custom jquery used on all pages
*/

$(document).ready(function() {
	
	$('#submitButton').live('click',function(){
		
		$('#submitButton').hide();
		$('#contactForm').append('<p id="loading" style="margin-left:9em;"><strong>Sending...</strong> <img src="../images/icons/ajax-loader.gif" /></p>');
		
		var data=$('#contactForm').serializeArray();
		
		if(data){ //Tests if empty
			$.ajax({
				type: 'POST',
				dataType: 'json',
				url: "/common/email.php",
				data: data,
				success: function(data) {

					if(data.error === false){
						//$('#contactForm').slideUp();
						$('#loading').html('<p><strong>Your request has been sent to our staff. Thank you!</strong></p>');
					}
					else {
						$('#loading').html('<p><strong>An error occurred. Please refresh the page and try again.</strong></p>');
					}
					
				}
			});
		}		
		return false;
	});
	
});

