
         
          // Initialize a Web 2.0 connection (determine browser capabililtes)
            var request = false;
            try {
              request = new XMLHttpRequest();
            } catch (trymicrosoft) {
              try {
                request = new ActiveXObject("Msxml2.XMLHTTP");
              } catch (othermicrosoft) {
                try {
                  request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (failed) {
                  request = false;
                }
              }
            }
             
 
// Function that updates the status in the box for the call. This function is called as a result of a state change after making the AJAX request. 
            function update_status_message(){
             
                if (request.readyState < 4) {
		    //document.getElementById('submitbtn').src='ibpimages/button_processing.jpg'                               
             
                } else if (request.readyState==4) {
		    //document.getElementById('submitbtn').src='ibpimages/button_connected.jpg'                       
                }
            }
            
// Function called by clicking on the "Click to Call" button in the form.
// This function combines the three fields in the form into a 10 digit phone number field and if it is of a valid form, then call the proxy module
// to perform the functions.
//
            function request_call_local(){
              if (!request) {
                    Alert ("sorry, click to call will not work with your browser");
                }
                else
                {
                    var phone = document.getElementById("cb-01").value .concat(document.getElementById("cb-02").value) .concat(document.getElementById("cb-03").value);
                    if (validate_phone(phone) ) {
                        // insert your click to xyz building block ID where indicated in the next line or you will receive invalid account responses.
                        // get the click to xyz building block id from the Tools menu
                         var url = "clickto_proxy.php?phone_to_call="+escape(phone)+
                         "&click_id=" + document.getElementById("clickID").value+ // replace this line with the appropriate clickid (or have a hidden value for this element) ... 
                         "&key=" + document.getElementById("publicKey").value; // replace this line with the appropriate public key for your account (or have a hidden value for this element) ... 
                        request.onreadystatechange = update_status_message;
                        request.open("GET", url, true);
                        request.send(null);
                     }
                 }
             
            }


// Simple phone number validation that confirms that the data entered was 10 digits.

            function validate_phone(phone) {
             if (phone.length != 10) {
                    alert("Sorry, the phone number you entered does not have 10 digits! ");
                    return 0;
               }
             
            return 1;
            }
 // generic module that will change the focus of the cursor to the defined element after entering the specified number of characters.
 // field - field that is being entered
 // limit - number of characters to enter before transferring focus.
 // next  - field to transfer focus to when the limit number of characters has been entered.
 // evt   - pointer to the keyup event
            function autofocus(field, limit, next, evt) {
                evt = (evt) ? evt : event;
                var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
                    ((evt.which) ? evt.which : 0));
                if (charCode > 31 && field.value.length == limit) {
                    field.form.elements[next].focus( );
                }
            }
            
  

