function onChangeCountry()
{
    // get the selected country value
    var x = document.getElementById("country").selectedIndex;
    var intCountryID = document.getElementById("country").options[x].value;

    var countyList;

    switch (intCountryID)
    {
        case "1": // England "1"
            countyList = EnglandCounties;
            break;
        case "4": // NI
            countyList = NIrelandCounties;
            break;
        case "2": // wales
            countyList = WalesCounties;
            break;
        case "3": // scotland
            countyList = ScotlandCounties;
            break;
        case "0": // all
            break;
        default: 
            intCountryID="0";
            break;
    }

    // filter county list based on country
    var countySelect = document.getElementById("county")
    var i, intSelectedValue;
    // preserve selection for case where country remains same
    intSelectedValue = countySelect.options[countySelect.selectedIndex].value;
    while(countySelect.length>1)
        countySelect.remove(1);
    if(intCountryID=="0")
    {
        document.getElementById("county").disabled = true;
    }
    else
    {
        document.getElementById("county").disabled = false;
        for(i=0;i<countyList.length/2;i++)
        {
            var y=document.createElement('option');
            y.text = countyList[i*2+1];
            y.value = countyList[i*2];
            if(y.value == intSelectedValue)
                y.selected = true;
            try
            {
                countySelect.add(y,null); // standards compliant
            }
            catch(ex)
            {
                countySelect.add(y); // IE only
            }
        }
    }
}