<?php

// Array delle icone per le voci del menu
$menu_icons = array(
    'home' => 'bi bi-house-fill',
    'prodotti' => 'bi bi-box-seam',
    'catalogo' => 'bi bi-grid-3x3-gap',
    'chi siamo' => 'bi bi-people-fill',
    'chi-siamo' => 'bi bi-people-fill',
    'about' => 'bi bi-people-fill',
    'servizi' => 'bi bi-gear-fill',
    'contatti' => 'bi bi-envelope-fill',
    'dove siamo' => 'bi bi-geo-alt-fill',
    'dove-siamo' => 'bi bi-geo-alt-fill',
    'news' => 'bi bi-newspaper',
    'notizie' => 'bi bi-newspaper',
    'gallery' => 'bi bi-images',
    'galleria' => 'bi bi-images',
    'shop' => 'bi bi-cart-fill',
    'negozio' => 'bi bi-cart-fill',
    'areariservata' => 'bi bi-person-lock',
    'area riservata' => 'bi bi-person-lock',
    'login' => 'bi bi-box-arrow-in-right',
    'i-tuoi-ordini' => 'bi bi-list-check',
    'ordini' => 'bi bi-list-check',
    'profilo' => 'bi bi-person-lines-fill',
    'account' => 'bi bi-person-circle'
);

// Funzione per ottenere l'icona basata sul testo del menu
function getMenuIcon($menuText, $sectionName = '') {
    global $menu_icons;
    
    $searchText = strtolower(trim($menuText));
    $searchSection = strtolower(trim($sectionName));
    
    // Cerca prima per nome sezione, poi per testo del menu
    if($searchSection && isset($menu_icons[$searchSection])) {
        return $menu_icons[$searchSection];
    }
    if(isset($menu_icons[$searchText])) {
        return $menu_icons[$searchText];
    }
    
    // Icona di default se non trova corrispondenze
    return 'bi bi-circle';
}

if(!$logged){

	?>
<a href="tel:+39%20" ><i class="bi bi-telephone-fill" style="color:white"></i><span class="w-text-value">+39 </span></a>
	<?

$idmenu = 2;
$nlink = 0;

if(isset($a_lnkmenu[$idmenu]) && is_array($a_lnkmenu[$idmenu]))
	$nlink = count($a_lnkmenu[$idmenu]);

if($nlink>0){

 $msid="";
 if($logged=='1') $msid="?MSID=".$mysessionid."&";
# if($_cks == "KO") $msid="?_cks=KO";
 ?>

 <ul class="menu2"><li>|</li>
 <?
	for ($i=0;$i<$nlink;$i++){
	  $left=3;if($i==0)$left=0;
	  $href0 = $urlbase;#."index.php?".$msid."strparam=$strparam";
	  
	  #$href  = $href0."?sz=".$a_sezmenu[$idmenu][$i];
	  $href  = $href0.$language."/".$a_sezmenu[$idmenu][$i]."/";
	  if($msid!="") $href.= $msid;
	  
	  $class="menu2off";
	  if($isezione==$a_isezmenu[$idmenu][$i]){ $class = "menu2on"; }
	?>
	<li >
<a href="<?=$href?>" class="<?=$class?>">
    <i class="<?=getMenuIcon($a_lnkmenu[$idmenu][$i], $a_sezmenu[$idmenu][$i])?>"></i>
    <? echo trim(ucfirst(strtolower($a_lnkmenu[$idmenu][$i])));?>
</a>
<!-- <img src="main/contents/immagini/menusep.jpg" /> -->
<? 
#if($i<$nlink-1) 
echo "<li>|</li>";#echo "&nbsp;|&nbsp;"; 
?></li>

 <?
 }

?>
</ul>
<? }
} else { 
	
if($level<=2) $idmenu = 4;
else $idmenu = 5;

$nlink = 0;
if(isset($a_lnkmenu[$idmenu])) $nlink = count($a_lnkmenu[$idmenu]);

 $msid="";if($logged=='1') $msid="MSID=".$mysessionid."&";	

 $aClassMenu = array();
$aClassMenu['areariservata'] = '';
$aClassMenu['i-tuoi-ordini'] = '';	

?>
<ul class="menu4">

<?
	for ($i=0;$i<$nlink;$i++){
	  $left=3;if($i==0)$left=0;
	 
	  
	  $href  = "index.php?sz=".$a_sezmenu[$idmenu][$i]."&".$msid."&language=$language";

	  $class="menu4off";
	  if($isezione==$a_isezmenu[$idmenu][$i]){ $class = "menu4on"; }
	?>
	<li >
<a href="<?=$href?>" class="<?=$class?>">
    <i class="<?=getMenuIcon($a_lnkmenu[$idmenu][$i], $a_sezmenu[$idmenu][$i])?>"></i>
    <? echo trim(ucfirst(strtolower($a_lnkmenu[$idmenu][$i])));?>
</a>
</li>

 <?
 }
/*
?>

<li><a href="javascript:logout()" class="menu4off">
<i class="bi bi-box-arrow-right"></i>
Esci</a></li>
*/ ?>
</ul>

<? } ?>