function RadioButtons(oRadx,sId,oParams) {
	var oRad,
		iRad,
		aParams;


	if (oParams && oParams.SpriteMini)
	{
		for (iRad=1;oRad=document.getElementById(sId+"_"+iRad);iRad++)
			$(oRad).removeClass("radio-selected").removeClass("radio-unselected").addClass("radio-unselected");
		$(oRadx).removeClass("radio-unselected").removeClass("radio-selected").addClass("radio-selected");
	} else {
		for (iRad=1;oRad=document.getElementById(sId+"_"+iRad);iRad++)
			oRad.src=ROOT_URL+"images/controllers/radio/radio-unselected.gif";
		oRadx.src=ROOT_URL+"images/controllers/radio/radio-selected.gif";
	}

	if (oRadx.getAttribute("onEdit")) eval(oRadx.getAttribute("onEdit"));

}

function RadioButtonsReset(sId) {
	for (iRad=1;oRad=document.getElementById(sId+"_"+iRad);iRad++)
		oRad.src=ROOT_URL+"images/controllers/radio/radio-unselected.gif";
}

function RadioButtons_Poll(oRadx,sId) {
	var oRad,
		iRad,
		aParams;

	for (iRad=1;oRad=document.getElementById(sId+"_"+iRad);iRad++) {
		oRad.src = oRad.src.substring(0,oRad.src.lastIndexOf("/"))+"/poll-vote.gif";
	}

	
	oRadx.src=oRadx.src.substring(0,oRadx.src.lastIndexOf("/"))+"/pollvote-checked.gif";

	if (oRadx.getAttribute("onEdit")) eval(oRadx.getAttribute("onEdit"));
}

function CheckboxButtons(oCB,oParams) {


	if (isChecked(oCB)) oCB.src=ROOT_URL+"images/controllers/checkbox/checkbox-unselected.gif";
	else oCB.src=ROOT_URL+"images/controllers/checkbox/checkbox-selected.gif";
	

	if (oCB.getAttribute("onEdit")) eval(oCB.getAttribute("onEdit"));
}

function isChecked(oCB) {
	if (oCB.src.indexOf("-unselected.gif")==-1) return true;
	else return false;
}

function SetCbValue(sId) {

	
	
	var oCB=document.getElementById("CB_"+sId),
		oHidden=document.getElementById(sId);
	
	oHidden.value=isChecked(oCB) ? 1 : 0;
}

function SetRadValue(sId,sValue) {
	var oHidden=document.getElementById(sId);

	oHidden.value=sValue;
}



var oTab_Activated = "none";
function SelectTab(oTab) {

	if (oTab_Activated != "none")
	{
		oTab_Activated.className=oTab_Activated.getAttribute("DefaultCSS");
		document.getElementById("Tab_"+oTab_Activated.firstChild.innerHTML.replace(/\s/gi,"").replace(/\&nbsp;/gi,"")).style.display = 'none';
	}

	if (oTab.getAttribute("DefaultCSS").indexOf("itemEnd") > -1) oTab.className="itemactiveEnd";
	else if (oTab.getAttribute("DefaultCSS").indexOf("itemStart") > -1) oTab.className="itemactiveStart";
	else oTab.className="itemactive";
	oTab_Activated = oTab;
	
	document.getElementById("Tab_"+oTab_Activated.firstChild.innerHTML.replace(/\s/gi,"").replace(/\&nbsp;/gi,"")).style.display = 'block';
}


function ActiveTab(oTab) {
	// if (oTab_Activated == "none" || oTab != oTab_Activated)
	// {
		if (oTab_Activated != "none")
			oTab_Activated.className=oTab_Activated.getAttribute("DefaultCSS");

		oTab.setAttribute("DefaultCSS",oTab.className);
		if (oTab.getAttribute("DefaultCSS").indexOf("itemEnd") > -1) oTab.className="itemactiveEnd";
		else if (oTab.getAttribute("DefaultCSS").indexOf("itemStart") > -1)	oTab.className="itemactiveStart";
		else oTab.className="itemactive";
	// }
}

function InactiveTah(oTabs) {
	if (oTab_Activated == "none" || oTab_Activated != oTabs) {
		oTabs.className=oTabs.getAttribute("DefaultCSS");
		SelectTab(oTab_Activated);
	}
}


var SelectBoxGlobal = {

	// ----------------------------------------------------------------------------------------
	
	Packages:					{},										// Reference to all selectboxes objects

	// ----------------------------------------------------------------------------------------

	IdCounter:					0,										// Id reference
	IdPrefix:					"SelectBox-",
	GetId:						function() { return this.IdPrefix + this.IdCounter++; },

	// ----------------------------------------------------------------------------------------

	Route:						function (sId,sFunction,aArguments) {	// Route functions
		var oSelect=this.Packages[sId],
			oFunction=sFunction.BuildPath(oSelect),
			aArguments=aArguments || [];

		oFunction.apply(oSelect,aArguments);
	}	

};


// Build function path from string
String.prototype.BuildPath=function (oEl) {
	var aPath=this.split("."),
		iPath;

	for (iPath=0;iPath<aPath.length;iPath++) {
		oEl=oEl[aPath[iPath]];
	}

	return oEl;
}