﻿
function AutoCompleteInitializer() {
    $().ready(function() {
        function log(event, data, formatted) {            
            LoadPostcodesBySuburb(formatted);
        }        
        $("#suburb").autocomplete(suburbs);
        $(":text, textarea").result(log).next().click(function() {
            $(this).prev().search();
        });
    });
}
function LoadPostCodes() {
    var _suburb = document.getElementById('suburb').value;
    if (_suburb != "") {
        LoadPostcodesBySuburb(_suburb);
    }   
}
function LoadPostcodesBySuburb(suburb) {
    Sys.Net.WebServiceProxy.invoke("/Services/HerringboneService.asmx", 
        "LoadPostCodes", false,{ Suburb: suburb },
        function(result) {
            $('#divPostCodes').html(result);
        }, null, null);
}