if(typeof document.attachEvent!='undefined'){window.attachEvent('onload',init);document.attachEvent('onmousemove',moveMouse);document.attachEvent('onclick',checkMove)}else{window.addEventListener('load',init,false);document.addEventListener('mousemove',moveMouse,false);document.addEventListener('click',checkMove,false)}var oDv=document.createElement("div");var dvHdr=document.createElement("div");var dvBdy=document.createElement("div");var windowlock,boxMove,fixposx,fixposy,lockX,lockY,fixx,fixy,ox,oy,boxLeft,boxRight,boxTop,boxBottom,evt,mouseX,mouseY,boxOpen,totalScrollTop,totalScrollLeft;boxOpen=false;ox=10;oy=10;lockX=0;lockY=0;function init(){oDv.appendChild(dvHdr);oDv.appendChild(dvBdy);oDv.style.position="absolute";oDv.style.visibility='hidden';document.body.appendChild(oDv)}function defHdrStyle(){dvHdr.innerHTML='<img  style="vertical-align:middle"  src="info.gif">&nbsp;&nbsp;'+dvHdr.innerHTML;dvHdr.style.fontWeight='bold';dvHdr.style.width='150px';dvHdr.style.fontFamily='arial';dvHdr.style.border='1px solid #A5CFE9';dvHdr.style.padding='3';dvHdr.style.fontSize='11';dvHdr.style.color='#4B7A98';dvHdr.style.background='#D5EBF9';dvHdr.style.filter='alpha(opacity=85)';dvHdr.style.opacity='0.85'}function defBdyStyle(){dvBdy.style.borderBottom='1px solid #A5CFE9';dvBdy.style.borderLeft='1px solid #A5CFE9';dvBdy.style.borderRight='1px solid #A5CFE9';dvBdy.style.width='150px';dvBdy.style.fontFamily='arial';dvBdy.style.fontSize='11';dvBdy.style.padding='3';dvBdy.style.color='#1B4966';dvBdy.style.background='#FFFFFF';dvBdy.style.filter='alpha(opacity=85)';dvBdy.style.opacity='0.85'}function checkElemBO(txt){if(!txt||typeof(txt)!='string')return false;if((txt.indexOf('header')>-1)&&(txt.indexOf('body')>-1)&&(txt.indexOf('[')>-1)&&(txt.indexOf('[')>-1))return true;else return false}function scanBO(curNode){if(checkElemBO(curNode.title)){curNode.boHDR=getParam('header',curNode.title);curNode.boBDY=getParam('body',curNode.title);curNode.boCSSBDY=getParam('cssbody',curNode.title);curNode.boCSSHDR=getParam('cssheader',curNode.title);curNode.IEbugfix=(getParam('hideselects',curNode.title)=='on')?true:false;curNode.fixX=parseInt(getParam('fixedrelx',curNode.title));curNode.fixY=parseInt(getParam('fixedrely',curNode.title));curNode.absX=parseInt(getParam('fixedabsx',curNode.title));curNode.absY=parseInt(getParam('fixedabsy',curNode.title));curNode.offY=(getParam('offsety',curNode.title)!='')?parseInt(getParam('offsety',curNode.title)):10;curNode.offX=(getParam('offsetx',curNode.title)!='')?parseInt(getParam('offsetx',curNode.title)):10;curNode.fade=(getParam('fade',curNode.title)=='on')?true:false;curNode.fadespeed=(getParam('fadespeed',curNode.title)!='')?getParam('fadespeed',curNode.title):0.04;curNode.delay=(getParam('delay',curNode.title)!='')?parseInt(getParam('delay',curNode.title)):0;if(getParam('requireclick',curNode.title)=='on'){curNode.requireclick=true;document.all?curNode.attachEvent('onclick',showHideBox):curNode.addEventListener('click',showHideBox,false);document.all?curNode.attachEvent('onmouseover',hideBox):curNode.addEventListener('mouseover',hideBox,false)}else{if(getParam('doubleclickstop',curNode.title)!='off'){document.all?curNode.attachEvent('ondblclick',pauseBox):curNode.addEventListener('dblclick',pauseBox,false)}if(getParam('singleclickstop',curNode.title)=='on'){document.all?curNode.attachEvent('onclick',pauseBox):curNode.addEventListener('click',pauseBox,false)}}curNode.windowLock=getParam('windowlock',curNode.title).toLowerCase()=='off'?false:true;curNode.title='';curNode.hasbox=1}else curNode.hasbox=2}function getParam(param,list){var reg=new RegExp('([^a-zA-Z]'+param+'|^'+param+')\\s*=\\s*\\[\\s*(((\\[\\[)|(\\]\\])|([^\\]\\[]))*)\\s*\\]');var res=reg.exec(list);var returnvar;if(res)return res[2].replace('[[','[').replace(']]',']');else return''}function Left(elem){var x=0;if(elem.calcLeft)return elem.calcLeft;var oElem=elem;while(elem){if((elem.currentStyle)&&(!isNaN(parseInt(elem.currentStyle.borderLeftWidth)))&&(x!=0))x+=parseInt(elem.currentStyle.borderLeftWidth);x+=elem.offsetLeft;elem=elem.offsetParent}oElem.calcLeft=x;return x}function Top(elem){var x=0;if(elem.calcTop)return elem.calcTop;var oElem=elem;while(elem){if((elem.currentStyle)&&(!isNaN(parseInt(elem.currentStyle.borderTopWidth)))&&(x!=0))x+=parseInt(elem.currentStyle.borderTopWidth);x+=elem.offsetTop;elem=elem.offsetParent}oElem.calcTop=x;return x}var ah,ab;function applyStyles(){if(ab)oDv.removeChild(dvBdy);if(ah)oDv.removeChild(dvHdr);dvHdr=document.createElement("div");dvBdy=document.createElement("div");CBE.boCSSBDY?dvBdy.className=CBE.boCSSBDY:defBdyStyle();CBE.boCSSHDR?dvHdr.className=CBE.boCSSHDR:defHdrStyle();dvHdr.innerHTML=CBE.boHDR;dvBdy.innerHTML=CBE.boBDY;ah=false;ab=false;if(CBE.boHDR!=''){oDv.appendChild(dvHdr);ah=true}if(CBE.boBDY!=''){oDv.appendChild(dvBdy);ab=true}}var CSE,iterElem,LSE,CBE,LBE,totalScrollLeft,totalScrollTop,width,height;var ini=false;function SHW(){if(document.body&&(document.body.clientWidth!=0)){width=document.body.clientWidth;height=document.body.clientHeight}if(document.documentElement&&(document.documentElement.clientWidth!=0)&&(document.body.clientWidth+20>=document.documentElement.clientWidth)){width=document.documentElement.clientWidth;height=document.documentElement.clientHeight}return[width,height]}var ID=null;function moveMouse(e){e?evt=e:evt=event;CSE=evt.target?evt.target:evt.srcElement;if(!CSE.hasbox){iElem=CSE;while((iElem.parentNode)&&(!iElem.hasbox)){scanBO(iElem);iElem=iElem.parentNode}}if((CSE!=LSE)&&(!isChild(CSE,dvHdr))&&(!isChild(CSE,dvBdy))){if(!CSE.boxItem){iterElem=CSE;while((iterElem.hasbox==2)&&(iterElem.parentNode))iterElem=iterElem.parentNode;CSE.boxItem=iterElem}iterElem=CSE.boxItem;if(CSE.boxItem&&(CSE.boxItem.hasbox==1)){LBE=CBE;CBE=iterElem;if(CBE!=LBE){applyStyles();if(!CBE.requireclick)if(CBE.fade){if(ID!=null)clearTimeout(ID);ID=setTimeout("fadeIn("+CBE.fadespeed+")",CBE.delay)}else{if(ID!=null)clearTimeout(ID);COL=1;ID=setTimeout("oDv.style.visibility='visible';ID=null;",CBE.delay)}if(CBE.IEbugfix){hideSelects()}fixposx=!isNaN(CBE.fixX)?Left(CBE)+CBE.fixX:CBE.absX;fixposy=!isNaN(CBE.fixY)?Top(CBE)+CBE.fixY:CBE.absY;lockX=0;lockY=0;boxMove=true;ox=CBE.offX?CBE.offX:10;oy=CBE.offY?CBE.offY:10}}else if(!isChild(CSE,dvHdr)&&!isChild(CSE,dvBdy)&&(boxMove)){if((!isChild(CBE,CSE))||(CSE.tagName!='TABLE')){CBE=null;if(ID!=null)clearTimeout(ID);fadeOut();showSelects()}}LSE=CSE}else if(((isChild(CSE,dvHdr)||isChild(CSE,dvBdy))&&(boxMove))){totalScrollLeft=0;totalScrollTop=0;iterElem=CSE;while(iterElem){if(!isNaN(parseInt(iterElem.scrollTop)))totalScrollTop+=parseInt(iterElem.scrollTop);if(!isNaN(parseInt(iterElem.scrollLeft)))totalScrollLeft+=parseInt(iterElem.scrollLeft);iterElem=iterElem.parentNode}if(CBE!=null){boxLeft=Left(CBE)-totalScrollLeft;boxRight=parseInt(Left(CBE)+CBE.offsetWidth)-totalScrollLeft;boxTop=Top(CBE)-totalScrollTop;boxBottom=parseInt(Top(CBE)+CBE.offsetHeight)-totalScrollTop;doCheck()}}if(boxMove&&CBE){bodyScrollTop=document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;bodyScrollLet=document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft;mouseX=evt.pageX?evt.pageX-bodyScrollLet:evt.clientX-document.body.clientLeft;mouseY=evt.pageY?evt.pageY-bodyScrollTop:evt.clientY-document.body.clientTop;if((CBE)&&(CBE.windowLock)){mouseY<-oy?lockY=-mouseY-oy:lockY=0;mouseX<-ox?lockX=-mouseX-ox:lockX=0;mouseY>(SHW()[1]-oDv.offsetHeight-oy)?lockY=-mouseY+SHW()[1]-oDv.offsetHeight-oy:lockY=lockY;mouseX>(SHW()[0]-dvBdy.offsetWidth-ox)?lockX=-mouseX-ox+SHW()[0]-dvBdy.offsetWidth:lockX=lockX}oDv.style.left=((fixposx)||(fixposx==0))?fixposx:bodyScrollLet+mouseX+ox+lockX+"px";oDv.style.top=((fixposy)||(fixposy==0))?fixposy:bodyScrollTop+mouseY+oy+lockY+"px"}}function doCheck(){if((mouseX<boxLeft)||(mouseX>boxRight)||(mouseY<boxTop)||(mouseY>boxBottom)){if(!CBE.requireclick)fadeOut();if(CBE.IEbugfix){showSelects()}CBE=null}}function pauseBox(e){e?evt=e:evt=event;boxMove=false;evt.cancelBubble=true}function showHideBox(e){oDv.style.visibility=(oDv.style.visibility!='visible')?'visible':'hidden'}function hideBox(e){oDv.style.visibility='hidden'}var COL=0;var stopfade=false;function fadeIn(fs){ID=null;COL=0;oDv.style.visibility='visible';fadeIn2(fs)}function fadeIn2(fs){COL=COL+fs;COL=(COL>1)?1:COL;oDv.style.filter='alpha(opacity='+parseInt(100*COL)+')';oDv.style.opacity=COL;if(COL<1)setTimeout("fadeIn2("+fs+")",20)}function fadeOut(){oDv.style.visibility='hidden'}function isChild(s,d){while(s){if(s==d)return true;s=s.parentNode}return false}var cSrc;function checkMove(e){e?evt=e:evt=event;cSrc=evt.target?evt.target:evt.srcElement;if((!boxMove)&&(!isChild(cSrc,oDv))){fadeOut();if(CBE&&CBE.IEbugfix){showSelects()}boxMove=true;CBE=null}}function showSelects(){var elements=document.getElementsByTagName("select");for(i=0;i<elements.length;i++){elements[i].style.visibility='visible'}}function hideSelects(){var elements=document.getElementsByTagName("select");for(i=0;i<elements.length;i++){elements[i].style.visibility='hidden'}}function prohod(dalsiudaje){prvek=document.getElementById(dalsiudaje);if(prvek.className=='displaynone'){prvek.className='displayblock'}else{prvek.className='displaynone'}}

/**
 * @copyright by AdOcean 2010
 * @author Piotr Sadowski
 */

var AdoElement=function(config){var that=this;this.loadingLib=false;this.buff=ado.placeholder;this.tmpBuff="";this.config=config;this.onLoad=config.onLoad;this.DOMElement={};this.regs={scriptBegin:/^\s*(<script\s*)(\s*(\w+)\s*=\s*(([^\s\"\'>]{1}[^\s>]*)|\"([^\"]*)\"|\'([^\']*)\'))*[^\w>]*>/i,scriptEnd:/(<\/script\b([^>\"\']|\"[^\"]*\"|\'[^\']*\')*>)/i,attr:/(\s*(\w+)\s*=\s*(([^\s\"\'>]{1}[^\s>]*)|\"([^\"]*)\"|\'([^\']*)\'))/};this.myWrite=function(t){that.tmpBuff+=t;};this.myWriteln=function(t){that.myWrite(t+"\n");};this.isMaster=function(){return this.config.master;};this.isSlave=function(){return this.config.slave;};this.initBuffor=function(){ado.busy=true;window.document.open=function(){};window.document.close=function(){};document.write=that.myWrite;document.writeln=that.myWriteln;};this.rewriteBuffor=function(){if(this.buff.indexOf(ado.placeholder)!==-1){this.buff=that.buff.replace(ado.placeholder,that.tmpBuff);}
else{this.buff=this.tmpBuff+this.buff;}
this.tmpBuff="";};this.preDispatch=function(){if(typeof this.config!=="object"){return;}
if(!this.config.id||!this.config.server){return;}
if(ado.protocol.substr(0,4)!=='http'){return;}
this.getDOMElement();this.emptyDOMElement();if(!this.isSlave()){if(this.config.preview){this.config.url=this.config.server;}
else{this.makeUrl();}}
this.appendRedirUrl();if(ado.mode==='old'||!ado.isBrowserSupport()){document.write("<scr"+"ipt type='text/javascript' src='"+that.config.url+"'></scr"+"ipt>");}
else{this.initBuffor();this.appendScript(this.config.url,null,true);}};this.postDispatch=function(){ado.busy=false;ado.start();};this.dispatch=function(){this.deleteComment();var arr=[];var that=this;if(this.regs.scriptBegin.test(this.buff)&&this.regs.scriptBegin.test(this.buff)){arr=this.regs.scriptBegin.exec(that.buff);var attr=this.processAttributes(arr[0]);if(attr.src){this.processSrcScript(arr,attr.src,attr.charset);}
else if(attr.language!=="VBScript"&&attr.type!='text/vbscript'){this.processInlineScript(arr);}
else{this.processVBScript(arr);}}
else{var rewrite=function(){if(that.DOMElement){that.addToDOMElement(that.buff.replace(ado.placeholder,""));that.buff="";}
if(typeof that.config.onLoad==="function"){that.onLoad();that.onLoad=false;}
that.postDispatch();};if(!this.regs.scriptBegin.test(that.buff)){var regexp=/<script/i;arr=regexp.exec(that.buff);if(arr){var index=that.buff.indexOf(arr[0]);that.DOMElement=ado.getById(that.config.id);if(that.DOMElement){that.addToDOMElement(this.buff.substr(0,index).replace(ado.placeholder,""));}
this.buff=this.buff.substr(index);this.dispatch();}
else{rewrite();}}}
return;};this.deleteComment=function(){var c=/\<!\s*--(.*?)(--\s*\>)/m;while(c.test(that.buff)){that.buff=that.buff.replace(c,"");}};this.processVBScript=function(arr){var scriptEnd=this.regs.scriptEnd.exec(that.buff);td_flashinstalled=2;td_browserFlashversion=8;this.buff=ado.placeholder+this.buff.substr(scriptEnd.index+scriptEnd[0].length);that.dispatch();};this.processSrcScript=function(arr,src,charset){that.buff=that.buff.substr(arr[0].length);var scriptEnd=this.regs.scriptEnd.exec(that.buff);this.buff=ado.placeholder+this.buff.substr(scriptEnd.index+scriptEnd[0].length);this.appendScript(src,charset);};this.appendScript=function(url,charset,fast,callback){var onscriptload=function(object){that.loadingLib=false;if(typeof callback==="function"){callback();}
that.rewriteBuffor();that.dispatch();};this.loadingLib=true;ado.loadScript(url,onscriptload,charset);return;};this.onServerEmission=function(){var empty=function(){if(typeof that.config.onServerEmissionEmpty==="function"){that.config.onServerEmissionEmpty();}};if(typeof adserver_emissions==="object"){var length=0;for(var i in adserver_emissions){if(typeof adserver_emissions[i]!=="function"){length++;}}
if(length>ado.adserverEmissions){ado.adserverEmissions++;if(typeof that.config.onServerEmission==="function"){that.config.onServerEmission();}}
else{empty();}}
else{empty();}};this.processInlineScript=function(arr){if(that.loadingLib){return;}
this.buff=this.buff.substr(arr[0].length);var scriptEnd=this.regs.scriptEnd.exec(that.buff);var iS=this.buff.substr(0,scriptEnd.index);this.buff=ado.placeholder+this.buff.substr(scriptEnd.index+scriptEnd[0].length);iS=iS.replace('/*<![CDATA[*/','');iS=iS.replace('<![CDATA[','');iS=iS.replace('/* <![CDATA[ */','');iS=iS.replace('/* ]]> */','');iS=iS.replace('/*]]>*/','');iS=iS.replace('<!--','');iS=iS.replace('//-->','');iS=iS.replace('//]]>-->','');iS=iS.replace(/\/\*.*\*\//g,'');try{ado.evaluate(iS);}
catch(ex){}
this.rewriteBuffor();this.dispatch();return;};this.processAttributes=function(tag){var att={};while(tag.length>0){var arr=that.regs.attr.exec(tag);if(!arr){break;}
tag=tag.substr(arr.index+arr[1].length);var value=null;if(arr[4]){value=arr[4];}
if(arr[5]){value=arr[5];}
if(arr[6]){value=arr[6];}
att[arr[2].toLowerCase()]=value;}
return att;};this.getDOMElement=function(){this.DOMElement=ado.getById(this.config.id);if(!this.DOMElement){return;}};this.emptyDOMElement=function(){if(this.DOMElement){this.DOMElement.innerHTML="";this.DOMElement.style.display="none";}};this.addToDOMElement=function(str){if(this.DOMElement&&str!==""){this.DOMElement.style.display="block";this.DOMElement.innerHTML+=str;}};this.insertToDOMElement=function(str){if(this.DOMElement&&str!==""){this.DOMElement.style.display="block";this.DOMElement.innerHTML=str;}};this.makeUrl=function(){if(this.config.preview){this.config.server=this.config.emiter;}
var ct=this.config.contentType;switch(ct){case'txt':case'xml':case'js':break;default:ct='js';break;}
this.config.url=ado.protocol+"//"+this.config.server;this.config.url+="/_"+(new Date()).getTime()+"/ad."+ct+"?id="+ado.trimAdoPrefix(this.config.orgId)+"/x="+screen.width+"/y="+screen.height;this.config.url+=ado.makeKeywords(this.config.keys)+ado.makeVars(this.config.vars)+ado.makeFlash();return;};this.appendRedirUrl=function(){if(this.config.redir&&this.config.redir!==""&&this.config.redir!="<%%REDIR%%>"){this.config.url=this.config.url+"/redir="+this.config.redir;}};};var AdoContainer=function(){var that=this;var userAgent=navigator.userAgent.toLowerCase();var tuneId=function(config){config.orgId=config.id;config.id=config.id+""+ado.iterator++;var de=ado.getById(config.orgId);if(de){de.id=config.id;}
return config;};var keywordEncode=function(s){var d="";var k=0;var c='';if(!s){return;}
for(k=0;k<s.length;k++){c=s.charCodeAt(k);if(c<0x80){d+=s.charAt(k);}
else
if(c>=0x80&&c<=0x7ff){d+=String.fromCharCode(((c>>6)&0x1f)|0xc0,(c&0x3f)|0x80);}
else{d+=String.fromCharCode((c>>12)|0xe0,((c>>6)&0x3f)|0x80,(c&0x3f)|0x80);}}
return escape(d).replace(/\//g,'%2F').replace(/\@/g,'%40').replace(/\*/g,'%2A').replace(/\+/g,'%2B').replace(/\%/g,'$');};this.elems=[];this.urlsMapping=[];this.masterSlaves=[];this.queue=[];this.iterator=0;this.busy=false;this.placeholder="__MARKER__";this.mode="old";this.characterEncoding=true;this.xml=false;this.previewUrl="";this.previewEnabled=[];this.tmp=[];this.adserverEmissions=0;this.windowLoad=false;this.protocol="";this.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};this.config=function(cfg){this.mode=cfg.mode;this.xml=cfg.xml;this.characterEncoding=cfg.characterEncoding;if(cfg.protocol){this.protocol=cfg.protocol;}
else{this.protocol=location.protocol;}};this.resolvId=function(id,soft){for(var i in ado.elems){var cfg=ado.elems[i].config;if(cfg){if(soft){if(cfg.orgId===id||cfg.orgId==="ado-"+id){return i;}}
else{if((cfg.orgId===id||cfg.orgId==="ado-"+id)&&ado.elems[i].begin===false){return i;}}}}
return false;};this.addAdoPrefix=function(config){if(config.id.length===46){config.id="ado-"+config.id;}
return config;};this.trimAdoPrefix=function(orgId){if(orgId.length==46){return orgId;}
else if(orgId.indexOf('ado-')===0){return orgId.substring(4,50);}
else{return orgId;}};this.beginCreative=function(config){var tmp=this.elems[ado.resolvId(config.id,true)];if(tmp){tmp.onServerEmission();}
return tmp;};this.beginExternal=function(){};this.endExternal=function(){};this.refresh=function(id){var elem=ado.elems[ado.resolvId(id,true)];if(elem.isMaster()){ado.master(elem.config);this.masterSlaves[elem.config.orgId]=[];for(var i in ado.elems){if(typeof ado.elems[i]==="object"&&ado.elems[i].config.slave&&ado.elems[i].config.myMaster===elem.config.orgId){var config=ado.elems[i].config;ado.elems[i].emptyDOMElement();ado.slave(config.orgId,config);}}}
else{ado.placement(elem.config);ado.start();}};this.placement=function(config){if(!config.id||!config.server){return;}
if(!config.orgId){config=tuneId(config);}
var test=(ado.mode=="new"&&!ado.windowLoad&&this.isBrowserSupport());if((ado.mode=="new"&&!ado.windowLoad&&this.isBrowserSupport())||ado.busy){ado.queue.unshift(function(){ado.placement(config);});return;}
if(ado.previewEnabled['http://'+config.server]){config.preview=true;config.server=ado.previewUrl+"?id="+ado.trimAdoPrefix(config.orgId);}
this.elems[config.id]=new AdoElement(config);if(!ado.elems[config.id].DOMElement){return;}
this.elems[config.id].preDispatch();};this.master=function(config){config.master=true;if((ado.mode=="new"&&!ado.windowLoad&&this.isBrowserSupport())||ado.busy){ado.queue.unshift(function(){ado.master(config);});return;}
if(!config.orgId){config=tuneId(config);}
if(typeof this.masterSlaves[config.orgId]==="undefined"){this.masterSlaves[config.orgId]=[];}
this.elems[config.id]=new AdoElement(config);if(ado.previewEnabled['http://'+config.server]){config.preview=true;config.server=ado.previewUrl+"?id="+ado.trimAdoPrefix(config.orgId);}
this.elems[config.id].preDispatch();};this.slave=function(fnName,config){if(!fnName||typeof fnName!=="string"||fnName===""){return;}
if(!config||!config.myMaster){return;}
if(!config.id){config.id=fnName;}
config.slave=true;if((ado.mode=="new"&&!ado.windowLoad&&this.isBrowserSupport())||ado.busy){ado.queue.unshift(function(){ado.slave(fnName,config);});return;}
if(typeof this.masterSlaves[config.myMaster]!=="object"){this.masterSlaves[config.myMaster]=[];}
this.masterSlaves[config.myMaster].push(fnName);if(!config.orgId){config=tuneId(config);}
this.elems[config.id]=new AdoElement(config);this.elems[config.id].getDOMElement();this.elems[config.id].emptyDOMElement();if(ado.mode==="old"||!this.isBrowserSupport()){document.write("<scr"+"ipt type='text/javascript'>if(typeof "+config.orgId+"=='function'){"+config.orgId+"();}</scr"+"ipt>");if(typeof config.onLoad==="function"){config.onLoad();config.onLoad=false;}}
else{this.slaveStart(config);}};this.slaveStart=function(config){eval(config.orgId);this.elems[config.id].buff="<scr"+"ipt type=\"text/javascript\">"+config.orgId+"();</scr"+"ipt>";this.elems[config.id].begin=false;this.elems[config.id].initBuffor();this.elems[config.id].dispatch();};this.preview=function(config){if(config.enabled===false){return;}
config.server=config.emiter;if(config.preview!==true){config.url=ado.protocol+"//"+config.server+'/_'+(new Date()).getTime()+'/ad.js?id='+config.id;}
if(!config.orgId){config=tuneId(config);}
if(ado.mode=='new'&&!ado.windowLoad&&ado.isBrowserSupport()){ado.queue.unshift(function(){ado.preview(config);});return}
if(ado.mode=="old"){document.write('<sc'+'ript src="'+config.url+'"></scr'+'ipt>');}
else{this.elems[config.id]=new AdoElement(config);this.elems[config.id].preDispatch();}};this.turnOnPreview=function(){for(var i in ado.tmp){if(typeof ado.previewEnabled[ado.tmp[i]]!=='function'){ado.previewEnabled[ado.tmp[i]]=true;}}
ado.tmp=[];};this.turnOffPreview=function(){for(var i in ado.previewEnabled){if(typeof ado.previewEnabled[i]!=="function"){if(ado.previewEnabled[i]){ado.tmp.push(i);}
ado.previewEnabled[i]=false;}}};this.getByTag=function(n,i){if(!i){i=0;}
var objs=ado.getAllByTag(n);return objs[i];};this.getAllByTag=function(n){var objs=[];if(document.all){objs=document.all.tags(n);}
else if(document.getElementsByTagName){objs=document.getElementsByTagName(n);}
else if(document.layers){objs=document.layers[n];}
return objs;};this.bind=function(elem,eventName,fn){if(elem.addEventListener){elem.addEventListener(eventName,fn,false);}
else if(elem.attachEvent){elem.attachEvent("on"+eventName,fn);}
else if(document.getElementById){}};this.isBrowserSupport=function(){return(document.createElement&&document.appendChild&&document.getElementById)?true:false;};this.evaluate=function(code){if(window.execScript){window.execScript(code);return null;}
var result=globalScope.eval?globalScope.eval(code):eval(code);return result;};this.loadScript=function(url,callback,charset){var done=false;var script=document.createElement('script');var indexOf=url.indexOf("javascript:");if(url.indexOf("javascript:")!==-1){var fn=url.substr(indexOf);ado.evaluate(fn);callback(this);return;}
script.src=url;if(typeof charset!=="undefined"&&charset!==null){script.charset=charset;}
script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;callback(this);}};if(ado.browser.msie&&ado.loadingPreviewSettings){ado.onDOMReady(function(){ado.head.appendChild(script);});}
else{ado.head.appendChild(script);}};this.makeKeywords=function(keys){var addNuggaddKey=function(keys){if(typeof na_prof==='string'){if(keys===''){keys='/key=';}
else{keys+=',';}
keys+=na_prof;}
return keys;}
if(typeof keys==='string'){keys=keys.split(',');}
var k='';if(typeof keys==='object'&&keys.length>0){for(var key in keys){if(typeof keys[key]==="string"){if(ado.characterEncoding){k+=","+keywordEncode(keys[key].toLowerCase());}
else{k+=","+keys[key].toLowerCase();}}}
k="/key="+k.slice(1);}
k=addNuggaddKey(k);return k;};this.makeVars=function(vars){var v='';if(typeof vars==='object'){for(var key in vars){if(typeof vars[key]==="string"||typeof vars[key]==='number'){v+="/"+key+"="+vars[key];}}}
else if(typeof vars==='string'){if(vars.charAt(0)!=="&"){vars="&"+vars;}
if(vars.charAt(vars.length-1)==="&"){vars=vars.substr(0,vars.length-1);}
vars=vars.replace("&","/");while(vars.indexOf('&')!==-1){vars=vars.replace("&","/");}
v=vars;}
return v;};this.makeFlash=function(){var fv='-';var fo=null;eval('try { f=(d==top.document)?1:2; if (typeof top.document.referrer=="string") { ref=top.document.referrer } } catch(e) {f=3;}');eval('try { fv=navigator.plugins["Shockwave Flash"].description; } catch (e) {}');eval('if (typeof ActiveXObject!="undefined") { try { fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); } catch(e) { try { fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); fv="X"; fo.AllowScriptAccess="always"; } catch(e) { if (fv=="X") { fv="WIN 6,0,20,0"; }} try { fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch(e) {} } if ((fv=="-" || fv=="X") && fo) { fv=fo.GetVariable("$version"); }}');return'/fv='+escape(fv);};this.getById=function(id){return document.getElementById(id);};this.onDOMReady=function(readyFn){var countStyleSheets=function(){var style=ado.getAllByTag('style');var links=ado.getAllByTag('link');var j=0;for(var i in links){if(links[i].rel==="stylesheet"){j++;}}
return style.length+j;};function bindReady(){if(document.addEventListener&&!ado.browser.opera){document.addEventListener("DOMContentLoaded",readyFn,false);ado.windowLoad=true;return;}
else if(ado.browser.msie&&window==top){(function(){if(ado.windowLoad){return;}
try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,1);return;}
readyFn();ado.windowLoad=true;return;})();}
else if(ado.browser.opera){document.addEventListener("DOMContentLoaded",function(){if(ado.windowLoad){return;}
for(var i=0;i<document.styleSheets.length;i++){if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}}
readyFn();ado.windowLoad=true;return;},false);}
else if(ado.browser.safari){var numStyles;(function(){if(ado.windowLoad){return;}
if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}
if(numStyles===undefined){numStyles=countStyleSheets();}
if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}
readyFn();ado.windowLoad=true;return;})();}
else{window.onload=readyFn;ado.windowLoad=true;return;}}
bindReady();};this.closeLivePreview=function(){window.location=ado.previewDisableUrl+"?url="+encodeURIComponent(encodeURIComponent(window.location.href));};this.start=function(){if(ado.queue.length>0){var fn=ado.queue.pop();if(typeof fn==="function"){fn();}}}};if(typeof ado==="undefined"){ado=new AdoContainer();if(typeof ado.head==="undefined"){ado.head=ado.getByTag("head",0);}
var go=function(){ado.windowLoad=true;ado.start();}
if(window.addEventListener){window.addEventListener("load",go,true);}
else if(window.attachEvent){window.attachEvent("onload",go);}
else if(document.getElementById){window.onload=go;}}
var globalScope=this;

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
}

function google_ad_request_done(google_ads) {
    /*
    * This function is required and is used to display
    * the ads that are returned from the JavaScript
    * request. You should modify the document.write
    * commands so that the HTML they write out fits
    * with your desired ad layout.
    */

    var boxAds_1 = "";
    var boxAds_2 = "";
    var boxAds_3 = "";
    var boxAds_4 = "";
    var ads_div_1_parts = new Array(2);
    var ads_div_2_parts = new Array(2);
    var ads_div_3_parts = new Array(2);
    var ads_div_4_parts = new Array(2);
    var i;
    var rows_separator;

    // Divs we use to display data
    if ((typeof(adsense_unit_1) != "undefined") && adsense_unit_1 != "") {
        ads_div_1_parts = adsense_unit_1.split(":", 2);
    }
    if ((typeof(adsense_unit_2) != "undefined") && adsense_unit_2 != "") {
        ads_div_2_parts = adsense_unit_2.split(":", 2);
    }

    if ((typeof(adsense_unit_3) != "undefined") && adsense_unit_3 != "") {
        ads_div_3_parts = adsense_unit_3.split(":", 2);
    }
    if ((typeof(adsense_unit_4) != "undefined") && adsense_unit_4 != "") {
        ads_div_4_parts = adsense_unit_4.split(":", 2);
    }

    // Default number of ads for each separate type
    if (!ads_div_1_parts[1]) {ads_div_1_parts[1] = 3;}
    if (!ads_div_2_parts[1]) {ads_div_2_parts[1] = 3;}
    if (!ads_div_3_parts[1]) {ads_div_3_parts[1] = 3;}
    if (!ads_div_4_parts[1]) {ads_div_4_parts[1] = 3;}

    var s = '';


    if (!ad_detail) ad_detail = '';

    /*
    * Verify that there are actually ads to display.
    */
    if (google_ads.length == 0) {
    return;
    }

    //if (getQueryVariable('y')) alert(google_ads.length);

    /*
    * If an image ad is returned, display that ad.
    * Otherwise, build a string containing all the ads and
    * then use a document.write() command to print that string.
    */

    if (google_ads[0].type == "image") {

           s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' +
        '<a target="_blank" href="' + google_ads[0].url +
        '" target="_top" title="go to ' + google_ads[0].visible_url +
        '"><img border="0" src="' + google_ads[0].image_url +
        '"width="' + google_ads[0].image_width +
        '"height="' + google_ads[0].image_height + '"></a>';

    } else {

        if (!ad_detail){
            if (google_ads.length == 1) {
                /*
                * Partners should adjust text sizes
                * so ads occupy the majority of ad space.
                */
                boxAds_1 += '<p style="text-align:left;margin-left:120px"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a></p>'
                for(i = 0; i < google_ads.length; ++i) {
                    boxAds_1 += '<p class="adsensetitle' + ad_detail +'"><a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].line1 + '</a></p>' +
                    '<p class="adsensepopisek">' +
                    google_ads[i].line2 + ' ' +
                    google_ads[i].line3 +

                    ' <a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].visible_url + '</a>'

                    + '</p>';
                }

            } else if (google_ads.length > 1) {

                boxAds_1 += '<p style="text-align:left;margin-left:120px"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a></p>';
                boxAds_2 += '<p style="text-align:left;margin-left:120px"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a></p>';
                boxAds_3 += '<p style="text-align:left;margin-left:120px"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a></p>';

                /*
                 * For text ads, append each ad to the string.
                 */

                for(i = 0; i < google_ads.length; ++i) {
                    if (i < parseInt(ads_div_1_parts[1])) {
                        boxAds_1 += '<p class="adsensetitle' + ad_detail +'"><a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].line1 + '</a></p>' +
                    '<p class="adsensepopisek">' +
                    google_ads[i].line2 + ' ' +
                    google_ads[i].line3 +

                    ' <a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].visible_url + '</a>'

                    + '</p>';
                    }
                    else if (i < (parseInt(ads_div_1_parts[1]) + parseInt(ads_div_2_parts[1]))) {
                        boxAds_2 += '<p class="adsensetitle' + ad_detail +'"><a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].line1 + '</a></p>' +
                    '<p class="adsensepopisek">' +
                    google_ads[i].line2 + ' ' +
                    google_ads[i].line3 +

                    ' <a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].visible_url + '</a>'

                    + '</p>';
                    }
                    else if (i < (parseInt(ads_div_1_parts[1]) + parseInt(ads_div_2_parts[1]) + parseInt(ads_div_3_parts[1]))) {
                        boxAds_3 += '<p class="adsensetitle' + ad_detail +'"><a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].line1 + '</a></p>' +
                    '<p class="adsensepopisek">' +
                    google_ads[i].line2 + ' ' +
                    google_ads[i].line3 +

                    ' <a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].visible_url + '</a>'

                    + '</p>';
                    }
                }



            }

        }else{

            if (google_ads.length == 1) {
                /*
                * Partners should adjust text sizes
                * so ads occupy the majority of ad space.
                */
                boxAds_4 += '<p style="text-align:left"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a></p>';
                for(i = 0; i < google_ads.length; ++i) {
                    boxAds_4 += '<p class="adsensetitle' + ad_detail +'"><a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].line1 + '</a></p>' +
                    '<p class="adsensepopisek' + ad_detail +'">' +
                    google_ads[i].line2 + ' ' +
                    google_ads[i].line3 + '</p>' +
                    '<p class="adsenseurl' + ad_detail +'"><a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].visible_url + '</a></p>';
                }

            } else if (google_ads.length > 1) {


                boxAds_4 += '<p style="text-align:left"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a></p>';

                /*
                 * For text ads, append each ad to the string.
                 */

                for(i = 0; i < google_ads.length; ++i) {
                    if (i < parseInt(ads_div_4_parts[1])) {
                        boxAds_4 += '<p class="adsensetitle' + ad_detail +'"><a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].line1 + '</a></p>' +
                    '<p class="adsensepopisek' + ad_detail +'">' +
                    google_ads[i].line2 + ' ' +
                    google_ads[i].line3 + '</p>' +
                    '<p class="adsenseurl' + ad_detail +'"><a target="_blank" href="' + google_ads[i].url + '" ' +
                    'onmouseout="window.status=\'\'" ' +
                    'onmouseover="window.status=\'go to ' +
                    google_ads[i].visible_url + '\'" ' + '>' +
                    google_ads[i].visible_url + '</a></p>';
                    }

                }
            }
        }
    }
    /*
    onClick="javascript: pageTracker._trackPageview(\'/adsenseclick/' + google_ads[i].visible_url + '\');"
    */

    // Assing HTML
    if ((typeof(ads_div_1_parts[0]) != "undefined") && ads_div_1_parts[0] != "") {
        document.getElementById(ads_div_1_parts[0]).innerHTML = boxAds_1;
    }
    if ((typeof(ads_div_2_parts[0]) != "undefined") && ads_div_2_parts[0] != "") {
        document.getElementById(ads_div_2_parts[0]).innerHTML = boxAds_2;
    }
    if ((typeof(ads_div_3_parts[0]) != "undefined") && ads_div_3_parts[0] != "") {
        document.getElementById(ads_div_3_parts[0]).innerHTML = boxAds_3;
    }
    if ((typeof(ads_div_4_parts[0]) != "undefined") && ads_div_4_parts[0] != "") {
        document.getElementById(ads_div_4_parts[0]).innerHTML = boxAds_4;
    }


    //document.write(s);
    return;
  }



  




function skrytodkryt(prvek){
    if (document.getElementById(prvek).className=="displaynone") {
        document.getElementById(prvek).className="displayblock";
    }else document.getElementById(prvek).className="displaynone";
}
function checkuncheck(prvek){
    if (document.getElementById(prvek).checked==false) {
        document.getElementById(prvek).checked=true;
    }else document.getElementById(prvek).checked=false;
}
function skryt(prvek){
    document.getElementById(prvek).style.display="none";
}
function odkryt(prvek){
    document.getElementById(prvek).style.display="block";
}
function disableprvek(prvek){
    document.getElementById(prvek).disabled=true;
}
function enableprvek(prvek){
    document.getElementById(prvek).disabled=false;
}
function vypln(co,cim){
    prvek = document.getElementById(co);
    prvek.value = cim;
}


/*NLS*/
var nlsTree = new Object();
var nlsTreeIc = new Object();

var _ua=window.navigator.userAgent;
var nls_isIE = (_ua.indexOf("MSIE") >=0);
var nls_isSafari = (_ua.indexOf("Safari") >=0);
var nls_isOpera = (_ua.indexOf("Opera") >=0);
if (nls_isOpera) nls_isIE=false;

var NLSTREE = NlsTree.prototype;
function NlsTree(tId) {
  this.tId = tId;
  this.opt = new StdOpt();
  this.nLst = {};
  this.ctxMenu = null;
  this.rt = null;
  this.selNd = null;
  this.defImgPath="/img/treemenu/";
  this.chUrl=null;

  /*internal*/
  this.selElm=null;
  this.tmId = null;
  this.nCnt = 0;
  this._fl=true;
  this.msNds={};
  this.rtm={};

  nlsTree[this.tId] = this;

  var asc = (document.getElementsByTagName ? document.getElementsByTagName("SCRIPT"): document.scripts);
  for (var i=0;i<asc.length;i++) {
    if (asc[i].src.toLowerCase().indexOf("nlstree.js")>=0) {this.defImgPath=asc[i].src.replace(/nlstree.js/gi, "../../img/treemenu/");break;}
  }

  this.useIconSet(new StdIco(this.defImgPath));
  this.renderer = new DefRenderer(tId);

  return this;
};

function NlsTreeUtil() {};

function StdIco(path) {
    path = 'http://img.i-bazar.cz/img/treemenu/';
  this.pnb = path+"plusnb.gif";
  this.pb  = path+"plusb.gif";
  this.pnl = path+"plusnl.gif";
  this.mnb = path+"minusnb.gif";
  this.mb  = path+"minusb.gif";
  this.mnl = path+"minusnl.gif";
  this.opf = path+"folderopen.gif";
  this.clf = path+"folder.gif";
  this.chd = path+"leaf.gif";
  this.rot = path+"root.gif";
  this.lnb = path+"lineang.gif";
  this.lb  = path+"lineints.gif";
  this.lin = path+"line.gif";
  this.bln = path+"blank.gif";
  this.lod = path+"loading.gif";

  this.toString = function() { return "Standard Icons"}  ;
  return this;
};

function StdOpt() {
  this.enbScroll=false;
  this.height="300px";
  this.width="200px";
  this.trg = "_self";
  this.stlprf = "";
  this.sort = "no"; /*desc, no, asc*/
  this.icon = true;
  this.check = false;
  this.editable = false;
  this.selRow = false;
  this.editKey = 113;
  this.oneExp = false;
  this.enableCtx = true;
  this.oneClick = false;
  this.mntState = false;
  this.icAsSel=false;
  this.checkIncSub=true;
  this.checkParents=false;
  this.indent=true;
  this.hideRoot=false;
  this.showExpdr=false;
  this.checkOnLeaf=false;
  this.renderOnDemand=false;

  this.evDblClick=false;
  this.evCtxMenu=false;
  this.evMouseUp=false;
  this.evMouseDown=false;
  this.evMouseMove=false;
  this.evMouseOut=false;
  this.evMouseOver=false;

  return this;
};

function NlsNode(orgId, capt, url, ic, exp, chk, xtra, title) {
  this.orgId = orgId;
  this.id = "";
  this.capt = capt;
  this.url = (url==null || url=="") ? "" : url;
  this.ic = null;
  this.exp = exp==null ? false : exp;
  this.chk = (chk?chk:false);
  this.xtra = xtra==null ? false : xtra;
  this.ctxMenu = null;
  this.cstStyle = "";
  this.trg=null;
  this.custom=null;
  this.title=title==null?capt:title;
  this.editablity=true;
  this.checkbox=true;

  this.setIcon=function(ic) {
    var ac=(ic==null||ic=="")?null:ic.split(",");
    if (ac) {for(var i=0;i<ac.length;i++) preloadIcon(ac[i]);};
    this.ic=ac;
  }
  this.isCustomNode=function() {return this.custom==null;};
  this.nx = null; this.pv = null; this.fc = null; this.lc = null; this.pr = null;
  this.equals = function (nd) {if(!nd) return false; else return (this.id == nd.id); };
  this.setIcon(ic);
};

NLSTREE.genIntId = function(id) { return this.tId+id; };
NLSTREE.genOrgId = function(intId) { return intId.substr(this.tId.length); };
NLSTREE.compareNode = function(aN, bN) { return (aN.capt >= bN.capt); };

NLSTREE.add = function(id, prn, capt, url, ic, exp, chk, xtra, title) {
  var nNd = new NlsNode(((id==null||String(id)=="")?("int"+ (++this.nCnt)):id), capt, url, ic, exp, chk, xtra, title);
  nNd.id = this.genIntId(nNd.orgId);
  if (this.nLst[nNd.id]!=null) { return; }
  if (this.rt==null) { this.rt = nNd; } else {
    var pnd = this.nLst[this.genIntId(prn)];
    if (pnd==null ) { return; }
    nNd.pr = pnd;
    if (pnd.lc==null) {
        pnd.fc = nNd; pnd.lc = nNd;
    } else {
      var t=pnd.fc;
      if (this.opt.sort!="no") {
        do {
          if (this.opt.sort=="asc" ? this.compareNode(t, nNd) : this.compareNode(nNd, t)) break;
          t = t.nx;
        } while (t!=null);
        if (t!=null) {
          if (t.pv==null) { t.pv=nNd; pnd.fc=nNd; } else { nNd.pv=t.pv; t.pv.nx=nNd; t.pv=nNd; }
          nNd.nx=t;
        }
      }
      if (this.opt.sort=="no" || t==null) { nNd.pv = pnd.lc; pnd.lc.nx = nNd; pnd.lc = nNd; }
    }
  }
  this.nLst[nNd.id] = nNd;
  return nNd;
};

NLSTREE.addCustomNode=function(id, prn, custom) {
  var nd=this.add(id, prn, ""); nd.capt=""; nd.custom=custom;
  return nd;
};

NLSTREE.addBefore = function (id, sib, capt, url, ic, exp, chk, xtra, title) {
  var nd=this.getNodeById(sib);
  if (nd==null) return;

  var nNd = new NlsNode(((id==null||id=="")?("int"+ (++this.nCnt)):id), capt, url, ic, exp, chk, xtra, title);
  nNd.id = this.genIntId(nNd.orgId);
  if (this.nLst[nNd.id]!=null) { alert("Item with id " + id + " already exist"); return; }
  this.nLst[nNd.id] = nNd; nNd.pr=nd.pr; nNd.nx=nd;
  if (nd.pv==null) { nd.pv=nNd; nd.pr.fc=nNd; } else { nNd.pv=nd.pv; nd.pv.nx=nNd; nd.pv=nNd; }
  return nNd;
};

NLSTREE.addAfter = function (id, sib, capt, url, ic, exp, chk, xtra, title) {
  var nd=this.getNodeById(sib);
  if (nd==null) return;

  var nNd = new NlsNode(((id==null||id=="")?("int"+ (++this.nCnt)):id), capt, url, ic, exp, chk, xtra, title);
  nNd.id = this.genIntId(nNd.orgId);
  if (this.nLst[nNd.id]!=null) { alert("Item with id " + id + " already exist"); return; }
  this.nLst[nNd.id] = nNd; nNd.pr=nd.pr; nNd.pv=nd;
  if (nd.nx==null) { nd.nx=nNd; nd.pr.lc=nNd; } else { nNd.nx=nd.nx; nd.nx.pv=nNd; nd.nx=nNd; }
  return nNd;
};

NLSTREE.append = function(id, prn, capt, url, ic, exp, chk, xtra, title) {
  var nd = this.add(id, prn, capt, url, ic, exp, chk, xtra, title);
  this.reloadNode(prn);
  return nd;
};

NLSTREE.remove = function(id, reload) {
  var rNd = (id!=null ? this.nLst[this.genIntId(id)] : this.selNd);
  if (rNd!=null) {
    if (this.rt.equals(rNd)) { this.rt=null; this.nLst=new Object(); this.selNd=null; this.selElm=null; return rNd};
    if (this.selNd && rNd.equals(this.selNd)) { this.selNd=null; this.selElm=null; }
    var pr = rNd.pr;
    if (pr.lc.equals(rNd)) pr.lc=rNd.pv;
    if (pr.fc.equals(rNd)) pr.fc=rNd.nx;
    if (rNd.pv!=null) rNd.pv.nx=rNd.nx;
    if (rNd.nx!=null) rNd.nx.pv=rNd.pv;
    rNd.nx=null;rNd.pv=null;rNd.pr=null;
    var treeId = this.tId;
    this.loopTree(rNd, function (n) { nlsTree[treeId].nLst[n.id]=null;});
    if (this.opt.multiSel) { delete this.msNds[rNd.id]; }
    if (reload==null || reload) this.reloadNode(this.genOrgId(pr.id));
  }
  return rNd;
};

NLSTREE.removeSelected = function() {
  var sNds=this.getSelNodes();
  for (var i=0; i<sNds.length; i++) {
    this.remove(sNds[i].orgId);
  }
}

NLSTREE.removeChilds = function(id, reload) {
  var rNd = (id!=null ? this.nLst[this.genIntId(id)] : this.selNd);
  if (rNd!=null) {
    while(rNd.fc) this.remove(rNd.fc.orgId, false);
    if (reload==null || reload) this.reloadNode(id);
  }
};

NLSTREE.getSelNode = function() { return this.selNd; };

NLSTREE.getSelNodes=function() {
  var a=[];
  if (this.opt.multiSel) { for (var it in this.msNds) {if(this.msNds[it] instanceof NlsNode) a[a.length]=this.msNds[it]; } } else
  if (this.selNd!=null) { a[0]=this.selNd; }
  return a;
}

NLSTREE.isSelected=function(orgId) {
  var nd=this.getNodeById(orgId);
  var sNds=this.getSelNodes();
  for (var i=0; i<sNds.length; i++) {  if (nd.id==sNds[i].id) return true; }
  return false;
}

NLSTREE.genTree = function() { return this.renderer.genTree(); };

NLSTREE.genAttrib=function() {
  var attr="<input id='ndedt"+this.tId+"' type='text' class='"+this.opt.stlprf+"nodeedit' style='display:none' value='' onblur='if (nlsTree."+this.tId+"._fl) nlsTree."+this.tId+".liveNodeWrite()'>" +
    (!NlsGetElementById("ddGesture")?"<div id='ddGesture' style='position:absolute;border:#f0f0f0 1px solid;left:0px;top:0px;display:none'></div>":"");
  if (typeof(nlsctxmenu)!="undefined") {
    for (var it in nlsctxmenu) {
      if(nlsctxmenu[it] instanceof NlsCtxMenu) {
        if(!NlsGetElementById(it)) attr+=nlsctxmenu[it].genMenu();         
      }
    }
  }
  return attr;
}

NLSTREE.renderAttributes = function(plc) {
  var oPl=(plc?NlsGetElementById(plc):null);
  if(oPl) oPl.innerHTML="";
  var attr=this.genAttrib();
  if(oPl) oPl.innerHTML=attr; else document.write(attr);
};

NLSTREE.render = function(plc) {
  //generate the attributes.
  var dv=NlsGetElementById(this.tId+"$attr");
  if(!dv) {
    dv=document.createElement("SPAN");dv.id=this.tId+"$attr";
    document.body.insertBefore(dv, document.body.childNodes[0]);
  } else {dv.innerHTML="";}
  dv.innerHTML=this.genAttrib();

  if(this.opt.renderOnDemand) this.renderer.genNodes=DefRenderer.$genNodes;

  this.renderer.render(plc);
  this.initEvent();
  this.selNd=null; this.selElm=null;

  var sid=null;
  if (this.opt.mntState && nls_getCookie) {
    var sid=nls_getCookie(this.tId+"_selnd");
    nls_maintainNodeState(this.tId, true);
  }

  if(sid && sid!="") this.selectNodeById(sid);
};

/*render to specific node, incCh:include current node*/
NLSTREE.renderTo=function(id, incCh) {
  var n=this.getNodeById(id), tmp=n, apt=[];
  if(incCh && n.fc && !NlsGetElementById(n.fc.id)) {apt[apt.length]=n;}
  while (tmp) {if(NlsGetElementById(tmp.id)) break; apt[apt.length]=tmp.pr; tmp=tmp.pr;}
  for(var i=apt.length;i>0;i--) { this.reloadNode(apt[i-1].orgId); }
}

function DefRenderer(tId) {
  var tr=nlsTree[tId];

  this.tr=tr;
  this.rat=new Object();
  this.dsp=new Object();

  this.initRender = function() {
    var opt=tr.opt; var ico=tr.ico;
    var ev="onclick=\"return nls_c2(event, '"+tId+"','@id')\" ";
    if (opt.evDblClick) ev+="ondblclick=\"return nls_c3(event, '"+tId+"', '@id')\" ";
    if (opt.evCtxMenu) ev+="oncontextmenu=\"return nls_c4(event, '"+tId+"', '@id')\" ";
    if (opt.evMouseUp) ev+="onmouseup=\"return nls_c5(event, '"+tId+"', '@id')\" ";
    if (opt.evMouseDown) ev+="onmousedown=\"return nls_c6(event, '"+tId+"', '@id')\" ";
    if (opt.evMouseOver) ev+="onmouseover=\"return nls_c7(event, '"+tId+"', '@id')\" ";
    if (opt.evMouseOut) ev+="onmouseout=\"return nls_c8(event, '"+tId+"', '@id')\" ";
    if (opt.evMouseMove) ev+="onmousemove=\"return nls_c9(event, '"+tId+"', '@id')\" ";

    var cbev="onclick=\"nls_cb1(event, '"+tId+"','@id')\"";
    var ex=["<img src='@expdr' onclick=\"nls_c1(event, '"+tId+"', '@id')\" onmouseover=\"nls_c11(event, '"+tId+"', '@id')\" onmouseout=\"nls_c12(event, '"+tId+"', '@id')\" />", "<img src='@expdr' />", "<img src='@ic' "+ev+" />"];

    this.rat["cnt"]=["<div id='@id' class='"+opt.stlprf+"row' title=\"@title\">", "<div id='@id' class='"+opt.stlprf+"row' title=\"@title\" style='display:none'>", "</div><div style='display:block' id='ch_@id'>", "</div><div style='display:none' id='ch_@id'>"];
    this.rat["ex"]=[[[ex[1].replace(/@expdr/gi,ico.lnb),ex[1].replace(/@expdr/gi,ico.lb)],[ex[1].replace(/@expdr/gi,ico.lnb),ex[1].replace(/@expdr/gi,ico.lb)]],
                    [[ex[0].replace(/@expdr/gi,ico.pnb),ex[0].replace(/@expdr/gi,ico.pb)],[ex[0].replace(/@expdr/gi,ico.mnb),ex[0].replace(/@expdr/gi,ico.mb)]]];
    this.rat["mn"]=["<table cellspacing=0 cellpadding=0><tr><td nowrap>","</td><td nowrap>", "</td><td nowrap>","</td><td nowrap>", "</td><td width='100%'>", "</td></tr></table>"];
    this.rat["ics"]=ex[2];
    this.rat["ic"]=[[ex[2].replace(/@ic/gi, ico.chd), ex[2].replace(/@ic/gi, ico.chd)], [ex[2].replace(/@ic/gi, ico.clf), ex[2].replace(/@ic/gi, (tr.opt.icAsSel?ico.clf:ico.opf))]];
    this.rat["rt"]=[ex[2].replace(/@ic/gi, ico.rot), [ex[0].replace(/@expdr/gi,ico.pnl), ex[0].replace(/@expdr/gi,ico.mnl)]];
    this.rat["ln"]=["<img src=\""+ico.bln+"\" />", "<img src=\""+ico.lin+"\" />"];
    this.rat["cust"]=["<img src=\""+ico.lb+"\" />", "<img src=\""+ico.lb+"\" />"];
    this.rat["ac"]=["<label for='rb_@id' onclick='javascript:prvek = document.getElementById(\"rb_@id\"); if (prvek) prvek.checked=\"checked\";'><a class=\"@nstyle\" style='display:block' href=\"javascript:void(0);\" "+ev+" >@capt</a></label>", "<a class=\"@nstyle\" style='display:block' "+ev+" href=\""];
    //EDIT this.rat["ac"]=["<a class=\"@nstyle\" style='display:block' href=\"javascript:void(0);\" "+ev+" >@capt</a>", "<a class=\"@nstyle\" style='display:block' target='@trg' "+ev+" href=\""];
    this.rat["st"]=[opt.stlprf+"node", opt.stlprf+"prnnode"];
    this.rat["cb"]=["<input style='height:14px;margin:1px' type='checkbox' id='cb_@id' name='cb_@id' "+cbev+" >", "<input style='height:14px;margin:1px' type='checkbox' checked id='cb_@id' name='cb_@id' "+cbev+" >"];
    //EDIT this.rat["rd"]=["<input style='height:14px;margin:1px' type='radio' name='rd_@id'>", "<input style='height:14px;margin:1px' type='radio' checked name='rd_@id'>"];
    this.rat["rd"]=["<input style='height:14px;margin:1px' type='radio' name='rd_id' value='@id' id='rb_@id' onclick='tree.selectNode(\"@id\");' />", "<input style='height:14px;margin:1px' type='radio' checked name='rd_id' value='@id' id='rb_@id' />"];
  };

  this.genANode = function(sNd) {
    this.dsp["ln"]="";this.dsp["ic"]="";this.dsp["chk"]="";
    var n=sNd.pr;
    if (tr.opt.indent) while (true) {if (!n || n.equals(tr.rt) && !tr.opt.showExpdr || (tr.opt.hideRoot && (n.equals(tr.rt) || (!tr.opt.showExpdr && n.pr.equals(tr.rt))))) break; this.dsp["ln"]=this.rat["ln"][(n.nx!=null?1:0)]+this.dsp["ln"]; n=n.pr;}

    if (sNd.custom!=null) {
      this.dsp["nd"]=sNd.custom;
      this.dsp["ip"]=this.rat["cust"][0];
      return this.rat["mn"][0]+this.dsp["ln"]+this.rat["mn"][1]+this.dsp["ip"]+this.dsp["ic"]+this.rat["mn"][2]+this.dsp["chk"]+this.rat["mn"][4]+this.dsp["nd"]+this.rat["mn"][5];
    } else {
      var fc=1,ex=0,nx=1, rt=0; if (!sNd.fc) {fc=0; sNd.exp=false;}; if(sNd.svrLoad && sNd.loaded==0) {fc=1;} if (sNd.exp) ex=1; if (!sNd.nx) nx=0;if(sNd.id==tr.rt.id) rt=1;
      this.dsp["ip"]=this.rat["ex"][fc][ex][nx];
      if (rt==1) {this.dsp["ip"]=(tr.opt.showExpdr?this.rat["rt"][1][ex]:"");} else
      if (tr.opt.hideRoot && !tr.opt.showExpdr && sNd.pr.id==tr.rt.id) {this.dsp["ip"]="";}

      if (tr.opt.icon||rt==1) {
        if (sNd.ic!=null) { this.dsp["ic"]=this.rat["ics"].replace(/@ic/gi,sNd.ic[(!tr.opt.icAsSel && sNd.ic[ex]?ex:0)]); }
        else {
          this.dsp["ic"]=this.rat["ic"][fc][ex];
          if (rt==1) this.dsp["ic"]=this.rat["rt"][0];
        }
      }

      if (sNd.url) { this.dsp["nd"]=this.rat["ac"][1].replace(/@trg/gi, (sNd.trg==null?tr.opt.trg:sNd.trg))+ sNd.url+"\">"+sNd.capt+"</a>"; }
      else { this.dsp["nd"]=this.rat["ac"][0].replace(/@capt/gi, sNd.capt);}

      if (sNd.cstStyle!="") {this.dsp["nd"]=this.dsp["nd"].replace(/@nstyle/gi, sNd.cstStyle);} else {this.dsp["nd"]=this.dsp["nd"].replace(/@nstyle/gi, this.rat["st"][fc]);}

      //EDIT if (tr.opt.check && sNd.checkbox) {var c=tr.opt.checkOnLeaf; if (!c || (c && fc==0)) this.dsp["chk"]=this.rat["cb"][(sNd.chk?1:0)];}
      if (tr.opt.check && sNd.checkbox) {var c=tr.opt.checkOnLeaf; if (!c || (c && fc==0)) this.dsp["chk"]=this.rat["rd"][(sNd.chk?1:0)];}
      if (sNd.pr && sNd.pr.rad) { this.dsp["chk"]=this.rat["rd"][(sNd.chk?1:0)].replace(/@id/gi, sNd.pr.id);}


      return this.rat["mn"][0]+this.dsp["ln"]+this.rat["mn"][1]+this.dsp["ip"]+this.dsp["ic"]+this.rat["mn"][2]+this.dsp["chk"]+this.rat["mn"][3]+this.dsp["nd"]+this.rat["mn"][5];
    }
  };

  this.genNodes = function(sNd, incpar, wrt) {
    var s="";
    if (incpar) { s=this.rat["cnt"][(tr.opt.hideRoot && sNd.equals(tr.rt)?1:0)]+this.genANode(sNd)+this.rat["cnt"][(sNd.fc && sNd.exp?2:3)]; };
    s=s.replace(/@id/gi,sNd.id).replace(/@title/gi, sNd.title);
    if (wrt) document.write(s);
    if (sNd.fc !=null) {
        var chNode = sNd.fc;
        do {
          if (wrt) this.genNodes(chNode, true, wrt); else s=s+this.genNodes(chNode, true, wrt);
          chNode = chNode.nx;
        } while (chNode != null)
    }
    if (wrt) {
      if (incpar) document.write("</div>"); return "";
    } else {
      s= incpar ? (s+"</div>") : s; return s;
    }
  };

  this.genTree = function() {
    this.initRender();
    return this.genNodes(tr.rt, true, false);
  };

  this.render = function(plc) {
    var sc="class='"+this.tr.opt.stlprf+"nlstree' ";
    if(this.tr.opt.enbScroll) sc+="style='overflow:auto;height:"+this.tr.opt.height+";width:"+this.tr.opt.width+";' onmousemove=\"return nls_c10(event, '"+tId+"')\"";
    if (plc && plc!="") {
      NlsGetElementById(plc).innerHTML = "<div id=\""+tId+"\" "+sc+" >" + this.genTree() + "</div>";
    } else {
      this.initRender();
      document.write("<div id=\""+tId+"\" "+sc+" >");
      this.genNodes(tr.rt, true, true);
      document.write("</div>");
    }
  };
  return this;
};

DefRenderer.$genNodes=function(sNd, incpar, wrt) {
  var s="", tr=this.tr;
  if (incpar) { s=this.rat["cnt"][(tr.opt.hideRoot && sNd.equals(tr.rt)?1:0)]+this.genANode(sNd)+this.rat["cnt"][(sNd.fc && sNd.exp?2:3)]; };
  s=s.replace(/@id/gi,sNd.id).replace(/@title/gi, sNd.title);
  if (wrt) document.write(s);
  var chNode = sNd.fc, tmp="";
  while(chNode) {
    if(chNode.exp) {
      if(wrt) this.genNodes(chNode,true,wrt); else s=s+this.genNodes(chNode,true,wrt);
    } else {
      tmp=this.rat["cnt"][0]+this.genANode(chNode)+this.rat["cnt"][(chNode.fc && chNode.exp?2:3)]+"</div>";
      tmp=tmp.replace(/@id/gi,chNode.id).replace(/@title/gi, chNode.title);
      if (wrt) document.write(tmp); else s=s+tmp;
    }
    chNode=chNode.nx;
  }

  if (wrt) {
    if (incpar) document.write("</div>"); return "";
  } else {
    s= incpar ? (s+"</div>") : s; return s;
  }
};

function $getAnchor(nd){return nd.childNodes[0].childNodes[0].childNodes[0].childNodes[3].childNodes[0]}

NLSTREE.initEvent = function() {
  var orgEvent = (nls_isIE?document.body.onkeydown:window.onkeydown);
  if (!orgEvent || orgEvent.toString().search(/orgEvent/gi) < 0) {
    var newEvent = function(e) { if (nlsTree.selectedTree) nlsTree.selectedTree.liveNodePress(nls_isIE?event:e); if (orgEvent) return orgEvent();};
    if (nls_isIE) document.body.onkeydown=newEvent; else window.onkeydown=newEvent;
  }
};

NLSTREE.reloadNode = function(id, incChd) {
  this.renderer.initRender();
  var intId = this.genIntId(id);
  var cNode=this.nLst[intId];
  var dvN = NlsGetElementById("ch_"+intId);
  if (incChd!=false) {
    var s = this.renderer.genNodes(cNode, false);
    dvN.innerHTML = s;
    if (dvN.innerHTML=="") dvN.style.display="none";
  }
  if (cNode.exp==true && cNode.fc!=null) dvN.style.display="";
  dvN = NlsGetElementById(intId);
  dvN.innerHTML = "";
  dvN.innerHTML = this.renderer.genANode(cNode).replace(/@id/gi, intId);
  dvN.setAttribute("title", cNode.title);
  if (this.selNd!=null) {var sId=this.selNd.id; this.selNd=null; this.selElm=null; this.selectNode(sId); }
};

NLSTREE.selNToggle = function(id) {
  this.toggleNode(id);
  if (!this.selNd || this.selNd.id!=id) this.selectNode(id);
  if (this.tmId!=null) { clearTimeout(this.tmId); this.tmId=null; }
};

function $pbsHasChild(n) {
  return (n.fc||(n.svrLoad && n.loaded==0));
};

function nls_setStyle(tree, sNd, sElm, selected) {
  var prf= (selected?"sel":"");
  if (tree.opt.selRow) sElm.className = tree.opt.stlprf+prf+"row";
  ac = $getAnchor(sElm);
  if (sNd){
      if (sNd.cstStyle!="") {
        ac.className = prf+sNd.cstStyle;
      }else{
        ac.className = tree.opt.stlprf+prf+($pbsHasChild(sNd)?"prnnode":"node");
      }
  }else{
    ac.className = tree.opt.stlprf+prf+("node");
  }

  //ac.className = (sNd.cstStyle!=""?prf+sNd.cstStyle:tree.opt.stlprf+prf+($pbsHasChild(sNd)?"prnnode":"node"));
};

function nls_setNodeIcon(tree, sNd, sElm, selected) {
  if (tree.opt.icon) {
    ic=sElm.childNodes[0].childNodes[0].childNodes[0].childNodes[1];
    if (ic.childNodes.length==2) {ic=ic.childNodes[1];} else {ic=ic.childNodes[0];}
    if (selected) {
      if (sNd.ic!=null) { ic.src=nlsTreeIc[sNd.ic[1]?sNd.ic[1]:sNd.ic[0]].src } else { ic.src=nlsTreeIc[(sNd.id==tree.rt.id?tree.ico.rot:($pbsHasChild(sNd)?tree.ico.opf:tree.ico.chd))].src; }
    } else {
      if (sNd.ic!=null) { ic.src=nlsTreeIc[sNd.ic[0]].src } else { ic.src=nlsTreeIc[(sNd.id==tree.rt.id?tree.ico.rot:($pbsHasChild(sNd)?tree.ico.clf:tree.ico.chd))].src; }
    }
  }
};

NLSTREE.selectNode = function (id) { /*id is internal id*/
  nlsTree.selectedTree=this;
  if (this.opt.editable) {
    var sNd=this.selNd;
    if (sNd!=null && sNd.id!=id) { if (this.tmId) { clearTimeout(this.tmId); this.tmId=null;}  }
    if (sNd!=null && sNd.id==id && !NlsTree._blockEdit) { this.tmId=setTimeout("nlsTree."+this.tId+".liveNodeEdit('"+id+"')", 1000); }
    var edt=NlsGetElementById("ndedt"+this.tId);
    if (edt && edt.style.display=="") {  edt.style.display="none"; edt.disabled=true;}
  }

  var ac=null;var ic=null;
  var sNd=this.selNd;
  var sElm=this.selElm;
  if (sElm!=null) {
    nls_setStyle(this, sNd, sElm, false);
    if (this.opt.icAsSel) nls_setNodeIcon(this, sNd, sElm, false);
  }
  sNd = this.nLst[id];

  if(this.opt.renderOnDemand) { this.renderTo(sNd.orgId);}

  this.selNd = sNd;
  this.selElm= NlsGetElementById(id);
  sElm=this.selElm;
  nls_setStyle(this, sNd, sElm, true);
  if (this.opt.icAsSel) nls_setNodeIcon(this, sNd, sElm, true);
  if (this.opt.mntState && nls_setCookie) nls_setCookie(this.tId+"_selnd", sNd.orgId);

  if (this.opt.multiSel) {
    this.msRemoveAll();
    this.msAdd(sNd);
  }
};

NLSTREE.selectNodeById = function(id) {
  var node = this.getNodeById(id);
  if (!node) return;
  var tmp = node.pr;
  //if(this.opt.renderOnDemand) { this.renderTo(id);}
  while (tmp!=null) { this.expandNode(tmp.orgId); tmp=tmp.pr; }
  this.selectNode(node.id);  /*select the node*/
};

NLSTREE.unselectNodeById=function(id) {
  var nd=this.getNodeById(id);
  if (this.selNd!=null && this.selNd.equals(nd)) {
    var oNode=NlsGetElementById(nd.id)
    if (this.opt.icAsSel) nls_setNodeIcon(this, nd, oNode , false);
    if (this.opt.mntState && nls_setCookie) nls_removeCookie(this.tId+"_selnd");
    this.selNd=null; this.selElm=null;
    nls_setStyle(this, nd, oNode, false);
  }
};

NLSTREE.isChild = function(c, p) {
  var nd=this.getNodeById(c);
  if (!nd) return false;
  var tmp=nd.pr;
  while (tmp!=null) { if (tmp.orgId==p) return true; tmp=tmp.pr;}
  return false;
};

NLSTREE.hasChild=function(id) {
  var nd=this.getNodeById(id);
  return (nd.fc!=null);
};

NLSTREE.expandNode = function(id) {
  var sNd = this.getNodeById(id);
  if ((!sNd.exp && sNd.fc) || (sNd.svrLoad && sNd.loaded==0)) {
    this.toggleNode(sNd.id);
    return;
  }
  if (this.arrNodePath.length > 0) this.selectNodePath();
  return;
};

NLSTREE.collapseNode = function(id) {
  var sNd = this.nLst[this.genIntId(id)];
  if (sNd.exp && sNd.fc) this.toggleNode(sNd.id);
};

NLSTREE.UpravSirku = function(){
    var BrowserDetect = {
        init: function () {
            this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
            this.version = this.searchVersion(navigator.userAgent)
                || this.searchVersion(navigator.appVersion)
                || "an unknown version";
            this.OS = this.searchString(this.dataOS) || "an unknown OS";
        },
        searchString: function (data) {
            for (var i=0;i<data.length;i++)    {
                var dataString = data[i].string;
                var dataProp = data[i].prop;
                this.versionSearchString = data[i].versionSearch || data[i].identity;
                if (dataString) {
                    if (dataString.indexOf(data[i].subString) != -1)
                        return data[i].identity;
                }
                else if (dataProp)
                    return data[i].identity;
            }
        },
        searchVersion: function (dataString) {
            var index = dataString.indexOf(this.versionSearchString);
            if (index == -1) return;
            return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
        },
        dataBrowser: [
            {
                string: navigator.userAgent,
                subString: "Chrome",
                identity: "Chrome"
            },
            {     string: navigator.userAgent,
                subString: "OmniWeb",
                versionSearch: "OmniWeb/",
                identity: "OmniWeb"
            },
            {
                string: navigator.vendor,
                subString: "Apple",
                identity: "Safari",
                versionSearch: "Version"
            },
            {
                prop: window.opera,
                identity: "Opera"
            },
            {
                string: navigator.vendor,
                subString: "iCab",
                identity: "iCab"
            },
            {
                string: navigator.vendor,
                subString: "KDE",
                identity: "Konqueror"
            },
            {
                string: navigator.userAgent,
                subString: "Firefox",
                identity: "Firefox"
            },
            {
                string: navigator.vendor,
                subString: "Camino",
                identity: "Camino"
            },
            {        // for newer Netscapes (6+)
                string: navigator.userAgent,
                subString: "Netscape",
                identity: "Netscape"
            },
            {
                string: navigator.userAgent,
                subString: "MSIE",
                identity: "Explorer",
                versionSearch: "MSIE"
            },
            {
                string: navigator.userAgent,
                subString: "Gecko",
                identity: "Mozilla",
                versionSearch: "rv"
            },
            {         // for older Netscapes (4-)
                string: navigator.userAgent,
                subString: "Mozilla",
                identity: "Netscape",
                versionSearch: "Mozilla"
            }
        ],
        dataOS : [
            {
                string: navigator.platform,
                subString: "Win",
                identity: "Windows"
            },
            {
                string: navigator.platform,
                subString: "Mac",
                identity: "Mac"
            },
            {
                   string: navigator.userAgent,
                   subString: "iPhone",
                   identity: "iPhone/iPod"
            },
            {
                string: navigator.platform,
                subString: "Linux",
                identity: "Linux"
            }
        ]

    };
    BrowserDetect.init();


    var zakaz = 0;

    if (BrowserDetect.browser == 'Firefox' && BrowserDetect.version == '2') zakaz = 1;
    if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '6') zakaz = 1;



    if (!zakaz && this.opt.upravsirku){
        var hlavniobsah = document.getElementById("hlavniobsah");
        var menukategorie = document.getElementById("menu-kategorie2");
        var menu = document.getElementById("vyberkategorie");

        if (hlavniobsah && menukategorie && menu) {

            menu.style.position = "absolute";
            var sirka = menu.offsetWidth + 25;
            hlavniobsah.style.margin = "0 0 0 "+sirka+"px";
            menukategorie.style.width = sirka;
            menu.style.position = "static";
        }
    }
}

NLSTREE.prepareToggle = function(id) {
  var sNd = this.selNd;
  if (sNd==null) { this.selectNode(id); return; }
  if (sNd.id==id) return;
  while(sNd!=null && sNd.id!=id) {sNd=sNd.pr;}
  if (sNd==null) return;
  if (sNd.id==id) this.selectNode(id);
};

NLSTREE.toggleNode = function(id) {
  var sNd = this.nLst[id];
  if(sNd.svrLoad && sNd.loaded==0) {this.ajaxLoadChildNodes(sNd.orgId);return;};
  if(this.opt.renderOnDemand) {this.renderTo(sNd.orgId, true);}

  var nd = NlsGetElementById("ch_" + id), ip=null;
  if (id!=this.rt.id || (id==this.rt.id && this.opt.showExpdr)) {ip=NlsGetElementById(id).childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[0];}
  if (this.opt.hideRoot && !this.opt.showExpdr && sNd.pr && sNd.pr.equals(this.rt)) ip=null;
  if (sNd.exp) {
    sNd.exp = false;
    nd.style.display="none";
    if (ip!=null && sNd.fc!=null) ip.src=(id==this.rt.id?this.ico.pnl:(sNd.nx ? this.ico.pb : this.ico.pnb));
    if (!this.opt.icAsSel) nls_setNodeIcon(this, sNd, NlsGetElementById(id), false);
    if (this.opt.mntState && nls_delExpandedId) nls_delExpandedId(this.tId+"_ndstate", sNd.orgId);
    this.treeOnCollapse(sNd.orgId);
  } else {
    if (this.opt.oneExp && sNd.pr) {
      var tNd = sNd.pr.fc;
      while (tNd) { if (tNd.id!=id && tNd.exp) this.collapseNode(tNd.orgId); tNd=tNd.nx;}
    }
    sNd.exp = true;
    nd.style.display="block";
    if (ip!=null && sNd.fc!=null) ip.src=(id==this.rt.id?this.ico.mnl:(sNd.nx ? this.ico.mb : this.ico.mnb));
    if (!this.opt.icAsSel) nls_setNodeIcon(this, sNd, NlsGetElementById(id), true);
    if (this.opt.mntState && nls_addExpandedId) nls_addExpandedId(this.tId+"_ndstate", sNd.orgId);
    this.treeOnExpand(sNd.orgId);
  }
};

NLSTREE.expandAll = function (id) {
  var treeId=this.tId;
  var startNode=(!id?this.rt:this.getNodeById(id));
  this.loopTree(startNode, function(n) { nlsTree[treeId].expandNode(n.orgId); });
};

NLSTREE.collapseAll = function (incPr, id) {
  var treeId=this.tId;
  var startNode=(!id?this.rt:this.getNodeById(id));
  this.loopTree(startNode, function(n) { if (n.fc && (!startNode.equals(n) || incPr)) nlsTree[treeId].collapseNode(n.orgId); });
};

NLSTREE.checkNode = function(intId, chkOvr) {
  var nd = NlsGetElementById("cb_" + intId);
  var sNd = this.nLst[intId];
  if (arguments.length>1) nd.checked=chkOvr;
  sNd.chk = nd.checked;

  if (this.opt.checkIncSub) { if(nd.checked==true) { this.loopTree(sNd, $nlsCheck); } else { this.loopTree(sNd, $nlsUnCheck);} }
  if (this.opt.checkParents) { var t=sNd;
    if(nd.checked==true) {
      while(t) {$nlsCheck(t); t=t.pr;};
    } else {
      var t2,fl=false;
      while(t) {
        $nlsUnCheck(t);
        t2=t; if(t2.pr!=null)t2=t2.pr.fc;
        while(t2) {if(t2.chk==true){ fl=true; break;} t2=t2.nx;}
        if(fl)break;
        t=t.pr;
      };
    }
  }
};

function $nlsCheck(sNd) {$setCheck(sNd,true);}
function $nlsUnCheck(sNd) {$setCheck(sNd,false);}
function $setCheck(sNd,f) { if(!sNd.checkbox)return; var nd = NlsGetElementById("cb_" + sNd.id); if(nd) nd.checked=f; sNd.chk = f; }

NLSTREE.setNodeStyle = function (id, cls, rt) {
  var nd = this.getNodeById(id);
  nd.cstStyle=cls;
  if (rt) {
    var oNd = NlsGetElementById(nd.id);
    if (oNd) {
      var ac=$getAnchor(oNd);
      ac.className =cls;
    }
  }
};

NLSTREE.setNodeCaption = function(id, capt) {
  var intId = this.genIntId(id);
  var nd = $getAnchor(NlsGetElementById(intId));
  var sNd = this.nLst[intId];
  nd.innerHTML = capt;
  sNd.capt = capt;
};

NLSTREE.getNodeById = function(id) {
  return this.nLst[this.genIntId(id)]
};

NLSTREE.setGlobalCtxMenu = function(ctx) {
  this.opt.evCtxMenu=true;
  this.ctxMenu = ctx;
  ctx.container=this;
};

NLSTREE.setNodeCtxMenu = function(id, ctx) {
  this.opt.evCtxMenu=true;
  var nd = this.nLst[this.genIntId(id)];
  nd.ctxMenu = ctx;
  if (ctx.mId) ctx.container=this;
};

NLSTREE.setNodeTarget = function(id, trg) {
  var nd = this.nLst[this.genIntId(id)];
  nd.trg=trg;
};

NLSTREE.setEditablity = function(id, v) {
  var nd = this.nLst[this.genIntId(id)];
  nd.editablity=v;
};

NLSTREE.enableCheckbox = function(id, v) {
  var nd = this.nLst[this.genIntId(id)];
  nd.checkbox=v;
};

NLSTREE.useIconSet = function(icSet) {
  this.ico=icSet;
  preloadIcon(icSet.pnb,icSet.pb,icSet.pnl,icSet.mnb,
    icSet.mb,icSet.mnl,icSet.opf,icSet.clf,icSet.chd,
    icSet.rot,icSet.lnb,icSet.lb,icSet.lin,icSet.bln,
    icSet.lod);
};

NLSTREE.contextMenu = function(ev, id) {
  if (!this.opt.enableCtx) return false;
  var sNd=this.nLst[id]; var ctx=null;
  if (sNd.ctxMenu && sNd.ctxMenu.mId) ctx=sNd.ctxMenu; else
  if (sNd.ctxMenu=="DEFAULT") ctx=null; else
  if (sNd.ctxMenu=="NONE") return false; else ctx=this.ctxMenu;
  if (!ctx) return true;

  if (this.opt.multiSel && this.isSelected(sNd.orgId)) {
    /*check if all the ctx menu*/
    var sNds=this.getSelNodes();
    for (var i=0; i<sNds.length; i++) {
      var t=(sNds[i].ctxMenu==null?this.ctxMenu:sNds[i].ctxMenu);
      if (t!=null && t.mId!=ctx.mId) {this.selectNode(id); break;}
    }
  } else {
    this.selectNode(id);
  }

  if (this.tmId) clearTimeout(this.tmId);
  ctx.container=this;
  ctx.showMenu(ev.clientX, ev.clientY);

  return false;
};

NLSTREE.loopTree = function(sNd, act) {
  act(sNd);
  if (sNd.fc !=null) {
      var chNode = sNd.fc;
      do {
          this.loopTree(chNode, act);
          chNode = chNode.nx;
      } while (chNode != null)
  }
};

NLSTREE.liveNodeEditStart = function(id) {
  this.tmId = setTimeout("nlsTree."+this.tId+".liveNodeEdit('"+id+"')", 0)
};

NLSTREE.liveNodeEdit = function(id) {
  if (!this.nLst[id].editablity) {this.tmId=null; return;}
  if (this.tmId!=null) {
    var edt = NlsGetElementById("ndedt"+this.tId);
    var ac = $getAnchor(NlsGetElementById(id));
    var x=0,y=0,elm=ac;
    while(elm) { x += elm.offsetLeft; y+=elm.offsetTop; elm=elm.offsetParent; }
    elm=NlsGetElementById(this.tId);
    if (elm) {y-=elm.scrollTop; x-=elm.scrollLeft;}

    edt.disabled=false;
    var posAdj=this.editBoxPosAdj();
    edt.style.top=y+posAdj[1]+"px"; edt.style.left=x+posAdj[0]+"px"; edt.style.display="block";
    edt.focus();
    //value = ac.innerHTML;
    edt.value=this.nLst[id].capt;

    this.tmId = null;
    this.$editing=true;
  }
};

NLSTREE.liveNodeWrite = function() {
  var edt = NlsGetElementById("ndedt"+this.tId);
  if (edt.style.display=="none") return;
  var ac = $getAnchor(NlsGetElementById(this.selNd.id));

  if (edt.value != "" && edt.value!=this.selNd.capt) { if (this.treeOnBeforeNodeChange(this.selNd.orgId)) { ac.innerHTML=edt.value; this.selNd.capt=edt.value; this.treeOnNodeChange(this.selNd.orgId);} else {return;} }
  edt.style.display="none";
  edt.disabled=true;
  this.$editing=false;
};

NLSTREE.liveNodePress = function(e) {
  if (!this.opt.editable) return;
  if (e.keyCode==13) {
    this._fl=false;
    this.liveNodeWrite();
    this._fl=true;
  } else if(e.keyCode==27) {
    var edt=NlsGetElementById("ndedt"+this.tId); edt.style.display="none"; edt.disabled=true;
  } else if(e.keyCode==this.opt.editKey) {/*f2*/
      this.tmId = setTimeout("nlsTree."+this.tId+".liveNodeEdit('"+this.selNd.id+"')", 10);
  }
};

NLSTREE.editBoxPosAdj=function() { return [0,0]; };
/*NLSTREE.ctxPosAdj=function() { return [0,0]; };*/
/*NLSTREE.ddPosAdj=function() { return [0,0]; };*/

function nls_c1(e, tId, nId){
  nlsTree[tId].prepareToggle(nId);
  nlsTree[tId].toggleNode(nId);
};

function nls_c2(e, tId, nId){
  var t=nlsTree[tId]; var nd=t.nLst[nId];
  if (e.ctrlKey && e.altKey) { if (e.stopPropagation) {e.stopPropagation();} else {e.cancelBubble=true}; return t.contextMenu(e, nId); }
  if (t.opt.multiSel) { if (!nls_msTreeOnClick(e, tId, nId)) return false; }

  //EDIT if ((t.opt.oneClick || (t.opt.hideRoot && t.rt.equals(nd.pr))) && t.nLst[nId].fc ) { t.selNToggle(nId); } else { t.selectNode(nId); }
  if ((t.opt.oneClick || (t.opt.hideRoot && t.rt.equals(nd.pr)))) { t.selNToggle(nId); } else { t.selectNode(nId); }
  return t.treeOnClick(e, t.genOrgId(nId));
};

function nls_c3(e, tId, nId){
  var t=nlsTree[tId];
  if (t.nLst[nId].fc) t.selNToggle(nId);
  return t.treeOnDblClick(e, t.genOrgId(nId));
};

function nls_c4(e, tId, nId) {
  var t=nlsTree[tId]; return t.contextMenu(e, nId);
};

function nls_c5(e, tId, nId) {
  var t=nlsTree[tId]; return t.treeOnMouseUp(e, t.genOrgId(nId));
};

function nls_c6(e, tId, nId) {
  var t=nlsTree[tId]; return t.treeOnMouseDown(e, t.genOrgId(nId));
};

function nls_c7(e, tId, nId) {
  var t=nlsTree[tId]; return t.treeOnMouseOver(e, t.genOrgId(nId));
};

function nls_c8(e, tId, nId) {
  var t=nlsTree[tId]; return t.treeOnMouseOut(e, t.genOrgId(nId));
};

function nls_c9(e, tId, nId) {
  var t=nlsTree[tId]; return t.treeOnMouseMove(e, t.genOrgId(nId));
};

function nls_c10(e, tId) {var t=nlsTree[tId]; return t.$treeMove(e);};

function nls_c11(e, tId, nId) {var t=nlsTree[tId]; t.$expdrMove(e, t.genOrgId(nId));};
function nls_c12(e, tId, nId) {var t=nlsTree[tId]; t.$expdrOut(e, t.genOrgId(nId));};

function nls_cb1(e, tId, nId) {
  var t=nlsTree[tId];
  t.checkNode(nId);
  t.treeOnCheck(t.genOrgId(nId));
};

NLSTREE.$expdrMove=function(e,id) {}
NLSTREE.$expdrOut=function(e,id) {}
NLSTREE.$treeMove=function(e) {};
NLSTREE.treeOnClick = function(e, id) {


    return true;
};
NLSTREE.treeOnDblClick = function(e, id) {};
NLSTREE.treeOnMouseOver = function (e, id) {};
NLSTREE.treeOnMouseMove = function (e, id) {};
NLSTREE.treeOnMouseOut = function (e, id) {};
NLSTREE.treeOnMouseDown = function (e, id) {};
NLSTREE.treeOnMouseUp = function (e, id) {};
NLSTREE.treeOnCheck = function (id) {};
NLSTREE.treeOnExpand = function (id) {
    this.UpravSirku();
    return;
};
NLSTREE.treeOnCollapse = function (id) {
    this.UpravSirku();
    return;
};
NLSTREE.treeOnNodeChange = function (id) {};
NLSTREE.treeOnBeforeNodeChange = function (id) {return true;};

function preloadIcon() {
  var arg = preloadIcon.arguments, ic;
  for (var i=0;i<arg.length;i++) {
    if(!arg[i]) continue;
    ic=nlsTreeIc[arg[i]]
    if (!ic) {
      ic = new Image();
      ic.src=arg[i];
      nlsTreeIc[arg[i]]=ic;
    }
  }
};

/**Cross browser related methods*/
function NlsGetElementById(id) {
  if (document.all) {
      return document.all(id);
  } else
  if (document.getElementById) {
      return document.getElementById(id);
  }
};

NlsTree.isEquals=function(a, b) {
  if(!a || !b) return false;
  return (a.id==b.id);
}

/**
* nlstreeext_inc.js v1.0
* Copyright 2005-2006, addobject.com. All Rights Reserved
* Author Jack Hermanto, www.addobject.com
*/
NLSTREE.ajaxLoadChildNodes=function(id) {
  var nd=this.getNodeById(id);
  var req=NlsTree.AJAX.createRequest();
  var url=$nlsAddParam((nd.chUrl?nd.chUrl:this.chUrl), "nid="+id);
  var me=this;
  req.open("get", url, true);
  req.onreadystatechange=function() {
    if(req.readyState==4) {
      if(req.status==200 || req.status==304) {
        var de=req.responseXML.documentElement;
        if(!de||de.childNodes.length==0) { //if no submenu
        } else {
          me.removeChilds(id);
          me.addChildNodesXML(de, true);
          me.expandNode(id);

          if (me.arrNodePath.length > 0) me.selectNodePath();
        }
        nd.loaded=2;
      }
    }
  };
  //animate icon here, change the icon or text.
  if(this.opt.icon) {
    var sElm=NlsGetElementById(nd.id);
    var ic=sElm.childNodes[0].childNodes[0].childNodes[0].childNodes[1];
    if (ic.childNodes.length==2) {ic=ic.childNodes[1];} else {ic=ic.childNodes[0];}
    ic.src=nlsTreeIc[this.ico.lod].src;
  }// else {
  var oNd=$getAnchor(NlsGetElementById(nd.id));
  //oNd.innerHTML="(Loading...) - "+oNd.innerHTML;
  //};
  nd.loaded=1; //loading
  req.send(null);
};

NLSTREE.setServerLoad=function(id, url) {
  n=this.getNodeById(id);
  n.svrLoad=true;
  n.loaded=0;
  n.chUrl=url;
};

NlsNode.prototype.loaded=0;
NlsNode.prototype.chUrl=null;

NLSTREE.arrNodePath = new Array();
//NLSTREE.treeOnCheck = function (id) {};
NLSTREE.FuncOnNodePathComplete = function (id) {
    prvek = document.getElementById("rb_"+this.tId+id);
    if (prvek) prvek.checked="checked";
};
NLSTREE.setNodePath = function(arrNodeIDs, funcOnComplete) {
    this.arrNodePath = arrNodeIDs;
    this.funcOnNodePathComplete = funcOnComplete;
}

NLSTREE.selectNodePath = function(arrNodeIDs) {
    if (this.arrNodePath.length > 1) {
        // Expand next node
        this.expandNode(this.arrNodePath.shift());
    }else if (this.arrNodePath.length == 1) {
        // Select the last node, do not expand it
        idnode = this.arrNodePath.shift();
        this.selectNodeById(idnode);
        this.expandNode(idnode);

        // Execute custom function
        if (typeof this.FuncOnNodePathComplete == "function") this.FuncOnNodePathComplete(idnode);
    }
}

/*utility*/
function $nlsAddParam(url, par) {
  var s=(url.indexOf("?")!=-1?"&":"?");
  return url+s+par;
};

/**
* nlstreeext_xml.js v2.3
* To use with NlsTree Professional only.
* Copyright 2005-2006, addobject.com. All Rights Reserved
* Author Jack Hermanto, www.addobject.com
*/

NlsTree.AJAX={};

//NlsNode extension functions for XML
NlsNode.prototype.xmlOpn=function() {
  if(this.custom) {
    return "<customnode id=\""+this.orgId+"\">"+this.custom+"</customnode>";
  } else {
    return "<node id=\""+this.orgId+"\" caption=\""+this.capt+"\" url=\""+this.url+"\" ic=\""+(this.ic==null?"":this.ic)+"\" exp=\""+this.exp+"\" chk=\""+this.chk+"\" cststyle=\""+this.cstStyle+"\" target=\""+this.trg+"\" title=\""+this.title+"\">";
  }
};

NlsNode.prototype.xmlCls=function() { return "</node>"; };

//StdOpt extension function for XML
StdOpt.$prop=["enbScroll","height","width","trg","stlprf","sort","icon","check","editable","selRow","editKey",
"oneExp","enableCtx","oneClick","mntState","icAsSel","checkIncSub","checkOnLeaf","hideRoot","indent","evDblClick",
"evCtxMenu","evMouseUp","evMouseDown","evMouseMove","evMouseOut","evMouseOver"];

StdOpt.prototype.toXML=function() {
  var s=[], j=0, pr=StdOpt.$prop;
  s[j++]="<options>\n";
  for(var i=0;i<pr.length;i++) {
    s[j++]="  <opt name=\""+(pr[i]=="trg"?"target":pr[i].toLowerCase())+"\" value=\""+this[pr[i]]+"\"></opt>\n";
  }
  s[j++]="</options>\n";
  return s.join("");
};

//StdIco extension function for XML
StdIco.$prop=["pnb","pb","pnl","mnb","mb","mnl","opf","clf","chd",
  "rot","lnb","lb","lin", "bln","lod"];

StdIco.prototype.toXML=function() {
  var s=[], j=0, pr=StdIco.$prop;
  s[j++]="<icons>\n";
  for(var i=0;i<pr.length;i++) {
    s[j++]="  <ico name=\""+pr[i]+"\" value=\""+this[pr[i]]+"\"></ico>\n";
  }
  s[j++]="</icons>\n";

  return s.join("");
};

//NlsTree extension functions for XML
NLSTREE.nodeXML = function(sNd) {
  sNd=(sNd==null?this.rt:sNd);
  var n=sNd; var spc="";
  while (n != null && !n.equals(this.rt)) { spc+="  "; n=n.pr;}
  var s=(spc+sNd.xmlOpn()+"\n");
  if (sNd.fc !=null) {
      var chNode = sNd.fc;
      do {
          s+=this.nodeXML(chNode);
          chNode = chNode.nx;
      } while (chNode != null)
  }
  s+=(spc+sNd.xmlCls()+"\n");
  return s;
};

NLSTREE.toXML=function() {
  return "<tree id=\""+this.tId+"\">\n" + this.opt.toXML() + this.ico.toXML() + this.nodeXML(this.rt) + "</tree>";
};

function nls_addNodeXML(tree, prnId, xnd) {
  for (var i=0; i<xnd.childNodes.length; i++) {
    var nd=xnd.childNodes[i];
    if (nd.nodeType!=1) continue;
    if(nd.nodeName.toUpperCase()=="CUSTOMNODE") {
      tree.addCustomNode(nd.getAttribute("id"), prnId, nd.childNodes[0].nodeValue);
      continue;
    }
    var newNd=tree.add(nd.getAttribute("id"), prnId, nd.getAttribute("caption"), nd.getAttribute("url"), nd.getAttribute("ic"), nd.getAttribute("exp")=="true", nd.getAttribute("chk")=="true", null, nd.getAttribute("title"));
    newNd.cstStyle=nd.getAttribute("cststyle");
    newNd.trg=nd.getAttribute("target");
    if(nd.getAttribute("svrload")=="true") {
      tree.setServerLoad(nd.getAttribute("id"), (nd.getAttribute("churl")=="null"?null:nd.getAttribute("churl")));
    }
    if (nd.firstChild!=null) nls_addNodeXML(tree, newNd.orgId, nd);
  }
};

NLSTREE.addNodesXML=function(prn, rn, reload) {
  if (rn==null) return;
  if(rn.nodeName.toUpperCase()=="CUSTOMNODE") {
    this.addCustomNode(rn.getAttribute("id"), prn, rn.childNodes[0].nodeValue);
  } else {
    var newNd=this.add(rn.getAttribute("id"), prn, rn.getAttribute("caption"), rn.getAttribute("url"), rn.getAttribute("ic"), rn.getAttribute("exp")=="true", rn.getAttribute("chk")=="true", null, rn.getAttribute("title"));
    newNd.cstStyle=rn.getAttribute("cststyle");
    newNd.trg=rn.getAttribute("target");

    nls_addNodeXML(this, newNd.orgId, rn);
  }
  if (reload) {
    this.reloadNode(prn);
  }
};

NLSTREE.addNodesXMLString=function(prn, xml, reload) {
  var xmlDom=nls_parseXML(xml);
  if (xmlDom) this.addNodesXML(prn, xmlDom.documentElement, reload);
};

NLSTREE.addChildNodesXML=function(rn, reload, updateParent) {
  if (rn==null) return;
  if (updateParent) {
    var nd=this.getNodeById(rn.getAttribute("id"));
    nd.capt=rn.getAttribute("caption");
    nd.url=rn.getAttribute("url");
    nd.ic=rn.getAttribute("ic")==""?null:rn.getAttribute("ic").split(",");
    nd.exp=rn.getAttribute("exp")=="true";;
    nd.chk=rn.getAttribute("chk")=="true";
    nd.cstStyle=rn.getAttribute("cststyle");
    nd.trg=rn.getAttribute("target")=="null"?null:rn.getAttribute("target");
    nd.title=rn.getAttribute("title");
  }
  nls_addNodeXML(this, rn.getAttribute("id"), rn);
  if (reload) {
    this.reloadNode(rn.getAttribute("id"));
  }
};

NLSTREE.addChildNodesXMLString=function(xml, reload, updateParent) {
  var xmlDom=nls_parseXML(xml);
  if (xmlDom) this.addChildNodesXML(xmlDom.documentElement, reload, updateParent);
};

NLSTREE.setOptionsByXML=function(xopt) {
  var o=this.opt;
  for (var i=0; i<xopt.childNodes.length; i++) {
    var n=xopt.childNodes[i];
    if (n.nodeType!=1) continue;
    var v=n.getAttribute("value");
    switch (n.getAttribute("name")) {
      case "trg":
      case "target": o.trg=v; break;
      case "enbscroll": o.enbScroll=(v=="true"); break;
      case "height": o.height=v;break;
      case "width": o.width=v;break;
      case "stlprf": o.stlprf=v; break;
      case "sort": o.sort=v; break;
      case "icon": o.icon=(v=="true"); break;
      case "check": o.check=(v=="true"); break;
      case "editable": o.editable=(v=="true"); break;
      case "selrow": o.selRow=(v=="true"); break;
      case "editkey": o.editKey=v; break;
      case "oneexp": o.oneExp=(v=="true"); break;
      case "enablectx": o.enableCtx=(v=="true"); break;
      case "oneclick": o.oneClick=(v=="true"); break;
      case "mntstate": o.mnState=(v=="true"); break;
      case "icassel": o.icAsSel=(v=="true"); break;
      case "checkincsub": o.checkIncSub=(v=="true"); break;
      case "checkparents": o.checkParents=(v=="true"); break;
      case "checkonleaf": o.checkOnLeaf=(v=="true"); break;
      case "hideroot": o.hideRoot=(v=="true"); break;
      case "indent": o.indent=(v=="true"); break;
      case "showexpdr": o.showExpdr=(v=="true"); break;
      case "renderondemand": o.renderOnDemand=(v=="true"); break;
      case "evdblclick": o.evDblClick=(v=="true"); break;
      case "evctxmenu": o.evCtxMenu=(v=="true"); break;
      case "evmouseup": o.evMouseUp=(v=="true"); break;
      case "evmousedown": o.evMouseDown=(v=="true"); break;
      case "evmousemove": o.evMouseMove=(v=="true"); break;
      case "evmouseout": o.evMouseOut=(v=="true"); break;
      case "evmouseover": o.evMouseOver=(v=="true"); break;
    }
  }
};

NLSTREE.setIconsByXML=function(xico) {
  var c=this.ico;
  for (var i=0; i<xico.childNodes.length; i++) {
    var n=xico.childNodes[i];
    if (n.nodeType!=1) continue;
    c[n.getAttribute("name")]=n.getAttribute("value");
  }
  this.useIconSet(c);
};

//load tree from XML Document.
NLSTREE.loadFromXML=function(xml) {
  var rt=xml;

  //set tree options
  for (var i=0; i<rt.childNodes.length; i++) {
    var n=rt.childNodes[i];
    if (n.nodeType==1) {
      if (n.nodeName=="options") {
        this.setOptionsByXML(n);
      } else
      if (n.nodeName=="icons") {
        this.setIconsByXML(n);
      } else
      if (n.nodeName=="node") {
        //add root node
        this.addNodesXML("root", n, false);
      }
    }
  }
};

//load tree from XML string
NLSTREE.loadFromXMLString=function(sXML) {
  var txml=nls_parseXML(sXML);
  this.loadFromXML(txml.documentElement);
};

//load tree from xml file
NLSTREE.loadFromXMLFile=function(fName) {
  var me=this;
  var req=NlsTree.AJAX.createRequest();
  req.open("get", fName, false);
  req.send(null);
  this.loadFromXML(req.responseXML.documentElement);
};

function nls_parseXML(sXml) {
  var xmlDom=null;
  if (typeof(DOMParser) != "undefined") {
    var parser=new DOMParser(); //gecko browser xml dom
    xmlDom=parser.parseFromString(sXml, "text/xml");
  } else {
    xmlDom=nls_createXMLDoc();
    xmlDom.loadXML(sXml);
  }
  return xmlDom;
};

//create empty xml doc
function nls_createXMLDoc() {
  var ieXML=["MSXML2.DOMDocument.5.0",
    "MSXML2.DOMDocument.4.0", "MSXML2.DOMDocument.3.0",
    "MSXML2.DOMDocument", "Microsoft.XmlDom"];
  var xmlDom=null;
  if(nls_isIE) {
    for (var i=0;i<ieXML.length;i++) {
      try {
        xmlDom=new ActiveXObject(ieXML[i]);
        break;
      } catch (e) {}
    }
  } else {
    xmlDom=document.implementation.createDocument("","",null);
  }
  return xmlDom;
};

NlsTree.AJAX.createRequest=function() {
  if (typeof XMLHttpRequest != "undefined") { //for mozilla
    return (new XMLHttpRequest());
  } else {
    var arrObj=["MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0",
      "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMHttp"];
    var req=null;
    for (var i=0;i<arrObj.length;i++) {
      try {
        req=new ActiveXObject(arrObj[i]);
        return req;
      } catch (e) { }
    }
  }
};


/***************/
var utf8Url = {

    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

function highlightOnLoad() {
  // Get search string
  if (/fulltext\=/.test(window.location.search)) {
    var searchString = getSearchString();
    searchString = bezdiak(searchString);
    // Starting node, parent to all nodes you want to search
    var textContainerNode = document.getElementById("hlavni");

    // Informational message for search
    var searchInfo = 'Search Results for: ';

    // Split search terms on '|' and iterate over resulting array
    var searchTerms = searchString.split('|');
    for (var i in searchTerms)     {
      searchTerms[i] = rozsirregexp(searchTerms[i]);
      // The regex is the secret, it prevents text within tag declarations to be affected
      var regex = new RegExp(">([^<]*)?("+searchTerms[i]+")([^>]*)?<","ig");
      highlightTextNodes(textContainerNode, regex, i);
      // Add to info-string
      searchInfo += ' <span class="highlighted term'+i+'">'+searchTerms[i]+'</span> ';
    }

    // Create div describing the search
    var searchTermDiv = document.createElement("H2");
    searchTermDiv.className = 'searchterms';
    //searchTermDiv.innerHTML = searchInfo;

    // Insert as very first child in searched node
    textContainerNode.insertBefore(searchTermDiv, textContainerNode.childNodes[0]);
  }
}

// Pull the search string out of the URL
function getSearchString() {
  // Return sanitized search string if it exists
  var rawSearchString = window.location.search.replace(/[a-zA-Z0-9\?\&\=\%\#]+fulltext\=([^&]+)(\&.*)?/,"$1");
  rawSearchString = utf8Url.decode(rawSearchString);
  // Replace '+' with '|' for regex
  // Also replace '%20' if your cms/blog uses this instead (credit to erlando for adding this)
  return rawSearchString.replace(/\%20|\+/g,"\|");
}

function highlightTextNodes(element, regex, termid) {
  var tempinnerHTML = element.innerHTML;
  // Do regex replace
  // Inject span with class of 'highlighted termX' for google style highlighting
  element.innerHTML = tempinnerHTML.replace(regex,'>$1<span class="highlighted term'+termid+'">$2</span>$3<');
}

sdiak = "áàäąćčďéèěëęíìľĺłńňóòôöőřśšťůúùüýźžżÁÀÄĄĆČĎÉÈĚËĘÍÌĽĹŁŃŇÓÒÔÖŐŘŚŠŤŮÚÙÜÝŹŽŻß";
bdiak = "aaaaccdeeeeeiilllnnooooorsstuuuuyzzzAAAACCDEEEEEIILLLNNOOOOORSSTUUUUYZZZs";
function bezdiak(string)
{
  tx = "";
  txt = string;
  for(p = 0; p < txt.length; p++)
  {
    if (sdiak.indexOf(txt.charAt(p)) != -1)
    {
      tx += bdiak.charAt(sdiak.indexOf(txt.charAt(p)));
    }
    else tx += txt.charAt(p);
  }
  return tx;
}
function rozsirregexp(string)
{
    var dia_reg = new Array();
    dia_reg["e"]='[ěeéëĚEÉË]';
    dia_reg["s"]='[šsŠS]';
    dia_reg["r"]='[řrŘR]';
    dia_reg["z"]='[žzŽZ]';
    dia_reg["y"]='[yýYÝ]';
    dia_reg["a"]='[aáäAÁÄ]';
    dia_reg["o"]='[oóöôõòőOÓÖÔÕÒŐ]';
    dia_reg["i"]='[iíïIÍÏ]';
    dia_reg["d"]='[dďDĎ]';
    dia_reg["t"]='[tťTŤ]';
    dia_reg["n"]='[nňNŇ]';
    dia_reg["l"]='[lľĺLĹĽ]';
    dia_reg["u"]='[uúůüUÚŮÜ]';
    dia_reg["c"]='[cčCČ]';
    tx = "";
    txt = string;
    for(p = 0; p < txt.length; p++)
    {
        var current = txt.charAt(p);
        if (dia_reg[current]) tx+=dia_reg[current];
            else tx+= current;
    }
    return tx;
}



