/**
 * Some Jquery to post the newsletter form and fade a thankyou message in if successful
 */
jQuery(document).ready(function() {
	jQuery("#newsletter-form").submit(function() {
		
		jQuery.ajax({
			type : 'POST',
			url : "http://www.pro-trek.co.uk/testsite/", // location.href
			data : ({
						js : 1, 
						op : 'newsletter-signup', 
						newsletter_first_name : (jQuery("#newsletterFirstName").val()),
						newsletter_last_name : (jQuery("#newsletterLastName").val()),
						newsletter_email : (jQuery("#newsletterEmail").val()),
					}),
			dataType : "text",
			success : function (data) {
						
						//jQuery("#newsletter-feedback").hide();
						
						if(data == "OK") {
							if(jQuery("#newsletter-feedback:eq(0)").length == 0) {
								theItem = jQuery('<div id="newsletter-feedback">Thank you, you are now signed up to the newsletter</div>').insertBefore("#newsletter-form");
							} else {
								theItem = jQuery("#newsletter-feedback").html("Thank you, you are now signed up to the newsletter");
							}
						} else {
							if(jQuery("#newsletter-feedback:eq(0)").length == 0) {
								theItem = jQuery('<div id="newsletter-feedback">Error: You need to fill in all the fields.</div>').insertBefore("#newsletter-form");
							} else {
								theItem = jQuery("#newsletter-feedback").html("Error: You need to fill in all the fields.");
							}
						}
						
						//jQuery("#newsletter-feedback").show();
						//theItem.css({'background-color' : '#e96b46'});
						
						theItem.animate({ backgroundColor:"#f8a835", color:"#ffffff", textShadow:"0px -1px 0px #c68527" }, { duration:400 } )
								.animate({ backgroundColor:"#e96b46", color:"#000000", textShadow:"0px 1px 0px #e3856a" }, { duration:400 } );
						
						
					}
			});
		
		return false;
	});
});



