// History:
//   Dopln�a detekce jazyka dokumentu (ve zna�e body)
//   Ped��o na jinou strukturu adres�, dopln�o poukov��odkaz
//   Oprava regul�n�o vrazu tak, aby nekazil odkaz Nahoru v pati�e

//var undefined;    // Pro zpetnou kompatibilitu kdyby JS nepodporoval undefined

var RelPath="";     // Prom�n�pro uloen�relativn�cesty k rootu webu
                    // Vechny cesty v tomto skriptu pak maj�bt cestami od
                    // rootu webu (nap�lad Web/PIC/MLAB.ico)

function Test()
// Testovac�funkce pro lad��
{
  with (document)
  {
    var Info;
    // Test
    // Uite�� document.URL (cesta a jm�o souboru str�ky)
    write('<p class="MenuText Small">');
    write('document language '+DocLang());
    write('</p>');
    write('<p class="MenuText Small">');
    write('document language '+navigator.appVersion);
    write('</p>');
    write('<p class="MenuText Small">');
    write('document language '+document.body.lang);
    write('</p>');
    write('<p class="MenuText Small">');
    write('navigator language '+navigator.language);  // FF ano, IE6 ne
    write('</p>');
  }
}


function DocLang()
// Vrac�zkratku jazyka str�ky ( cs en )
// Nen�li v dokumentu uveden�vrac�en
{
  var s;
  s=document.body.lang.toLowerCase();
  if(s=="cs") return "cs";  // To by m�zaj�alo pro�je �tina cs a ne cz
  if(s=="sk") return "cs";  // Pro slov�y bude asi �tina vhodn��
  return "en";              // Pro vechny ostatn�d�e angli�inu
}


function SetRelativePath(Path)
// Nastav�relativn��st cesty tak, abychom se dostali k rootu webu
// Nap�lad pro str�ky v adres�i "Web" je tento parametr "../"
{
  // Zapamatuji si relativn�cestu
  RelPath=Path;
  // P�adn�dopln� na konec lom�ko
  if (RelPath.length!=0)
    if (RelPath.charAt(RelPath.length-1)!='/')
      RelPath+='/';
}


function PokeRelativePath(Content)
// Vezme et�ec a dopln�v n� vechny odkazy o relativn��st cesty
{
  Content=(Content.replace(/(\s+href=[\"\'])([^#])/ig,'$1'+RelPath+'$2'));
  Content=(Content.replace(/(\s+src=[\"\'])([^#])/ig,'$1'+RelPath+'$2'));
  return Content;
}


function DrawHeader(MoreInfo)
// Nepovinny parametr udava nadpis stranky
// Neni-li uveden bere se text ze znacky title dokumentu
{
  // Prom�n�pro vznikaj��vkl�an obsah
  var Content="";
  // Default informace pokud je parametr nezadany
  if(MoreInfo==undefined) MoreInfo=document.title;
  // Vlozeni HTML kodu
  Content+='<div class="InnerHeader"> ';
  if (DocLang()=="cs")
    { // �sk text
      Content+='<a href="index.cs.html" title="Dom"><span class="HeaderLogo">MLAB</span><img border=0 width=120 height=57 src="Web/PIC/MLAB_online.gif" alt="MLAB Logo"></a>';
    }
  else
    { // English text
      Content+='<a href="index.en.html" title="Home"><span class="HeaderLogo">MLAB</span><img border=0 width=120 height=57 src="Web/PIC/MLAB_online.gif" alt="MLAB Logo"></a>';
    }
  Content+='<span class="HeaderText">'+MoreInfo+'</span>';
  Content+='</div> ';
  // Korekce cest v odkazech
  Content=PokeRelativePath(Content);
  // Vstup sestaven�o textu
  document.write(Content);
}


function DrawMenu(MoreInfo)
// Nepovinny parametr udava nazev menu
// Neni-li uveden dava se text Menu
{
  // Prom�n�pro vznikaj��vkl�an obsah
  var Content="";
  // Default text
  if(MoreInfo==undefined) MoreInfo="Menu";
  // Vlastni menu
  Content+='<div class="InnerMenu">';
  Content+='  <div class="Navigation">';
  Content+='    <div class="MenuText">';
  Content+=       MoreInfo;
  Content+='    </div>';
  if (DocLang()=="cs")
    { // �sk text
      Content+='<ul>';
      Content+='  <li> <a href="index.cs.html" title="Dom">Home</a> </li>';
      Content+='  <li> <a href="Web/Modules.cs.html" title="Jednotliv�moduly MLAB">Moduly</a> </li>';
      Content+='  <li> <a href="Web/Apparatus.cs.html" title="Samostatn�za�en�>Za�en�/a> </li>';
      Content+='  <li> <a href="Web/Articles.cs.html" title="��ky, informace">Texty</a> </li>';
      Content+='  <li> <a href="Web/Photos.cs.html" title="Galerie fotografi�>Fotogalerie</a> </li>';
      Content+='  <li> <a href="../Forum" title="Forum uivatel a autor">Forum</a> </li>';
      Content+='  <li> <a href="Web/About.cs.html" title="O webu, stavebnici MLAB atd.">O projektu</a> </li>';
      Content+='</ul>';
    }
  else
    { // English text
      Content+='<ul>';
      Content+='  <li> <a href="index.html" title="Home">Home</a> </li>';
      Content+='  <li> <a href="Web/Modules.en.html" title="Individual MLAB Modules">Modules</a> </li>';
      Content+='  <li> <a href="Web/Apparatus.en.html" title="Independed Devices">Apparatus</a> </li>';
      Content+='  <li> <a href="Web/Articles.en.html" title="Articles and other Texts">Texts</a> </li>';
      Content+='  <li> <a href="Web/News.cen.html" title="News">News</a> </li>';
      Content+='  <li> <a href="Web/Photos.en.html" title="Photo Gallery">Photogallery</a> </li>';
      Content+='  <li> <a href="../Forum" title="Forum MLAB">Forum</a> </li>';
      Content+='  <li> <a href="Web/About.en.html" title="About Project">About</a> </li>';
      Content+='</ul>';
    }
  Content+='  </div>';
  Content+='</div> ';
  // Korekce cest v odkazech
  Content=PokeRelativePath(Content);
  // Vstup sestaven�o textu
  document.write(Content);
}


function DrawFooter(MoreInfo)
// Nepovinny parametr pro text do paticky
{
  // Prom�n�pro vznikaj��vkl�an obsah
  var Content="";
  // Default text je prazdny
  if(MoreInfo==undefined) MoreInfo="";
  // Vlozeni HTML kodu
  Content+='<div class="InnerFooter">';
  Content+='&nbsp;';   // stupek IE6 (chyba vpo�u �ky pi nenulov� paddingu )
  if (DocLang()=="cs")
    { // �sk text
      Content+='<a href="#">Nahoru</a> &nbsp; ';
      Content+='<a href="Web/Copyright.cs.html">Copyright</a> &copy; ';
      Content+='<a href="Web/AboutAuthors.cs.html">Autoi MLAB</a> &nbsp; ';
    }
  else
    { // English text
      Content+='<a href="#">Up</a> &nbsp; ';
      Content+='<a href="Web/Copyright.en.html">Copyright</a> &copy; ';
      Content+='<a href="Web/AboutAuthors.en.html">MLAB Authors</a> &nbsp; ';
    }
  Content+='['+document.lastModified+'] &nbsp;&nbsp;&nbsp;';
  Content+=MoreInfo;
  Content+='</div>';
  // Korekce cest v odkazech
  Content=PokeRelativePath(Content);
  // Vstup sestaven�o textu
  document.write(Content);
}