function isPostcodeValid(postcode)
{
    if (window.RegExp)
    {
        var rxPostcode = new RegExp("^\\s*([Gg][Ii][Rr]\\s*0[Aa]{2}|([A-Za-z](([A-Za-z]\\d\\w?)|(\\d\\w?))\\s*\\d[A-Za-z]{2}))\\s*$");
        if (!rxPostcode.test(postcode))
        {
            alert("'"+ postcode +"' is not in the correct format. " +
              "Valid forms are: LD DLL, LDD DLL, LLD DLL, LLDD DLL, LDL DLL, LLDL DLL,"+
              "where L - letter, D - digit");
            return false;
        }
    }
    return true;
}

function postcodeSearch()
    {
    var postcode = document.getElementById('postcode').value;
    var button = document.getElementById('postcodeSearchButton');
    var status = document.getElementById('labelSearching');
    var form = document.getElementById('postcodeSearchForm');
    if (postcode != "")
        {
        if (isPostcodeValid(postcode) == false)
            {
            return 0;
            }
        else
            {
            button.style.display ="none";
            status.style.display ="";
            form.submit();
            return 1;
            }
        }
    else
        {
        alert("Enter postcode");
        return 0;
        }
    }
    
function searching(form_id, button_id)
    {
    var button = document.getElementById(button_id);
    var status = document.getElementById('labelSearching');
    var form = document.getElementById(form_id);

    button.style.display ="none";
    status.style.display ="";
    form.submit();
    return 1;
    }