<script language="javascript"> 
<?php
  include( create_button_control( $modo_RAD ) );
?>

/**
 *  button_mouseClick()
 */
  function button_mouseClick( objID )
  {
    if( objID.indexOf('button') != -1 )
    {
      //alert('Objeto button Clicado ');
    }

  }// End function()

/**
 *  button_mouseDblClick()
 */
  function button_mouseDblClick( objID )
  {
    if( objID.indexOf('button') != -1 )
    {
      //alert('Objeto button DblClick ');
    }// End if( objID.indexOf('button') != -1 )
  }// End function button_mouseDblClick( objID )

/**
 *  button_mouseDown()  
 */  
  function button_mouseDown( objID )  
  {  
    if( objID.indexOf('button') != -1 )  
    {  
    
    }  
  }// End function()
  
/**  
 *  button_mouseUp()  
 */  
  function button_mouseUp( objID )  
  {  
    if( objID.indexOf('button') != -1 )  
    {  
    
    }  
  }// End function()
  
/**  
 *  button_mouseOver()  
 */  
  function button_mouseOver( objID )  
  {  
    if( objID.indexOf('button') != -1 &&
        button_enabled[ getButton_index( objID ) ]
      )
    {
      objDom = findDOM( objID, 1 );
//      alert( objDom );
      switch( button_over[ getButton_index( objID ) ] )
      {
        case 'color':
          objDom.color = button_color_new;
          break;
        case 'bold':
          objDom.fontWeight = 'bold';
          break;
        case 'box':
          if( button_tipo[ idx ] == 'normal' )
          {
            objDom.border = '2px solid';
          }else
          {
            objDom.border = '1px solid';
          }// End if( button_tipo[ idx ] == 'normal' )
          break;
        default:
          break;
      }// Endswitch( button_over[ getButton_index( objID ) ] )
    }// End if( objID.indexOf('button') != -1 )
  }// End function()
  
/**  
 *  button_mouseOut()  
 */
  function button_mouseOut( objID )  
  {  
    if( objID.indexOf('button') != -1 )  
    {
      objDom = findDOM( objID, 1 );
      idx = getButton_index( objID );
      switch( button_over[ idx ] )
      {
        case 'color':
          objDom.color = button_color[ idx ];
          break;
        case 'bold':
          if( !button_bold[ idx ] )
            objDom.fontWeight = 'normal';
          break;
        case 'box':
          if(button_tipo[ idx ] == 'normal')
          {
            objDom.border = '2px outset';
          }else
          {
            objDom.border = '1px outset';
          }// End if(button_tipo[ idx ] == 'normal')
          break;
        default:
          break;
      }// End switch( button_over[ idx ] )
    }// End if( objID.indexOf('button') != -1 )
  }// End function()

  
//  ------------------------------------------------------------  //
//  Lista de Métodos do Componente                                //
//  Conjunto de funções para manipular as propriedades do Objeto  //
//  ------------------------------------------------------------  //


  /**
   * Metodo getButton_color
   * retorna o valor atual da cor do caption do button
   */
  function getButton_color( nObj )
  {
    objDOM = findDOM( nObj, 0 );
    idx = getButton_index( nObj );
    if( button_color[ idx ] == 'ButtonText')
    {
      nColor = button_color_auto;
    }else
    {
      nColor = button_color[ idx ];
      if( nColor.substr(0, 1) == '#' )
      {
        nColor = nColor.slice(1);
      }// End if( nColor.substr(0, 1) == '#' )
    }// End if( button_color[ idx ] == 'ButtonText')
    alert( nColor );
    return nColor;
  }// End function getButton_color( nObj )


  /**
   * Metodo setButton_color
   * configura o valor atual da cor do caption do button
   */
  function setButton_color( nObj, nColor )
  {
    if( nObj.indexOf('_') == -1 )
    {
      objID = nObj + '_Caption';
    }else
    {
      objID = nObj;
    }// End if( nObj.indexOf('_') == -1 )
    objDOM = findDOM( objID, 1 );

    idx = getButton_index( nObj );

    if( button_color[ idx ] == nColor )
    {
      objDOM.color = 'ButtonText';
    }else
    {
      objDOM.color = '#' + nColor;
    }// End if( button_color[ idx ] == nColor )

  }// End function setButton_color( nObj, nColor )


  /**
   *  Metodo getButton_caption
   *  retorna o valor atual do Caption
   */
  function getButton_caption( nObj )
  {
    if( nObj.indexOf('_') == -1 )
    {
      objID = nObj + '_Caption';
    }else
    {
      objID = nObj;
    }// End if( nObj.indexOf('_') == -1 )
    objDOM = findDOM( objID, 0 );

    // retirar a hotkey
    nCaption = objDOM.value;
//    alert( nCaption );

    hotkey_ = objDOM.getAttribute('accesskey');
    
    if( hotkey_ !== '' && hotkey_ !== null )
    {
      ix = nCaption.toLowerCase().indexOf( hotkey_ );
      if( ix != -1)
      {
        if(nCaption.substr(0, 1) == '<')
        {
          nCaption = nCaption.substr(24, 1) + nCaption.slice(32);
        }else
        {
          ini = nCaption.indexOf('<');
          nCaption = nCaption.substr(0, ini) + nCaption.substr(ini + 24, 1) + nCaption.slice(ini + 32);

        }// End if(nCaption.substr(0, 1) == '<')
      }else
      {
        //alert( nCaption );
      }// End if( ix != -1)
    }// End if( hotkey_ !== '' && hotkey_ !== null )

    return nCaption;

  }// End function getButton_caption( nObj )

  
  /**
   *  Metodo setButton_caption
   *  configura um valor para o Caption
   */
  function setButton_caption( nObj, nCaption )
  {
    if( nObj.indexOf('_') == -1 )
    {
      objID = nObj + '_Caption';
    }else
    {
      objID = nObj;
    }// End if( nObj.indexOf('_') == -1 )
    
    objDOM = findDOM( objID, 0 );

    /**
     *  atualiza a Hotkey
     */
    hot_key_ = objDOM.getAttribute('accesskey');

    if( hot_key_ !== '' && hot_key_ !== null )
    {
      /* verifica se hotkey existe no novo caption */
      ix = nCaption.toLowerCase().indexOf( hot_key_ );
      if( ix != -1 )
      {
        nomeObj = nObj.slice(0, nObj.indexOf('_') );
        if( ix == 0 )
        {
          nCaption = '<span class="'+nomeObj+'_key">'+ nCaption.slice(0, 1)+ '</span>' + nCaption.slice(1);
        }else
        {
          nCaption = nCaption.slice(0, ix) + '<span class="'+nomeObj+'_key">'+ nCaption.substr( ix, 1 )+ '</span>' + nCaption.slice(ix + 1);
        }// End if( ix == 0 )
      }// End if( ix != -1 )
    }// End if( hotkey !== '' && hotkey !== null )

//    alert( objDOM.value );
    objDOM.value = nCaption;

  }// End function setButton_caption( nObj, nCaption )


  
  /**
   * Metodo getButton_enabled
   * retorna o valor de habilitação do button
   */
  function getButton_enabled( nObj )
  {
    if( nObj.indexOf('_') == -1 )
    {
      objID = nObj + '_Caption';
    }else
    {
      objID = nObj;
    }// End if( nObj.indexOf('_') == -1 )
    objDOM = findDOM( objID, 0 );
    
    return objDOM.disabled;
  }// End function getButton_enabled( nObj )


  /**
   * Metodo setButton_enabled
   * configura o valor de habilitação do button
   */
  function setButton_enabled( nObj, status )
  {
    if( nObj.indexOf('_') == -1 )
    {
      objID = nObj + '_Caption';
    }else
    {
      objID = nObj;
    }// End if( nObj.indexOf('_') == -1 )
    objDOM = findDOM( objID, 0 );
    if( status )
    {
      objDOM.disabled = !status;

    }else
    {
      objDOM.disabled = !status;
//      alert( objDOM.disabled );
    }// End if( status )

    button_enabled[ getButton_index( nObj ) ] = status;
  }// End function setButton_enabled( nObj, nDisabled )
  
  /**
   * Metodo getButton_visible
   * retorna o valor de visibilidade do button
   */
  function getButton_visible( nObj )
  {
    ret = eval( nObj+'.style.visibility' );
    
    if( ret == 'inherit' )
    {
      ret = 'visible';
    }
    return ret;
  }// End function getButton_visible( nObj )


  /**
   * Metodo setButton_visible
   * configura o valor de visibilidade do button
   */
  function setButton_visible( nObj, status )
  {
    objID = nObj;
    objDOM = findDOM( objID, 1 );

    if( status || status == 'true' )
    {
      objDOM.visibility = "inherit";
    }else
    {
      objDOM.visibility = "hidden";
    }// End if( status == 'true' )


  }// End function setButton_visible( nObj, status )



  /**
   * Metodo getButton_click
   * retorna o valor
   */
  function getButton_index( objID )
  {
    ix = objID.indexOf('_');
    if( ix != -1 )
    {
      idx = objID.slice( 6, ix );
    }else
    {
      idx = objID.slice( 6 );
    }// End
    return (parseInt(idx) - 1);
  }// End function getButton_index( objID )


/**
 *  retorna o ID do Button
 */
  function getButton_name( objID )
  {
    ix = objID.indexOf('_');
    if( ix != -1 )
    {
      name = objID.slice( 0, ix );
    }else
    {
      name = objID.slice( 0, 6 );
    }// End
    return( name );
  }
  
</script> 
