﻿function Stat()
{
  url;
  ligil;
  dosieruj;
  nombr;
  klapar;
}

function sxargxiKlapar()
{
  if(window.document.getElementById)
  {
    var i = 0;
    var o;
    Stat.klapar = new Array();
    while(o = document.getElementById("fl"+(i+1)))
    {
      Stat.klapar[i] = parseInt(i + 1) + o.firstChild.data;
      i++;
    }
  }
}

function markiLigilon()
{
  Stat.ligil.style.fontWeight = "normal";
  try
  {
    if(document.getElementById("fenestrtekst"))
      document.getElementById("fenestrtekst").style.visibility="visible";
    var e = document.getElementById("fenestr");
    if(e.contentWindow && e.contentWindow.document)
    {
      /(\w+)\.html/.test(e.contentWindow.document.URL);
      var lig = document.getElementById(RegExp.$1);
      if(lig)
      {
        lig.style.fontWeight = "bold";
        Stat.ligil = lig;
        Stat.url = lig.href;
      }
      switch (RegExp.$1)
      {
        case "fotoalbum": document.getElementById("fenestr").style.height = "1205px"; break;
        case "gotenburgo": document.getElementById("fenestr").style.height = "1770px"; break;
        case "grammatik":
        case "stadgar": document.getElementById("fenestr").style.height = "700px"; break;
        default : document.getElementById("fenestr").style.height = "630px";
      }
    }
    Stat.ligil.blur();
  }
  catch(ex)
  {
    Stat.ligil.blur();
    if(document.getElementById("fenestrtekst") && !/http/.test(Stat.url))
      document.getElementById("fenestrtekst").style.visibility="hidden";
  }
}

function fenestrRand()
{
  if(window.document.attachEvent || window.document.addEventListener)
  {
    window.document.write('<a id="fenestrtekst" title="T.ex. f&ouml;r att skriva ut sidan eller f&ouml;r att l&auml;ttare scrolla i stora sidor" onclick="this.href=Stat.url;" href="aktuellt.html" target="_blank">&Ouml;ppna nedanst&aring;ende sida i nytt f&ouml;nster / ny flik</a>');
  }
}

function fenestrRand_eo()
{
  if(window.document.attachEvent || window.document.addEventListener)
  {
    window.document.write('<a id="fenestrtekst" title="Ekz. por elprinti la pa&#285;on a&#365; povi pli facile orienti&#285;i en grandaj pa&#285;oj" onclick="this.href=Stat.url;" href="aktuale.html" target="_blank">Aperigu la suban pa&#285;on en nova fenestro / klapo</a>');
  }
}

function startKlapoj()
{
  if(window.document.getElementById)
  {
    window.document.write('<p id="flikbakgr" style="height:60px;">&nbsp;</p>');
    window.document.write('<p class="linje" style="top:50px;">&nbsp;</p>');
    window.document.write('<p class="flikar" style="top:21px;left:30px;height:39px;width:95px;"><a id="fl3" href="javascript:;" onclick="klapoj(\'3\');this.blur();">Ingas l&auml;nktips</a></p>');
    window.document.write('<p class="linje" style="top:51px;border:0;">&nbsp;</p>');
    window.document.write('<p class="linje" style="top:55px;">&nbsp;</p>');
    window.document.write('<p class="flikar" style="top:33px;left:20px;height:26px;width:100px;"><a id="fl2" href="javascript:;" onclick="klapoj(\'2\');this.blur();">Organisationer</a></p>');
    window.document.write('<p class="linje" style="top:56px;border:0;">&nbsp;</p>');
    window.document.write('<p class="linje" style="top:60px;">&nbsp;</p>');
    window.document.write('<p class="flikar" style="top:46px;left:10px;height:14px;width:105px;"><a id="fl1" class="flikar" href="javascript:;" onclick="klapoj(\'1\');this.blur();">Diverse l&auml;nkar</a></p>');
    sxargxiKlapar();
  }
  else
    window.document.write('<p id="flikbakgr" style="color:white;text-align:center;font-weight:bold;font-size:11px;">Eksteraj ligiloj</p>');
}

function startKlapoj_eo()
{
  if(window.document.getElementById)
  {
    window.document.write('<p id="flikbakgr" style="height:60px;">&nbsp;</p>');
    window.document.write('<p class="linje" style="top:50px;">&nbsp;</p>');
    window.document.write('<p class="flikar" style="top:21px;left:30px;height:39px;width:100px;"><a id="fl3" href="javascript:;" onclick="klapoj(\'3\');this.blur();">Ligilsugestoj de Inga</a></p>');
    window.document.write('<p class="linje" style="top:51px;border:0;">&nbsp;</p>');
    window.document.write('<p class="linje" style="top:55px;">&nbsp;</p>');
    window.document.write('<p class="flikar" style="top:33px;left:20px;height:26px;width:105px;"><a id="fl2" href="javascript:;" onclick="klapoj(\'2\');this.blur();">Organiza&#309;oj</a></p>');
    window.document.write('<p class="linje" style="top:56px;border:0;">&nbsp;</p>');
    window.document.write('<p class="linje" style="top:60px;">&nbsp;</p>');
    window.document.write('<p class="flikar" style="top:46px;left:10px;height:14px;width:110px;"><a id="fl1" class="flikar" href="javascript:;" onclick="klapoj(\'1\');this.blur();">Diversaj ligiloj</a></p>');
    sxargxiKlapar();
  }
  else
    window.document.write('<p id="flikbakgr" style="color:white;text-align:center;font-weight:bold;font-size:11px;">Eksteraj ligiloj</p>');
}

function klakita(e)
{
  if(window.event && window.event.srcElement && window.event.srcElement.href)
  {
    //IE metas informon en la href-atribuo ankaux por bildoj, tial: !window.event.srcElement.src
    if(!window.event.srcElement.src)
      Stat.url = window.event.srcElement.href;
    else if(window.event.srcElement.parentNode.href)
      Stat.url = window.event.srcElement.parentNode.href;
  }
  else if(e && e.target) //e cxar IE iras cxi tien kiam oni klakas ekster ligilo
  {
    if(e.target.href)
      Stat.url = e.target.href;
    else if(e.target.parentNode.href)
      Stat.url = e.target.parentNode.href;
  }
}

function klapoj(fl)
{
  if(fl>1)
  {
    var l = Stat.klapar.length;
    var p1, p2, flp;
    p1 = Stat.klapar.slice(0,fl-1);
    flp = Stat.klapar.slice(fl-1,fl);
    if(fl<l)
    {
      p2 = Stat.klapar.slice(fl);
      p1 = p1.concat(p2);
    }
    Stat.klapar = flp.concat(p1);
    var i = 0;
    var o;
    while(o = document.getElementById("fl"+(i+1)))
    {
      o.firstChild.data = Stat.klapar[i].substr(1);
      document.getElementById("lankar"+(i+1)).style.display = "none";
      i++;
    }
    document.getElementById("lankar"+Stat.klapar[0].substr(0,1)).style.display = "block";
  }
}

function subFenestr()
{
  if(window.location.hash)
    window.document.getElementById('fenestr').src=Stat.url=window.location.hash.substring(1)+'.html';
}

function ant(nr)
{
  if(window.document.replaceChild)
  {
    var e = document.getElementById("bildoj");
    if(!nr)
    {
      nr = e.src.match(/\/(\d+)\.jpg/i)[1];
      nr = parseInt(nr)-1;
    }
    if(nr>0)
    {
      e.src = "./"+Stat.dosieruj+"/" + nr + ".jpg";
      var t = document.getElementById("tekst");
      if(t) t.replaceChild(document.createTextNode(tekstoj[nr]),t.firstChild);
    }
    if(nr<=1)
      document.getElementById("anta").style.color = "black";
    else
      document.getElementById("anta").style.color = "#9999ff";
    document.getElementById("sekva").style.color = "#9999ff";
  }
  else alert("Bildv\u00E4xlingen fungerar tyv\u00E4rr inte i denna webbl\u00E4sare! \n\nLa bild\u015Dan\u011Dado beda\u016Drinde ne funkcias en \u0109i tiu retumilo!");
}

function sekv(nr)
{
  if(window.document.replaceChild)
  {
    var e = document.getElementById("bildoj");
    if(!nr)
    {
      nr = e.src.match(/\/(\d+)\.jpg/i)[1];
      nr = parseInt(nr)+1;
    }
    if(nr<=Stat.nombr)
    {
      e.src = "./"+Stat.dosieruj+"/" + nr + ".jpg";
      var t = document.getElementById("tekst");
      if(t) t.replaceChild(document.createTextNode(tekstoj[nr]),t.firstChild);
    }
    if(nr>=Stat.nombr)
      document.getElementById("sekva").style.color = "black";
    else
      document.getElementById("sekva").style.color = "#9999ff";
    document.getElementById("anta").style.color = "#9999ff";
  }
  else alert("Bildv\u00E4xlingen fungerar tyv\u00E4rr inte i denna webbl\u00E4sare! \n\nLa bild\u015Dan\u011Dado beda\u016Drinde ne funkcias en \u0109i tiu retumilo!");
}

function kasxuAdreson(mesagx,adres)
{
  if(document.createElement)
    document.write("<a id='"+adres+"' href=\"javascript:montruAdreson('"+adres+"');\">"+mesagx+"</a>");
  else
    document.write(adres);
}

function montruAdreson(adres)
{
 var e = window.document.getElementById(adres);
 adres = adres.replace(/\([A-Z-]+\)/,"@");
 e.href = "mailto:" + adres;
 e.firstChild.data = adres;
}

function klickat(e)  /*** La funkcio montrigas la html-dosierojn cxiam en la sama fenestro ***/
{
  var fe;
  var r = new RegExp("pdf");
  if(window.event && window.event.srcElement && window.event.srcElement.href && !r.test(window.event.srcElement.href))
  {
    fe = window.open(window.event.srcElement.href,'novfen');
    fe.focus();
  }
  else if(e && e.target && e.target.href && !r.test(e.target.href)) /* e cxar IE iras cxi tien kiam oni klakas ekster ligilo */
  {
    fe = window.open(e.target.href,'novfen','','true');
    fe.focus();
  }
}

function visaUppdat(ligil)  /*** Montrigas pagxon gxisdatigitan ***/
{
  var ligilar = window.parent.document.getElementsByTagName("A");
  var l = ligilar.length;
  var n = ligil.firstChild.data;
  var i;
  for(i=0;i<l;i++)
  {
    if(n==ligilar[i].firstChild.data)
    {
      ligilar[i].click();
      break;
    }
  }
}
