<script language="javascript"> 
<?php
  include( create_fieldSet_control( $modo_RAD ) );
?>
/**
 *  fieldSet_mouseClick()
 */  
  function fieldSet_mouseClick( objID )
  {  
    if( objID.indexOf('fieldSet') != -1 &&
        objID.indexOf('Input')    != -1 )
    {  

      nrFieldSet = getFieldSet( objID );
      nrField    = getField( objID );
//alert(nrField);
      if ( nrField != fieldSet_selected[nrFieldSet -1] &&
           fieldSet_selected[nrFieldSet -1] > 0
         )
      {
        setFieldSet_select( nrFieldSet, fieldSet_selected[nrFieldSet -1], false );

      }// End if()
      
      if( fieldSet_enable[nrFieldSet -1][nrField -1] >= 1 )
      {
        setFieldSet_select( nrFieldSet, nrField, true );
        
      }// End if()
      //alert('Click: ' + objID);
    }// End if()
  }// End function()
  
/**  
 *  fieldSet_mouseDown()
 */  
  function fieldSet_mouseDown( objID )
  {  
    if( objID.indexOf('fieldSet') != -1 )
    {  
    
    }  
  }// End function()
  
/**  
 *  fieldSet_mouseUp()
 */  
  function fieldSet_mouseUp( objID )
  {  
    if( objID.indexOf('fieldSet') != -1 )
    {  
    
    }  
  }// End function()
  
/**  
 *  fieldSet_mouseOver()
 */  
  function fieldSet_mouseOver( objID )
  {  
    if( objID.indexOf('fieldSet') != -1 )
    {  
    
    }  
  }// End function()
  
/**  
 *  fieldSet_mouseOut()
 */  
  function fieldSet_mouseOut( objID )
  {  
    if( objID.indexOf('fieldSet') != -1 )
    {  
    
    }  
  }// End function()
  
/**  
 *  fieldSet_mouseMove()
 */  
  function fieldSet_mouseMove( objID )
  {  
    if( objID.indexOf('fieldSet') != -1 )
    {  
    
    }  
  }// End function()


function getFieldSet( objID )
{
  ix = objID.indexOf('_');

  if ( ix == -1 )
  {
    ix = objID.length;
  }// End if()

  if ( objID.substr( ix-2, 1 ) == 't')
  {
    nx = 1;
  }else
  {
    nx = 2;
  }// End if()

  return objID.substr(ix -nx, nx);
}// End function()

function getField( objID )
{
  ix = objID.indexOf('_');
  ix = objID.indexOf('_', ix +1 );
  
  if ( ix == -1 )
  {
    ix = objID.length;
  }
  if ( objID.substr( ix-2, 1 ) == 'd')
  {
    nx = 1;
  }else
  {
    nx = 2;
  }// End if()
  nrItem = objID.substr( ix - nx, nx );

  return nrItem;
}// End function()





//  Conjunto de funções para manipular as propriedades do Objeto  //
//  ------------------------------------------------------------  //


function setFieldSet_value( nrFieldSet, nrField, newVal )
{
  var nObj = 'fieldSet' + nrFieldSet + '_field' + nrField + '_Input';
// alert( nObj );
  objDOM = findDOM( nObj, 0 );
  objDOM.value = newVal;
}// End function()

function getFieldSet_value( nrFieldSet, nrField )
{
  var nObj = 'fieldSet' + nrFieldSet + '_field' + nrField + '_Input';
// alert( nObj );
  objDOM = findDOM( nObj, 0 );
  
  return objDOM.value;
}// End function()

function setFieldSet_label( nrFieldSet, nrField, newVal )
{
  var nObj = 'fieldSet' + nrFieldSet + '_field' + nrField + '_Label';
  var cmd = nObj + '.innerHTML = "' + newVal + '";';
  eval( cmd );
}// End function


function getFieldSet_label( nrFieldSet, nrField )
{
  var nObj_ = 'fieldSet' + nrFieldSet + '_field' + nrField + '_Label';
  var cmd = 'cod = ' + nObj_ + '.innerHTML;';
  eval( cmd );

//alert( cod );

  return cod;
}// End function

function setFieldSet_select( nrFieldSet, nrField, newVal )
{
  if ( newVal == 'true' ||
       newVal == true
      )
  {
    nV = 'bold';
    bG = '#FFFFFF';
  }else
  {
    nV = 'normal';
    bG = fieldSet_bgcolor[ nrFieldSet ];
  }
//alert( 'cor: '+bG );
//alert('select: ' + newVal + '  novo: ' + nV);
  nObj = 'fieldSet' + nrFieldSet + '_field' + nrField + '_Label';
  fieldDOM = findDOM( nObj, 1 );
  fieldDOM.fontWeight = nV;
  nObj = 'fieldSet' + nrFieldSet + '_field' + nrField + '_Input';
  fieldDOM = findDOM( nObj, 1 );
  fieldDOM.backgroundColor = bG;

  fieldSet_selected[nrFieldSet -1] = nrField;
}

function setFieldSet_enable( nrFieldSet, nrField, newVal )
{
  if ( newVal == 'true' ||
       newVal == true
     )
  {
    nV = true;
  }else
  {
    nV = false;
  }// End if ()
  fieldSet_enable[ nrFieldSet ][ nrField ] = nV;
}

function setFieldSet_enableAll( fieldSetID, newVal )
{
  nrFieldSet = getFieldSet( fieldSetID );
  nrItens = fieldSet_nrFields[ nrFieldSet -1 ];

  if ( newVal == 'true' ||
       newVal == true
     )
  {
    nV = true;
  }else
  {
    nV = false;
  }// End if ()
  for( ix = 1; ix <= nrItens; ix ++ )
  {
    fieldSet_enable[ nrFieldSet ][ nrField ] = newVal;
  }// End for()
}

function setFieldSet_visible( fieldSetID, Valor )
{
  if ( Valor == 'visible')
  {
    nVal = 'inherit';
  }else
  {
    nVal = 'hidden';
  }
  
  nLabel = fieldSetID + '_Label';
  fieldDOM = findDOM( nLabel, 1 );
  fieldDOM.visibility = nVal;
  
  nInput = fieldSetID + '_Input';
  fieldDOM = findDOM( nInput, 1 );
  fieldDOM.visibility = nVal;
//alert( nLabel );
}

function setFieldSet_visibleAll( fieldSetID, Valor )
{
  nrFieldSet = getFieldSet( fieldSetID );
  nrItens = fieldSet_nrFields[ nrFieldSet -1 ];

  if ( Valor == 'visible')
  {
    nVal = 'inherit';
  }else
  {
    //nVal = 'hidden';
    nVal = 'visible';
  }// End if()

  for( ix = 1; ix <= nrItens; ix ++ )
  {
    nObj   = 'fieldSet' + nrFieldSet + '_field' + ix;
    setFieldSet_visible( nObj, Valor );
  }//End for()
}

function setFieldSet_reset( fieldSetID )
{
  nrFieldSet = getFieldSet( fieldSetID );
  nrItens = fieldSet_nrFields[ nrFieldSet -1 ];

  for( ix = 1; ix <= nrItens; ix ++ )
  {
    nObj   = 'fieldSet' + nrFieldSet + '_field' + ix;
    setFieldSet_visible( nObj, 'hidden' );
    setFieldSet_enable( nrFieldSet, ix, 'false' )
  }//End for()
}// End function()


</script>
