MktoForms2.whenReady(function (form){
  function validateEmail(email) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
  }
  form.onValidate(function()
  {
    var vals = form.vals();
    var email = vals.Email;
    if (validateEmail(email))
    {
      form.submittable(true);
    }
    else {
      var emailval = form.getFormElem().find("#Email");
      form.showErrorMessage("Enter Valid Email Address", emailval);
      form.submittable(false);
      return false;
    }

//Check if the honeypot field is empty
if (vals.bMS == "") {
// Not a spam bot! Submit the form          
form.submittable(true);
}
else {
// This is a spam bot! Don't submit the form
form.submittable(false);
}

});

// Add an onSuccess handler
form.onSuccess(function(values, followUpUrl) {   
  $(document).ready(function() {
    btnpopup();
    mktoButton:enable;
  });
  form.submittable(true);
  return false;
});
});

function btnpopup(){
  $("#popup1").css("display","block");
  return false;
};
$("#popclose").click( function(){
  $("#popup1").css("display","none");
  $(".mktoButtonWrap").html("<button type='submit' class='mktoButton'>Submit To Learn More</button>");
  return false;
});