//April 4, 2006

//*******************************************************************************'
//is the radiobutton checked?
//return true or false

function radioButtonIsChecked(elementObj) //as Boolean
{
	//default the return value
  var blnReturnValue = false; //as Boolean
  
	//make sure the element is of the right object type
	//if(elementObj.type == "radio")
	//ASP.NET does not reconize the "type"attribute of its radiobutton list
	if(true)
	{

		//if the element has a length property...
		//i.e. more than 1 child
		if(elementObj.length)
		{
		  //for each child of the element...
			for(var i = 0; i < elementObj.length; i++)
		  {
				//if this child of this element is check, return true
		    if(elementObj[i].checked == true)
				{
					blnReturnValue = true;
					
					//break out of the for loop
					break;
				}
		  }
			
		}
		else
		//this element has only 1 radio button
		{
			blnReturnValue = elementObj.checked;
		}
		
	}
	else
	//wrong element type
	{
		blnReturnValue = false;
	}
	
	//return the return value
  return blnReturnValue;
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
//syntax version

function radiobuttonischecked(elementObj) //as Boolean
{
	return radioButtonIsChecked(elementObj)
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
//syntax version

function RadioButtonIsChecked(elementObj) //as Boolean
{
	return radioButtonIsChecked(elementObj)
}

//*******************************************************************************'
//return the index if the first check radiobutton

function selectedRadioIndex(elementObj) //as Integer
{
	//default the return value
	var intIndex = -1;
	
	//make sure the element is of the right object type
	if(elementObj.type == "radio")
	{

		//for each child of the element...
		for(var i = 0; i < elementObj.length; i++)
	  {
			//if this child of the element is checked, save the index
	    if(elementObj[i].checked == true)
			{ 
				intIndex = i;
				
				//break out of the for loop
				break;
			}
	  }
		
	}
	else
	//wrong element type
	{
		intIndex = -1;
	}
	
	//return the return value
  return intIndex;
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
//syntax version

function selectedradioindex(elementObj) //as Integer
{
	return selectedRadioIndex(elementObj)
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
//syntax version

function SelectedRadioIndex(elementObj) //as Integer
{
	return selectedRadioIndex(elementObj)
}

//*******************************************************************************'
//de-select all children of the element
//select optSelected if specified
//requires ../format/trim.js

function clearRDOSelected(elementObj, optSelected)
{
	//make sure the element is of the right object type
	if(elementObj.type == "radio")
	{

		//clear all checked options
		for(var i = 0; i < elementObj.length; i++)
		{
			//if this child of the element is checked, uncheck it
			elementObj[i].checked = false;
		}
	
		//select the radio button specified
		if(optSelected.length > 0)
		{
			//for each child of the element...
			for(var i = 0; i < elementObj.length; i++)
			{
				//if this child's value matches the passed value to select...
				if(Trim(elementObj[i].value) == Trim(optSelected))
				{
					//check the object
					elementObj[i].checked = true;
					
					//break out of the for loop
					break;
				}
			}
		}
		
	}
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
//syntax version

function clearrdoselected(elementObj, optSelected)
{
	clearRDOSelected(elementObj, optSelected)
}	

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
//syntax version

function ClearRDOSelected(elementObj, optSelected)
{
	clearRDOSelected(elementObj, optSelected)
}	


