$(function(){
	jQuery.validator.addMethod("smtpValidate", function(email, element) {
		if ( this.optional(element) ) {
			return true;
		}

		$.ajax({
			type: "POST",
			url: "/ajax/check_email.php",
			data: "email="+email,
			async: false,
			success: function(msg)
			{
				if (msg == "1")
				{
					disable_popup();
					// append a value to the form, stating that this email is valid
					$('input[name="passed_valid_email"]').val(1);
					return true;
				}
				else
				{
					$('#email_address_submitted').html(email);
					$('#check_your_email').show("fast");

					$(".continue_anyway").click(function(){
						disable_popup();
						$('#check_your_email').hide();
						$("#lead_form").submit();
					});

					$(".fix_it").click(function(){
						$("#email").focus().select();
						$('#check_your_email').hide();
						return true;
					});

					return false;
				}
			}
		});

		return false;
	});
});
