
	
	function lookupPostcode(contextPath){
		
		$('#ajaxLoading').removeClass('invisible');
		$('#ajaxLoading').show();
		
		var args = { 
			postcode: $('#postcode').val()
		};
		
		$.get(contextPath + "/postcodeLookup", args,
			function(data){
				$('#addressOptions').html(data).hide();
				
				if(data == "No Matches"){
				
					$('#addressOptions').show();
					$('#selectPrompt').hide();
					$('#ajaxLoading').hide();
					return;
					
				}
				
				if($('#foundvals option').length > 1){
				
					$('#addressOptions').show();
					$('#selectPrompt').removeClass('invisible');
					$('#selectPrompt').show();
					
				}else{
				
					$('#selectPrompt').hide();
				
				}
				
				$('#ajaxLoading').hide();
				insertVals($('#foundvals').val());
				
			},"html");
		
	}
	
	function insertVals(vals, removePrompt){

		if (removePrompt){
		
			$('#addressOptions').hide();
			$('#selectPrompt').hide();
		
		}
		
		var valArray = vals.split("|",3);
		
		$('#addressLine1').val(valArray[0].replace(/\+/g," "));
		$('#addressLine2').val(valArray[1].replace(/\+/g," "));
		$('#addressLine3').val(valArray[2].replace(/\+/g," "));
		
		$('#addressLine1').effect("highlight", {}, 1000);
		$('#addressLine2').effect("highlight", {}, 1000);
		$('#addressLine3').effect("highlight", {}, 1000);
		
	}
