// return the object with the specified id
function getElementById2(id) 
{
  if (document.getElementById)  // W3C (IE5+,NS6+)
    return document.getElementById(id);
  if (document.all) // IE4
    return document.all[id];
  if (document.layers) // NS4
    return document.layers[id];
  return null;
}

function ShowText(id)
{
	var DivObj = getElementById2('TextD'+ id);
	var LblObj = getElementById2('TextL'+ id);
	
	if (DivObj && LblObj)
		if (DivObj.style.display == '')
    {
      DivObj.style.display = 'none';
      LblObj.innerHTML = '+';
    }
    else
    {
      DivObj.style.display = '';
      LblObj.innerHTML = '-';
    }
}

function SearchRFieldInit(aSlot,aRadioName)
{
	// radio field initialise
	var FieldObj = getElementById2('FldCtrl'+ aSlot);
  var RadioCtrl = document.mainform[aRadioName];
	if (FieldObj && RadioCtrl)
    if (RadioCtrl.length)
    {
      for (var i = 0; i < RadioCtrl.length; i++)
        if (RadioCtrl[i].value == FieldObj.value)
        {
        	RadioCtrl[i].checked = true;
        	break;
        }
    }
    else
      RadioCtrl.checked = true;
}

function SearchRFieldChange(aSlot, aRadio)
{
	// radio field change
	var FieldObj = getElementById2('FldCtrl'+ aSlot);
	if (FieldObj) FieldObj.value = aRadio.value;
}

function GetFormField(aGroup, aIndex)
{
  if (aGroup && aGroup.length > 0) 
  {
    // get base group key name, add 'O' suffix if it ends with a digit
    var Name = 'FLX' + aGroup.toUpperCase().replace(/[^0-9A-Z]/g, '');
    if (Name.substring(Name.length-1).search(/\d/) != -1) Name += 'O';
      
    return (Name + aIndex);
  }

  return ('FL' + aIndex);
}

