<?php
// declare(strict_types=0);
function crea_nav($dom,$texto='',$refer='',$title='',$icon='')
{
     global $xuli;
     if(empty($title)){$title=$texto;}
//     
//      📔❌👤
//      

     if(empty($icon))
     {
          if(mb_stristr(strtolower($texto),'cerrar')){$icon='❌';}
          if(mb_stristr(strtolower($texto),'perfil')){$icon='👤';}
     }          
          
     $texto=$icon.$texto;
//      if(strlen(trim($texto))<=2){return;}
     $list=$xuli->appendChild($dom->createElement("li"," "));   
//           $list->setAttribute('size90','');
     $link=$list->appendChild($dom->createElement("a",$texto));
          if(!empty($title))
          {$list->setAttribute('title',htmlspecialchars($title));}
     
     if(substr($refer,0,1)=='.')
     {
          $link->setAttribute("href","#");
          $link->setAttribute("data-target",$refer);
     }
     else
     {
          if(mb_stristr($refer,'{'))
          {$link->setAttribute("onclick",$refer);}
          else
          {$link->setAttribute("href",$refer);}
     }
     
     $list=$xuli->appendChild($dom->createElement("li"));   
          $list->setAttribute("class","divider-vertical");
}

// set_bcos();

$user0=data_maes('empr',$cfg_empr);



$escolor1=escolor10($empr0['empr_color1']);
$escolor2=escolor10($empr0['empr_color2']);
$xcolor2=$empr0['empr_color2'];
if($escolor1!=$escolor2)
{
    // $xxstyle.='color:'.$empr0['empr_color2'].';';
}
else
{
     $xcolor2=oscurece_color($empr0['empr_color2'],0.4);
    //  $xxstyle.='color:'.$xcolor2.';';
}


$dom=new DomDocument();
     $dom->encoding = 'utf-8';
     $dom->xmlVersion = '1.0';
     $dom->xmlStandalone = true;
     $dom->formatOutput = true;

$xstyle='';
$xstyle.="text-align:center;";
$xstyle.="color:".$xcolor2.";";
$xtop=$dom->appendChild($dom->createElement("div"));   
     $xtop->setAttribute("style",$xstyle);

$logo1='../.logo/logo'.$cfg_empr.'1.png';
if(!file_exists($logo1))
{$logo1='.logo/logo'.$cfg_empr.'1.png';}





//div left
{
// if(file_exists('../.logo/logo'.$cfg_empr.'1.png'))
if(file_exists($logo1))
{
     $xstyle='';
     $xstyle.="width:auto; max-height:45px;";
     $xstyle.="color:".$xcolor2.";";
     $xdiv=$xtop->appendChild($dom->createElement("div"));
          $xdiv->setAttribute("style","float:left;top:0;display:inline-block;max-width:19%;");
     $xlink=$xdiv->appendChild($dom->createElement("a"));
          $xlink->setAttribute("href","?");
     $ximg=$xlink->appendChild($dom->createElement("img"));
     //      $ximg->setAttribute("class","nav-collapse collapse");
          $ximg->setAttribute("tabindex","-1");
          $ximg->setAttribute("src","//vcrxol.com/.logo/logo".$cfg_empr."1.png");
          $ximg->setAttribute("style",$xstyle);
}
     
if(!file_exists($logo1))
{
     $xstyle='';
     $xstyle.="font-size:1.5em;";
     $xstyle.="color:".$xcolor2.";";
     
     $xdiv=$xtop->appendChild($dom->createElement("div"));
          $xdiv->setAttribute("style","float:left;top:0;display:inline-block;max-width:19%;");
     $xlink=$xdiv->appendChild($dom->createElement("a",strtoupper($cfg_empr)));
          $xlink->setAttribute("href","?");
          $xlink->setAttribute("class","brand");
          $xlink->setAttribute("style",$xstyle);
     
}
     
}
//div center
{
     
$xdiv=$xtop->appendChild($dom->createElement("div"));   
     $xdiv->setAttribute("style","float:center;top:0;margin:0 auto;display:inline-block;max-width:59%;");
//      $xdiv->setAttribute("style","float:left;top:0;margin:0 auto;display:inline-block;max-width:99%;");
// $xlink=$xdiv->appendChild($dom->createElement("a",$empr_descri)); 
     
if(empty($empr_descri))
{$empr_descri='SIN NOMBRE';}     
     
{
$xlink=$xdiv->appendChild($dom->createElement("a",htmlspecialchars($empr_descri))); 
     $xlink->setAttribute("id","topcenter");
     $xlink->setAttribute("class","brand");
     $xlink->setAttribute("href","?");
     
//      if(!esMovil())
//      {$xlink->setAttribute("style","font-size:2em;");}
//      else
//      {
//           $xlink->setAttribute("style","font-size:2em;");
//           if(strlen(trim($empr_descri))>16)
//           {$xlink->setAttribute("style","font-size:1em;");}
//           if(strlen(trim($empr_descri))>20)
//           {$xlink->setAttribute("style","font-size:.8em;");}
//      }

     $xstyle='';
     
     {$xstyle.="color:".$xcolor2.";";}
     
     if(!esMovil())
     {$xstyle.="font-size:2em;";}
     else
     {
          $xstyle.="font-size:2em;";
          if(strlen(trim($empr_descri))>16)
          {$xstyle.="font-size:1em;";}
          if(strlen(trim($empr_descri))>20)
          {$xstyle.="font-size:.8em;";}
     }

     
     $xlink->setAttribute("style",$xstyle);
     
}
     
}
//div right
{
$xdiv=$xtop->appendChild($dom->createElement("div"));   
     $xdiv->setAttribute("style","float:right;top:0;min-width:19%;");
//      $xdiv->setAttribute("style","position:absolute;right:10;top:0;min-width:1%;");
$xbutton=$xdiv->appendChild($dom->createElement("button"));   
     $xbutton->setAttribute("type","button");
     $xbutton->setAttribute("class","btn btn-navbar");
     $xbutton->setAttribute("data-toggle","collapse");
     $xbutton->setAttribute("data-target",".nav-collapse");
     $favicon='../'.$cfg_empr.'/favicon.ico';
     if(file_exists($favicon))
     {
          $ximg=$xbutton->appendChild($dom->createElement("img"));   
          $ximg->setAttribute("style","width:auto; max-height:30px;");
          $ximg->setAttribute("src","//vcrxol.com/".$cfg_empr."/favicon.ico");
     }
     else
     {
          for($idx=1;$idx<=3;$idx++)
          {
               $ximg=$xbutton->appendChild($dom->createElement("span"," "));   
               $ximg->setAttribute("class","icon-bar");
          }
     }

// navigation
$xdiv=$xtop->appendChild($dom->createElement("div"));   
     $xdiv->setAttribute("id","menutop");
     $xdiv->setAttribute("class","nav-collapse collapse");
     $xdiv->setAttribute("style","float:right;");

$xuli=$xdiv->appendChild($dom->createElement("ul"));   
     $xuli->setAttribute("class","nav");

$list=$xuli->appendChild($dom->createElement("li"));   
     $list->setAttribute("class","divider-vertical");

     
     // Menu NAV
     $user0=data_maes('user',$_SESSION['user_codigo']);
     $user_descri=$user0['user_descri'];
     if(empty($user_descri)){$user_descri='Mi Perfil';}
     
     $scri_ctlg='ctlg_item3';
     if($empr0['empr_inmobil']==1){$scri_ctlg='ctlg_bbii3';}
     
     if($empr0['empr_carr']==1)
     {crea_nav($dom,'Catálogo','?scri='.$scri_ctlg);}
     
     if($empr0['empr_ctlg']==1)
     {crea_nav($dom,'Catálogo','?scri='.$scri_ctlg);}
     
//      crea_nav($dom,'IniSes','#login');
     crea_nav($dom,'Contactos','?scri=contactos');
     if(empty($_SESSION['user_codigo']))
     {crea_nav($dom,'➲Iniciar Sesión','?'.'&scri=user_login0','➲Iniciar Sesión');}
     else
     {
          $user_nombre=substr($user_descri,0,strpos($user_descri,' '));
          crea_nav($dom,''.$user_nombre.' ('.$user0['user_codigo'].')','?scri=regi_maes3&modu=user','Mi Perfil','👤');
          crea_nav($dom,'❌','{user_logout();}','Cerrar Sesión');
     }
}

echo $dom->saveXML();

?>

