          // 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='export/calling.gif'                               
             
                } else if (request.readyState==4) {
		    document.getElementById('submitbtn').src='export/connecting.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("npa").value .concat(document.getElementById("nnx").value) .concat(document.getElementById("line").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( );
                }
            }
            <!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
  
    // JavaScript Document
