
var radioSet = [];
function initRadios() {
	var divSet=document.getElementsByTagName("DIV");
	for (var i=0;i<divSet.length;i++) {
		if (divSet[i].className=="radio") {

			var mydiv = divSet[i];

			mydiv.name = mydiv.getAttribute("name");
			mydiv.checked = mydiv.getAttribute("checked");
			mydiv.value = mydiv.getAttribute("value");
			mydiv.disabled = mydiv.getAttribute("disabled");

			mydiv.radioSet = radioSet[mydiv.name] || (radioSet[mydiv.name]=[]);
			mydiv.radioSet[mydiv.radioSet.length] = mydiv;

			var mysrc = "off";
			if (mydiv.checked) mysrc="on";
			if (mydiv.disabled) mysrc="disabled";

			mydiv.innerHTML = '<img src="/nova/global/images/g_radio_' + mysrc + '.gif" border="0" />';

			mydiv.onclick = function() {
				this.select();
			}
			mydiv.disable = function() {
				if (this.disabled) return;
				this.childNodes[0].src="nova/global/images/g_radio_disabled.gif";
				this.disabled=true;
			}
			mydiv.enable = function() {
				if (!this.disabled) return;
				if (this.checked) {
					this.childNodes[0].src="nova/global/images/g_radio_on.gif";
				} else {
					this.childNodes[0].src="nova/global/images/g_radio_off.gif";
				}
				this.disabled=false;
				this.radioSet.current=null;
			}
			mydiv.select = function() {
				if (this.disabled) return;
				for (var i=0;i<this.radioSet.length;i++) {
					if (this.radioSet[i].disabled) continue;
					this.radioSet[i].childNodes[0].src="nova/global/images/g_radio_off.gif";
					this.radioSet[i].checked=false;
				}
				this.checked=true;
				this.radioSet.value=this.value;
				this.radioSet.current=this;
				this.childNodes[0].src="nova/global/images/g_radio_on.gif";
				try {
					if (onRadioChanged) onRadioChanged();
				} catch (e) {
					//radio changed event not present
				}
			}
			mydiv.unselect = function() {
				this.checked=false;
				this.radioSet.value=null;
				this.radioSet.current=null;
				this.childNodes[0].src="nova/global/images/g_radio_off.gif";
			}

		}
	}
}

