﻿if(typeof HTMLElement!="undefined"&&!HTMLElement.prototype.insertAdjacentElement)
{HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode)
{switch(where)
{case'beforeBegin':this.parentNode.insertBefore(parsedNode,this)
break;case'afterBegin':this.insertBefore(parsedNode,this.firstChild);break;case'beforeEnd':this.appendChild(parsedNode);break;case'afterEnd':if(this.nextSibling)
this.parentNode.insertBefore(parsedNode,this.nextSibling);else this.parentNode.appendChild(parsedNode);break;}}
HTMLElement.prototype.insertAdjacentHTML=function(where,htmlStr)
{var span=document.createElement('span');span.innerHTML=htmlStr;this.insertAdjacentElement(where,span)}
HTMLElement.prototype.insertAdjacentText=function(where,txtStr)
{var parsedText=document.createTextNode(txtStr);this.insertAdjacentElement(where,parsedText);}}
var LocoMenu={initialize:function(clientId,MenuDatas,menuTheme,boxTheme,itemTheme,overTheme,nodeTemplate,delay,splitter,nodeWidth,nodeHeight,hIndent,vIndent,isHorizontal,direction,selectedTheme)
{var info=new Object();info.defBoxTheme=boxTheme;info.defItemTheme=itemTheme;info.defOverTheme=overTheme;info.nodeTemplate=nodeTemplate;info.width=nodeWidth;info.height=nodeHeight;info.vIndent=vIndent;info.hIndent=hIndent;info.delay=delay;info.clientId=clientId;if(selectedTheme==null)
info.selectedTheme=overTheme;else
info.selectedTheme=selectedTheme;var MenuInstance=loco$(clientId+'_Menu');var width=0;var hwidth=0;for(var i=0;i<MenuDatas.length;i++)
{var data=this.renderMenu(info,MenuDatas[i],isHorizontal,direction,1);MenuInstance.insertAdjacentElement("beforeEnd",data.Menu);if(data.SubMenu!=null)
data.Menu.insertAdjacentElement("beforeEnd",data.SubMenu);width+=parseInt(data.width)+2;if(data.width>hwidth)
hwidth=data.width;}
var w=this.GetWidth(menuTheme);if(w.indexOf('%')!=-1||parseInt(width)<parseInt(w))
width=w;MenuInstance.extraTheme='';this.setTheme(info,MenuInstance,menuTheme,0);},GetWidth:function(cssText)
{var sp=document.createElement('span');sp.style.cssText=cssText;return sp.style.width.replace('px','');},renderMenu:function(info,menu,isHorizontal,direction,zIndex)
{var menuElem=document.createElement('div');var subElem;var tempElem=this.renderTemplate(info,menu,isHorizontal,direction);var width=this.GetWidth(menu.it);if(width==null||width=='')
width=info.width;menuElem.extraTheme=';z-index:'+zIndex+';height:'+info.height+'px;'+(isHorizontal==true?('Float:'+(direction?'right;':'left;')):'')+(isHorizontal?'width:'+width+'px;':'');var loc=window.location+'&';var type=1;this.setTheme(info,menuElem,menu.it,type);if(menu.l!=''&&loc.indexOf(menu.l)>-1)
{type=3;this.setTheme(info,menuElem,menu.st,type);}
menuElem.type=type;menuElem.insertAdjacentHTML("afterBegin",tempElem);menuElem.info=info;menuElem.it=menu.it;menuElem.ot=menu.ot;menuElem.st=menu.st;menuElem.onmouseover=LocoMenu.menuItemOver;menuElem.onmouseout=LocoMenu.menuItemOut;if(menu.s!=null)
{subElem=document.createElement('div');var swidth=0;for(var i=0;i<menu.s.length;i++)
{var data=this.renderMenu(info,menu.s[i],false,direction,parseInt(zIndex)+1);subElem.insertAdjacentElement("beforeEnd",data.Menu);if(data.SubMenu!=null)
data.Menu.insertAdjacentElement("beforeEnd",data.SubMenu);swidth+=parseInt(data.width);}
subElem.extraTheme=';z-index:'+zIndex+';position:absolute;margin: '+(isHorizontal?(1):(parseInt(info.vIndent)-1))+'px '+(isHorizontal?'-1':(parseInt(info.width)+parseInt(info.hIndent)))+'px 0px 0px;';this.setTheme(info,subElem,menu.bt,0);subElem.style.display='none';var id=Math.round(Math.random()*100000);while(loco$('SubId_'+id)!=null)
id=Math.round(Math.random()*100000);subElem.id='SubId_'+id;menuElem.subId=subElem.id;}
var result=new Object();result.Menu=menuElem;result.SubMenu=subElem;result.width=width;return result;},setTheme:function(info,element,theme,type)
{var temp='';if(theme==null)
{switch(type)
{case 0:temp=info.defBoxTheme;break;case 1:temp=info.defItemTheme;break;case 2:temp=info.defOverTheme;break;case 3:temp=info.selectedTheme;break;}}
else
temp=theme;element.style.cssText=temp+';'+element.extraTheme;},menuItemOver:function()
{LocoMenu.setTheme(this.info,this,this.ot,2);for(var obj=loco$(this.subId);obj!=null;obj=loco$(obj.subId))
{if(obj.style.display=='block')
break;obj.style.display='block';}},menuItemOut:function()
{if(this.type==1)
LocoMenu.setTheme(this.info,this,this.it,this.type);else
if(this.type==3)
LocoMenu.setTheme(this.info,this,this.st,this.type);for(var obj=loco$(this.subId);obj!=null;obj=loco$(obj.subId))
{if(obj.style.display=='none')
break;obj.style.display='none';}},Replace:function(String,Pattern,Value)
{while(String.indexOf(Pattern)!=-1)
String=String.replace(Pattern,Value);return String;},renderTemplate:function(info,menu,isHorizontal,direction)
{var result=info.nodeTemplate;result=LocoMenu.Replace(result,'[%Title%]',menu.t);result=LocoMenu.Replace(result,'[%Link%]',menu.l);var temp=menu.i;if(temp!=null)
temp='<img src="'+menu.i+'" style="position:absolute;"/>';result=LocoMenu.Replace(result,'[%Icon%]',temp==null?'':temp);var img=' ';if(menu.s!=null)
img=isHorizontal?'<img src="images/menu_arrow_down.gif"/>':(direction?'<img src="images/menu_arrow_left.gif"/>':'<img src="images/menu_arrow_right.gif"/>');return'<table style="" cellpadding="0" cellspacing="0"><tr align=center valign=middle width=100%><td width="*">'+result+'</td></tr></table>';}}