    $(document).ready( function() {
      
      var mailto = {};  
       
        /*******************************************************************
         * Submit the email to the handling page
         */
        function send_form(body,phone,email,businame,recipient,terms) {
          $.ajax( {
            type: "POST",
            url: "/ajaxcontact/form-submit.php",
            data: "recipient="+recipient+"&body="+body+"&businame="+businame+"&phone="+phone+"&email="+email+"&terms="+terms,
            success: function(msg) {
              $("#requestform").hide();
              $("#back").show();
              $(".form-inner").append("<div class='result'>"+msg+"</div>");
            } //end success
          }); // end ajax
        }
        /************************
         * Build the workspace & Get the form.
         */
        function get_form(recipient) {
          
          // Since IE can't handle fixed positioning, we calculate from the top
          var browser_top = document.getElementsByTagName('body')[0].scrollTop;
          
          // destroy any existing workspace
          $(".ajaxform").remove();
          
          // Create the workspace after the body
          $("body").append("<div class='ajaxform' style='top:"+browser_top+"px'><div id='close'>X</div><div id='back'><-</div><div class='form-inner'></div></div>");
          
          //Setup close and back buttons  
          $("#close").click(function() {
            $(this).parent(".ajaxform").hide().remove();
          });
              $("#back").hide().click(function() {
                $(".ajaxform .result").remove();
                $("#requestform").show();
                $(this).hide();
              });
          $.ajax( {
            type: "POST",
            url: "/ajaxcontact/info-request.php",
            data: "mailto=" + recipient,
            success: function(inforequest){
              //append the form inside the workspace
              $(".form-inner").empty().append(inforequest);
              $(".ajaxform").slideDown();
              
              // Submitting the real form
              $(".submit").click( function() {
                var body      = $("#body").val();
                var phone     = $("#phone").val();
                var email     = $("#email").val();
                var businame  = $("#businame").val();
                var recipient = $("#recipient").val();
                var terms     = $("#terms:checked").val();
                 
                send_form(body,phone,email,businame,recipient,terms);
              }) // end click  
            },// end success on first call
            error: function(msg) {
              $("#requestform").hide();
              $("#back").show();
              $(".form-inner").append("<div class='error'>"+msg+"</div>");
            } // end failure
          }); // end ajax first call
        }
        /*******************************************************************
         * Retrieve the allowed email list 
         */
        function get_allowed() {
          var allowed = '';
          $.ajax({
              async: false,
              type: "GET",
              url: "/ajaxcontact/allowed-list.txt",
              success: function(msg) {
                allowed = msg;
                return allowed;
              }, // end success
              error: function(msg) {
                $("body").append("<!--"+msg+"-->"); // failed to get allowed list
              } // error
          });
          return allowed;
        }
        
        /*******************************************************************
         * Compare the current mailto: link with the allowed list
         */
        function check_allowed(recipient, allowed_list) {
          var good = allowed_list.indexOf(recipient);
          if(good == '-1') {
            $(this).end(); // I hope this does what I think
          } else {
              //rebuild the link with our replacement
              $("a[href^=mailto:"+recipient+"]").attr({href:"#contact", rel: recipient })
                .click( function() {
                  // Get the info-request form
                  get_form(recipient);
                });// end click function
          } // end if - good check
        }
        /*******************************************************************
         * The real work is done here.
         */
        // get the allowed list
        var allowed_list = get_allowed();
        
        // get all the mailto: links on the page into an array
        var all_mail_tos = [];
        all_mail_tos = jQuery.makeArray($("a[href^=mailto:]"));
        
        // If the recipient is on the list, convert mail link
        jQuery.each(all_mail_tos, function() {
          var recipient = $(this).attr("href");
          recipient = recipient.substr(7); // Get rid of mailto:
          check_allowed(recipient,allowed_list);    
        });
      /* The End */
      });