// -----------------------------------------------------------------
// -----------------------------------------------------------------
// 
// Aeon Blu JQuery File
// 
// ajaxExample.js
// Date: 01/14/2010
// Version: 1.2.1
// 
// -----------------------------------------------------------------
// -----------------------------------------------------------------

/*
	----------------------------------------------------------------
	Version History
	----------------------------------------------------------------
	


*/

$(function(){
	
	$("#contactFormSubmit").click(function() {
		
		$("#formSubmitLoader").append('<img src="/img/jquery/ajax-loader.gif" />');
		$(".toggleSubmit").toggle();
		$.post("/info/ajaxController.php", $("#contactForm").serialize(), function(response){
			$("#formSubmitLoader").html('');
			$(".formResponseError").remove();
			$("#formResponseMsg").html('');
			if(!response.error) {
				$("#formResponseMsg").html('Thanks for sending a message to Agent '+response.contactCharacterName+'.<br />Please check your email.');
				$("#formResponseMsg").show().idle(3000).fadeOut("slow");
			} else {
				if(!response.contactName) {
					$("#contactName").parent().append('<p class="formResponseError">name required</p>');
				}
				if(!response.contactEmailExists) {
					$("#contactEmail").parent().append('<p class="formResponseError">email required</p>');
				}
				if(!response.contactEmailValid) {
					$("#contactEmail").parent().append('<p class="formResponseError">email must be valid</p>');
				}
			}
			
			//setTimeout($(".toggleSubmit").toggle(),5000);			
			$(".toggleSubmit").toggle();
			
		}, "json");
     	
		return false;
	});
});





