		var a = new Array();
	
		function doLookup(){
			var fr = document.getElementById('lookup');
			var ch = document.getElementById('pc');
			fr.src = '/lookup/?pc=' + ch.value;
		}
		
		function doList(){
			doForm(-1);
			var drop = document.getElementById('addchoose');
			drop.options.length = 0;
			if (a.length == 0){
				drop.options[drop.options.length] = new Option('postcode not found, please try again', -1);
				doForm(-1);
			}else{
				drop.options[drop.options.length] = new Option('Please select',-1);
				for (i=0; i<a.length; i++){
					var thisItem = 	((a[i].building != '') ? a[i].building + ', ' : '') + 
									((a[i].street != '') ? a[i].street + ', ' : '') + 
									((a[i].area != '') ? a[i].area + ',  ' : '' ) + 
									((a[i].city != '') ? a[i].city + ', ' : '') +
									((a[i].county != '') ? a[i].county + ', ' : '') +
									a[i].postcode;
					drop.options[drop.options.length] = new Option(thisItem, i);
				}
				if (a.length == 1){
					drop.options.selectedIndex = 1;
					doForm(0);
				}
			}
		}
		function doForm(id){
			document.getElementById('street').value = (id < 0) ? '' : ((a[id].building != '' ? a[id].building+' ' : '') + a[id].street);
			document.getElementById('area').value = (id < 0) ? '' : a[id].area;
			document.getElementById('city').value = (id < 0) ? '' : a[id].city;
			document.getElementById('county').value = (id < 0) ? '' : a[id].county;
			document.getElementById('geoarea').value = (id < 0) ? '' : a[id].geoarea;
			document.getElementById('postcode').value = (id < 0) ? '' : a[id].postcode;
			if (id >= 0) document.getElementById('number').focus();
		}