////////////// RADIO GROUP //////////////////////////////////////////////////
//--------------------------------------------------------------------------------
function CRadioGroup(sFormName, sRadioGroupName){
	this.m_sImageChecked = "";
	this.m_sImageNotChecked = "";
	this.m_sImageMouseOver = "";
	this.m_sRadioGroupName = sRadioGroupName;
	arElements = document.getElementsByName(sFormName);
	for(i = 0; i < arElements.length; i++){
		if(arElements[i].tagName.toUpperCase() == "FORM")
			this.m_oForm = arElements[i];
	}
	this.m_oInputField = document.createElement("input");
	this.m_oInputField.type = "hidden";
	this.m_oInputField.name = sRadioGroupName;
	this.m_oInputField.value = "";
	this.m_oForm.appendChild(this.m_oInputField);
	this.m_arRadioButtons = new Array();
	
	//--------------------------------------------------------------------------------
	this.CreateRadioButton = function(sContainerId, sValue, nChecked){
		var oContainer = document.getElementById(sContainerId);
		var oRadioButton = document.createElement('IMG');
		oRadioButton = oContainer.appendChild(oRadioButton);
		oRadioButton.oGroupRef = this;
		oRadioButton.onclick = new Function("this.oGroupRef.Check(this);");
		oRadioButton.sRadioButtonValue = sValue;
		oRadioButton.nChecked = nChecked;
		if(oRadioButton.nChecked == 1)
			oRadioButton.src = this.m_sImageChecked;
		else
			oRadioButton.src = this.m_sImageNotChecked;
		if(this.m_sImageMouseOver.length){
			oRadioButton.sDefaultImage = oRadioButton.src;
			oRadioButton.onmouseover =  new Function("if(this.nChecked != 1) this.src='"+this.m_sImageMouseOver+"'");
			oRadioButton.onmouseout =  new Function("this.src=this.sDefaultImage");
		}
		this.m_arRadioButtons[this.m_arRadioButtons.length] = oRadioButton;
	};
	
	//--------------------------------------------------------------------------------
	this.Check = function(oRadioButton){
		this.UncheckAll();
		if(this.m_sImageChecked.length){
			oRadioButton.src = this.m_sImageChecked;
			oRadioButton.sDefaultImage = oRadioButton.src;
		}
		this.m_oInputField.value = oRadioButton.sRadioButtonValue;
		oRadioButton.nChecked = "1";
	};
	
	//--------------------------------------------------------------------------------
	this.UncheckAll = function(){
		if(this.m_sImageNotChecked.length){
			for(i = 0; i < this.m_arRadioButtons.length; i ++){
				this.m_arRadioButtons[i].src = this.m_sImageNotChecked;
				this.m_arRadioButtons[i].nChecked = "0";
				this.m_arRadioButtons[i].sDefaultImage = this.m_arRadioButtons[i].src;
			}
		}
	};
	
	//--------------------------------------------------------------------------------
	this.GetSelectedValue = function(){
		for(i = 0; i < this.m_arRadioButtons.length; i ++){
			if(this.m_arRadioButtons[i].nChecked == 1)
				return this.m_arRadioButtons[i].sRadioButtonValue;
		}
		return null;
	};
}