var iNum;var myPC="";var myDiv=null;function doHttpRequest(c){iNum=c;pcE=document.getElementById("postcodefind"+iNum);if(pcE!=null){var a=document.getElementById("postcodefind"+iNum).value}else{var a=document.getElementById("postcode"+iNum).value}myPC=a;var b=document.getElementById("house"+iNum).value;if(b=="House no/Name"){b=""}b=Trim(b);var d=httpMode+"/AFDajax.asp?postcode="+a+"&house="+b+"&num="+iNum;http.open("GET",d,true);pauseComp(200);http.onreadystatechange=function(){getHttpRes()};http.send(null)}function getHttpRes(){showRes=false;if(http.readyState==1){res="Waiting for response................";showRes=true}if(http.readyState==4){res=http.responseText;showRes=true}if(showRes){el=document.getElementById("postcodefind"+iNum);x=el.offsetLeft;y=el.offsetTop;w=el.offsetWidth;while((el=el.offsetParent)!=null){x+=el.offsetLeft;y+=el.offsetTop}if(myDiv==null){myDiv=document.createElement("div");myDiv.setAttribute("id","myDiv");myDiv.className="AFDClass";myDiv.style.position="absolute";document.body.appendChild(myDiv)}if(document.all){for(var a=0;a<document.all.tags("SELECT").length;++a){document.all.tags("SELECT")[a].style.visibility="hidden"}}el=myDiv;s1='<table class="AFDAjaxTable">';s1+="<tr>";s1+='<td align="left">&nbsp;Address Selector</td>';s1+='<td align="right"><a class="close" href="javascript:AFDCloseDiv()">Close</a>&nbsp;</td>';s1+="</tr>";s1+="<tr>";s1+='<td colspan="2" class="main">';s1+='<div id="addrList'+iNum+'" style="z-index:100;">';s2="</div>";s2+="</td>";s2+="</tr>";s2+="</table>";el.style.visibility="visible";el.style.display="block";el.innerHTML=s1+res+s2;w1=el.offsetWidth;x=x-Math.round((w1-w)/2);y=y-20;w=el.offsetWidth;h=el.offsetHeight;sw=-1;if(self.innerWidth){sw=self.innerWidth}else{if(document.documentElement&&document.documentElement.clientWidth){sw=document.documentElement.clientWidth}else{if(document.body){sw=document.body.clientWidth}}}sh=-1;if(self.innerHeight){sh=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){sh=document.documentElement.clientHeight}else{if(document.body){sh=document.body.clientHeight}}}if((sw>-1)){if(x<0){x=0}if((x+w)>sw-10){x=sw-w-10}}if((sh>-1)){if(y<0){y=0}if((y+h)>sh-10){y=sh-h-10}}if(x<0){x=0}if(y<0){y=0}el.style.left=x+"px";el.style.top=y+"px"}}function getXHTTP(){var a;try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(d){try{a=new ActiveXObject("Microsoft.XMLHTTP")}catch(c){try{a=new XMLHttpRequest()}catch(b){a=false}}}return a}function showAddress(j){if(j=="undefined"){j=""}var g=document.getElementById("addressList"+j).value;if(g!=""){var f=/\t/;g=g.replace(f,"");g=Trim(g);g=g.replace(/, /g,",");var e=g.split(",");if(e.length>2){var m=e[e.length-2]}else{var m=""}if(e.length>1){var l=e[e.length-1]}else{var l=""}var k=m.indexOf("Not Found");if(k>0){m=""}e.length=e.length-2;g=e.join("\n");if(document.getElementById("address"+j)!=null){document.getElementById("address"+j).value=g}if(document.getElementById("street"+j)!=null){document.getElementById("street"+j).value=g}if(document.getElementById("city"+j)!=null){document.getElementById("city"+j).value=m}if(document.getElementById("town"+j)!=null){document.getElementById("town"+j).value=m}if(document.getElementById("postcode"+j)!=null){document.getElementById("postcode"+j).value=l}}AFDCloseDiv()}function pauseComp(a){var c=new Date();var b=null;do{b=new Date()}while(b-c<a)}function AFDCloseDiv(){if(document.getElementById("addrList"+iNum)!=null){document.getElementById("addrList"+iNum).style.display="none"}if(document.getElementById("addrSel"+iNum)!=null){document.getElementById("addrSel"+iNum).style.display="none"}myDiv.style.display="none";if(document.all){for(var a=0;a<document.all.tags("SELECT").length;++a){document.all.tags("SELECT")[a].style.visibility="visible"}}};