﻿function captureEmail(){
   var email = $('#emailBox').val();
   if(validEmail(email)){
      $.ajax({
         type: "get",
         url: "ajax_capture_email.asp?email="+encodeURIComponent(email)+'&ms='+(new Date().getTime()),
         dataType: "xml",
         error: function(msg){
            jAlert('error:'+msg.status+' : '+msg.statusText+' : '+msg.responseText,'Communications Error');
         },
         success: function(xmlDocument){
            if(parseInt($('status',xmlDocument).attr('value'))==1){
               jAlert("Your are subscribed to the newsletter","Thank You");
            }else{
               jAlert("That email is already subscribed to the newsletter","Sorry");
            }
         }
      });
   }else{
      jAlert("Please enter a valid email address.",'Validation Error');
   }
}
function validEmail(inputvalue){	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){         
		return true;
    }else{   
		return false;
    }
} 