// #################################################### // ---------------------------------------------------- // JavaScript Document // jMenu Class // licence - GNU GPL 2.0 // programing - Martin.Chudoba // email - martin.chudoba@seznam.cz // ---------------------------------------------------- // #################################################### var l_timer = null; var l_timer_anim = null; var l_prvek = null; var l_opacity = 0.0; var l_prvek_height = 0; var l_anim_height = 0; var l_anim_type = 'lightning'; //else 'scroll' function jMenuInit(xmenu, id) { if(document.getElementById) { l_opacity = 0.0; l_anim_height = 0; isEnabledSub(); allHide(xmenu); var browName = navigator.appName; var menu = document.getElementById('menu'); var y = 104;//menu.style.height+menu.style.padding-top; if (browName == "Microsoft Internet Explorer") { var objBody = document.getElementsByTagName("body").item(0); var x = id.offsetLeft.toString()-10;//((objBody.offsetWidth-900)/2);//+id.offsetLeft-100; } else var x = id.offsetLeft.toString(); //animace //---------------------------------------- var prvek = document.getElementById(xmenu); if (prvek.style.display != 'block') { if (l_anim_type == 'lightning') { prvek.style.opacity = ".0"; //prvek.style.opacity = l_opacity; if (browName == "Microsoft Internet Explorer") { prvek.style.filter = "alpha(opacity="+l_opacity+")"; } prvek.style.display = 'block'; } else if (l_anim_type == 'scroll') { prvek.style.display = 'block'; prvek.style.height = "auto"; l_prvek_height = prvek.clientHeight; l_prvek_height = l_prvek_height - 17; l_prvek_height = l_prvek_height.toString(); prvek.style.height = 0; } //konec animace //---------------------------------------- if (browName == "Microsoft Internet Explorer") { prvek.style.left = x; prvek.style.top = y; } else { prvek.style.left = x-10+"px"; prvek.style.top = y+"px"; } if (browName == "Opera") l_timer_anim=setTimeout(function() { Animate(prvek); },40); else l_timer_anim=setTimeout(function() { Animate(prvek); },1); } } } function jMenuStop(xmenu) { if(document.getElementById) { l_prvek = document.getElementById(xmenu); l_timer=setTimeout("jHideMenu();",50); } } function jHideMenu() { var menu = document.getElementById('menu'); var x = menu.scrollLeft; var y = 60;//menu.scrollHeight+menu.style.padding-top; l_prvek.style.display = 'none'; l_prvek.style.x = x; l_prvek.style.top = y; l_opacity = 0.0; l_anim_height = 0; } function allHide(xmenu) { for (i = 0; i < l_pole.length; i++) { var menu = document.getElementById('menu'); l_prvek = document.getElementById(l_pole[i]); if (xmenu == l_pole[i]) { continue; } var x = menu.scrollLeft; var y = 60;//menu.scrollHeight+menu.style.padding-top; if (!l_prvek)break; l_prvek.style.display = 'none'; l_prvek.style.x = x; l_prvek.style.top = y; l_opacity = 0.0; l_anim_height = 0; } } function isEnabledSub() { clearTimeout(l_timer); l_timer = null; } function Animate(a_prvek) { var browName = navigator.appName; if (l_anim_type == 'lightning') { if (browName == "Opera") l_opacity = l_opacity + 0.1; else l_opacity = l_opacity + 0.03; var myStr = l_opacity.toString(); myStr = myStr.replace("0", ""); a_prvek.style.opacity = myStr; if (browName == "Microsoft Internet Explorer") { var l_opacity2 = l_opacity*100; a_prvek.style.filter = "alpha(opacity="+l_opacity2+")"; } if (a_prvek.style.opacity >= 1.0) { clearTimeout(l_timer_anim); l_timer_anim = null; } else { if (browName == "Opera") l_timer_anim=setTimeout(function() { Animate(a_prvek); },40); else l_timer_anim=setTimeout(function() { Animate(a_prvek); },1); } } else if (l_anim_type == 'scroll') { l_anim_height = l_anim_height + 2.4; if (l_anim_height > l_prvek_height) a_prvek.style.height = "auto"; else a_prvek.style.height = l_anim_height+"px"; if (l_anim_height >= l_prvek_height) { a_prvek.style.height = "auto"; clearTimeout(l_timer_anim); l_timer_anim = null; } else l_timer_anim=setTimeout(function() { Animate(a_prvek); },1); } }