$(function(){
    $("#postcode_button").click(function(e)
    {
        e.preventDefault();
        map_search();
    });
    
    $('#postcode_form').submit(function(e){
        e.preventDefault();
        map_search();
    
    });
});



function map_search(){
        if($('#postcode').val() == '')
        {
            $('#map_error').html('<span class="map_error">You must enter a postcode</span>');                    
        }
        else
        {
            usePointFromPostcode($('#postcode').val(),
                function (point) {
                    $('#latitude').val(point.lat());
                    $('#longitude').val(point.lng());
                    $('#postcode_form').unbind('submit');
                    $('#postcode_form').submit();
            });
        }

}
