/** начало js-меню **/
var CLR=new Object();
CLR.AddEvent=function(obj,event,handler){tmp='__tmp';obj[event]=function(e){if(!e){e=window.event;}
if(!e.target){e.target=e.srcElement;}obj[tmp]=handler;result=obj[tmp](e);obj[tmp]=null;return result;}};CLR.AddStrictEvent=function(obj,event,handler){tmp='__tmp';obj[event]=function(e){if(!e){e=window.event;}if(!e.target){e.target=e.srcElement;}obj[tmp]=handler;result=obj[tmp](e);obj[tmp]=null;e.cancelBubble=true;if(e.stopPropagation){e.stopPropagation();}return result;}};CLR.Append=function(baseVar,newValue){return newValue?newValue:baseVar;};CLR.ArrayToQuery=function(arr){var data='';for(var key in arr){data+='&'+key+'='+encodeURIComponent(arr[key]);}return data.substr(1);};CLR.FormatNumber=function(num,decNum,decSep,thSep){base=String(Math.ceil(num));fbase='';for(j=base.length;j>=0;j--){if((j<base.length-3)&&((base.length-j-1)%3==0)){fbase=thSep+fbase;}fbase=base.substr(j,1)+fbase;}base=fbase;tmp=String(Math.round(num*Math.pow(10,decNum)));decimals=tmp.substr(tmp.length-decNum,decNum);return base+decSep+decimals;};CLR.GetObject=function(id){return document.getElementById(id);};CLR.GetParentNode=function(name,node){while(node&&node.tagName.toLowerCase()!=name){node=node.parentNode;}return node;};CLR.GetClass=function(node){return(cname=node.getAttribute('class'))?cname:node.getAttribute('className');};CLR.GetCSSValue=function(element,property){if(element.currentStyle){return element.currentStyle[property];}else if(window.getComputedStyle){return document.defaultView.getComputedStyle(element,null).getPropertyValue(property);}};CLR.GetPixelLeft=function(obj){var curleft=0;if(obj.offsetParent){while(obj.offsetParent){curleft+=obj.offsetLeft;obj=obj.offsetParent;}}else if(obj.x){curleft+=obj.x;}return curleft;};CLR.GetPixelTop=function(obj){var curtop=0;if(obj.offsetParent){while(obj.offsetParent){curtop+=obj.offsetTop;obj=obj.offsetParent;}}else if(obj.y){curtop+=obj.y;}return curtop;};CLR.GetUserAgentInfo=function(){if(window.userAgentInfo){return window.userAgentInfo;}var userAgent=navigator.userAgent;var userAgentName=navigator.appName;var userAgentVersion=navigator.appVersion;var info=new Object();var matches;if(userAgentName.search(/Microsoft\sInternet\sExplorer/i)!=-1){info.engine='MSIE';info.name='Internet Explorer';matches=userAgentVersion.match(/(\d\.\d)/);if(matches&&matches[1].length>0){info.version=matches[1];}else{info.version=false;}}else if(userAgent.search(/Firefox/i)!=-1){info.engine='Gecko';info.name='Firefox';matches=userAgentVersion.match(/Firefox\/(\d\.\d)/);if(matches&&matches[1].length>0){info.version=matches[1];}else{info.version=false;}}else if(userAgent.search(/Mozilla/i)!=-1){info.engine='Gecko';info.name='Mozilla';matches=userAgentVersion.match(/(\d\.\d)/);if(matches&&matches[1].length>0){info.version=matches[1];}else{info.version=false;}}else if(userAgentName.search(/Opera/i)!=-1){info.engine='Opera';info.name='Opera';matches=userAgentVersion.match(/(\d\.\d)/);if(matches&&matches[1].length>0){info.version=matches[1];}else{info.version=false;}}else{info.engine=false;info.name=false;info.version=false;}window.userAgentInfo=info;return info;};CLR.ProcessTemplate=function(template,values){for(var key in values){template=template.replace(new RegExp('\{'+key+'\}'),values[key]);}return template;};CLR.RandomNumber=function(min,max){return Math.round(min+(max-min)*Math.random());};CLR.RandomString=function(len){matrix='0123456789abcdefghijklmnopqrstuvwxyz';str='';for(i=1;i<=len;i++){str+=matrix.substr(CLR.RandomNumber(0,matrix.length-1),1);};return str;};CLR.ReplaceNodeContents=function(dstNode,srcNode){var i,nodes,node;nodes=dstNode.childNodes;for(i=nodes.length-1;i>=0;i--){dstNode.removeChild(nodes[i]);}nodes=srcNode.childNodes;for(i=0;i<nodes.length;i++){dstNode.appendChild(nodes[i].cloneNode(true));}};CLR.RxGet=function(str,rx,i){if(m=str.match(rx)){return m[i];}};CLR.RxQuote=function(str){};CLR.SetClass=function(node,value){node.setAttribute((navigator.appName.search(/Microsoft\sInternet\sExplorer/i)!=-1)?'className':'class',value);};
function TreeMenu(target){this.__construct=function(target){this.uid=0;this.root=null;this.opened=new Object();this.browser=CLR.GetUserAgentInfo();this.classProp=(this.browser.engine=='MSIE')?'className':'class';this.cfg=new Object();this.cfg.timeout=500;this.cfg.direction=2;var menu=CLR.GetObject(target);this.BuildMenu(menu,true);};this.BuildMenu=function(ul,isRoot){ul.id=this.GetUID('ul');ul.isRoot=isRoot;if(isRoot){this.root=ul;}else{ul.style.display='none';}var self=this;var ulSel=function(e){self.OnMenuSelect(e);};var ulDes=function(e){self.OnMenuDeselect(e);};var liSel=function(e){self.OnMenuItemSelect(e);};var liDes=function(e){self.OnMenuItemDeselect(e);};CLR.AddStrictEvent(ul,'onmouseover',ulSel);CLR.AddStrictEvent(ul,'onmouseout',ulDes);for(var i=0;i<ul.childNodes.length;i++){li=ul.childNodes[i];li.id=this.GetUID('li');CLR.AddStrictEvent(li,'onmouseover',liSel);CLR.AddStrictEvent(li,'onmouseout',liDes);for(var j=0;j<li.childNodes.length;j++){child=li.childNodes[j];if(child.tagName=='UL'){li.menu=child;child.parent=ul;this.BuildMenu(child);}else if(child.tagName){CLR.AddStrictEvent(child,'onmouseover',liSel);CLR.AddStrictEvent(child,'onmouseout',liDes);}}}};this.GetMenuTop=function(li){if(li.parentNode.isRoot){switch(this.cfg.direction){case 1:return CLR.GetPixelTop(li)-li.parentNode.offsetHeight;case 2:return CLR.GetPixelTop(li);case 3:return CLR.GetPixelTop(li)+li.offsetHeight;case 4:return CLR.GetPixelTop(li);}}else{return CLR.GetPixelTop(li)-CLR.GetPixelTop(li.parentNode.parentNode);}};this.GetMenuLeft=function(li){if(li.parentNode.isRoot){switch(this.cfg.direction){case 1:return CLR.GetPixelLeft(li);case 2:return CLR.GetPixelLeft(li)+li.offsetWidth;case 3:return CLR.GetPixelLeft(li);case 4:return CLR.GetPixelLeft(li)-li.parentNode.offsetWidth;}}else{return li.offsetWidth;}};this.GetNode=function(name,node){while(node&&node.tagName!=name){node=node.parentNode;}return node;};this.GetUID=function(prefix){this.uid++;return prefix?prefix+'_'+this.uid:this.uid;};this.OnMenuSelect=function(e){this.ul=e.target;};this.OnMenuDeselect=function(e){this.ul=null;};this.OnMenuItemSelect=function(e){li=this.GetNode('LI',e.target);this.SetNodeClass(li,'selected');this.li=li;if(li.menu){this.ShowMenu(li.menu);this.HideOtherMenus(li.menu);}else{this.HideOtherMenus(li.parentNode);}if(!li.parentNode.isRoot){this.SetNodeClass(li.parentNode.parentNode,'selected');}};this.OnMenuItemDeselect=function(e){li=this.GetNode('LI',e.target);this.SetNodeClass(li,false);this.li=null;this.HideAllMenus();};this.SetNodeClass=function(node,newClass){var oldClass;if(newClass){node.setAttribute('oldclass',node.getAttribute(this.classProp));node.setAttribute(this.classProp,newClass);}else{if(oldClass=node.getAttribute('oldclass')){node.setAttribute(this.classProp,oldClass);node.removeAttribute('oldclass');}else{node.removeAttribute(this.classProp);}}};this.ShowMenu=function(ul){this.opened[ul.id]=ul;ul.style.display='block';li=ul.parentNode;ul.style.top=this.GetMenuTop(li);ul.style.left=this.GetMenuLeft(li);};this.HideMenu=function(ul){this.opened[ul.id]=null;ul.style.display='none';for(var i=0;i<ul.childNodes.length;i++){if(!ul.childNodes[i].parentNode.isRoot){this.SetNodeClass(ul.childNodes[i].parentNode.parentNode,false);}}};this.HideAllMenus=function(ok){if(ok){if(!this.li){for(var key in this.opened){if(this.opened[key]){this.HideMenu(this.opened[key]);}}}}else{window.treemenu=this;window.setTimeout('treemenu.HideAllMenus(1)',this.cfg.timeout);}};this.HideOtherMenus=function(ul){parents=new Object();node=ul;i=0;while(node&&i<100){if(node.tagName=='UL'){parents[node.id]=node;}node=node.parentNode;i++;}for(var key in this.opened){if(this.opened[key]&&(parents[key]==null)){this.HideMenu(this.opened[key]);}}};this.__construct(target);}
/** конец js-меню **/


