function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

/*function getElemById(id)
{
	if (document.all!=null)
	{return eval('document.all.' + id);}
	else{return document.getElementById(id);}
}
*/
function getElemById(baseObject, id)
{
	if (document.all!=null)
	{return eval(baseObject + '.all.' + id);}
	else{return eval(baseObject).getElementById(id);}
}

function elemNotNull(id)
{return (getElemById('document',id)!=null);}


function setElemInnerHTML(id,sValue)
{
	if(elemNotNull(id))
	{
	// Security : check for inner html validity
		if(getElemById('document',id).tagName=='INPUT')
		{
			raiseJavascriptError('element ' + id + ' is not a text string');
		}
		else
		{
			getElemById('document',id).innerHTML=sValue;
		}
	}
}

function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

function IsEmpty(aTextField) {
   if ((aTextField.value.length==0) ||
   (aTextField.value==null)) {
      return true;
   }
   else { return false; }
}	


function isValidEmail(aTextField) {

	if (IsEmpty(aTextField)) 
	{
		return false;
	}

	return (aTextField.value.indexOf(".") > 2) && (aTextField.value.indexOf("@") > 0);
}   


