function disable () {
    var id = document.getElementById('j_id');
    id.disabled = true;
    id = document.getElementById('subdomain');
    id.disabled = true;
}
function enable () {
    var id = document.getElementById('j_id');
    id.disabled = false;
    id = document.getElementById('subdomain');
    id.disabled = false;
}

var states_arr = new Array ('All','Federal','Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','Florida','Georgia','Havaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina', 'North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','Washington DC','West Virginia','Wisconsin','Wyoming');

var federal_arr = new Array ('1');
var other_arr   = new Array ('2','3','4','5','6','8','10','11','14','15','16','17','20','22','23','24','26','27','28','30','31','32','33','34','35','37','38','41','44','45','48','50','51','52');

function refresh_onload (jur_id) {
    var subdomain_obj = document.getElementById('subdomain');
    refresh2(subdomain_obj, jur_id);
}
function refresh2 (subdomain_obj,jur_id) {
    var j_id_obj = document.getElementById('j_id');
    var len = j_id_obj.options.length;
    
    // all together
    if (subdomain_obj.value == '0' ||
        subdomain_obj.value == 'business' ||
        subdomain_obj.value == 'criminal' ||
        subdomain_obj.value == 'personal-injury' ||
        subdomain_obj.value == 'tax') {
            insert_first(jur_id);
            insert_all(jur_id);
    }
    // only federal
    if (subdomain_obj.value == 'bankruptcy') {
        insert_federal(jur_id);
    }
    // only other
    if (subdomain_obj.value == 'divorce' ||
        subdomain_obj.value == 'insurance' ||
        subdomain_obj.value == 'wills') {
            insert_first(jur_id);
            insert_other(jur_id);
    }
        
    for (x=0; x < len; x++) {
        var element = j_id_obj.options[x];
        j_id_obj.remove(element);
    }
}

function insert_all (jur_id) {
    insert_federal (jur_id);
    insert_other (jur_id);
}
    
function insert_federal (jur_id) {
    var j_id_obj = document.getElementById('j_id'); 
    var len = federal_arr.length;
    for (x=0; x<len; x++) {
        var opt = document.createElement('OPTION');
        opt.text = states_arr[federal_arr[x]];
        opt.value = federal_arr[x];
        if (jur_id == opt.value) {
            opt.selected = true;
        }
        try {
            j_id_obj.add(opt,null);
        }
        catch(ex) {
            j_id_obj.add(opt); // IE only
        }
    }
}

function insert_other (jur_id) {
    var j_id_obj = document.getElementById('j_id');
    var len = other_arr.length;
   for (x=0; x<len; x++) {
        var opt = document.createElement('OPTION');
        opt.text = states_arr[other_arr[x]];
        opt.value = other_arr[x];
        if (jur_id == opt.value) {
            opt.selected = true;
        }
        try {
            j_id_obj.add(opt,null);
        }
        catch(ex) {
            j_id_obj.add(opt); // IE only
        }

    }
    
}

function insert_first (jur_id) {
    var j_id_obj = document.getElementById('j_id');
    var opt = document.createElement('OPTION');
    opt.text = 'All';
    opt.value = 0;
    if (jur_id == opt.value) {
        opt.selected = true;
    }
    try {
        j_id_obj.add(opt,null);
    }
    catch(ex) {
        j_id_obj.add(opt); // IE only
    }
}


