$(document).ready(function(){
	$("#emaillist_submit").click(function(){		//Submit Button ID			   				   
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
		var emailVal = $("#emaillist_email").val(); //field ID + Validation
		if(emailVal == '') {
			$("#emaillist_msg").css('color','red');
			$("#emaillist_msg").html('Please enter a valid email address above.');
			hasError = true;
		} else if(!emailReg.test(emailVal)) {
			$("#emaillist_msg").css('color','red');
			$("#emaillist_msg").html('Please enter a valid email address above.');
			hasError = true;
		}		
		
		if(hasError == false) {
			$(this).hide();
			
			var formaction = $("#emaillist_form").attr('action');
			var regex = new RegExp("[^0-9]*");
			formaction = formaction.replace(regex,"");
			formaction = '../scripts/submitform.asp?formid=' + formaction;
			
			$("#emaillist_email").after('<img src="images/loading.gif" alt="" width="16" height="16" id="loading" style="margin:2px 0px 0px 3px;"/>');
			$("#emaillist_msg").css('color','#999');
			$("#emaillist_msg").html('Processing your submission ...............');
			
			$.post(formaction,
   				{ Email: emailVal },
   					function(data){
						$("#emaillist_form").fadeTo('fast',0);
						$("#emaillist_form").html('<span class="emailtxt">Thanks for your submission. Your email address has been added to our eMail list.</span>')
						$("#emaillist_form").show().fadeTo('slow',1);
   					}
				 );
		}
		
		return false;
	});						   
});