// JavaScript Document

 $(document).ready(function() {
							
							
		// move the background of the search box when they set focus to it
		$("#searchBox").focus(function() {
										
			$(this).css('background-position', '0px -26px');								
		});
							
		$('#go_button').click(function() {
									   
				
				var emailAddress = $('#email_address').val();
											   
					  // validate the email address
					 function isValidEmailAddress(emailAddress)
					 {
						var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
						return pattern.test(emailAddress);
					};
		
					$("#messages").css('display', 'none');
					$("#msg").html(null);
					
					if(isValidEmailAddress(emailAddress) == false)
					{
									$("#messages").css('background', '#FF0000');
									$("#msg").html('Enter a valid email address');
							 // An error was found, the email address is not a valid format
									$("#messages").fadeIn(1000, function () {
											
									 });
					}
					else
					{
									$("#messages").css('background', '#006600');
									$("#msg").html('Thank you!');
						// clear any error that was set
									$("#messages").fadeIn(1000).delay(3000).fadeOut(1000);
						
						// log the email address, send it to whomever
						
						
					}
				
		});

  
 });


