###
### Global header
###
### The uppermost area of each page
### Contains the company logo, links to global actions and the search facility
###
#if($context.getMode()==0) ## Visible only in a page
<div id="headerglobal" class="layoutsection">
#if($context.action == "view")
<div class="minwidthb"></div>
#else
<div class="minwidthd"></div>
#end
  <div id="company">
  <div id="companylogo">
#if ($doc.space=="Inemar")
    <a href="$!xwiki.getURL("Inemar.WebHome", "view")" title="Home" rel="home">
#if($doc.fullName == "Inemar.HomeLombardia")
                #set($logoname = $xwiki.getSkinPreference("logo", "images/testadt.png"))
#else
                #set($logoname = $xwiki.getSkinPreference("logo", "images/testa.png"))
#end
#elseif ($doc.space=="FontiEmissioni")
    <a href="$!xwiki.getURL("FontiEmissioni.WebHome", "view")" title="Home" rel="home">
		#set($logoname = $xwiki.getSkinPreference("logo", "images/testafe.png"))
#elseif ($doc.space=="InemarDatiWeb")
    <a href="$!xwiki.getURL("InemarDatiWeb.WebHome", "view")" title="Home" rel="home">
		#set($logoname = $xwiki.getSkinPreference("logo", "images/testadt.png"))
#else
    <a href="$!xwiki.getURL("InemarWiki.WebHome", "view")" title="Home" rel="home">
		#set($logoname = $xwiki.getSkinPreference("logo", "images/testa.png"))
#end
#set($logo = $!prefdoc.getAttachment($logoname))
#if(!$logo)
#set($logourl = $xwiki.getSkinFile($logoname))
#if ($doc.space=="Inemar" || $doc.space=="InemarDatiWeb")
       <img src="$!logourl" alt="XWiki" width="200" height="70" usemap="#linkmap"/>
<map name="linkmap">
  <area shape="rect" coords="735,0,835,30" href="http://www.arpalombardia.it/" target="_blank" alt="ARPA della Lombardia" title="ARPA della Lombardia" />
  <area shape="rect" coords="840,0,930,30" href="http://www.regione.lombardia.it/" target="_blank" alt="Regione Lombardia" title="Regione Lombardia" />
</map>
#else
       <img src="$!logourl" alt="XWiki" width="200" height="70"/>
#end
#else
#set($logourl = $prefdoc.getAttachmentURL($logo.filename, "download"))
      <img src="$!logourl" alt="XWiki"/>
#end
    </a>
  </div>
  <div id="globaldoctitle">
    <h1>$!headertitle</h1>
  </div>
  </div>
  <div id="globallinks">
    <div id="globalmenu">
#if (!$isGuest)
#if ($context.user == 'XWiki.superadmin')
      $!msg.get("superadmin") #sep()
#else
      <a class="glink" href="$!xwiki.getURL($context.user, "view")" id="headeruser">$!xwiki.getUserName($context.user, false)</a> #sep()
#end
#end
#if(!$context.action.startsWith("login"))
#if($isGuest)
#set($loginurl = $xwiki.getURL("XWiki.XWikiLogin", "login", "xredirect=$util.encodeURI($logredir)"))
      <a class="glink" href="$!loginurl" id="headerlogin">$!msg.get("login")</a>#sep()
#else
#set($logouturl = $xwiki.getURL("XWiki.XWikiLogout","logout", "xredirect=$util.encodeURI($logredir)"))
      <a class="glink" href="$!logouturl" id="headerlogout">$!msg.get("logout")</a>#sep()
#end
#end
#if($isGuest && $xwiki.hasAccessLevel("register", "XWiki.XWikiPreferences"))
#set($regurl = $xwiki.getURL("XWiki.Register", "register"))
      <a class="glink" href="$!regurl" id="headerregister">$!msg.get("core.register")</a>#sep()
#end
#if($xwiki.isMultiLingual())
  <span class="glink" id="headerlanguages">
  <a href="$!doc.getURL("view", "language=$doc.getDefaultLanguage()")">$!doc.getDefaultLanguage()</a>
  #foreach($lang in $doc.translationList)
    / <a href="$!doc.getURL("view", "language=$lang")">$!lang</a>
  #end
  </span>
#end
##      <a href="$!xwiki.getURL("Doc.WebHome","view")">$!msg.get("doc")</a>
    </div> #*
#if($searchdoc.isNew()==false)
    <div id="globalsearch">
      <form action="$!searchdoc.getURL("view")">
        <p><input type="text" name="text" value="" size="15"/>&nbsp;<input type="submit" class="button" value="Search"/></p>
      </form>
    </div>
#end *#
  </div>
</div>
#end
### TODO: Format the header for pdf output
