
//-------------------------------------------------------------------------
//  AJAX stuff
//-------------------------------------------------------------------------
   var iNum
   function doHttpRequest(i) {  
     iNum = i
     var pc = document.getElementById("postcode"+iNum).value; 
     var iURL = httpMode+"/AFDajax.asp?postcode="+pc+"&num="+iNum
     
     http.open("GET", iURL, true);
     pauseComp(200);
     http.onreadystatechange = function(){ getHttpRes(); };
     http.send(null);
   }

   function getHttpRes() {
    if (http.readyState == 1) {
        document.getElementById('addrSel'+iNum).innerHTML = 'Waiting for response................';
    }
     if (http.readyState == 4) { 
       res = http.responseText;  
       document.getElementById('addrSel'+iNum).innerHTML = res;	
      }
   }

   function getXHTTP() {
     var xhttp;
      try {   // The following "try" blocks get the XMLHTTP object for various browsers…
         xhttp = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
         try {
           xhttp = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (e2) {
 		 // This block handles Mozilla/Firefox browsers...
	       try {
	         xhttp = new XMLHttpRequest();
	       } catch (e3) {
	         xhttp = false;
	       }
         }
       }
     return xhttp; // Return the XMLHTTP object
   }

   function showAddress(iNum) {
      if (iNum=='undefined') iNum='';
      var a = document.getElementById("addressList"+iNum).value;
      var x = /\t/;
      a = a.replace(x,' ');
      a = LTrim(a);
      var b = a.split(",");
      var c = b[b.length-1];
      b.length = b.length-1;
      a = b.join('\n');
      document.getElementById("address"+iNum).value=a;
      document.getElementById("city"+iNum).value=c;
      document.getElementById("addrList"+iNum).style.display='none';
   }

   function pauseComp(millis) {
      var date = new Date();
      var curDate = null;
      do { curDate = new Date(); }
      while(curDate-date < millis);
   }

//-------------------------------------------------------------------------

