//deklaracja zmiennych globalnych
var t=false, current, link=Array(), ul1, ul2, current2, current3;
function SetupMenu()
{
//zapisanie wszystkich znaczników <li>
opcje=document.getElementsByTagName("li");
for (i=0; i<opcje.length; i++)
{
//warunek zapisania funkcji do poszczegolnych linkow z menus poziomu 1
if (opcje[i].className == "menu11")
{
link[i]=findChild(opcje[i], "A");
link[i].onmouseover=ShowMenu;
link[i].onmouseout=StartTimer;
if (ul=findChild(opcje[i], "UL"))
{
ul.style.display="none";
}
}
//warunek zapisania funkcji do poszczegolnych linkow z menus poziomu 2
if (opcje[i].className == "menu2")
{
//var link=Array();
link[i]=findChild(opcje[i], "A");
link[i].onmouseover=ResetTimer2;
link[i].onmouseout=StartTimer;
}
//warunek zapisania funkcji do poszczegolnych linkow z menus poziomu 3
if (opcje[i].className == "menu3")
{
link[i]=findChild(opcje[i], "A");
link[i].onmouseover=ResetTimer3;
link[i].onmouseout=StartTimer;
}
}
baner();
}
//funkcja wyszukuj?ca obiekt potomny
function findChild(obj,tag)
{
   cn = obj.childNodes;
   for (k=0; k<cn.length; k++) {
   if (cn[k].nodeName==tag) return cn[k];
   }
   return false;
}
//wyswietla menu poziomu II
function ShowMenu(e) {
   if (!e) var e = window.event;
   // na którym ł?czu była mysz?
   thislink = (e.target) ? e.target: e.srcElement;
   ResetTimer();
   // ukryj poprzednie menu, je?li było
   if (current) HideMenu(current);
   // chcemy LI, nie ł?cze
   a1=thislink;
   a1.style.borderLeftColor="#219b00";
   thislink = thislink.parentNode;
   //thislink.style.background = "#5f77f1";
   current=thislink;
   // znajd. podmenu, je?li jest
   ul = findChild(thislink,"UL");
   if (!ul) return;
   ul.style.display="block";
   opcje2=document.getElementsByTagName("li");
   for (i=0; i<opcje2.length; i++)
   {
   if (opcje2[i].className == "menu2")
   {
   ul=findChild(opcje2[i], "UL")
   if (!ul) return;
   ul.style.display="none";
   }
   }
}
//przerwanie czasu bezczynnosci
function HideMenu(thelink) {
   // znajd. podmenu, je?li jest
   ul = findChild(thelink,"UL");
   if (!ul) return;
   ul.style.display="none";
}

function ResetTimer() {
   if (t) window.clearTimeout(t);
}

function StartTimer() {
   a1.style.borderLeftColor = "#726a6a";
   //current.style.background = "none";
   if (current2)
   {
   a2.style.borderLeftColor = "#726a6a";
   //current2.style.background = "none";
   t = window.setTimeout("HideMenu(current)",500);
   }
   else
   {
   t = window.setTimeout("HideMenu(current)",500);
   }
}
//zaladowanie funkcji setupmenu po otwarciu strony
function ResetTimer2(f)
{
if (!f) var f = window.event;
   // na którym ł?czu była mysz?
   thislink = (f.target) ? f.target: f.srcElement;
   ResetTimer();
   // ukryj poprzednie menu, je?li było
   if (current2) HideMenu(current2);
   // chcemy LI, nie ł?cze
   a2=thislink;
   a2.style.borderLeftColor="#219b00";
   thislink = thislink.parentNode;
   //thislink.style.background = "#5f77f1";
   //current.style.background = "#5f77f1";
   current2=thislink;
   // znajd. podmenu, je?li jest
   ul = findChild(thislink,"UL");
   if (!ul) return;
   ul.style.display="block";
}
function ResetTimer3(g)
{
if (!g) var g = window.event;
   // na którym ł?czu była mysz?
   thislink = (g.target) ? g.target: g.srcElement;
   ResetTimer();
   // ukryj poprzednie menu, je?li było
   if (current3) HideMenu(current3);
   // chcemy LI, nie ł?cze
   thislink = thislink.parentNode;
   current3=thislink;
   // znajd. podmenu, je?li jest
   ul = findChild(thislink,"UL");
   if (!ul) return;
   ul.style.display="block";
}
//funkcja wyswietlajaca napis na pasku z aktualnosciami oraz powitaniem
x=770;
function baner()
{
x=x-1;
document.getElementById("pasek").style.left=x + "px";
if (x>-2500) {
window.setTimeout("baner();", 15);
}
if (x==-2500)
{
x=770;
baner();
}
}
window.onload=SetupMenu;
