<script language="javascript"> 
<?php
  include( create_treeView_config( $modo_RAD ) );
//  include( CFG . 'treeView.config.php' )
?>
/**
 *  treeView_mouseClick()  
 */  
  function treeView_mouseClick( objID )  
  {  
    if( objID.indexOf('treeView') != -1 )  
    {  
      //alert('click: ' + objID );
    }  
  }// End function()
  
/**  
 *  treeView_mouseDown()  
 */  
  function treeView_mouseDown( objID )  
  {  
    if( objID.indexOf('treeView') != -1 )  
    {  
    
    }  
  }// End function()
  
/**  
 *  treeView_mouseUp()  
 */  
  function treeView_mouseUp( objID )  
  {  
    if( objID.indexOf('treeView') != -1 )  
    {  
    
    }  
  }// End function()
  
/**  
 *  treeView_mouseOver()  
 */  
  function treeView_mouseOver( objID )  
  {  
    if( objID.indexOf('treeView') != -1 &&
        objID.indexOf('item') != -1  &&
        objID.indexOf('label') != -1
      )
    {  
      labelDOM = findDOM( objID, 1 );
      labelDOM.color="#000080";
      labelDOM.fontWeight = 'bold';
    }
  }// End function()
  
/**  
 *  treeView_mouseOut()  
 */  
  function treeView_mouseOut( objID )  
  {  
    if( objID.indexOf('treeView') != -1 &&
        objID.indexOf('item') != -1  &&
        objID.indexOf('label') != -1
      )
    {
      labelDOM = findDOM( objID, 1 );
      labelDOM.color = '#000000';
      labelDOM.fontWeight = 'normal';
    }
  }// End function()
  
/**  
 *  treeView_mouseMove()  
 */  
  function treeView_mouseMove( objID )  
  {  
    if( objID.indexOf('treeView') != -1 )  
    {  
    
    }  
  }// End function()
  
  
function retPos_X( objID )
{
  var xAtual = '';
  
  objDOM   = findDOM( objID, 0 );
  objSTYLE = findDOM( objID, 1 );

  if (objSTYLE.left)
    xAtual = objSTYLE.left;
  else
    if (objSTYLE.pixelLeft)
      xAtual = objSTYLE.pixelLeft;
    else
      if (objDOM.offsetLeft)
        xAtual = objDOM.offsetLeft;
      else
        xAtual = '0';

  if ( typeof( xAtual ) == 'string' )
  {
    var iix = xAtual.indexOf( 'px' );
    if ( iix != -1 )
      xAtual = xAtual.substr( 0, iix );
  }
  return( xAtual );
}

function getTreeView( objID )
{
  var len_= objID.length;
//alert( 'len: ' + len_ );
  if ( typeof( objID.substr( len_ -2, 1 ) ) == 'number' )
  {
    var ret = objID.substr( len_ -2 );
  }else
  {
    var ret = objID.substr( len_ -1 );
  }// End if()
  
  return( ret );
}

function retPos_Y( objID )
{
  objDOM   = findDOM( objID, 0 );
  objSTYLE = findDOM( objID, 1 );

  if (objSTYLE.top)
    yAtual = objSTYLE.top;
  else
    if (objSTYLE.pixelTop)
      yAtual = objSTYLE.pixelTop;
    else
      if (objDOM.offsetTop)
        yAtual = objDOM.offsetTop;
      else
        yAtual = '0';
        
  if ( typeof( yAtual ) == 'string' )
  {
    var iix = yAtual.indexOf( 'px' );
    if ( iix != -1 )
      yAtual = yAtual.substr( 0, iix );
  }
  return( yAtual );
}

  
//  Conjunto de funções para manipular as propriedades do Objeto  //
//  ------------------------------------------------------------  //
  function getTreeView_label( treeViewID )
  {
    cmd = 'ret = ' + treeViewID + '.innerHTML';
    eval( cmd );
    return ret;
  }
  
  function setTreeView_reset( treeViewID )
  {
    var nrTreeView = getTreeView( treeViewID );
    var nDiv_  = treeViewID + '_linhas';
    
    treeView_nrItens[ nrTreeView -1 ] = 0;
    
    var cmd = nDiv_ + '.innerHTML = ""';
    eval( cmd );
    
  }// End if()
  
  /**
   *  addTreeView_Item()
   *  adicionar um item a arvore
   */
  function addTreeView_Item( treeViewID, label_ )
  {
    var nrTreeView = getTreeView( treeViewID );
    var old = treeViewID + '_linha' + treeView_nrItens[ nrTreeView -1 ];

    if ( treeView_nrItens[ nrTreeView -1 ] == 0 )
    {
      var _top_  = 10;
      var _left_ = 8;
    }else
    {
      var _top_  = parseInt( retPos_Y( old ) ) +18;
      var _left_ = parseInt( retPos_X( old ) );
    }

    treeView_nrItens[ nrTreeView -1 ] ++;
    
    var nrItem = treeView_nrItens[ nrTreeView -1 ];
    var nDiv_  = treeViewID + '_linhas';
    
//alert( 'item: ' + treeView_nrItens[0] + '  top: ' +_top_+ '  left: ' + _left_);

    //  monta a linha
    var _linha_ = treeViewID + '_linha' + nrItem;
    //alert( _linha_ );
    var _html_ = '<img id="' + _linha_ + '" class="treeView_dinamico" src="imagens/cotovelo1.gif">';
    var cmd = nDiv_ + ".insertAdjacentHTML('BeforeEnd','" + _html_ + "');";
    eval(cmd);
    objDOM = findDOM( _linha_, 1 );
    objDOM.top = _top_ + 'px';
    objDOM.left = _left_ + 'px';
    
    // monta o Icone
    var _item_ = treeViewID + '_item' + nrItem;
    var _html_ = '<img id="' + _item_ + '" class="treeView_dinamico" src="imagens/projeto.gif">';
    var cmd = nDiv_ + ".insertAdjacentHTML('BeforeEnd','" + _html_ + "');";
    eval(cmd);
    objDOM = findDOM( _item_, 1 );
    objDOM.top  = (_top_ + 5) + 'px';
    objDOM.left = (_left_ + 20 ) + 'px';
    
    // monta a Label
    var _label_ = treeViewID + '_item' + nrItem + '_label' + nrItem;
    var _html_ = '<label id="' + _label_ + '" class="treeView_label" src="imagens/projeto.gif">'+label_+'</label>';
    var cmd = nDiv_ + ".insertAdjacentHTML('BeforeEnd','" + _html_ + "');";
    eval(cmd);
    objDOM = findDOM( _label_, 1 );
    objDOM.top  = (_top_ + 10) + 'px';
    objDOM.left = (_left_ + 50 ) + 'px';
    
    
  }// End function()
  
  
  
  
  
  
</script> 
