/**
 * @author Ryan Sadwick
 * Loader Component
 */


$(document).ready(function(){
	
	
	jQuery.preLoadImages("images/woman_bg.gif", "images/site_bg.gif");
	


	$('#features li:nth-child(odd)').addClass('alternate');


	// validate the comment form when it is submitted
	//$("#commentForm").validate();
	
	$("#commentForm").validate({
	   errorLabelContainer: "#invalidField",
	   wrapper: "li",
   	   submitHandler: function() 
	   {
	   		//Success!
			$("#successEmail").show('slow');
			//reset form
			//$("#commentForm").resetForm();
			//Send mail:
	   		var emailToVal = $("#email").val();
			var nameToVal = $("#name").val();
			var phoneToVal = $("#phone").val();
			var emailFromVal = "sales@printresellerpro.com";
			var subjectVal = "Print Reseller Sales Lead";
			var questionVal = $("#questions").val();
			var messageVal = "<b>Customer</b>: " + nameToVal + " <b>Email</b>: " + emailToVal + " <b>Phone</b>: " + phoneToVal + "<br><br><b>Questions:</b> " + questionVal;

	   		$.post("mailer/send_email.php",
   				{ emailTo: emailToVal, emailFrom: emailFromVal, subject: subjectVal, message: messageVal, customer: nameToVal, questions: questionVal, phone: phoneToVal },
   					function(data){
						jQuery("input[name='name']").val('');
						jQuery("input[name='email']").val('');
						jQuery("input[name='phone']").val('');
						jQuery("textarea[name='questions']").val('');
						$("#successEmail").slideUp("normal", function() {				   
							
							$("#successEmail").text('Success!  Your submission was sent.');
							$("#successEmail").show('slow');

							//$("#successEmail").before('Success!  Your subbmision was sent.');											
						});
   					}
				 );
		

	   }

	})

   






});
