var lastMenu="";
var currentMenu="";
var parentMenu="";

var px=149; // 270
var ly=155;
var dy=20;
var dx=119;

var cy=-1;

function showPanel(panel) {
    if (document.getElementById) {
       if (document.all) dw=380; else dw=385;
       lx=(document.body.clientWidth/2)-dw+15;
       document.getElementById(panel).style.left=lx;
       document.getElementById(panel).style.top=ly+80;
       document.getElementById(panel).style.filter="alpha(opacity=85)";
       document.getElementById(panel).style.display="block";
    }
}

function showmenu(menu,lp) {
    if (document.getElementById) {
		//if (document.all) dw=380; else dw=385;
       if (document.all) dw=0; else dw=0;
       lx=px+(document.body.clientWidth/2)-dw;
       if (document.getElementById(menu)) {
              hideTimer(lastMenu);
              cur=0;sn=0;

              while(cur<menu.length) {
                     if (menu.charAt(cur) == "_") sn++;
                     cur++;
              }
              
              document.getElementById(menu).style.left=lx+(sn-2)*dx;
              document.getElementById(menu).style.top=ly+lp*dy;
       
              aniShow(menu);
              //document.all[menu].style.visibility="visible";
              lastMenu=menu;
              currentMenu=menu;
       }
    }
}

function showmenu2(menu,my,mx) {
    if (document.getElementById) {
		//if (document.all) dw=380; else dw=385;
       //if (document.all) dw=mx; else dw=mx-5;
	   if (document.all) dw=155; else dw=155-5;
       lx=dw;
       if (document.getElementById(menu)) {
              hideTimer(lastMenu);
              cur=0;sn=0;

              while(cur<menu.length) {
                     if (menu.charAt(cur) == "_") sn++;
                     cur++;
              }
              
              document.getElementById(menu).style.left=lx+(sn-2)*dx;
              document.getElementById(menu).style.top=my;
       
              aniShow(menu);
              //document.all[menu].style.visibility="visible";
              lastMenu=menu;
              currentMenu=menu;
       }
    }
}

function aniShow(menu) {
//       if (alpha<100) {
//              document.all[menu].style.filter="alpha(Opacity="+alpha+")";
//              document.all[menu].style.visibility="visible";
              document.getElementById(menu).style.display="block";
//              document.getElementById(menu).style.visibility="visible";
//              alpha+=5;
//              setTimeout("aniShow('"+menu+"')",1);
//       }
}

function hidemenu(menu) {
       if (document.getElementById(menu)) {
              currentMenu="";
              setTimeout("hideTimer('"+menu+"')",1000);
       }
}

function hidesubmenu(parent,menu) {
       var sum = parent + "_" + menu;
       
       if (sum != "") {
              hidemenu(parent+"_"+menu);
              cur=sum.length;
              while (cur>0) {
                     if (sum.charAt(cur) == "_") hidemenu(sum.substr(0,cur));
                     cur--;
              }

//              hidemenu(parent);
       }
       parentMenu="";
}

function hideTimer(menu) {
       if (currentMenu != menu && parentMenu != menu && parentMenu.substr(0,menu.length) != menu && lastMenu != "") {
              document.getElementById(menu).style.display="none";
       }
}

function parentShow() {
       var carg=arguments[2];
       for(i=3;i<arguments.length;i++) {
              carg+="_"+arguments[i];
              if (document.getElementById(carg)) {
                     document.getElementById(carg).style.display="block";
              }
       }
       parentMenu=carg;
       currentMenu=carg;
       showmenu(carg+"_"+arguments[1],arguments[0]);
}

function mover(el) {
       document.getElementById(el).style.background="#FFF17C";
       document.getElementById(el).style.color="#ffffff";
}

function mout(el) {
       document.getElementById(el).style.background="#ffffff";
       document.getElementById(el).style.color="#000000";
}

function gourl(s) {
       document.href=s;
}


//------------- do galerii

function powie1(url) {
              dy = 60;
           screenWidth =  650;
              screenHeight = 600;
       dx = 0;dy = 0;
       var Win = window.open(url,"displayWindow",'width='+screenWidth+',height='+(screenHeight+5)+',resizable=0,scrollbars=no,left='+dx+',top='+dy );
}

function powie(url,wys,szer) {
       dx = 100;dy = 100;
       var Win = window.open(url,"displayWindow",'width='+wys+',height='+szer+',resizable=0,scrollbars=no,left='+dx+',top='+dy );
}

//---------------------------

pop=false;

if (document.layers) {nn=1} 
else {nn=0}; 
if (document.all) {ie=1} 
else {ie=0} 

function view(obj,state) { 
if (state) {
       if (nn) document.layers[obj].visibility="show"; 
       if (ie) document.all[obj].style.visibility="visible"; 
} else {
       if (nn) document.layers[obj].visibility="hide"; 
       if (ie) document.all[obj].style.visibility="hidden"; 
}
} 

function change() {
       pop=!pop;
       view('poprzedni',pop);
}

// -- ogolne

function displayWindow(url, width, height) {
        var Win,left,top;
              left=screen.width/2-width/2;
              top=screen.height/2-height/2;
              Win = window.open(url,"displayWindow",'left='+left+',top='+top+',width=' + width + ',height='+height + ',resizable=0,scrollbars=no,menubar=no' );
}

function select_kal(key,fld) {
        open("script/kalendarz/kalendarz.php?key="+key+"&field="+fld,"","toolbar=no,left=200,top=150,width=250,height=250,scrollbars=no");
}

