function levelsmenu(rootid,menucodel1,menucodel2,menucodel3){ var root=document.getElementById(rootid); function toint(str){ if(str=='auto'){ str=0; }else{ str=parseInt(str); } return str; } function rplks(str,keywords,newkey) { //var patt=new RegExp(eval("/"+keywords+"/g")); var patt=new RegExp(keywords,'g'); if(patt.exec(str)!= null){ var str=str.replace(patt,newkey); } return str; } function curh(obj){ $(" li>a",$(obj.parentNode.parentNode)).each(function (){ $(">img:first",this).attr('src',rplks($(">img:first",this).attr('src'),"_on.png","_off.png")); }) $(">img:first",$(obj)).attr('src',rplks($(">img:first",obj).attr('src'),"_off.png","_on.png")); } function cur(obj){ curh(obj); if(obj.parentNode.parentNode.getElementsByTagName('ul').length>0){ $(" ul",$(root)).each(function (){ slup(this); }) } if(obj.parentNode.getElementsByTagName('ul').length>0){ sldown($(">ul:first",obj.parentNode)); } } function cur1(obj){ curh(obj); if(obj.parentNode.getElementsByTagName('ul').length>0 ){ sldown($(">ul:first",obj.parentNode)); } } function cur2(obj){ //if($(obj).data('notoggle')=='true'){ //}else{ //} curh(obj); stg($(">ul:first",obj.parentNode)); } function sethover(){ if(typeof(menucodel1)=='undefined'||menucodel1==''){ cur(root.getElementsByTagName('a')[0]); }else{ $(">li>a",$(root)).each(function (i){ if(i==menucodel1-1){ cur(this); $(">ul>li>a",$(this.parentNode)).each(function (i){ if(i==menucodel2-1){ cur(this); } }) } }) } } function rehover(){ if(typeof(menucodel1)=='undefined'||menucodel1==''){ cur(root.getElementsByTagName('a')[0]); }else{ $(">li>a",$(root)).each(function (i){ if(i==menucodel1-1){ cur1(this); $(">ul>li>a",$(this.parentNode)).each(function (i){ if(i==menucodel2-1){ cur1(this); } }) } }) } } function setData(obj){ if(obj.parentNode.getElementsByTagName('ul').length>0){ if(document.activeElement!=obj&&$(">ul:first",obj.parentNode).height()<=5){ $(obj).data('notoggle','true'); }else{ $(obj).data('notoggle','false'); } } } $(">li>ul",root).each(function(){ $(this) .css({'overflow':'hidden'}) .data('height',toint($(this).height())+5) .data('paddingtop',toint($(this).css('padding-top'))) .data('paddingbottom',toint($(this).css('padding-bottom'))) .data('margintop',toint($(this).css('margin-top'))) .data('marginbottom',toint($(this).css('margin-bottom'))); }); function slup(obj){ if($(obj).height()>0){ $(obj).animate({height:5},{queue:false,duration:200}) .animate({paddingTop:0},{queue:false,duration:200}) .animate({paddingBottom:0},{queue:false,duration:200}) .animate({marginTop:0},{queue:false,duration:200}) .animate({marginBottom:0},{queue:false,duration:200}); } } function sldown(obj){ $(obj) .animate({height:$(obj).data('height')},{queue:false,duration:200}) .animate({paddingTop:$(obj).data('paddingtop')},{queue:false,duration:200}) .animate({paddingBottom:$(obj).data('paddingbottom')},{queue:false,duration:200}) .animate({marginTop:$(obj).data('margintop')},{queue:false,duration:200}) .animate({marginBottom:$(obj).data('marginbottom')},{queue:false,duration:200}); } function stg(obj){ if($(obj).height()>5){ slup(obj); }else{ sldown(obj); } } if(root){ for(var i=0; i0){ return false; } }); $(root.getElementsByTagName('a')[i]).mousedown(function(e){ //setData(this); }); $(root.getElementsByTagName('a')[i]).focus(function(e){ //cur1(this); }); root.getElementsByTagName('a')[i].onmouseover=function(e){ if(this.parentNode.parentNode!=root){ curh(this); } }; } $(root).hover(function (){},function (){ sethover(); }) sethover(); } }