<?php
function crea_nav($dom,$texto,$href='',$target='')
{
     global $xuli;
     $list=$xuli->appendChild($dom->createElement("li"));   
          $link=$list->appendChild($dom->createElement("a",$texto));   
          $link->setAttribute("href",$href);
     //      $link->setAttribute("data-target",$target);
     $list=$xuli->appendChild($dom->createElement("li"));   
          $list->setAttribute("class","divider-vertical");
}

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

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

//div left
{
if(file_exists('../_logo/logo'.$cfg_empr.'1.png'))
{
$xdiv=$xtop->appendChild($dom->createElement("div"));
     $xdiv->setAttribute("style","float:left;top:0;");
$xlink=$xdiv->appendChild($dom->createElement("a"));
     $xlink->setAttribute("href","?");
$ximg=$xlink->appendChild($dom->createElement("img"));
     $ximg->setAttribute("class","nav-collapse collapse");
     $ximg->setAttribute("style","width:auto; max-height:45px;");
     $ximg->setAttribute("src","//vcrxol.com/_logo/logo".$cfg_empr."1.png");
}
}
//div center
{
$xdiv=$xtop->appendChild($dom->createElement("div"));   
     $xdiv->setAttribute("style","float:center;top:0;margin:0 auto;display:inline-block;");
$xlink=$xdiv->appendChild($dom->createElement("a",$empr_descri));   
     $xlink->setAttribute("class","brand");
     $xlink->setAttribute("href","?");
//      $xlink->setAttribute("data-target","");
}
//div right
{
$xdiv=$xtop->appendChild($dom->createElement("div"));   
     $xdiv->setAttribute("style","float:right;top:0;");
$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");

crea_nav($dom,'Catálogo','?scri=ctlg_item');
crea_nav($dom,'Contactos','?scri=ctlg_item');
if(empty($_SESSION['user_codigo']))
{crea_nav($dom,'Iniciar Sesión','#login');}
else
{crea_nav($dom,'Mi Perfil','?scri=');}
}

echo $dom->saveXML();

?>

