<?php

function activeMenu($page){
	$activeMenu = array();
	//Recherche
	$activeMenu[] = array('recherche', 'international_recherche');
	//Identite
	$activeMenu[] = array('identite', 'identite_procol', 'etablissements',
		'liens', 'evenements');
	//Dirigeants
	$activeMenu[] = array('dirigeants');
	//Elements Financier
	$activeMenu[] = array('synthese', 'bilans', 'ratios', 'liasse',
		'bourse', 'banque');
	//Elements Juridiques
	$activeMenu[] = array('annonces', 'infosreg', 'competences',
		'conventions', 'marques');
	//Banque De France
	if ( hasPerm('bdf') ) $activeMenu[] = array('bdf');
	//Evaluation
	$activeMenu[] = array('indiscore', 'scorescf', 'enquetec', 'indiscore3',
		'indiscore2');
	//Pieces officielles
	$activeMenu[] = array('pieces', 'kbis2', 'kbis', 'greffes', 'privileges');
	//Options
    $activeMenu[] = array('moncompte', 'surveillance', 'portefeuille',
						'greffescmd', 'international_commandes',
                        'giant_commandes',
                        'administration', 'stats', 'survliste');
    
	$menuIndex = 0;
	foreach ($activeMenu as $key => $pages)
	{
		if( in_array($page, $pages)) { $menuIndex = $key; break; }
	}

	$output = '';
	if ($menuIndex!=0){
		$output = "'activate', ".$menuIndex;
	}
	return $output;
}


function defineMenu(){

	$menu = array();

	// Recherche
	$children = array();
	$children[] = array('data' => 'Rechercher une entreprise',
						'href' => 'menu_href_recherche_ent');
	$children[] = array('data' => 'Rechercher par dirigeant',
						'href' => 'menu_href_recherche_dir');
	$children[] = array('data' => 'Recherche Internationale',
						'href' => 'menu_href_international',
						'perm' =>
							array(
								'list' => array( 'INTERNATIONAL'),
							 	'hidden' => true
							)
						);
	$children[] = array('data' => 'Rechercher une annonce',
						'href' => 'menu_href_annonce');
	$children[] = array('data' => 'Derni&egrave;re recherche',
						'href' => 'menu_href_list_pre');
	$children[] = array('data' => 'Liste des derni&egrave;res recherches',
						'href' => 'menu_href_list_derniere_recherche');
	$children[] = array('data' => 'Centrale IparI &copy;',
						'href' => 'menu_href_ipari',
						'perm' =>
							array(
								'list' => array( 'IPARI' ),
								'hidden' => true
							)
						);
	$menu[] = array( 'data'=> 'RECHERCHES', 'children'=>$children );

	// Identité
	$children = array();
	$children[] = array('data' => 'Fiche d\'identit&eacute;',
						'href' => 'menu_href_identite');
	$children[] = array('data' => 'Fiche AGS',
						'href' => 'menu_href_identite_profil',
						'profil' => array('name'=>'identite','hidden'=>true));

	$children[] = array('data' => 'Fiche Procédure Collective',
						'href' => 'menu_href_procol',
						'perm' => array(
								'list' => array( 'IDPROCOL' ),
								'hidden' => true)
						);
	$children[] = array('data' => 'Liste des &eacute;tablissements',
						'href' => 'menu_href_etablissement' );
	$children[] = array('data' => 'Liens inter-entreprise',
						'href' => 'menu_href_lienentreprise');
	$children[] = array('data' => 'Modifications Insee',
						'href' => 'menu_href_insee',
						'perm' =>
							array(
								'list' => array( 'EVENINSEE' ),
								'hidden' => true
							)
						);
	$menu[] = array( 'data'=>'IDENTIT&Eacute;', 'children'=>$children);

	// Dirigeants
	$children = array();
	$children[] = array('data' => 'Liste des dirigeants',
						'href' => 'menu_href_dirigeants');
	$children[] = array('data' => 'Historique des dirigeants',
						'href' => 'menu_href_histodirigeants');
	$menu[] = array( 'data'=>'DIRIGEANTS', 'children'=>$children);

	// ELEMENTS FINANCIERS
	$children = array();
	$children[] = array('data' => 'Synth&egrave;se',
						'href' => 'menu_href_synthese');
	$children[] = array('data' => 'Bilans, Compte de r&eacute;sultat',
						'href' => 'menu_href_bilans');
	$children[] = array('data' => 'Ratios',
						'href' => 'menu_href_ratios');
	$children[] = array('data' => 'Liasse fiscale',
						'href' => 'menu_href_liasse');
	$children[] = array('data' => 'Bourse &amp; Cotations',
						'href' => 'menu_href_bourse');
	$children[] = array('data' => 'Relations bancaires',
						'href' => 'menu_href_banque');
	$menu[] = array( 'data'=>'ELEMENTS FINANCIERS', 'children'=>$children);

	// Elements juridiques
	$children = array();
	$children[] = array('data' => 'Annonces L&eacute;gales',
						'href' => 'menu_href_annonces');
	$children[] = array('data' => 'Information R&eacute;glement&eacute;e',
						'href' => 'menu_href_infosreg');
	$children[] = array('data' => 'Comp&eacute;tences Territoriales',
						'href' => 'menu_href_competences');
	$children[] = array('data' => 'Conventions collectives',
						'href' => 'menu_href_conventions');
	$children[] = array('data' => 'Marques d&eacute;pos&eacute;es',
						'href' => 'menu_href_marques',
						'perm' =>
							array(
								'list' => array( 'MARQUES' ),
								'hidden' => true
							)
						);
	$menu[] = array( 'data'=>'ELEMENTS JURIDIQUES', 'children'=>$children);

	// Banque de France
	$children = array();
	$children[] = array('data' => '27. Panorama',
						'href' => 'menu_href_bdf27');
	$children[] = array('data' => '28. Concours Bancaires',
						'href' => 'menu_href_bdf28');
	$children[] = array('data' => '29. Impayés',
						'href' => 'menu_href_bdf29');
	$children[] = array('data' => '37. Cotation',
						'href' => 'menu_href_bdf37');
	$children[] = array('data' => '40. Relations Bancaires',
						'href' => 'menu_href_bdf40');
	$children[] = array('data' => '51. Dirigeants',
						'href' => 'menu_href_bdf51');
	$children[] = array('data' => 'Autres',
						'href' => 'menu_href_bdfautres');
	$menu[] = array( 'data' => 'BANQUE DE FRANCE', 'children'=>$children,
					 'perm' =>
						array(
							'list' => array('BDF'),
							'hidden' => true
						)
					);

	// Evaluation
	$children = array();
	$children[] = array('data' => 'IndiScore &copy;',
						'href' => 'menu_href_indiscore',
						'perm' =>
							array(
								'list' => array( 'INDISCORE', 'INDISCOREP' ),
								'hidden' => false
							)
						);
	$children[] = array('data' => 'Rapport de synthèse',
						'href' => 'menu_href_indiscore2',
						'perm' =>
							array(
								'list' => array( 'INDISCORE2', 'INDISCORE2P' ),
								'hidden' => true
							)
						);
	$children[] = array('data' => 'Rapport complet',
						'href' => 'menu_href_indiscore3',
						'perm' =>
							array(
								'list' => array( 'INDISCORE3', 'INDISCORE3P' ),
								'hidden' => true
							)
						);

	$children[] = array('data' => 'Scoring Credit Safe &copy;',
						'href' => 'menu_href_creditsafe',
						'perm' =>
							array(
								'list' => array( 'SCORECSF' ),
								'hidden' => true
							)
						);
	$children[] = array('data' => 'Enqu&ecirc;te commerciale',
						'href' => 'menu_href_enquetec',
						'perm' =>
							array(
								'list' => array( 'ENQUETEC' ),
								'hidden' => true
							)
						);
	$menu[] = array( 'data'=>'EVALUATION', 'children'=>$children);

	//Pieces officielles
	$children = array();
	$children[] = array('data' => 'Commande de Pi&egrave;ces',
						'href' => 'menu_href_pieces',
						'perm' =>
							array(
								'list' => array( 'kbis', 'privileges' ),
								'hidden' => true
							)
						);
	/*$children[] = array('data' => 'K-Bis',
						'href' => 'menu_href_kbis',
						'perm' => array( 'name'=>'KBIS', 'hidden'=>true ) );*/
	$children[] = array('data' => 'Comptes annuels',
						'href' => 'menu_href_greffesbilans');
	$children[] = array('data' => 'Actes &amp; Statuts',
						'href' => 'menu_href_greffesactes');
	$children[] = array('data' => 'Suivi Privilèges',
						'href' => 'menu_href_privileges',
						'perm' =>
							array(
								'list' => array( 'survpriv' ),
								'hidden' => true
							)
						);
	$menu[] = array( 'data'=>'PIECES OFFICIELLES', 'children'=>$children);

	// Options
	$children   = array();
	$children[] = array('data' => 'Mes options',
	                    'href' => 'menu_href_mesoptions');
	$children[] = array('data' => 'Mes surveillances',
	                    'href' => 'menu_href_surveillances',
	                    'perm' => array('list'   => array('SURVLISTE'),
	                                    'hidden' => true));
	$children[] = array('data' => 'Mon portefeuille',
	                    'href' => 'menu_href_portefeuille',
	                    'perm' => array('list'   => array( 'PORTEFEUILLE' ),
	                                    'hidden' => true));
	$children[] = array('data' => 'Administration',
	                    'href' => 'menu_href_administration');
	$children[] = array('data' => 'Commandes Greffe',
	                    'href' => 'menu_href_greffescmd');
	$children[] = array('data' => 'Commandes International',
	                    'href' => 'menu_href_internationalcmd',
	                    'perm' => array('list'   => array( 'INTERNATIONAL' ),
	                                    'hidden' => true));
    
    $children[] = array('data' => 'Commandes Giant',
                            'href' => 'menu_href_giantcmd',
                            'perm' => array('list'   => array( 'INTERNATIONAL' ),
                                            'hidden' => true));
    $children[] = array('data' => 'Statistiques',
	                    'href' => 'menu_href_stats');
	$children[] = array('data' => 'Surveillances',
	                    'href' => 'menu_href_survliste');
	$children[] = array('data' => 'Se d&eacute;connecter',
	                    'href' => 'menu_href_logout');
	$menu[] = array('data' => 'OPTIONS', 'children' => $children);

	return $menu;

}