<script language="javascript">

<?php
  include( create_mainMenu_config( $modo_RAD ) );
?>
/**
 *  mainMenu_mouseClick()
 */  
function mainMenu_mouseClick( objID )
{
  if( objID.indexOf('mainMenu') != -1 &&
      objID.indexOf('item')     != -1  )
  {
    nrMenu = getMainMenu(objID);
    nrItem = getItem(objID);
    //alert(nrMenu);
    if ( nrItem != mainMenu_selected[nrMenu -1] )
    {
      if ( mainMenu_selected[nrMenu -1] > 0 )
      {
        // Desativa Item selecionado
        selected_ = "mainMenu" + nrMenu + "_item" + mainMenu_selected[nrMenu-1];
        iteSTYLE = findDOM( selected_, 1 );
        iteSTYLE.fontWeight = "normal";
        
        if ( mainMenu_subMenu[nrMenu -1][mainMenu_selected[nrMenu-1] -1] > 0 )
        {
        // desliga subMenu
          sub = "subMenu" + mainMenu_subMenu[nrMenu -1][mainMenu_selected[nrMenu-1] -1];
          iteSTYLE = findDOM( sub, 1 );
          iteSTYLE.visibility = "hidden";
        }// End if()

      }// End if()

      //alert(mainMenu_status[nrMenu-1]);
      if( mainMenu_status[nrMenu-1][nrItem-1] >= 1 )
      {
        // Ativa Item atual como selecionado
        iteSTYLE = findDOM( objID, 1 );
        iteSTYLE.fontWeight = "bold";
        mainMenu_selected[nrMenu-1] = nrItem;
        //alert('ok');
      }
    }// End if()
  }else
  {
    /**
     *  Click fora do Objeto MainMenu
     */
    for( ix_menu = 0; ix_menu < mainMenu_obj; ix_menu ++ )
    {
      // alert('menu: '+mainMenu_selected[ix_menu]);
      if ( mainMenu_selected[ix_menu] > 0 )
      {
        // Desativa Item selecionado
        selected_ = "mainMenu" + (ix_menu +1) + "_item" + mainMenu_selected[ix_menu];
        iteSTYLE = findDOM( selected_, 1 );
        iteSTYLE.fontWeight = "normal";

//alert(mainMenu_selected[ix_menu]);
//alert(mainMenu_subMenu[ix_menu][mainMenu_selected[ix_menu] -1]);
        if ( mainMenu_subMenu[ix_menu][mainMenu_selected[ix_menu] -1] > 0 )
        {
        // desliga subMenu
          sub = "subMenu" + mainMenu_subMenu[ix_menu][mainMenu_selected[ix_menu] -1];
          iteSTYLE = findDOM( sub, 1 );
          iteSTYLE.visibility = "hidden";
        }// End if()
        mainMenu_selected[ix_menu] = 0;

      }// End if()
    }//End if()
  }// End if()  
}// End function mainMenu_mouse_Click( objID )


/**
 *  mainMenu_mouseOver()
 */  
  function mainMenu_mouseOver( objID )
  {
    if( objID.indexOf('mainMenu') != -1 &&
        objID.indexOf('item')     != -1
       )
    {
      nrMenu = getMainMenu(objID);
      nrItem = getItem(objID);
      
      if( mainMenu_status[nrMenu-1][nrItem-1] >= 1 )
      {
        domStyle = findDOM( objID, 0 );
        
        set_efeitoOver();
        domStyle.style.zIndex = 20;
      
        objStyle = findDOM( objID, 1 );
        objStyle.cursor = "default";
      }// End if()
    }// End if()
    

    /**
     *  SubMenu  ---------------------------------
     */
    if( objID.indexOf('subMenu')  != -1  &&
        objID.indexOf('item')     != -1
       )
    {
      nrSub  = getMainMenu(objID);
      nrItem = getItem(objID);
//alert(objID);
// alert('menu['+(nrSub-1)+'] item['+(nrItem-1)+']  '+objID );

      //if( subStatus[nrMenu-1][nrItem-1] >= 1 )
      
      if( mainMenu_subStatus[0][nrSub-1][nrItem-1] >= 1 )
      {
        domStyle = findDOM( objID, 0 );

        set_efeitoOver();
        domStyle.style.zIndex = 20;

        objStyle = findDOM( objID, 1 );
        objStyle.cursor = "default";
      }// End if()
    }// End if()

  }// End function mainMenu_mouse_Over( objID )

function set_efeitoOver()
{
        tipoOver = "<?php echo($mainMenu1_Conf['over']);?>";
        corBorda = "<?php echo($mainMenu1_Global['color']);?>";

        switch( tipoOver )
        {
          case 'color':
            domStyle.style.color="#FFFFFF";
            break;
          case 'backGround':
            domStyle.style.backgroundColor="#000000";
            break;
          case 'upperCase':
            domStyle.style.color="#000000";
            break;
          case 'border':
            domStyle.style.borderTop    = "1px solid " + corBorda;
            domStyle.style.borderBottom = "1px solid " + corBorda;
            domStyle.style.borderLeft   = "1px solid " + corBorda;
            domStyle.style.borderRight  = "1px solid " + corBorda;
            break;
        }// End
}

/**
 *  mainMenu_mouseOut()
 */
  function mainMenu_mouseOut( objID )
  {
    if( ( objID.indexOf('mainMenu') != -1 ||
          objID.indexOf('subMenu')  != -1 )
        && objID.indexOf('item')     != -1 
       )
    {
      var domStyle = findDOM( objID, 0 );
      var tipoOver = "<?php echo($mainMenu1_Conf['over']);?>";
      var corBorda = "<?php echo($mainMenu1_Global['bgcolor']);?>";
    
      switch( tipoOver )
      {
        case 'color':
          domStyle.style.color="#FFFFFF";
          break;
        case 'backGround':
          domStyle.style.backgroundColor="#000000";
          break;
        case 'upperCase':
          domStyle.style.color="#000000";
          break;
        case 'border':
          domStyle.style.borderTop    = "1px solid " + corBorda;
          domStyle.style.borderBottom = "1px solid " + corBorda;
          domStyle.style.borderLeft   = "1px solid " + corBorda;
          domStyle.style.borderRight  = "1px solid " + corBorda;
          break;
      }// End
      domStyle.style.zIndex = 10;
    }
  }// End function mainMenu_mouse_Over( objID )



//  function mainMenu1_mouse_Over( tpo, domStyle )
//  {
//  }// End
  

  
function set_subMenu( subMenu, tpo )
{
  if ( tpo == 1 )
  {
    sub_status  = "inherit";
    sub_new = subMenu;
  }else
  {
    sub_status  = "hidden";
    sub_new = 0; 
//alert('desliga'+subMenu);     
  }
  
  iteSTYLE = findDOM( 'subMenu' + subMenu, 1 );
  iteSTYLE.visibility = sub_status;
  mainMenu_subMenu[subMenu] = sub_new;
}

function getMainMenu( objID )
{
  ix = objID.indexOf('_');
  
  if ( ix == -1 )
  {
    ix = objID.length;
  }// End if()
  
  ret = objID.substr(ix-1,1);
  return ret;
}// End function()

function getItem( objID )
{
  ix    = objID.length;
  nrItem = objID.substr(ix-1);
  
  return nrItem;
}// End function()

// pega o indice mainMenu do subMenu
function getMainSubMenu( objID )
{
  ret = 0;
  return ret;
}

// pega a cor do Item do Menu
function getColor( nrMainMenu )
{
  nObjeto = 'mainMenu' + nrMainMenu;
  return 'ActiveCaption';
}// End function()

// seta a cor do Item do SubMenu
function setColorSubItem( objID, nrItem, newStatus )
{
  nObjeto = objID + '_Item' + nrItem;

  objDOM = findDOM( nObjeto, 1 );
  if ( newStatus == 0 )
  {
    objDOM.color= '#808080';
  }else
  {
    objDOM.color= 'ActiveCaption';
  }
}

    
    
//  Conjunto de funções para manipular as propriedades do Objeto  //
//  ------------------------------------------------------------  //
function setMainMenu_status( objID, nrItem, newStatus )
{
  nrMainMenu = getMainMenu( objID );

  mainMenu_status[ nrMainMenu -1 ][ nrItem -1 ] = newStatus;
}// End function()

function setSubMenu_status( objID, nrItem, newStatus )
{
  nrMainMenu = getMainSubMenu( objID );
  nrSubMenu  = getMainMenu( objID );

  mainMenu_subStatus[nrMainMenu][ nrSubMenu -1 ][ nrItem -1 ] = newStatus;
  setColorSubItem( objID, nrItem, newStatus );
}// End function()



</script>
