// JavaScript Document

$(document).ready(function () {
							
			$("#loader3").ajaxStart(function(){ // fire if the ajax is started
				return false;
				//$("#movies").hide();
  				// $(this).show(); 
 			});
			
			$("#loader3").ajaxComplete(function(){ // fire if the ajax is completed
  				// $(this).hide(); 
				 //$("#movies").show();
				 return false;
 			});

	$("a#newsletter").click(function () {
			
			if(document.getElementById('emailAddress').value.indexOf('@') && document.getElementById('emailAddress').value.indexOf('.') == -1) {
				$("span#error").text("Invalid Email Address!");
				
			} else if($("input#emailAddress").val() == 'Your email here...') {
				
				$("span#error").text("Blank email field. Supply your email address to subscribe.");
				
			} else {
				
				$("span#error").text("Processing...");
				
				$.ajax({
					 
					 url: "subscribe.php",
					 type: "POST",
					 data: {emailAddress: $("input#emailAddress").val()},
					 
					 success: function (a,b) {
						 
						$("#movies").show();
						 
						 if(a == 0) {
						
						$("span#error").text("Your subscription was successful");
							
						} else {
							
						$("span#error").text("The email address you specified already exists in our database.");
							
						}
					},
					
					error: function (a,b,c) {
						
/*						 alert(a);
						 alert(b);
						 alert(c);
*/						
					}
					  });
				
				//$("span#error").text("Your subscription was successful");
			}
						
	});
});
