function radioStates() {
    var val = !radio1.getEnabled();
    radio1.setEnabled(val);
    radio2.setEnabled(val);
    radio3.setEnabled(val);
    var btn = document.theForm.disableBtn;
    btn.value = ((val) ? "Disable" : "Enable");
}
pRadioImages = {r1:new Image(), r2:new Image(), r3:new Image(), r4:new Image()};
with(pRadioImages) {
    r1.src = "images/radio_off.gif";
    r2.src = "images/radio_on.gif";
    r3.src = "images/radio_off_d.gif";
    r4.src = "images/radio_on_d.gif";
    r1.height = r2.height = r3.height = r4.height = 16;
    r1.width = r2.width = r3.width = r4.width = 16;
}
pRadioButton = function(name, value, label, state, form, ref) {
    if(arguments.length < 2) return;
    var arr = name+"_arr";
    this.writeField = false;
    if(document[arr] == undefined) {
        document[arr] = new Array();
        this.writeField = true;
    }
    this.radioGroup = document[arr];
    this.radioGroup.push(this);
    this.enabled = true;
    this.field = this.fieldName = this.fieldState = this.label = "";
    this.field = document.forms[form];
    this.fieldName = name;
    this.fieldValue = value;
    this.fieldState = state;
    this.imageName = "radioImg_"+this.fieldName+"_"+this.radioGroup.length;
    this.imgs = [pRadioImages.r1, pRadioImages.r2, pRadioImages.r3, pRadioImages.r4];
    this.label = label;
    this.reference = ref;
    this.init();
};
pRadioButton.prototype.init = function() {
    var c="", events = 'href="javascript:void(0)" onClick="return '+this.reference+'.setState(true,true)" onDragStart="return false"';
    if(this.writeField) c += '<input type="hidden" name="'+this.fieldName+'">';
    c += '<table><tr>';
    c += '<td><a '+events+' style="cursor:hand" class="image"><img name="'+this.imageName+'" src="'+this.imgs[0].src+'" width='+this.imgs[0].width+' height='+this.imgs[0].height+' border="0" alt=""></a></td>';
    if(this.fieldValue != "") c += '<td><a '+events+' class="radiotext">'+this.label+'</a></td>';
    c += '</tr></table>';
    document.write(c);
    if(this.getState() != "") this.setState(this.getState(), true);
    if(!this.getEnabled()) this.setEnabled(this.getEnabled());
};
pRadioButton.prototype.getEnabled = function() {
    return this.enabled;
};
pRadioButton.prototype.getState = function() {
    return this.fieldState;
};
pRadioButton.prototype.setEnabled = function(val) {
    this.enabled = val;
    document.images[this.imageName].src = this.imgs[(this.getState()) ? ((!val)?3:1) : ((!val)?2:0)].src;
};
pRadioButton.prototype.setState = function(val, doAll) {
    if(!this.enabled) return false;
    var rLen = this.radioGroup.length;
    if(rLen > 0 && doAll) {
        for(var i=0; i<rLen; i++) {
            var curr = this.radioGroup[i];
            if(curr != this) curr.setState(false, false);
        }
        this.field[this.fieldName].value = (val) ? this.fieldValue : "";
    }
    document.images[this.imageName].src = (val) ? this.imgs[1].src : this.imgs[0].src;
    this.fieldState = val;
    return false;
};