var provinces = new Array();
var undefined;

    // Changes the Provinces based on the country selected
    function changeProvinces()
    {
        var country_value = document.getElementById('country_id').value * 1;
        var province_selected = document.getElementById('province_id').value * 1;
        
        // Checks to see if there are provinces for the selected country
        if (undefined === window.provinces[country_value])
        {
            // Since there are no provinces, set the country_value to zero so that we only get the Other option
            country_value = 0;
        }
        
        // Update the Provinces element
        var province_html = '';
        var max = provinces[country_value]['max'];
        
        for (x = 0; x < max; x++)
        {
            // Generate the option tag for the given province
            province_html = province_html.concat('<option value="');
            province_html = province_html.concat(provinces[country_value][x]['value']);
            
            // Outputs if this was the option previously selected
            if (provinces[country_value][x]['value'] == province_selected)
            {
                province_html = province_html.concat('" selected="selected">');
            }
            else
            {
                province_html = province_html.concat('">');
            }
            
            province_html = province_html.concat(provinces[country_value][x]['name']);
            province_html = province_html.concat('</option>\n');
        }
        
        // Output the select tag and select the correct item
        document.getElementById('province_span').innerHTML = '<select id="province_id" name="province_id">' + province_html + '</select>';
    }