var menu_tree=null;var drops=[];function dNode(id,pid,name,url,title,target,icon,iconOpen,open,action,backSrc,class_name){this.id=id;this.pid=pid;this.name=name;this.url=url;this.title=title;this.target=target;this.icon=icon;this.iconOpen=iconOpen;this.backSrc=backSrc;this._io=open||false;this._is=false;this._ls=false;this._hc=false;this._ai=0;this._p;this.class_name=class_name||'';if(typeof action!="undefined"){this.action=action;}else{this.action='';}}
function dTree(objName,dirIcons){this.config={target:null,folderLinks:true,useSelection:true,useCookies:false,useLines:true,useIcons:true,useStatusText:false,closeSameLevel:false,inOrder:false,searcheable:true};this.icon={root:window.dir_images+'icons/silk/house.png',folder:dirIcons+'folder.gif',folderOpen:dirIcons+'folderopen.gif',node:dirIcons+'page.gif',empty:dirIcons+'empty.gif',line:dirIcons+'line.gif',join:dirIcons+'join.gif',joinBottom:dirIcons+'joinbottom.gif',plus:dirIcons+'plus.gif',plusBottom:dirIcons+'plusbottom.gif',minus:dirIcons+'minus.gif',minusBottom:dirIcons+'minusbottom.gif',nlPlus:dirIcons+'nolinesplus.gif',nlMinus:dirIcons+'nolinesminus.gif',eye:[window.dir_images+'icons/eye.png',window.dir_images+'icons/eye-strike.png']};this.obj=objName;this.aNodes=[];this.aIndent=[];this.root=new dNode(-1);this.selectedNode=null;this.selectedFound=false;this.completed=false;}
dTree.prototype.add=function(id,pid,name,url,title,target,icon,iconOpen,open,action,p_selected,backSrc,class_name){this.aNodes[this.aNodes.length]=new dNode(id,pid,name,url,title,target,icon,iconOpen,open,action,backSrc,class_name);if(p_selected!=0){this.selectedNode=this.aNodes.length-1;this.selectedFound=true;}};dTree.prototype.openAll=function(){this.oAll(true);};dTree.prototype.closeAll=function(){this.oAll(false);};dTree.prototype.toString=function(){var str='<div class="dtree">\n';if(this.config.useCookies){this.selectedNode=this.getSelected();}
str+=this.addNode(this.root,'');str+='</div>';if(!this.selectedFound){this.selectedNode=null;}
this.completed=true;return str;};dTree.prototype.addNode=function(pNode){var str='',n=0,cn;if(this.config.inOrder){n=pNode._ai;}
for(n;n<this.aNodes.length;n++){if(this.aNodes[n].pid==pNode.id){cn=this.aNodes[n];cn._p=pNode;cn._ai=n;this.setCS(cn);if(!cn.target&&this.config.target){cn.target=this.config.target;}
if(cn._hc&&!cn._io&&this.config.useCookies){cn._io=this.isOpen(cn.id);}
if(!this.config.folderLinks&&cn._hc){cn.url=null;}
if(this.config.useSelection&&cn.id==this.selectedNode&&!this.selectedFound){cn._is=true;this.selectedNode=n;this.selectedFound=true;}
str+=this.node(cn,n);if(cn._ls){break;}}}
return str;};dTree.prototype.node=function(node,nodeId){var str='<div class="node '+(node.class_name||'')+'" data-nodeid="'+node.id+'" >'+this.indent(node,nodeId),class_name;if(this.config.useIcons){if(!node.icon){node.icon=(this.root.id==node.pid)?this.icon.root:((node._hc)?this.icon.folder:this.icon.node);}
if(!node.iconOpen){node.iconOpen=(node._hc)?this.icon.folderOpen:this.icon.node;}
str+='<img id="i'+this.obj+nodeId+'" src="'+((node._io)?node.iconOpen:node.icon)+'" class="nodeIcon" />';}
if(node.url){if(nodeId==this.selectedNode){class_name='nodeSel';}else{class_name='node';}
if(node.url=='javascript:;'){class_name='nodeDisabled';}
if(nodeId==0){class_name="rootNode";}
str+='<a id="s'+this.obj+nodeId+'" class="'+class_name+'" href="'+node.url+'"';if(node.title){str+=' title="'+node.title+'"';}
if(node.target){str+=' target="'+node.target+'"';}
if(this.config.useStatusText){str+=' onmouseover="window.status=\''+node.name+'\';return true;" onmouseout="window.status=\'\';return true;" ';}
if(this.config.useSelection&&((node._hc&&this.config.folderLinks)||!node._hc)){if(node.url!='javascript:;'){str+=' onclick="javascript: '+this.obj+'.s('+nodeId+');"';}}
str+='>';if(typeof node.id=='number')
drops.push({nodeid:nodeId,id:node.id});}else if((!this.config.folderLinks||!node.url)&&node._hc&&node.pid!=this.root.id){if(node.action!=''){str+='<a href="javascript: '+this.obj+'.o('+nodeId+');'+node.action+'" class="node">';}else{str+='<a href="javascript: '+this.obj+'.o('+nodeId+');" class="node">';}}
str+=node.name;if(node.url||((!this.config.folderLinks||!node.url)&&node._hc)){str+='</a>';}
str+='</div>';if(node._hc){str+='<div id="d'+this.obj+nodeId+'" class="clip" style="display:'+((this.root.id==node.pid||node._io)?'block':'none')+';">';str+=this.addNode(node);str+='</div>';}
this.aIndent.pop();return str;};dTree.prototype.indent=function(node,nodeId){var str='';var backSrc='';if(node.backSrc.length>0){backSrc='background-image:url('+node.backSrc+');';}
if(this.root.id!=node.pid){for(var n=0;n<this.aIndent.length;n++){str+='<img src="'+((this.aIndent[n]==1&&this.config.useLines)?this.icon.line:this.icon.empty)+'" alt="" />';}
(node._ls)?this.aIndent.push(0):this.aIndent.push(1);if(node._hc){str+='<a href="javascript: '+this.obj+'.o('+nodeId+');"><img ';str+='style="'+backSrc+'" ';str+='id="j'+this.obj+nodeId+'" src="';if(!this.config.useLines){str+=(node._io)?this.icon.nlMinus:this.icon.nlPlus;}else{str+=((node._io)?((node._ls&&this.config.useLines)?this.icon.minusBottom:this.icon.minus):((node._ls&&this.config.useLines)?this.icon.plusBottom:this.icon.plus));}
str+='" alt="" /></a>';}else{str+='<img style="'+backSrc+'" src="'+((this.config.useLines)?((node._ls)?this.icon.joinBottom:this.icon.join):this.icon.empty)+'" alt="" />';}}
return str;};dTree.prototype.setCS=function(node){var lastId;for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n].pid==node.id)node._hc=true;if(this.aNodes[n].pid==node.pid)lastId=this.aNodes[n].id;}
if(lastId==node.id)node._ls=true;};dTree.prototype.getSelected=function(){var sn=this.getCookie('cs'+this.obj);return(sn)?sn:null;};dTree.prototype.s=function(id){if(!this.config.useSelection)return;var cn=this.aNodes[id];if(cn._hc&&!this.config.folderLinks)return;if(this.selectedNode!=id){if(this.selectedNode||this.selectedNode==0){eOld=document.getElementById("s"+this.obj+this.selectedNode);if(eOld)
eOld.className="node";}
eNew=$("s"+this.obj+id);if(eNew){eNew.className="nodeSel";}
this.selectedNode=id;if(this.config.useCookies)this.setCookie('cs'+this.obj,cn.id);}};dTree.prototype.o=function(id){var cn=this.aNodes[id];if(cn){this.nodeStatus(!cn._io,id,cn._ls);cn._io=!cn._io;if(this.config.closeSameLevel){this.closeLevel(cn);}
if(this.config.useCookies){this.updateCookie();}}};dTree.prototype.getNodeIdByName=function(name){for(var n=0;n<this.aNodes.length;n++){if(name==this.aNodes[n].name){return this.aNodes[n].id;}}
return null;};dTree.prototype.getNodeIdsByName=function(name,fuzzy){var foundNodes=[];for(var n=0;n<this.aNodes.length;n++){if(name==this.aNodes[n].name){foundNodes.push(this.aNodes[n].id);}}
return foundNodes;};dTree.prototype.oAll=function(status){for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n]._hc&&this.aNodes[n].pid!=this.root.id){this.nodeStatus(status,n,this.aNodes[n]._ls);this.aNodes[n]._io=status;}}
if(this.config.useCookies)this.updateCookie();};dTree.prototype.openTo=function(nId,bSelect,bFirst){if(!bFirst){for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n].id==nId){nId=n;break;}}}
var cn=this.aNodes[nId];if(cn){if(cn.pid==this.root.id||!cn._p){return;}
cn._io=true;cn._is=bSelect;if(this.completed&&cn._hc){this.nodeStatus(true,cn._ai,cn._ls);}
if(this.completed&&bSelect){this.s(cn._ai);}else if(bSelect){this._sn=cn._ai;}
this.openTo(cn._p._ai,false,true);}};dTree.prototype.closeLevel=function(node){for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n].pid==node.pid&&this.aNodes[n].id!=node.id&&this.aNodes[n]._hc){this.nodeStatus(false,n,this.aNodes[n]._ls);this.aNodes[n]._io=false;this.closeAllChildren(this.aNodes[n]);}}};dTree.prototype.closeAllChildren=function(node){for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n].pid==node.id&&this.aNodes[n]._hc){if(this.aNodes[n]._io){this.nodeStatus(false,n,this.aNodes[n]._ls);}
this.aNodes[n]._io=false;this.closeAllChildren(this.aNodes[n]);}}};dTree.prototype.nodeStatus=function(status,id,bottom){var eDiv=document.getElementById('d'+this.obj+id),eJoin=document.getElementById('j'+this.obj+id);if(this.config.useIcons){eIcon=document.getElementById('i'+this.obj+id);eIcon.src=(status)?this.aNodes[id].iconOpen:this.aNodes[id].icon;}
eJoin.src=(this.config.useLines)?((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):((status)?this.icon.nlMinus:this.icon.nlPlus);eDiv.style.display=(status)?'block':'none';};dTree.prototype.clearCookie=function(){var now=new Date(),yesterday=new Date(now.getTime()-1000*60*60*24);this.setCookie('co'+this.obj,'cookieValue',yesterday);this.setCookie('cs'+this.obj,'cookieValue',yesterday);};dTree.prototype.setCookie=function(cookieName,cookieValue,expires,path,domain,secure){document.cookie=escape(cookieName)+'='+escape(cookieValue)+
(expires?'; expires='+expires.toGMTString():'')+
(path?'; path='+path:'')+
(domain?'; domain='+domain:'')+
(secure?'; secure':'');};dTree.prototype.getCookie=function(cookieName){var cookieValue='',posName=document.cookie.indexOf(escape(cookieName)+'='),posValue,endPos;if(posName!=-1){posValue=posName+(escape(cookieName)+'=').length;endPos=document.cookie.indexOf(';',posValue);if(endPos!=-1){cookieValue=unescape(document.cookie.substring(posValue,endPos));}
else{cookieValue=unescape(document.cookie.substring(posValue));}}
return(cookieValue);};dTree.prototype.updateCookie=function(){var str='';for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n]._io&&this.aNodes[n].pid!=this.root.id){if(str){str+='.';}
str+=this.aNodes[n].id;}}
this.setCookie('co'+this.obj,str);};dTree.prototype.isOpen=function(id){var aOpen=this.getCookie('co'+this.obj).split('.');for(var n=0;n<aOpen.length;n++){if(aOpen[n]==id){return true;}}
return false;};dTree.prototype.addSearchCapabilities=function(){var $rootNodeContainer=$(this.obj).down('div[data-nodeid=0]');if($rootNodeContainer&&$(this.obj).down('div[data-nodeid=0] > a')){var $search_icon=new Element('img',{src:window.dir_images+'icons/silk/magnifier.png',id:'treeSearchIcon',className:'treeSearchIcon greyscale'});var $search_field=new Element('input',{type:'search',id:'treeSearchInput',placeholder:'Suche..',style:'display:none;border-radius:0;'});$rootNodeContainer.insert($search_field).insert($search_icon);$('treeSearchIcon').on("click",function(ev){$(this.obj).down('div[data-nodeid=0] > a').hide();$('treeSearchInput').show().focus();ev.findElement('img').hide();}.bind(this));$search_field.on('blur',this.hideSearchBox.bindAsEventListener(this));$search_field.on('keyup',this.keyInput.bindAsEventListener(this));$search_field.on('click',this.keyInput.bindAsEventListener(this));$search_field.on('keypress',function(e){if(e.keyCode==Event.KEY_RETURN)Event.stop(e);});}};dTree.prototype.hideSearchBox=function(){$('treeSearchIcon').show();$(this.obj).down('div[data-nodeid=0] > a').show();$('treeSearchInput').hide();$(this.obj).select('div.highlightSearch').each(function($el){$el.removeClassName('highlightSearch');});};dTree.prototype.o=function(id){var cn=this.aNodes[id];if(cn){this.nodeStatus(!cn._io,id,cn._ls);cn._io=!cn._io;if(this.config.closeSameLevel){this.closeLevel(cn);}
if(this.config.useCookies){this.updateCookie();}
$$('#dmenu_tree'+id+' > div.node').each(function(p_element){p_element.writeAttribute("style",null);});}};dTree.prototype.keyInput=function(ev){var $tree=$('dmenu_tree0'),$filter=ev.findElement('input'),value=$filter.getValue().toLowerCase(),controlKeys=[Event.KEY_RETURN,Event.KEY_DOWN,Event.KEY_UP,Event.KEY_ESC],unwantedKeys=[Event.KEY_LEFT,Event.KEY_RIGHT],hide=($('nodeVisibilityIcon').readAttribute('data-hide')==1),highlight=$tree.select('div.highlightSearch');if(unwantedKeys.indexOf(ev.keyCode)!==-1){return false;}
if(controlKeys.indexOf(ev.keyCode)!==-1){if(ev.keyCode==Event.KEY_RETURN){if(highlight.length>0){$tree.down('div.highlightSearch > a').simulate('click');}}
if(ev.keyCode==Event.KEY_ESC){this.hideSearchBox();$filter.setValue('');$tree.select('div.node:not(.hide)').each(function($node){$node.removeClassName('treeSearchResult');if(!$node.down('span')){$node.show();}});return;}
else{var $visible_elements=$tree.select('div.node:not(.hide)').findAll(function(el){return el.up().visible()&&el.visible();});if(highlight.length>0){var l_highlightedElement=highlight[0],l_highlightedElementIndex=$visible_elements.indexOf(l_highlightedElement),l_indexOfNext=0;l_highlightedElement.removeClassName('highlightSearch');if(ev.keyCode==Event.KEY_DOWN){l_indexOfNext=l_highlightedElementIndex+1;}else if(ev.keyCode==Event.KEY_UP){l_indexOfNext=l_highlightedElementIndex-1;}
if(!$visible_elements[l_indexOfNext])l_indexOfNext=0;$visible_elements[l_indexOfNext].addClassName('highlightSearch');ev.stop();}
else{$tree.down('div.node:not(.hide):visible').addClassName('highlightSearch');}}
return false;}
if(value.length>=2){this.oAll();$tree.select('div.node:not(.hide) > a').each(function($link){var i=0;if($link.innerHTML.toLowerCase().indexOf(value)!==-1){$link.up().addClassName('treeSearchResult').show();while($link.up('.clip',i)){$link.up('.clip',i).writeAttribute('style','display: block').previous().writeAttribute('style','display: block');if($link.up('.clip',i).previous().down('a > img[src*="plus.gif"]')){$link.up('.clip',i).previous().down('a').simulate('click');}
i++;}}else{$link.up().removeClassName('treeSearchResult').hide();}});}else{$tree.select('div.node').invoke('show');this.processVisibility();}};dTree.prototype.addNodesVisibility=function(hide){var $root_node_container=$(this.obj).down('div[data-nodeid="0"]'),$visibility_icon=new Element('img',{src:this.icon.eye[hide],id:'nodeVisibilityIcon',className:'greyscale','data-hide':hide});if($root_node_container){$root_node_container.insert($visibility_icon);$visibility_icon.on("click",function(){this.toggleVisibility();}.bind(this));this.processVisibility();}};dTree.prototype.toggleVisibility=function(){var $node_container=$('dmenu_tree0'),$toggler=$('nodeVisibilityIcon'),params={},hide=($toggler.readAttribute('data-hide')==1);$toggler.writeAttribute('data-hide',(hide?0:1)).writeAttribute('src',this.icon.eye[$toggler.readAttribute('data-hide')]);if($node_container){$node_container.select('span.noentries,span.obj_noentries').invoke('up','div').invoke((hide?'addClassName':'removeClassName'),'hide');}
if($node_container.down('.noentries')){params.categories=hide?0:1;}else{params.objtype=hide?0:1;}
new Ajax.Request('?call=menu&ajax=1&func=save_tree_visibility',{parameters:params});this.processVisibility();};dTree.prototype.processVisibility=function(){var $node_container=$('dmenu_tree0'),$toggler=$('nodeVisibilityIcon'),hide=($toggler.readAttribute('data-hide')==1);if($node_container){$node_container.select('span.noentries,span.obj_noentries').invoke('up','div').invoke((hide?'addClassName':'removeClassName'),'hide');if(!hide){$node_container.select('div.node.hide').invoke('removeClassName','hide');}}};function changeCount(val,direction,negate){if(direction=='up'){return parseInt(val)+1;}else{val=parseInt(val);if(negate==true){return val-1;}else{if(val<2){return val;}else{return val-1;}}}}
function checkNeg($el){if(Object.isElement($el)&&parseInt($el.getValue())<1){$el.setValue(1);}}
function checkNaN($el){var val;if(Object.isElement($el)){val=parseInt($el.getValue().replace(/\D/g,''));if(isNaN(val)){$el.setValue(1);}else{$el.setValue(val);}}}
function raidcalc(p_disks,p_space,p_raidtype,p_target){var l_num_disks=parseInt(p_disks),l_space="-",l_message="",l_diskspace_each=parseFloat(p_space),l_diskspace,strUtilization,factor=1,factor_potency=1024,unit=' B';if(l_num_disks%2!=0&&(p_raidtype=="1"||p_raidtype=="10")){l_message=" Disk amount must be a multiple of 2.";l_num_disks--;}
l_diskspace=(l_num_disks*l_diskspace_each);if(p_space>1024){factor=factor_potency;unit=' KB';if(p_space>(factor_potency=Math.pow(1024,2))){factor=factor_potency;unit=' MB';if(p_space>(factor_potency=Math.pow(1024,3))){factor=factor_potency;unit=' GB';if(p_space>(factor_potency=Math.pow(1024,4))){factor=factor_potency;unit=' TB';}}}}
switch(p_raidtype){case"1":if(l_num_disks>=2){strUtilization=(l_diskspace / factor)/ 2;l_space=parseInt(strUtilization*1000000)/ 1000000;}
break;case"10":if(l_num_disks>=4){strUtilization=(l_diskspace / factor)/ 2;l_space=parseInt(strUtilization*1000000)/ 1000000;}
break;case"2":break;case"3":if(l_num_disks>=3){strUtilization=((l_diskspace / factor)*((parseInt(((l_num_disks-1)/ l_num_disks)*10000)/ 100)/ 100));l_space=parseInt(strUtilization*1000000)/ 1000000;}
break;case"4":if(l_num_disks>=3){strUtilization=((l_diskspace / factor)*((parseInt(((l_num_disks-1)/ l_num_disks)*10000)/ 100)/ 100));l_space=parseInt(strUtilization*1000000)/ 1000000;}
break;case"5":if(l_num_disks>=3){strUtilization=((l_diskspace / factor)/ parseInt(l_num_disks))*(parseInt(l_num_disks)-1);l_space=parseInt(strUtilization*1000000)/ 1000000;}
break;case"6":if(l_num_disks>=4){strUtilization=((l_diskspace / factor)*((parseInt(((l_num_disks-2)/ l_num_disks)*10000)/ 100)/ 100));l_space=parseInt(strUtilization*1000000)/ 1000000;}
break;case"0":if(l_num_disks>=2){strUtilization=l_diskspace;l_space=parseInt(strUtilization*1000000)/ 1000000+l_message;}
break;}
if($(p_target)){if(l_space!=0&&isNumeric(l_space)){$(p_target).update(l_space+unit);}
else{$(p_target).update('0.00');}}
if(l_space!=0&&isNumeric(l_space)){return l_space;}}
if(!Date.hasOwnProperty('is_leap_year')){Date.prototype.is_leap_year=function(){var year=this.getFullYear();return((year%4===0&&year%100!==0)||year%400===0);};}
if(!Date.hasOwnProperty('get_days_in_month')){Date.prototype.get_days_in_month=function(){return[31,(this.is_leap_year()?29:28),31,30,31,30,31,31,30,31,30,31][this.getMonth()];};}
document.observe('dom:loaded',function(){"use strict";idoit.Notify=Class.create({initialize:function(options){var opt=Object.extend({location:'br'},options||{});this.notification_options={header:'',speedin:0.3,speedout:0.5,life:2,sticky:false,className:'',width:'250px',created:Prototype.emptyFunction,destroyed:Prototype.emptyFunction};this.locations={tr:{top:0,right:0},br:{bottom:'5px',right:'9px'},tl:{top:0,left:0},bl:{bottom:0,left:0},tc:{top:0,left:'25%',width:'50%'},bc:{bottom:0,left:'25%',width:'50%'}};this.element=new Element("div",{className:"Notify",id:"Notify"}).setStyle({position:"fixed",padding:"10px",zIndex:"50000"});if(opt.hasOwnProperty('location')&&this.locations.hasOwnProperty(opt.location)){this.element.setStyle(this.locations[opt.location]);}
this.element.wrap(document.body);},render:function(msg,options){var opt=Object.extend(Object.clone(this.notification_options),options||{}),notice,notify=this.element;opt.className=(opt.hasOwnProperty('className')?'item '+opt.className:'item');notice=new Element("div",{"class":opt.className}).setStyle({display:"block",opacity:0}).observe("notify:created",opt.created).observe("notify:destroyed",opt.destroyed);if(opt.sticky){notice.insert(new Element("div",{"class":"exit"}).update("&times;"));}
if(opt.width){notice.style.width=opt.width;}
notice.insert(new Element("div",{"class":"head"}).update(opt.header)).insert(new Element("div",{"class":"body"}).update(msg)).on('click',function(){this.remove(notice,opt);}.bind(this));notify.insert(notice);var opacity=new Effect.Opacity(notice,{to:0.85,duration:opt.speedin});if(!opt.sticky){this.remove.delay(opt.life,notice,opt);}
notice.fire("notify:created");return notice;},remove:function(notice,options){var opt=Object.extend(Object.clone(this.notification_options),options||{});var morph=new Effect.Morph(notice,{duration:opt.speedout,style:'margin-bottom:'+(notice.getHeight()*-1)+'px; opacity:0;',afterFinish:function(){try{notice.fire("notify:destroyed");notice.stopObserving().remove();}catch(e){}}});},message:function(message,options){options=Object.extend({header:idoit.Translate.get('LC__NOTIFY__MESSAGE')},options||{});options.className=(options.hasOwnProperty('className')?options.className+' box-grey':'box-grey');this.render(message,options);},success:function(message,options){options=Object.extend({header:idoit.Translate.get('LC__NOTIFY__SUCCESS')},options||{});options.className=(options.hasOwnProperty('className')?options.className+' box-green':'box-green');this.render(message,options);},error:function(message,options){options=Object.extend({life:10,header:idoit.Translate.get('LC__NOTIFY__ERROR')},options||{});options.className=(options.hasOwnProperty('className')?options.className+' box-red':'box-red');this.render(message,options);},info:function(message,options){options=Object.extend({header:idoit.Translate.get('LC__NOTIFY__INFO')},options||{});options.className=(options.hasOwnProperty('className')?options.className+' box-blue':'box-blue');this.render(message,options);},warning:function(message,options){options=Object.extend({header:idoit.Translate.get('LC__NOTIFY__WARNING')},options||{});options.className=(options.hasOwnProperty('className')?options.className+' box-yellow':'box-yellow');this.render(message,options);},renderNotification:function(notification){switch(notification.type){default:case 0:idoit.Notify.message(notification.message,notification.options);break;case 1:idoit.Notify.success(notification.message,notification.options);break;case 2:idoit.Notify.error(notification.message,notification.options);break;case 3:idoit.Notify.info(notification.message,notification.options);break;case 4:idoit.Notify.warning(notification.message,notification.options);break;}},test:function(){this.error('error',{sticky:true});this.success('success',{sticky:true});this.info('info',{sticky:true});this.warning('warning',{sticky:true});this.message('message',{sticky:true});}});idoit.Notify=new idoit.Notify();Ajax.Responders.register({onComplete:function(ev){var notification,cnt=0;while(notification=ev.getHeader('X-i-doit-Notification-'+cnt)){cnt++;idoit.Notify.renderNotification(notification.evalJSON());}}});});window.CMDB_Explorer=Class.create({vis:null,svg:null,layout:null,zoom_ev:null,options:{},profile:{},$tooltip_div:null,get_option:function(option){return this.options[option];},set_option:function(option,value){this.options[option]=value;return this;},get_svg:function(){return this.svg},set_svg:function(svg){this.svg=svg;return this;},initialize:function($el,data,options,profile,object_types){this.$element=$el;this.data=data||[];this.options={name:'',zoom:true,minZoomLevel:0.125,maxZoomLevel:2,nodeWidth:50,nodeHeight:10,node_row_height:20,mouseover:Prototype.emptyFunction,mouseout:Prototype.emptyFunction,click:Prototype.emptyFunction,dblclick:Prototype.emptyFunction,width:null,height:null,append_styles:this.append_styles,tooltips:false};this.profile=profile||{};this.object_types=object_types||{};this.options.width=$el.getWidth();this.options.height=$el.getHeight();idoit.callbackManager.registerCallback('visualization-zoom',this.zoom,this);Object.extend(this.options,options||{});this.svg=d3.select(this.$element).select('svg');this.zoom_ev=d3.zoom().scaleExtent([this.options.minZoomLevel,this.options.maxZoomLevel]).on('zoom',this.zooming.bind(this));if(!this.svg.node()){this.svg=d3.select(this.$element).append('svg').attr("xmlns","http://www.w3.org/2000/svg").attr('id',this.options.name).attr('width','100%').attr('height','100%');this.svg.call(this.zoom_ev).on('dblclick.zoom',null);}
this.flash_node();},flash_node:function(){setTimeout(function(){if(this.vis){this.vis.selectAll('.flash').select('rect').transition().style('stroke',this.profile['highlight-color']).style('stroke-width','7px').style('stroke-opacity',1).transition().delay(500).style('stroke',null).style('stroke-width',null).style('stroke-opacity',null)}
this.flash_node();}.bind(this),1000);},append_styles:function(){var defs=this.svg.select('defs');if(defs.node()===null){defs=this.svg.append('defs');defs.append('style').attr('type','text/css').text("text {                     font-size:11px;                     font-family: \"Helvetica Neue\", \"Lucida Grande\", \"Tahoma\", Arial;                 }                 .link {                     fill: none;                     stroke: #aaa;                     stroke-linejoin: round;                     stroke-width: 1px;                 }                .arrow {                    fill: #aaa;                }                .link.highlight {                    stroke-width: 3px;                }                .node {                    cursor: pointer;                }                .node:hover rect:first-child {                    stroke-width: 3px;                }                .node rect:first-child {                    fill: transparent;                    stroke: #000;                    stroke-opacity: 0.5;                }                .node.active rect:first-child {                    stroke-width: 4px;                    stroke-opacity: 1;                }                .node.highlight rect:first-child,                .node rect.root-object {                    stroke-width: 4px;                    stroke-opacity: 1;                }                .transparent {                    fill-opacity: 0.2;                    stroke-opacity: 0.2;                }");defs.append("svg:marker").attr("id",'end').attr("viewBox","0 -5 10 10").attr("refX",0).attr("refY",0).attr("markerWidth",18).attr("markerHeight",7).attr("orient","auto").append("svg:path").attr("d","M0,-5L10,0L0,5").attr("class","arrow");defs.append("svg:marker").attr("id",'end-highlight').attr("viewBox","0 -5 10 10").attr("refX",0).attr("refY",0).attr("markerWidth",18).attr("markerHeight",5).attr("orient","auto").append("svg:path").attr("d","M0,-5L10,0L0,5").attr("class","arrow-highlight").style('fill',this.profile['highlight-color']);}},process:Prototype.emptyFunction,render_nodes:function(nodes){var i,explorer=this,profile=this.profile,object_types=this.object_types,profile_rows=Object.keys(profile.rows).length,fillcolor,fontcolor,text,text_margin,row,pos_y=(profile_rows*this.options.node_row_height)*-0.5;nodes.attr('data-relation-obj-id',function(d){return d.data.data.relation_obj_id;}).attr('data-obj-type-id',function(d){return d.data.data.obj_type_id;}).attr('data-object-id',function(d){return d.data.data.obj_id}).attr('data-id',function(d){return d.data.id});if(profile.mikro){nodes.append('circle').attr('r','5px').attr('style',function(d){return'fill:'+d.data.obj_type_color+'; stroke:#eee; stroke-width:1px;';});nodes.append('text').attr('x',13).attr('y',4).text(function(d){return d.data.obj_type_title+': '+d.data.obj_title;});}
else{nodes.append('rect').attr('x',-(profile.width / 2)).attr('y',pos_y).attr('width',profile.width).attr('height',(profile_rows*this.options.node_row_height)).attr('class',function(d){return(d.data['root-object'])?'root-object':null;}).attr('style',function(d){var style='';if(d.data.data['root-object']){style+='stroke:'+profile['highlight-color']+';';}
if(d.data.data.doubling){style+='stroke-dasharray:7,2; stroke-width:3px;';}
return style;});for(i in profile.rows){if(profile.rows.hasOwnProperty(i)){row=profile.rows[i];fillcolor=row.fillcolor||'';fontcolor=row.fontcolor||'#000000';text=null;text_margin=0;if(!(Object.isString(fillcolor)&&fillcolor.substr(0,1)=='#')){fillcolor=function(d){return object_types[d.data.data.obj_type_id].color;};}
nodes.append('rect').style('fill',fillcolor).attr('x',-(profile.width / 2)).attr('y',pos_y).attr('width',profile.width).attr('height',this.options.node_row_height);if(row.option=='obj-type-title-icon'){nodes.append('image').attr('xlink:href',function(d){return object_types[d.data.data.obj_type_id].icon}).attr('x',-((profile.width / 2)-3)).attr('y',(pos_y+2)).attr('width',16).attr('height',16);text=nodes.append('text').text(function(d){return explorer.text_format.call(this,d.data.content[row.option],(profile.width-30));});if(row['font-align-right']){text_margin=5;}
else{text.attr('x',-((profile.width / 2)-22));}}
else if(row.option=='obj-title-type-title-icon-cmdb-status'){nodes.append('image').attr('xlink:href',function(d){return object_types[d.data.data.obj_type_id].icon}).attr('x',-((profile.width / 2)-3)).attr('y',(pos_y+2)).attr('width',16).attr('height',16);nodes.append('rect').style('fill',function(d){return d.data.content[row.option]['cmdb-color'];}).style('stroke','#000000').style('stroke-width',0.5).attr('rx',3).attr('ry',3).attr('x',((profile.width / 2)-13)).attr('y',(pos_y+4)).attr('width',10).attr('height',12);text=nodes.append('text').text(function(d){return explorer.text_format.call(this,d.data.content[row.option]['obj-type-title']+': '+d.data.content[row.option]['obj-title'],(profile.width-40));});if(row['font-align-right']){text_margin=15;}
else{text.attr('x',-((profile.width / 2)-22));}}
else if(row.option=='obj-title-cmdb-status'){nodes.append('rect').style('fill',function(d){return d.data.content[row.option]['cmdb-color'];}).style('stroke','#000000').style('stroke-width',0.5).attr('rx',3).attr('ry',3).attr('x',((profile.width / 2)-13)).attr('y',(pos_y+4)).attr('width',10).attr('height',12);text=nodes.append('text').text(function(d){return explorer.text_format.call(this,d.data.content[row.option]['obj-title'],(profile.width-40));});if(row['font-align-middle']){text_margin=10;}
else if(row['font-align-right']){text_margin=15;}
else{text.attr('x',-((profile.width / 2)-5));}}
else if(row.option=='cmdb-status'){nodes.append('rect').style('fill',function(d){return d.data.content[row.option].color;}).style('stroke','#000000').style('stroke-width',0.5).attr('rx',3).attr('ry',3).attr('x',-((profile.width / 2)-3)).attr('y',(pos_y+4)).attr('width',10).attr('height',12);text=nodes.append('text').text(function(d){return explorer.text_format.call(this,d.data.content[row.option].title,(profile.width-20));});if(row['font-align-right']){text_margin=5;}
else{text.attr('x',-((profile.width / 2)-16));}}
else{text=nodes.append('text').attr('x',-((profile.width / 2)-5)).text(function(d){return explorer.text_format.call(this,d.data.content[row.option],(profile.width-15));});}
if(text!==null){text.attr('y',(pos_y+4+(this.options.node_row_height / 2))).style('fill',fontcolor);if(row['font-align-middle']){text.attr('x',-text_margin).style('text-anchor','middle');}
if(row['font-align-right']){text.attr('x',function(d){return((profile.width / 2)-(this.getComputedTextLength()+text_margin));}).style('text-anchor','right');}
if(row['font-bold']){text.style('font-weight','bold');}
if(row['font-italic']){text.style('font-style','italic');}
if(row['font-underline']){text.style('text-decoration','underline');}}
pos_y+=this.options.node_row_height;}}}},stop:function(){this.layout.stop();},zooming:function(){var g=this.vis||d3.select('#'+this.options.name+'_g');this.hide_tooltip();g.attr('transform',d3.event.transform);},zoom:function(){var newTranslate=[0,0],newScale=1;this.hide_tooltip();if(this.instance==='CMDB_Explorer_Tree'){newTranslate=[(this.options.width / 2),(this.options.height / 2)];}
this.svg.transition().duration(500).call(this.zoom_ev.transform,d3.zoomIdentity.translate(newTranslate[0],newTranslate[1]).scale(newScale));},text_format:function(text,width){var result=text;if(width<=0){return'';}
d3.select(this).text(result);while(this.getComputedTextLength()>width){result=result.substr(0,(result.length-2));d3.select(this).text(result);}
if(result!=text&&width>2){result+='..';}
return result;},toggle_obj_type_transparency:function(obj_types){if(!Object.isArray(obj_types)){this.options.obj_type_filter=[];return false;}
this.vis.selectAll('[data-obj-type-id]').classed('transparent',function(d){return!obj_types.in_array(d.data.data.obj_type_id);}).selectAll('image').classed('opacity-30',function(d){return!obj_types.in_array(d.data.data.obj_type_id);});this.options.obj_type_filter=obj_types;},prepare_tooltips:function(){if(this.options.tooltips){if(!this.$tooltip_div){this.$tooltip_div=new Element('div',{className:'mouse-pointer explorer-tooltip',style:'position:fixed; top:-20; left:-20;'});}
this.$element.insert(this.$tooltip_div);this.vis.selectAll('.node').on('mouseover',function(d){var style={top:(d3.event.clientY-5)+'px',left:(d3.event.clientX-5)+'px',height:'10px',width:'10px'};this.$tooltip_div.stopObserving('click').on('click',function(){this.options.click(d);}.bind(this));this.$tooltip_div.stopObserving('dblclick').on('dblclick',function(){this.options.dblclick(d);}.bind(this));new Tip(this.$tooltip_div.setStyle(style),new Element('p',{className:'p5',style:'font-size:12px;'}).update(d.data.data.obj_type_title+': '+d.data.data.obj_title),{effect:'appear',style:'darkgrey'});}.bind(this));}
return this;},hide_tooltip:function(){if(this.options.tooltips&&this.$element.down('.explorer-tooltip')){this.$element.select('.explorer-tooltip').each(function($tooltip){$tooltip.setStyle({top:-20,left:-20})});}}});window.CMDB_Explorer_Graph=Class.create(window.CMDB_Explorer,{initialize:function($super,$el,data,options,profile,object_types){this.instance='CMDB_Explorer_Graph';this.options.gravity=.15;this.options.charge=-30;this.options.obj_type_filter=[];idoit.callbackManager.registerCallback('visualization-toggle-obj-types',this.toggle_obj_type_transparency,this);$super($el,data,options,profile,object_types);},show_root_path:function(d){var nodes=d3.select('.node.active').classed('active',false),node=d3.select('[data-id="'+d.id+'"]').classed('active',true);nodes.select('rect').style('stroke',null);node.select('rect').style('stroke',this.profile['highlight-color']);if(this.profile.mikro){nodes.select('text').style('font-weight',null);node.select('text').style('font-weight','bold');}
this.vis.selectAll('.link').classed('highlight',false).style('stroke',null).attr("marker-mid","url(#end)").filter(function(d2){return(d2.source===d||d2.target===d);}).classed('highlight',true).style('stroke',this.profile['highlight-color']).attr("marker-mid","url(#end-highlight)");},process:function(){var i,i2,width=this.$element.getWidth(),height=this.$element.getHeight(),linkDistance=(this.profile.mikro?200:Math.sqrt(Math.pow(this.options.nodeWidth,2)+Math.pow(this.options.nodeHeight,2))*1.5),idMapper=[],linkArray=[];if(!this.layout){this.layout=cola.d3adaptor(d3).convergenceThreshold(0.1);}
if(!this.vis){this.vis=this.svg.append('g').attr('id',this.options.name+'_g').attr('transform','translate(0,0) scale(1)');}
this.layout.size([width,height]).linkDistance(linkDistance).on("tick",function(){this.vis.selectAll('.node').attr('transform',function(d){return'translate('+d.x+','+d.y+')';});this.vis.selectAll('.link').attr('d',function(d){var dx=(d.target.x+d.source.x)/2,dy=(d.target.y+d.source.y)/2;return"M"+d.source.x+","+d.source.y+"L"+dx+","+dy+"L"+d.target.x+","+d.target.y;});if(Prototype.Browser.IE||!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)){this.vis.selectAll('.link').each(function(){this.parentNode.insertBefore(this,this);});}}.bind(this));for(i in this.data){if(this.data.hasOwnProperty(i)){if(idMapper.indexOf(parseInt(this.data[i].id))==-1){this.data[i].data.data=this.data[i].data;this.data[i].data.content=this.data[i].content;idMapper.push(parseInt(this.data[i].id));}}}
for(i in this.data){if(this.data.hasOwnProperty(i)){for(i2 in this.data[i].children){if(this.data[i].children.hasOwnProperty(i2)&&idMapper.indexOf(parseInt(this.data[i].children[i2]))!=-1){linkArray.push({source:idMapper.indexOf(parseInt(this.data[i].id)),target:idMapper.indexOf(parseInt(this.data[i].children[i2]))});}}
this.data[i].id=null;delete this.data[i].children;}}
this.render(linkArray);this.prepare_tooltips();this.options.append_styles.call(this);},render:function(list_array){var nodeEnter,node,link;this.layout.nodes(this.data).links(list_array).start(20,60,200);node=this.vis.selectAll('.node').data(this.layout.nodes());nodeEnter=node.enter().append("g").style("opacity",0).attr("class","node").on('mouseover',this.options.mouseover).on('mouseout',this.options.mouseout).on('click',this.options.click).on('dblclick',this.options.dblclick);this.vis.selectAll('.node').interrupt().transition().duration(500).style("opacity",1);link=this.vis.selectAll('.link').data(this.layout.links());link.enter().insert("path","g").style("opacity",0).attr("d",function(d){var dx=(d.target.x+d.source.x)/2,dy=(d.target.y+d.source.y)/2;return"M"+d.source.x+","+d.source.y+"L"+dx+","+dy+"L"+d.target.x+","+d.target.y;}).attr("class","link").attr("marker-mid","url(#end)");this.vis.selectAll('.link').interrupt().transition().duration(500).style("opacity",1);try{this.render_nodes(nodeEnter);}
catch(e){idoit.Notify.error(e);}
if(Object.isArray(this.options.obj_type_filter)){this.toggle_obj_type_transparency(this.options.obj_type_filter);}}});window.CMDB_Explorer_Tree=Class.create(CMDB_Explorer,{initialize:function($super,$el,data,options,profile,object_types){this.instance='CMDB_Explorer_Tree';this.options.vertical=true;this.options.levelDistance=100;this.options.mirrored=false;this.options.top_tree='';this.options.bottom_tree='';this.options.obj_type_filter=[];idoit.callbackManager.registerCallback('visualization-toggle-orientation',this.toggle_orientation,this);idoit.callbackManager.registerCallback('visualization-toggle-obj-types',this.toggle_obj_type_transparency,this);$super($el,data,options,profile,object_types);this.layout=d3.tree().size(['100%','100%']).separation(function(){return 1;});},appendChildren:function(children){this.data=this.data.concat(children);return this;},toggleChildren:function(d,filter){var i;for(i in this.data){if(this.data.hasOwnProperty(i)&&this.data[i].parent==d.id){this.data[i].filtered=filter;this.toggleChildren(this.data[i],filter);}}
return this;},findDataById:function(id){var data=this.data.filter(function(d){return d.id==id;});if(data.length){return data[0];}
return false;},show_root_path:function(d){this.svg.select('.node.active').classed('active',false);var parent=this.vis.select('[data-id="'+d.data.id+'"]').classed('active',true).data()[0],nodePath=[];this.svg.selectAll('.highlight').classed('highlight',false).select('rect:not(.root-object)').style('stroke',null);while(parent!==null){nodePath.push(parent);this.vis.select('[data-id="'+parent.id+'"]').classed('highlight',true).select('rect').style('stroke',this.profile['highlight-color']);parent=parent.parent;}
this.svg.selectAll('path.link').style('stroke',null).filter(function(d){return(nodePath.in_array(d.target));}).classed('highlight',true).style('stroke',this.profile['highlight-color']);},toggle_orientation:function(){this.options.vertical=!this.options.vertical;this.hide_tooltip();this.process();},process:function(){if(!this.vis){this.vis=this.svg.append('g').attr('id',this.options.name+'_g').attr('transform','translate('+(this.options.width / 2)+','+(this.options.height / 2)+') scale(1)');}
this.dataCache=this.data.filter(function(d){return!d.filtered;});this.layout.nodeSize(this.options.vertical?[this.options.nodeWidth,this.options.nodeHeight]:[this.options.nodeHeight,this.options.nodeWidth]);this.render();this.prepare_tooltips();this.options.append_styles.call(this);},render:function(){this.dataCache.sort(function(a,b){return a.name.localeCompare(b.name);});var that=this,root=d3.stratify().id(function(d){return d.id;}).parentId(function(d){return d.parent;})(this.dataCache),treeData=this.layout(root),nodes=treeData.descendants(),links=treeData.links(),nodeMargin=5,nodeEnter,node,link,i;var diagonal=function(s,d){var sourceX,sourceY,targetX,targetY,delta=(that.options.levelDistance / 5);if(that.options.vertical){sourceX=s.x;targetX=d.x;if(that.options.mirrored){delta=-Math.abs(delta);sourceY=-Math.abs(s.y)-(that.options.nodeHeight/2)+nodeMargin;targetY=-Math.abs(d.y)+(that.options.nodeHeight/2)-nodeMargin;}else{sourceY=(s.y+(that.options.nodeHeight/2)-nodeMargin);targetY=(d.y-(that.options.nodeHeight/2)+nodeMargin);}
return'M'+sourceX+' '+sourceY+'C'+sourceX+' '+(sourceY+delta)+','+targetX+' '+(targetY-delta)+','+targetX+' '+targetY;}
sourceY=s.x;targetY=d.x;if(that.options.mirrored){delta=-Math.abs(delta);sourceX=-Math.abs(s.y)-(that.options.nodeWidth/2)+nodeMargin;targetX=-Math.abs(d.y)+(that.options.nodeWidth/2)-nodeMargin;}else{sourceX=(s.y+(that.options.nodeWidth/2)-nodeMargin);targetX=(d.y-(that.options.nodeWidth/2)+nodeMargin);}
return'M'+sourceX+' '+sourceY+'C'+(sourceX+delta)+' '+sourceY+','+(targetX-delta)+' '+targetY+','+targetX+' '+targetY;};for(i in nodes){if(nodes.hasOwnProperty(i)){nodes[i].y=nodes[i].depth*that.options.levelDistance;if(that.options.mirrored){nodes[i].y*=-1;}}}
node=this.vis.selectAll("g.node").data(nodes,function(d){return d.id||(d.id=++i);});nodeEnter=node.enter().append("g").style("opacity",0).attr("class","node").attr("transform",function(d){if(that.options.vertical){return"translate("+d.x+","+(d.y*0.9)+")";}else{return"translate("+(d.y*0.9)+","+d.x+")";}}).on('mouseover',this.options.mouseover).on('mouseout',this.options.mouseout).on('click',this.options.click).on('dblclick',this.options.dblclick);this.vis.selectAll("g.node").interrupt().transition().duration(500).style("opacity",1).attr("transform",function(d){if(that.options.vertical){return"translate("+d.x+","+d.y+")";}else{return"translate("+d.y+","+d.x+")";}});node.exit().interrupt().transition().duration(500).style("opacity",0).remove();link=this.vis.selectAll("path.link").data(links,function(d){return d.target.data.id;});link.enter().insert("path","g").style("opacity",0).attr("class","link").attr('d',function(d){return diagonal(d.source,d.target);});this.vis.selectAll("path.link").interrupt().transition().duration(500).style("opacity",1).attr('d',function(d){return diagonal(d.source,d.target);});link.exit().interrupt().transition().duration(500).style("opacity",0).remove();this.render_nodes(nodeEnter);if(Object.isArray(this.options.obj_type_filter)){this.toggle_obj_type_transparency(this.options.obj_type_filter);}},zooming:function(){var top=d3.select('#'+this.options.top_tree+'_g'),bottom=d3.select('#'+this.options.bottom_tree+'_g');this.hide_tooltip();if(top){top.attr('transform',d3.event.transform);}
if(bottom){bottom.attr('transform',d3.event.transform);}}});var PropertySelector=Class.create();PropertySelector.prototype={initialize:function(name,options){this.name=name;this.options=options;this.$selectionList=$(this.name+'_selection_field');this.$selectionBox=this.$selectionList.up('div');this.$sortCanceler=new Element('img',{src:window.dir_images+'icons/silk/cross.png',className:'fr mr5 mouse-pointer hide',title:idoit.Translate.get('LC__UNIVERSAL__DESELECT')});this.options=Object.extend({url:'?call=get_category_data&ajax=1',provides:null,group:true,sortable:false,max_items:38,dynamic_properties:false,allow_sorting:false,default_sorting:null,check_sorting:false,report:false,custom_fields:false,allowed_prop_types:[],consider_rights:true,hidden_field_name:'lvls_raw',lvl:1,catg_selection:null,cats_selection:null,catg_custom_selection:null,parent_prop:null,selector_size:'',dialog_width:'',complete_selection:null,replace_dynamic_properties:false,searchable:false,obj_type_id:null},options||{});if(this.options.catg_selection==null&&$(this.name+'_catg_selection')){this.options.catg_selection=$(this.name+'_catg_selection').clone(true);}
if(this.options.cats_selection==null&&$(this.name+'_cats_selection')){this.options.cats_selection=$(this.name+'_cats_selection').clone(true);}
if(this.options.complete_selection==null){this.options.complete_selection=this.name+'__COMPLETE';}
$(this.name+'_catg_selection').on('change',function(){this.load_properties('g');}.bind(this));$(this.name+'_cats_selection').on('change',function(){this.load_properties('s');}.bind(this));if(this.options.searchable){$(this.name+'_search_button').on('click',function(){this.search_properties($(this.name+'_search_input').getValue());}.bind(this));$(this.name+'_search_input').on('keypress',function(evt){if($(this.name+'_search_input').getValue().length>2){$(this.name+'_search_button').removeAttribute('disabled');if(evt.keyCode==13){this.search_properties($(this.name+'_search_input').getValue());}}
else{$(this.name+'_search_button').setAttribute('disabled','disabled');$(this.name+'_search_input').highlight();}
if(evt.keyCode==13){evt.preventDefault();}}.bind(this));this.search_properties('');}
if(this.options.allow_sorting){this.$selectionBox.down('div').insert(this.$sortCanceler);this.$sortCanceler.on('click',function(){var $checked=this.$selectionBox.down(':checked');if($checked){$checked.setValue(0);this.$sortCanceler.addClassName('hide');}}.bind(this));this.$selectionBox.on('change','input',function(){this.$sortCanceler.removeClassName('hide');}.bind(this));}
this.load_properties('g');this.load_properties('s');if(this.options.custom_fields){if(this.options.catg_custom_selection==null&&$(this.name+'_catg_custom_selection')){this.options.catg_custom_selection=$(this.name+'_catg_custom_selection').clone(true);}
$(this.name+'_catg_custom_selection').on('change',function(){this.load_properties('g_custom');}.bind(this));this.load_properties('g_custom');}},load_properties:function(cat_type){var cat_const=$(this.name+'_cat'+cat_type+'_selection').value;new Ajax.Request(this.options.url+'&func=get_properties_by_database',{parameters:{'cat_const':cat_const,'cat_type':cat_type,'provide':this.options.provides,'dynamic_properties':this.options.dynamic_properties,'consider_rights':this.options.consider_rights,'replace_dynamic_properties':this.options.replace_dynamic_properties},method:"post",onSuccess:function(transport){var arr=transport.responseJSON,i,$prop_box=$(this.name+'_cat'+cat_type+'_properties').update('');if(Object.keys(arr).length===0){$prop_box.insert(new Element('div',{className:'category-field'}).update(idoit.Translate.get('LC__REPORT__NO_ATTRIBUTES_FOUND')));}else{for(i in arr){if(arr.hasOwnProperty(i)){var $add_button=new Element('span',{className:'plus'}),$property=new Element('div',{className:'category-field','data-cattype':cat_type,'data-catconst':cat_const,'data-propkey':i.split('#')[0],'data-propid':i.split('#')[1],'data-proptype':i.split('#')[2],'data-multi':i.split('#')[3],'data-indexed':i.split('#')[4]}).update(new Element('span').update(arr[i]||'<span class="text-grey">('+idoit.Translate.get('LC__UNIVERSAL__EMPTY')+')</span>')).insert($add_button);if(this.property_already_selected(i.split('#')[1])){$add_button.addClassName('hide');}
$add_button.on('click',this.add.bindAsEventListener(this));$prop_box.insert($property);}}}}.bind(this)});},search_properties:function(property_name){if(property_name.length>2){new Ajax.Request(this.options.url+'&func=get_filtered_properties_by_database',{parameters:{filter:property_name,provide:this.options.provides,dynamic_properties:this.options.dynamic_properties,consider_rights:this.options.consider_rights,replace_dynamic_properties:this.options.replace_dynamic_properties,custom_fields:this.options.custom_fields,obj_type_id:this.options.obj_type_id},method:"post",onLoading:function(){$(this.name+'_search_button').childElements()[0].toggle();$(this.name+'_search_button').childElements()[1].toggle();}.bind(this),onSuccess:function(transport){var arr=transport.responseJSON,i,$search_box=$(this.name+'_search_result_container').update(''),$search_count=$(this.name+'_search_count_container');if(Object.keys(arr).length===0){$search_count.hide();$search_box.insert(new Element('div',{className:'category-field'}).update(idoit.Translate.get('LC__REPORT__NO_ATTRIBUTES_FOUND')));}else{for(i in arr){if(arr.hasOwnProperty(i)){var $add_button=new Element('span',{className:'plus'}),$property=new Element('div',{className:'category-field','data-cattype':arr[i].cat_type,'data-catconst':arr[i].cat_const,'data-cattitle':arr[i].cat_title,'data-propkey':i.split('#')[0],'data-propid':i.split('#')[1],'data-proptype':i.split('#')[2],'data-multi':i.split('#')[3]}).update(new Element('span').update(arr[i].title)).insert($add_button);$add_button.on('click',this.add.bindAsEventListener(this));$search_box.insert($property);}}
$(this.name+'_search_count').show().update(Object.keys(arr).length);$search_count.show();}}.bind(this),onComplete:function(){$(this.name+'_search_button').childElements()[0].toggle();$(this.name+'_search_button').childElements()[1].toggle();}.bind(this)});}else{$(this.name+'_search_count').update('0');$(this.name+'_search_result_container').update(new Element('div',{className:'category-field'}).update(idoit.Translate.get('LC__REPORT__NO_ATTRIBUTES_FOUND')));}},add:function(ev){var $button=ev.findElement('span'),el=$button.up('div'),cat_type=el.readAttribute('data-cattype'),cat_const=el.readAttribute('data-catconst'),cat_name=(el.hasAttribute('data-cattitle')?el.readAttribute('data-cattitle'):$$('select#'+this.name+'_cat'+cat_type+'_selection option[value="'+$(this.name+'_cat'+cat_type+'_selection').value+'"]')[0].innerHTML),property=el.readAttribute('data-propkey'),property_id=el.readAttribute('data-propid'),property_type=el.readAttribute('data-proptype'),property_multi=el.readAttribute('data-multi'),property_indexed=el.readAttribute('data-indexed'),property_name=el.down().innerHTML.replace(/<span class="removeable-addon">(.)*<\/span>/,'');if(this.options.max_items>0&&this.count_items()>=this.options.max_items){$(this.name+'_attr_error').update((idoit.Translate.get('LC__REPORT__FORM__ATTRIBUTE_COUNT_ERROR')).replace('%i',this.options.max_items));Effect.Appear(this.name+'_attr_error',{duration:0.5});return;}
$button.addClassName('hide');if(this.property_already_selected(property_id)){return;}
if(this.options.group){this.add_with_grouping(cat_type,cat_const,cat_name,property,property_name,property_id,property_type,(property_indexed=='1'),property_multi);}else{this.add_without_grouping(cat_type,cat_const,cat_name,property,property_name,property_id,property_type,(property_indexed=='1'),property_multi);}
this.update_hiddenfield();if(this.options.sortable){this.make_sortable();}
this.callback_add();},add_with_grouping:function(cat_type,cat_const,cat_name,property,property_name,property_id,property_type,property_sortable,property_multi){$(this.name+'_attribute_remover').setStyle({display:'none'});var cat_div,prop_checked,remove_button,minus_style={},reference_style={},remove_method=this.remove.bindAsEventListener(this),translation=idoit.Translate.get('LC__UNIVERSAL__GLOBAL');if(cat_type=='s'){translation=idoit.Translate.get('LC__UNIVERSAL__SPECIFIC');}
cat_div=this.$selectionList.down('div.cat'+cat_type+'-'+cat_const);if(typeof cat_div=='undefined'){cat_div=new Element('div',{className:'selected-field cat'+cat_type+'-'+cat_const}).update(cat_name+' ('+translation+')');this.$selectionList.insert({bottom:cat_div});}
if(this.options.allow_sorting){minus_style={right:'25px'};reference_style={right:'45px'};}
remove_button=new Element('span',{className:'minus'}).observe('click',remove_method).setStyle(minus_style);prop_div=new Element('div',{className:'property','data-cattype':cat_type,'data-catconst':cat_const,'data-propkey':property,'data-propid':property_id,'data-proptype':property_type});if(this.options.report&&property_type=='object_browser'&&property_multi==0){reference_button=new Element('span',{className:'reference'}).setStyle(reference_style);reference_button.on('click',function(e){Element.childElements(e.findElement().up().up().up()).each(function(el){Element.childElements(el).each(function(el1){if(el1.hasClassName('selected-field-focus')){el1.removeClassName('selected-field-focus');}});});e.findElement().up().addClassName('selected-field-focus');var selector_name=e.findElement().up().readAttribute('data-propid');this.build_property_selector(cat_const+'-'+property,this.options.lvl);}.bind(this));cat_div.insert(prop_div.update(new Element('span').insert(' - '+property_name)).insert(reference_button).insert(remove_button));}
else{cat_div.insert(prop_div.update(new Element('span').insert(' - '+property_name)).insert(remove_button));}
if(this.options.allow_sorting){if(this.options.check_sorting){if(property_sortable){this.add_radio_button(cat_div,(this.options.default_sorting==property_id),property_id,false);}
else if(property_sortable==undefined){this.add_radio_button(cat_div,false,property_id,true);}}
else{this.add_radio_button(cat_div,(this.options.default_sorting==property_id),property_id,false);}}},add_without_grouping:function(cat_type,cat_const,cat_name,property,property_name,property_id,property_type,property_sortable,property_multi){$(this.name+'_attribute_remover').setStyle({display:'none'});var remove_method=this.remove.bindAsEventListener(this),prop,minus_style={},reference_style={},remove_button;if(!this.property_already_selected(property_id)){if(this.options.allow_sorting){minus_style={right:'25px'};reference_style={right:'45px'};}
remove_button=new Element('span',{className:'minus'}).observe('click',remove_method).setStyle(minus_style);if(this.options.report&&property_type=='object_browser'){var reference_button=new Element('span',{className:'reference'}).setStyle(reference_style);reference_button.on('click',function(e){Element.childElements(e.findElement().up().up().up()).each(function(el){Element.childElements(el).each(function(el1){if(el1.hasClassName('selected-field-focus')){el1.removeClassName('selected-field-focus');}});});e.findElement().up().addClassName('selected-field-focus');var selector_name=e.findElement().up().readAttribute('data-propid');this.build_property_selector(cat_const+'-'+property,this.options.lvl);}.bind(this));prop=new Element('div',{className:'selected-field property','data-cattype':cat_type,'data-catconst':cat_const,'data-propkey':property,'data-propid':property_id,'data-proptype':property_type}).update(new Element('span').insert(property_name+' ('+cat_name+')')).insert(reference_button).insert(remove_button);}
else{prop=new Element('div',{className:'selected-field property','data-cattype':cat_type,'data-catconst':cat_const,'data-propkey':property,'data-propid':property_id,'data-proptype':property_type}).update(new Element('span').insert(property_name+' ('+cat_name+')')).insert(remove_button);}
if(this.options.allow_sorting){if(this.options.check_sorting){if(property_sortable){this.add_radio_button(prop,(this.options.default_sorting==property_id),property_id,false);}
else if(property_sortable==undefined){this.add_radio_button(prop,false,property_id,true);}}
else{this.add_radio_button(prop,(this.options.default_sorting==property_id),property_id,false);}}
this.$selectionList.insert({bottom:prop});}},remove:function(e){Effect.Fade(this.name+'_attr_error',{duration:0.5});var el=e.findElement().up(),parent=el.up(),data_prop_id=el.readAttribute('data-propid'),data_cat_type=el.readAttribute('data-cattype'),data_const=el.readAttribute('data-catconst'),data_type=el.readAttribute('data-proptype'),data_prop_key=el.readAttribute('data-propkey');el.remove();var $propertyList=$(this.name+'_cat'+data_cat_type+'_properties');if($propertyList.down('[data-propid="'+data_prop_id+'"]')){$propertyList.down('[data-propid="'+data_prop_id+'"]').down('span.plus').removeClassName('hide');}
if(this.options.report&&data_type=='object_browser'){if(this.options.parent_prop!=null){var parent_prop_arr=this.options.parent_prop.split('--');var check_parent_prop=[];var check_prop='';if(parent_prop_arr.length>=1){for(a=0;a<parent_prop_arr.length;a++){check_parent_prop.push(parent_prop_arr[a]);}
check_prop=check_parent_prop.join('--')+'--'+data_const+'-'+data_prop_key;}
else{check_prop=data_const+'-'+data_prop_key;}
if($(check_prop+'__HIDDEN')){this.remove_hidden_fields(check_prop,true);}}else if($(data_const+'-'+data_prop_key+'__HIDDEN')){this.remove_hidden_fields(data_const+'-'+data_prop_key,true);}}
if(this.options.group&&parent.down()==null){parent.remove();}
if(this.$selectionList.select('.property').length==0){$(this.name+'_attribute_remover').setStyle({display:'block'});}
this.update_hiddenfield();this.callback_remove();},remove_hidden_fields:function(p_parent_key,p_delete){if($(p_parent_key+'__HIDDEN')){if($(p_parent_key+'__HIDDEN').value!=''){var hidden_field_value=JSON.parse($(p_parent_key+'__HIDDEN').value);hidden_field_value.each(function(ele){if(ele.g){for(var a in ele.g){if(ele.g.hasOwnProperty(a)){ele.g[a].each(function(ele2){this.remove_hidden_fields(p_parent_key+'--'+a+'-'+ele2,true);}.bind(this));}}}
if(ele.s){for(var a in ele.s){if(ele.s.hasOwnProperty(a)){ele.s[a].each(function(ele2){this.remove_hidden_fields(p_parent_key+'--'+a+'-'+ele2,true);}.bind(this));}}}
if(ele.g_custom){for(var a in ele.g_custom){if(ele.g_custom.hasOwnProperty(a)){ele.g_custom[a].each(function(ele2){this.remove_hidden_fields(p_parent_key+'--'+a+'-'+ele2,true);}.bind(this));}}}}.bind(this));if($(p_parent_key+'__HIDDEN')){if($(p_parent_key+'__HIDDEN').next('td')){$(p_parent_key+'__HIDDEN').next('td').remove();$(p_parent_key+'__HIDDEN').next('td').remove();$(p_parent_key+'__HIDDEN').next('td').remove();}
if(p_delete){$(p_parent_key+'__HIDDEN').remove();if($(p_parent_key+'__HIDDEN_IDS')){$(p_parent_key+'__HIDDEN_IDS').remove();}}}
var selection=JSON.parse($(this.options.complete_selection).value);var new_selection={};for(a in selection){if(a!=p_parent_key){new_selection[a]=selection[a];}}
$(this.options.complete_selection).value=Object.toJSON(new_selection);}}},update_hiddenfield:function(){var property_elements=this.$selectionList.select('.property'),selection=[],selection_complete=[],selection_ids=[];if(this.options.group){var c_cat_type='',c_cat_const='',tmp_selection=null,tmp_selection_complete=null;property_elements.each(function(el){var cat_type=el.readAttribute('data-cattype'),cat_const=el.readAttribute('data-catconst'),prop_key=el.readAttribute('data-propkey'),prop_title=el.down('span').innerHTML,prop_id=el.readAttribute('data-propid');if(c_cat_type==cat_type&&c_cat_const==cat_const){tmp_selection[cat_type][cat_const].push(prop_key);}else{if(tmp_selection!=null){selection.push(tmp_selection);}
tmp_selection={};tmp_selection[cat_type]={};tmp_selection[cat_type][cat_const]=[prop_key];tmp_selection_complete={};tmp_selection_complete[cat_type]={};tmp_selection_complete[cat_type][cat_const]=[prop_id,prop_key,prop_title];}
c_cat_type=cat_type;c_cat_const=cat_const;selection_ids.push(prop_id);}.bind(this));if(tmp_selection!=null){selection.push(tmp_selection);selection_complete.push(tmp_selection_complete);}}else{property_elements.each(function(el){var cat_type=el.readAttribute('data-cattype'),cat_const=el.readAttribute('data-catconst'),prop_key=el.readAttribute('data-propkey'),prop_id=el.readAttribute('data-propid'),prop_title=el.down('span').innerHTML,tmp_selection={},tmp_selection_complete={};tmp_selection[cat_type]={};tmp_selection[cat_type][cat_const]=[prop_key];tmp_selection_complete[cat_type]={};tmp_selection_complete[cat_type][cat_const]=[prop_id,prop_key,prop_title];selection.push(tmp_selection);selection_ids.push(prop_id);selection_complete.push(tmp_selection_complete);}.bind(this))}
var selection_complete_ele=$(this.options.complete_selection);$(this.name+'__HIDDEN').setValue(Object.toJSON(selection));$(this.name+'__HIDDEN_IDS').setValue(Object.toJSON(selection_ids));if(selection_complete_ele.value==''){var prop_hash={'root':selection_complete};}
else{var prop_hash=JSON.parse(selection_complete_ele.value);if(this.options.parent_prop==null){prop_hash['root']=selection_complete;}
else{prop_hash[this.options.parent_prop]=selection_complete;}}
selection_complete_ele.value=Object.toJSON(prop_hash);},count_items:function(){return this.$selectionList.select('.property').length;},handle_preselection:function(json){if(this.options.group){json.each(function(i){this.add_with_grouping(i.cat_type,i.cat_const,i.cat_title,i.prop_key,i.prop_title,i.prop_id,i.prop_type,i.prop_sortable,i.prop_multi);}.bind(this));}else{json.each(function(i){this.add_without_grouping(i.cat_type,i.cat_const,i.cat_title,i.prop_key,i.prop_title,i.prop_id,i.prop_type,i.prop_sortable,i.prop_multi);}.bind(this));}
this.update_hiddenfield();if(this.options.sortable){this.make_sortable();}},handle_preselection_lvls:function(json){var lvls=$H(json);lvls.each(function(el){var lvl=parseInt(el.key);var content=$H(el.value);if($('spacer_lvl_'+lvl)){var tr_spacer=$('spacer_lvl_'+lvl);var next_tr_spacer=new Element('tr',{className:'selector-spacer mt5',style:'min-width:30px',id:'spacer_lvl_'+(lvl+1)});tr_spacer.up().insert(next_tr_spacer);content.each(function(el2){var hidden_field=new Element('input',{type:'hidden',name:'lvls_raw['+lvl+']['+el2.key+']',id:el2.key+'__HIDDEN'});hidden_field.value=JSON.stringify(el2.value);tr_spacer.insert(hidden_field);});}});},make_sortable:function(){Position.includeScrollOffsets=true;Sortable.create(this.$selectionList,{tag:'div',onChange:function(){this.update_hiddenfield();}.bind(this)});if(!this.$selectionList.hasClassName('draggable')){this.$selectionList.addClassName('draggable');}
Element.makePositioned(this.$selectionList);},property_already_selected:function(prop_id){return!!this.$selectionList.select('.property').filter(function(i){return(i.readAttribute('data-propid')==prop_id);}).length;},add_radio_button:function(prop,prop_checked,property_id,property_sortable_check){var $checkbox=new Element('input',{type:'radio',style:'margin-top:2px',name:'default_sorting',value:property_id,checked:prop_checked});if(property_sortable_check===false){prop.insert(new Element('span',{style:'float:right'}).insert($checkbox));if(prop_checked){this.$sortCanceler.removeClassName('hide');}
return prop;}else{new Ajax.Request(this.options.url+'&func=is_property_sortable',{parameters:{prop_id:property_id},method:"post",onSuccess:function(transport){var check=transport.responseJSON;if(check===true){prop.insert(new Element('span',{style:'float:right'}).insert($checkbox));if(prop_checked){this.$sortCanceler.removeClassName('hide');}
return prop;}}.bind(this)});return prop;}},build_property_selector:function(p_id,p_lvl,p_data){var tr_spacer=$('spacer_lvl_'+p_lvl);if(p_lvl==1){var parent_prop=p_id;}
else{var parent_prop=this.options.parent_prop+'--'+p_id;}
if(typeof tr_spacer.down('td')!='undefined'){if(typeof tr_spacer.down('td').next('td')!='undefined'){tr_spacer.down('td').remove();tr_spacer.down('td').remove();tr_spacer.down('td').remove();var i=1;while($('spacer_lvl_'+(parseInt(p_lvl)+i))){if(!$('spacer_lvl_'+(parseInt(p_lvl)+i)).down('input')){$('spacer_lvl_'+(parseInt(p_lvl)+i)).remove();}
else{if($('spacer_lvl_'+(parseInt(p_lvl)+i)).down('td')){$('spacer_lvl_'+(parseInt(p_lvl)+i)).down('td').remove();$('spacer_lvl_'+(parseInt(p_lvl)+i)).down('td').remove();$('spacer_lvl_'+(parseInt(p_lvl)+i)).down('td').remove();}}
i++;}}}
if(!$(parent_prop+'__HIDDEN')){tr_spacer.insert(new Element('input',{type:'hidden',id:parent_prop+'__HIDDEN',name:this.options.hidden_field_name+'['+p_lvl+']['+parent_prop+']'}));}
if(!$(parent_prop+'__HIDDEN_IDS')){tr_spacer.insert(new Element('input',{type:'hidden',id:parent_prop+'__HIDDEN_IDS',name:this.options.hidden_field_name+'__IDS['+p_lvl+']['+parent_prop+']'}));}
if(typeof tr_spacer.down('td')=='undefined'){var selector_left=new Element('td',{className:'vat pt5'});var selector_right=new Element('td',{className:'vat pt5'});}
else{var selector_left=tr_spacer.down('td');var selector_right=tr_spacer.down('td').next('td');}
switch(this.options.selector_size){case'small':var min_width='305px';break;case'normal':default:var min_width='400px';break;}
var div_content_left=new Element('div',{className:'border fl mr20',style:'width:'+min_width});var ul_headline_left=new Element('ul',{className:'m0 gradient rowser-tabs',id:parent_prop+'_tabs'});var li_global=new Element('li').insert(new Element('a',{className:'text-shadow-white',href:'#'+parent_prop+'_catg_list'}).insert(idoit.Translate.get('LC__UNIVERSAL__GLOBAL')));var div_catg=new Element('div',{id:parent_prop+'_catg_list',className:'m10 browser-tab-content'});var li_specific=new Element('li').insert(new Element('a',{className:'text-shadow-white',href:'#'+parent_prop+'_cats_list'}).insert(idoit.Translate.get('LC__UNIVERSAL__SPECIFIC')));var div_cats=new Element('div',{id:parent_prop+'_cats_list',className:'m10 browser-tab-content',style:'display:none;'});if(this.options.catg_custom_selection!==null){var li_custom=new Element('li').insert(new Element('a',{className:'text-shadow-white',href:'#'+parent_prop+'_catg_custom_list'}).insert(idoit.Translate.get('LC__CMDB__CATG__CUSTOM')));var div_custom=new Element('div',{id:parent_prop+'_catg_custom_list',className:'m10 browser-tab-content'});}
var div_error=new Element('div',{id:parent_prop+'_attr_error',className:'box-red m10 p5',style:'display:none;'});if(this.options.catg_custom_selection!==null){selector_left.insert(div_content_left.insert(ul_headline_left.insert(li_global).insert(li_specific).insert(li_custom)).insert(div_catg).insert(div_cats).insert(div_custom).insert(div_error));}else{selector_left.insert(div_content_left.insert(ul_headline_left.insert(li_global).insert(li_specific)).insert(div_catg).insert(div_cats).insert(div_error));}
var div_content_right=new Element('div',{className:'border fl',style:'width:'+min_width});var div_headline_right=new Element('div',{className:'m0 p10 gradient browser-tabs',style:'box-sizing: border-box; height:33px; border-bottom:1px solid #888;'});var span_headline_right=new Element('span',{className:'text-shadow-white'}).insert(new Element('b',{style:'color:#333333;font-size:10px;'}).insert(idoit.Translate.get('LC__REPORT__INFO__CHOSEN_PROPERTIES_TEXT')));var div_selection_right=new Element('div',{className:'m10',id:parent_prop+'_selection_field'});var div_remover_right=new Element('div',{className:'category-field',id:parent_prop+'_attribute_remover'}).insert(idoit.Translate.get('LC__REPORT__NO_ATTRIBUTES_ADDED'));selector_right.insert(div_content_right.insert(div_headline_right.insert(span_headline_right)).insert(div_selection_right.insert(div_remover_right)));tr_spacer.insert(selector_left).insert(selector_right);if(!$('spacer_lvl_'+this.options.lvl+1)){var remover=new Element('span',{className:'property-remover'}).observe('click',function(){var delete_all=false,i=1;$('spacer_lvl_'+p_lvl).down('td').remove();$('spacer_lvl_'+p_lvl).down('td').remove();$('spacer_lvl_'+p_lvl).down('td').remove();this.remove_hidden_fields(parent_prop,true);if(!$('spacer_lvl_'+p_lvl).down('input')){delete_all=true;}
while($('spacer_lvl_'+(parseInt(p_lvl)+i))){if(delete_all){$('spacer_lvl_'+(parseInt(p_lvl)+i)).remove();}
else{if($('spacer_lvl_'+(parseInt(p_lvl)+i)).down('td')){$('spacer_lvl_'+(parseInt(p_lvl)+i)).down('td').remove();$('spacer_lvl_'+(parseInt(p_lvl)+i)).down('td').remove();$('spacer_lvl_'+(parseInt(p_lvl)+i)).down('td').remove();}}
i++;}}.bind(this));var td_remover=new Element('td',{className:'vat pt5 pl5'}).insert(remover);tr_spacer.insert(td_remover);if(!$('spacer_lvl_'+(parseInt(this.options.lvl)+1))){var td_next_spacer=new Element('tr',{id:'spacer_lvl_'+(parseInt(this.options.lvl)+1),style:'min-width:30px',className:'selector-spacer mt5'});tr_spacer.up().insert(td_next_spacer);}}
var catg_select=this.options.catg_selection.clone(true);catg_select.id=parent_prop+'_catg_selection';catg_select.name=parent_prop+'_catg_selection';var cats_select=this.options.cats_selection.clone(true);cats_select.id=parent_prop+'_cats_selection';cats_select.name=parent_prop+'_cats_selection';catg_select.selectedIndex=0;cats_select.selectedIndex=0;var div_properties_catg_left=new Element('div',{id:parent_prop+'_catg_properties'});var div_properties_cats_left=new Element('div',{id:parent_prop+'_cats_properties'});$(parent_prop+'_catg_list').insert(catg_select).insert(div_properties_catg_left);new Chosen(catg_select,{disable_search_threshold:10,width:'100%',height:'20px',search_contains:true});$(parent_prop+'_cats_list').insert(cats_select).insert(div_properties_cats_left);new Chosen(cats_select,{disable_search_threshold:10,width:'100%',height:'20px',search_contains:true});if(this.options.catg_custom_selection!==null){var catg_custom_select=this.options.catg_custom_selection.clone(true);catg_custom_select.id=parent_prop+'_catg_custom_selection';catg_custom_select.name=parent_prop+'_catg_custom_selection';catg_custom_select.selectedIndex=0;var div_properties_catg_custom_left=new Element('div',{id:parent_prop+'_catg_custom_properties'});$(parent_prop+'_catg_custom_list').insert(catg_custom_select).insert(div_properties_catg_custom_left);new Chosen(catg_custom_select,{disable_search_threshold:10,width:'100%',height:'20px',search_contains:true});}
var new_options={url:this.options.url,provides:this.options.provides,group:this.options.group,sortable:this.options.sortable,max_items:this.options.max_items,dynamic_properties:this.options.dynamic_properties,default_sorting:this.options.default_sorting,allow_sorting:false,check_sorting:false,report:this.options.report,custom_fields:this.options.custom_fields,consider_rights:this.options.consider_rights,hidden_field_name:this.options.hidden_field_name,lvl:this.options.lvl+1,catg_selection:this.options.catg_selection,cats_selection:this.options.cats_selection,catg_custom_selection:this.options.catg_custom_selection,parent_prop:parent_prop,selector_size:this.options.selector_size,dialog_width:this.options.dialog_width,complete_selection:this.options.complete_selection,replace_dynamic_properties:this.options.replace_dynamic_properties};var new_selector=new PropertySelector(parent_prop,new_options);if($(parent_prop+'__HIDDEN').value!=''){new Ajax.Request(this.options.url+'&func=format_preselection',{parameters:{'data':$(parent_prop+'__HIDDEN').value},method:"post",onSuccess:function(transport){new_selector.handle_preselection(transport.responseJSON);}.bind(new_selector)});}
window.category_tabs=new Tabs(parent_prop+'_tabs',{wrapperClass:'browser-tabs',contentClass:'browser-tab-content',tabClass:'text-shadow-white mouse-pointer'});},callback_add:Prototype.emptyFunction,callback_remove:Prototype.emptyFunction};window.RackAssignment=Class.create({initialize:function(objects,options){this.selectedObjectId=0;this.options=options;this.objects=objects;this.options=Object.extend({rackFront:null,rackRear:null,$unassignedObjects:null,$unassignedObjectsCounter:null,$assignmentBox:null,$assignmentOption:null,$assignmentInsertion:null,$assignmentPosition:null,$assignmentSegmentSlot:null,$assignmentSubmitButton:null,$heightChangeBox:null,$heightChangeSelect:null,$heightChangeButton:null,$segmentBox:null,$segmentObjectSelect:null,$segmentPreview:null,$segmentButton:null,segmentTemplates:{},rackObjectId:0,allowedToEdit:false,quickinfoCallback:Prototype.emptyFunction,OPTION_VERTICAL:4,OPTION_HORIZONTAL:3,INSERTION_FRONT:1,INSERTION_REAR:0,INSERTION_BOTH:2},options||{});this.setObserver();this.resetAssignment();},setObserver:function(){this.options.$unassignedObjects.on('render:list',this.updateUnassignedObjectsList.bindAsEventListener(this));this.options.$unassignedObjectsCounter.on('update:list',this.updateUnassignedObjectsCounter.bindAsEventListener(this));if(this.options.allowedToEdit){this.options.$unassignedObjects.on('click','.object-item',this.selectObjectForAssignment.bindAsEventListener(this));this.options.$unassignedObjects.on('click','.he-edit',this.editHeightUnits.bindAsEventListener(this));this.options.$unassignedObjects.on('click','.location-remove',this.detachObjectLocation.bindAsEventListener(this));this.options.$heightChangeButton.on('click',this.heightChangeSubmit.bindAsEventListener(this));this.options.$assignmentOption.on('change',this.assignmentOptionChanged.bindAsEventListener(this));this.options.$assignmentInsertion.on('change',this.assignmentInsertionChanged.bindAsEventListener(this));this.options.$assignmentPosition.on('change',this.assignmentPositionChanged.bindAsEventListener(this));this.options.$assignmentSegmentSlot.on('change',this.assignmentSegmentSlotChanged.bindAsEventListener(this));this.options.$assignmentSubmitButton.on('click',this.assignmentSubmit.bindAsEventListener(this));this.options.$segmentObjectSelect.on('change',this.segmentLoadPreview.bindAsEventListener(this));this.options.$segmentButton.on('click',this.segmentCreate.bindAsEventListener(this));}},setObjects:function(objects){this.objects=objects;},getObjects:function(){return this.objects;},resetAssignment:function(){this.selectedObjectId=0;$('object-positioning').down('span').update();$('rackview').select('.active').invoke('removeClassName','active');this.options.$heightChangeBox.addClassName('hide');this.options.$heightChangeSelect.addClassName('hide');this.options.$heightChangeButton.addClassName('hide');this.options.$assignmentBox.addClassName('hide');this.options.$assignmentOption.addClassName('hide');this.options.$assignmentInsertion.addClassName('hide');this.options.$assignmentPosition.addClassName('hide');this.options.$assignmentSegmentSlot.addClassName('hide');this.options.$segmentBox.addClassName('hide').writeAttribute({'data-slot-insertion':null,'data-slot-position':null});this.options.$segmentButton.addClassName('hide');this.options.rackFront.unselect();this.options.rackRear.unselect();},selectObjectForAssignment:function(ev){var $objectItem=ev.findElement('[data-object-id]'),objectTitle=$objectItem.readAttribute('data-object-title');this.resetAssignment();this.selectedObjectId=$objectItem.readAttribute('data-object-id');if($objectItem.up('.list')){$objectItem.down('.object-item').addClassName('active');}
$('object-positioning').down('span').update(objectTitle);this.options.$assignmentOption.removeClassName('hide').setValue(null).simulate('change');this.options.$assignmentBox.removeClassName('hide');},assignmentOptionChanged:function(){new Ajax.Request('?ajax=1&call=rack&func=get_rack_insertions',{parameters:{'obj_id':this.options.rackObjectId,'option':this.options.$assignmentOption.getValue()},method:"post",onSuccess:function(xhr){var i,json=xhr.responseJSON;this.options.$assignmentInsertion.update();for(i in json){if(!json.hasOwnProperty(i)){continue;}
this.options.$assignmentInsertion.insert(new Element('option',{value:json[i].id}).update(json[i].title));}
this.options.$assignmentInsertion.removeClassName('hide').setValue(null).simulate('change');}.bind(this)});},assignmentInsertionChanged:function(){new Ajax.Request('?ajax=1&call=rack&func=get_free_slots',{parameters:{'rack_obj_id':this.options.rackObjectId,'assign_obj_id':this.selectedObjectId,'option':this.options.$assignmentOption.getValue(),'insertion':this.options.$assignmentInsertion.getValue(),'rackSlotSort':this.options.rackFront.options.slot_sort||this.options.rackRear.options.slot_sort},method:"post",onSuccess:function(xhr){var i,fromto,json=xhr.responseJSON;this.options.$assignmentPosition.update();if(Object.keys(json).length){for(i in json){if(!json.hasOwnProperty(i)){continue;}
fromto=i.split(';');this.options.$assignmentPosition.insert(new Element('option',{value:fromto[0],'data-from':fromto[1],'data-to':fromto[2]}).update(json[i]));}
this.options.$assignmentPosition.removeClassName('hide').simulate('change');this.options.$assignmentSubmitButton.removeClassName('hide');}else{this.options.$assignmentPosition.addClassName('hide');this.options.$assignmentSubmitButton.addClassName('hide');}}.bind(this)});},assignmentPositionChanged:function(){var $positionOption=this.options.$assignmentPosition.down(':selected'),positionFrom=parseInt($positionOption.readAttribute('data-from')),positionTo=parseInt($positionOption.readAttribute('data-to')),horizontal=(this.options.$assignmentOption.getValue()==this.options.OPTION_HORIZONTAL),chassisData,i;this.options.rackFront.unselect();this.options.rackRear.unselect();if($positionOption.innerHTML.indexOf('(')>0&&$positionOption.innerHTML.indexOf(')')>0){this.options.$assignmentSegmentSlot.update();if(this.options.$assignmentInsertion.getValue()==this.options.INSERTION_FRONT||this.options.$assignmentInsertion.getValue()==this.options.INSERTION_BOTH){chassisData=this.options.rackFront.getChassisData(positionFrom);}
if(this.options.$assignmentInsertion.getValue()==this.options.INSERTION_REAR){chassisData=this.options.rackRear.getChassisData(positionFrom);}
for(i in chassisData){if(chassisData.hasOwnProperty(i)){this.options.$assignmentSegmentSlot.insert(new Element('option',{value:chassisData[i].id}).update(chassisData[i].title));}}
this.options.$assignmentSegmentSlot.removeClassName('hide').simulate('change');}
else{this.options.$assignmentSegmentSlot.addClassName('hide');if(this.options.$assignmentInsertion.getValue()==this.options.INSERTION_FRONT||this.options.$assignmentInsertion.getValue()==this.options.INSERTION_BOTH){this.options.rackFront.select(horizontal,positionFrom,positionTo);}
if(this.options.$assignmentInsertion.getValue()==this.options.INSERTION_REAR||this.options.$assignmentInsertion.getValue()==this.options.INSERTION_BOTH){this.options.rackRear.select(horizontal,positionFrom,positionTo);}
this.options.$assignmentSubmitButton.removeClassName('hide');}},assignmentSegmentSlotChanged:function(){var chassisSlotId=this.options.$assignmentSegmentSlot.getValue();if(this.options.$assignmentInsertion.getValue()==this.options.INSERTION_FRONT||this.options.$assignmentInsertion.getValue()==this.options.INSERTION_BOTH){this.options.rackFront.selectChassis(chassisSlotId);}
if(this.options.$assignmentInsertion.getValue()==this.options.INSERTION_REAR||this.options.$assignmentInsertion.getValue()==this.options.INSERTION_BOTH){this.options.rackRear.selectChassis(chassisSlotId);}},assignmentSubmit:function(){new Ajax.Request('?ajax=1&call=rack&func=assign_object_to_rack',{parameters:{'rack_obj_id':this.options.rackObjectId,'obj_id':this.selectedObjectId,'option':this.options.$assignmentOption.getValue(),'insertion':this.options.$assignmentInsertion.getValue(),'pos':this.options.$assignmentPosition.getValue(),'chassisSlot':(this.options.$assignmentSegmentSlot.hasClassName('hide')?null:this.options.$assignmentSegmentSlot.getValue())},method:"post",onSuccess:function(xhr){var json=xhr.responseJSON,$listEntry=this.options.$unassignedObjects.down('[data-object-id="'+this.selectedObjectId+'"]');if($listEntry){$listEntry.remove();}
this.setObjects(json);this.options.rackFront.setObjects(json).create_rack();this.options.rackRear.setObjects(json).create_rack();this.updateUnassignedObjectsList();this.resetAssignment();}.bind(this)});},detachObjectFromRack:function(objectId,callback){new Ajax.Request('?ajax=1&call=rack&func=remove_object_assignment',{parameters:{'rack_obj_id':this.options.rackObjectId,'obj_id':objectId},method:"post",onSuccess:function(xhr){var json=xhr.responseJSON;this.setObjects(json);this.options.rackFront.setObjects(json).create_rack();this.options.rackRear.setObjects(json).create_rack();this.updateUnassignedObjectsList();this.resetAssignment();if(Object.isFunction(callback)){callback();}}.bind(this)});},updateUnassignedObjectsList:function(){var i,object,$list=this.options.$unassignedObjects.down('.list').update();for(i in this.objects){if(!this.objects.hasOwnProperty(i)||this.objects[i].insertion||this.objects[i].pos){continue;}
object=this.objects[i];$list.insert(new Element('div').setStyle({background:object.color}).writeAttribute({'data-background':object.color,'data-object-id':object.id,'data-object-title':object.title,'data-object-height':object.height}).update(new Element('div',{className:'object-item fl'}).update(new Element('strong').update(object.height+idoit.Translate.get('LC__CMDB__CATG__RACKUNITS_ABBR'))).insert(new Element('p',{title:object.type+' &raquo; '+object.title}).update(object.type+' &raquo; '+object.title)).insert(new Element('em').update(idoit.Translate.get('LC__CMDB__CATG__FORMFACTOR_TYPE')+': '+(object.formfactor||'-')))).insert(new Element('span',{className:'mouse-pointer location-remove',title:idoit.Translate.get('LC_UNIVERSAL__REMOVE_LOCATION')}).update(new Element('img',{src:window.dir_images+'icons/silk/cross.png'}))).insert(new Element('span',{className:'mouse-pointer he-edit',title:idoit.Translate.get('LC__CMDB__CATS__RACK__CHANGE_HEIGHT_UNITS')}).update(new Element('img',{src:window.dir_images+'icons/silk/cog.png'}))).insert(new Element('a',{className:'mouse-pointer objectlink',href:'?objID='+object.id,target:'_blank',title:idoit.Translate.get('LC__UNIVERSAL__TITLE_LINK')}).update(new Element('img',{src:window.dir_images+'icons/silk/link.png'}))).insert(new Element('br',{className:'cb'})));}
$list.select('.object-item').each(function($item){this.options.quickinfoCallback($item,$item.up('div').readAttribute('data-object-id'));}.bind(this));this.options.$unassignedObjectsCounter.fire('update:list');},updateUnassignedObjectsCounter:function(){this.options.$unassignedObjectsCounter.update('('+this.options.$unassignedObjects.select('.object-item').length+')');},editHeightUnits:function(ev){var $objectItem=ev.findElement('[data-object-id]'),descriptionText=idoit.Translate.get('LC__CMDB__CATS__RACK__CHANGE_HEIGHT_UNITS__DESCRIPTION');this.resetAssignment();this.selectedObjectId=$objectItem.readAttribute('data-object-id');this.options.$heightChangeBox.removeClassName('hide');this.options.$heightChangeBox.down('p').update(descriptionText.replace('%s',new Element('strong').update($objectItem.readAttribute('data-object-title')).outerHTML));this.options.$heightChangeSelect.removeClassName('hide').setValue($objectItem.readAttribute('data-object-height'));this.options.$heightChangeButton.removeClassName('hide');},heightChangeSubmit:function(){new Ajax.Request('?ajax=1&call=rack&func=save_object_ru',{parameters:{'obj_id':this.selectedObjectId,'height':this.options.$heightChangeSelect.getValue()},method:"post",onSuccess:function(xhr){var json=xhr.responseJSON,$object=this.options.$unassignedObjects.down('[data-object-id="'+this.selectedObjectId+'"]');if(json.success){$object.writeAttribute('data-object-height',json.data.height).down('strong').update(json.data.height+idoit.Translate.get('LC__CMDB__CATG__RACKUNITS_ABBR'));new Effect.Highlight($object,{startcolor:'#88ff88',endcolor:$object.readAttribute('data-background')});this.resetAssignment();}
else{idoit.Notify.error(json.message||'An error occured!',{sticky:true});new Effect.Highlight($object,{startcolor:'#ffB7B7',endcolor:$object.readAttribute('data-background')});}}.bind(this)});},detachObjectLocation:function(ev){var $objectItem=ev.findElement('[data-object-id]'),remove=confirm(idoit.Translate.get('LC__CMDB__CATS__RACK__REMOVE_OBJECT_LOCATION'));if(remove){new Ajax.Request('?ajax=1&call=rack&func=detach_object_from_rack',{parameters:{'obj_id':$objectItem.readAttribute('data-object-id')},method:'post',onSuccess:function(xhr){var json=xhr.responseJSON;if(json.success){$objectItem.remove();}
else{new Effect.Highlight($objectItem,{startcolor:'#ffB7B7',endcolor:$objectItem.readAttribute('data-background')});}}});}},prepareSlotSegmentation:function(position,insertion){this.resetAssignment();this.options.$segmentObjectSelect.removeClassName('hide').setValue(null).simulate('change');this.options.$segmentBox.removeClassName('hide').writeAttribute({'data-slot-position':position,'data-slot-insertion':insertion});},detachSlotSegmentation:function(chassisObjectId){new Ajax.Request('?ajax=1&call=rack&func=detach_slot_segmentation',{parameters:{rackObjectId:this.options.rackObjectId,segmentationObjectId:chassisObjectId},method:'post',onSuccess:function(xhr){var json=xhr.responseJSON;if(json.success){this.setObjects(json.data);this.options.rackFront.setObjects(json.data).create_rack();this.options.rackRear.setObjects(json.data).create_rack();this.updateUnassignedObjectsList();this.resetAssignment();}
else{idoit.Notify.error(json.message,{sticky:true});}}.bind(this)});},segmentLoadPreview:function(){var segmentTemplateValue=this.options.$segmentObjectSelect.getValue(),callback=function(){new RackChassis(this.options.$segmentPreview,this.options.segmentTemplates[segmentTemplateValue]);this.options.$segmentButton.removeClassName('hide');}.bind(this);if(segmentTemplateValue>0){if(!this.options.segmentTemplates.hasOwnProperty(segmentTemplateValue)){new Ajax.Request('?ajax=1&call=rack&func=get_chassis_layout',{parameters:{'templateObjectId':segmentTemplateValue},method:'post',onSuccess:function(xhr){var json=xhr.responseJSON;if(json.success){this.options.segmentTemplates[segmentTemplateValue]=json.data;callback();}
else{idoit.Notify.error(json.message,{sticky:true});new Effect.Highlight(this.options.$segmentBox,{startcolor:'#ffB7B7',endcolor:'#ffffff'});}}.bind(this)});}else{callback();}}else{this.options.$segmentPreview.update();this.options.$segmentButton.addClassName('hide');}},segmentCreate:function(){var segmentTemplateValue=this.options.$segmentObjectSelect.getValue();if(segmentTemplateValue>0){this.options.$segmentButton.addClassName('hide').down('img').writeAttribute('src',window.dir_images+'ajax-loading.gif');new Ajax.Request('?ajax=1&call=rack&func=create_segment_from_template',{parameters:{rackObjectId:this.options.rackObjectId,templateObjectId:segmentTemplateValue,option:this.options.OPTION_HORIZONTAL,insertion:this.options.$segmentBox.readAttribute('data-slot-insertion'),position:this.options.$segmentBox.readAttribute('data-slot-position')},method:'post',onSuccess:function(xhr){var json=xhr.responseJSON;this.options.$segmentButton.down('img').writeAttribute('src',window.dir_images+'icons/silk/application_split.png');if(json.success){this.setObjects(json.data);this.options.rackFront.setObjects(json.data).create_rack();this.options.rackRear.setObjects(json.data).create_rack();this.updateUnassignedObjectsList();this.resetAssignment();}
else{idoit.Notify.error(json.message,{sticky:true});new Effect.Highlight(this.options.$segmentBox,{startcolor:'#ffB7B7',endcolor:'#ffffff'});}}.bind(this)});}else{this.options.$segmentPreview.update();this.options.$segmentButton.addClassName('hide');}}});function isWhitespaceChar(a){var charCode;charCode=a.charCodeAt(0);if(charCode<=32){return true;}
else{return false;}}
function isDigitChar(a){var charCode;charCode=a.charCodeAt(0);if(charCode>=48&&charCode<=57){return true;}
else{return false;}}
function compareRight(a,b){var bias=0;var ia=0;var ib=0;var ca;var cb;for(;;ia++,ib++){ca=a.charAt(ia);cb=b.charAt(ib);if(!isDigitChar(ca)&&!isDigitChar(cb)){return bias;}else if(!isDigitChar(ca)){return-1;}else if(!isDigitChar(cb)){return+1;}else if(ca<cb){if(bias==0){bias=-1;}}else if(ca>cb){if(bias==0)
bias=+1;}else if(ca==0&&cb==0){return bias;}}}
function natcompare(a,b){var ia=0,ib=0;var nza=0,nzb=0;var ca,cb;var result;while(true){nza=nzb=0;ca=a.charAt(ia);cb=b.charAt(ib);while(isWhitespaceChar(ca)||ca=='0'){if(ca=='0'){nza++;}else{nza=0;}
ca=a.charAt(++ia);}
while(isWhitespaceChar(cb)||cb=='0'){if(cb=='0'){nzb++;}else{nzb=0;}
cb=b.charAt(++ib);}
if(isDigitChar(ca)&&isDigitChar(cb)){if((result=compareRight(a.substring(ia),b.substring(ib)))!=0){return result;}}
if(ca==0&&cb==0){return nza-nzb;}
if(ca<cb){return-1;}else if(ca>cb){return+1;}
++ia;++ib;}}
(function(){"use strict";Autocompleter.Json=Class.create(Autocompleter.Base,{selectedItem:null,initialize:function(element,update,lookupFunction,options){options=options||{};options.minChars=options.minChars||3;options.searchPlaceHolder=options.searchPlaceHolder||'Search';options.updateElement=options.updateElement.bind(this)||null;this.baseInitialize(element,update,options);this.lookupFunction=lookupFunction;this.options.choices=options.choices||120;},getUpdatedChoices:function(){this.lookupFunction(this.getToken().toLowerCase(),this.updateJsonChoices.bind(this));},updateJsonChoices:function(choices){this.updateChoices('<ul>'+'<li data-search="1"><div class="title search-for">'+this.options.searchPlaceHolder.format(this.element.value)+'</div></li>'+
choices.slice(0,this.options.choices).map(this.jsonChoiceToListChoice.bind(this)).join('')+'</ul>');},jsonChoiceToListChoice:function(choice){var $choice='';if(choice.source){$choice=new Element('div',{className:'type',title:choice.source}).update(choice.source).outerHTML;}
return'<li data-link="'+choice.link+'">'+$choice+'<div class="title" title="'+choice.value+'">'+choice.value+'</div></li>';}});Autocompleter.RateLimiting=function(){this.currentRequest=null;this.scheduledRequest=null;};Autocompleter.RateLimiting.prototype={schedule:function(f,searchTerm,callback){this.scheduledRequest={f:f,searchTerm:searchTerm,callback:callback};this._sendRequest();},_sendRequest:function(){if(!this.currentRequest){this.currentRequest=this.scheduledRequest;this.scheduledRequest=null;this.currentRequest.f(this.currentRequest.searchTerm,this._callback.bind(this));}},_callback:function(data){try{this.currentRequest.callback(data);}
catch(e){}
this.currentRequest=null;if(this.scheduledRequest){this._sendRequest();}}};Autocompleter.Cache=Class.create({initialize:function(backendLookup,options){var self=this;this.fuse=false;this.cache=new Hash();this.backendLookup=backendLookup;this.rateLimiter=new Autocompleter.RateLimiting();this.options=Object.extend({choices:120,fuzzySuggestion:false,fuzzyNumericSearch:false,fuzzySuggestionThreshold:0.2,fuzzySuggestionDistance:50},options||{});idoit.Require.require(['fuse'],function(){self.fuse=true;});},lookup:function(term,callback){return this._lookupInCache(term,null,callback)||this.rateLimiter.schedule(this.backendLookup,term,this._storeInCache.curry(term,callback).bind(this));},_lookupInCache:function(fullTerm,partialTerm,callback){partialTerm=partialTerm||fullTerm;var result=this.cache.get(partialTerm);if(result==null||typeof result!='object'){if(partialTerm.length>1){return this._lookupInCache(fullTerm,partialTerm.substr(0,partialTerm.length-1),callback);}
else{return false;}}
else{if(fullTerm!=partialTerm){var hasMore=result.length>0&&result[result.length-1]['more']==true;result=this._localSearch(result,fullTerm);if(!hasMore){this._storeInCache(fullTerm,null,result);}
else{if(result.length<this.options.choices){return false}}}
if(result.length>0&&result[result.length-1]['more']!=undefined){result=result.slice(0,result.length-1);}
callback(result.slice(0,this.options.choices));return true;}},_naturalCompare:function(a,b){if(a!=b)for(var i,ca,cb=1,ia=0,ib=0;cb;){ca=a.charCodeAt?a.charCodeAt(ia++):0||0;cb=b.charCodeAt?b.charCodeAt(ib++):0||0;if(ca<58&&ca>47&&cb<58&&cb>47){for(i=ia;ca=a.charCodeAt(ia),ca<58&&ca>47;ia++);ca=(a.slice(i-1,ia)|0)+1;for(i=ib;cb=b.charCodeAt(ib),cb<58&&cb>47;ib++);cb=(b.slice(i-1,ib)|0)+1;}
if(ca!=cb)return(ca<cb)?-1:1;}
return 0;},_localSearch:function(data,term){var foundItems=[];if(this.options.fuzzySuggestion&&this.fuse){var f=new Fuse(data,{keys:['value'],threshold:this.options.fuzzySuggestionThreshold,distance:this.options.fuzzySuggestionDistance,shouldSort:false});foundItems=f.search(term);}else{var item,exp=(this.options.fuzzySuggestion)&&term.indexOf(' ')>0&&(!this.options.fuzzyNumericSearch&&isNaN(term))?new RegExp(term.gsub(/./,".*#{0}"),'i'):new RegExp(term.gsub(/\+\.\-\?\#/,""),'i');for(var i=0,len=data.length;i<len;++i){item=data[i];if(exp.test(item.value)){foundItems.push(item);}}}
return foundItems.sort(function(a,b){return typeof a=='object'?this._naturalCompare(a.value.toLowerCase(),b.value.toLowerCase()):this._naturalCompare(a.toLowerCase(),b.toLowerCase());}.bind(this));},_storeInCache:function(term,callback,data){this.cache.set(term,data);if(callback){var items=data.slice(0,this.options.choices);if(items.length>1&&items[items.length-1]['more']!=undefined){items=items.slice(0,items.length-1);}
callback(items);}}});}());function popup_open(element,width,height,minWidth,minHeight,maxWidth,maxHeight){var widthInPercent,heightInPercent,open_popups=$$('.popup').filter(function($el){return $el.visible();});if(!element){element=$('popup');}else{element=$(element);}
Position.includeScrollOffsets=true;if(!width){width=element.getWidth();}
if(!height){height=element.getHeight();}
show_overlay();widthInPercent=(Object.isString(width)&&width.substr(-1)=='%');heightInPercent=(Object.isString(height)&&height.substr(-1)=='%');element.setStyle({position:"fixed",width:parseInt(width)+'px',height:parseInt(height)+'px',top:"50%",left:"50%",marginLeft:-parseInt(width/2)+'px',marginTop:-parseInt(height/2)+'px',zIndex:(1100+open_popups.length)});if(widthInPercent){element.setStyle({width:width,minWidth:(minWidth?parseInt(minWidth)+'px':null),maxWidth:(maxWidth?parseInt(maxWidth)+'px':null),left:((100-parseInt(width))/ 2)+'%',marginLeft:null});}
if(heightInPercent){element.setStyle({height:height,minHeight:(minHeight?parseInt(minHeight)+'px':null),maxHeight:(maxHeight?parseInt(maxHeight)+'px':null),top:((100-parseInt(height))/ 2)+'%',marginTop:null});}
if(window.hasOwnProperty("popupNoAnimation")&&window.popupNoAnimation===1){element.removeClassName('slideDown');element.show();}
else{new Effect.toggle(element,'appear',{duration:0.3,afterFinish:function(){"use strict";element.addClassName('visible');}});}}
function all_popups_closed(){"use strict";var open_popups=$$('.popup:not(.custom-popup)').filter(function($el){return $el.visible();});return open_popups.length===0;}
function popup_close(element){"use strict";if(!element){element=$('popup');}else{element=$(element);}
var afterFinishHandler=function(){if(all_popups_closed()){window.hide_overlay();}
element.removeClassName('loaded').removeClassName('visible');};if(window.hasOwnProperty("popupNoAnimation")&&window.popupNoAnimation===1){element.hide();afterFinishHandler();}
else{new Effect.Fade(element,{duration:0.3,afterFinish:afterFinishHandler});new Effect.Move(element,{x:'50%',y:-500,mode:'absolute',duration:0.3});}}
function get_popup(p_popupname,p_urlparams,width,height,parameters,destinationPopup,minWidth,minHeight,maxWidth,maxHeight){var url=window.www_dir+'?mod=cmdb&popup='+p_popupname;destinationPopup=destinationPopup||'popup';if(p_urlparams){url+='&'+p_urlparams;}
$(destinationPopup).update('');popup_open($(destinationPopup),width,height,minWidth,minHeight,maxWidth,maxHeight);document.on('keydown',function(ev){ev=ev||window.event;if(ev.keyCode==Event.KEY_ESC){popup_close();}});new Ajax.Submit(url,destinationPopup,false,{history:false,onComplete:function(){$(destinationPopup).addClassName('loaded');},parameters:parameters});}
function get_commentary(callbackAccept,callbackCancel){get_popup('commentary','editMode=1&callbackAccept='+callbackAccept+'&callbackCancel='+callbackCancel,490,260,null,'popup_commentary');}
function expandEntry(id,p_archive,p_logbookid){if($('logb'+id).innerHTML==""){var l_url='?moduleID='+p_logbookid+'&request=expandLogbookEntry&log_id='+id;if(p_archive){l_url=l_url+'&inArchive=1';}
aj_submit(l_url,'get','logb'+id,null,null,null,null,function(){if(!$('tr'+id).visible()){new Effect.Appear('tr'+id,{duration:0.15});swapExpandCollapse(id);}});}
else{if(!$('tr'+id).visible()){new Effect.Appear('tr'+id,{duration:0.15});swapExpandCollapse(id);}}}
function collapseEntry(id){if($('tr'+id).visible()){new Effect.Fade('tr'+id,{duration:0.15});swapExpandCollapse(id);}}
function swapExpandCollapse(id){var $td=$('ec'+id);if($td.down('img').readAttribute('src').indexOf('bullet_toggle_minus')===-1){$td.update(new Element('img',{src:window.dir_images+'icons/silk/bullet_toggle_minus.png'})).onclick=function(){collapseEntry(id);};}
else{$td.update(new Element('img',{src:window.dir_images+'icons/silk/bullet_toggle_plus.png'})).onclick=function(){expandEntry(id);};}}
var mainMenuObserver=Class.create({options:{},initialize:function(options){this.options=Object.extend({scrollingInterval:''},options||{});this.$menuScrollLeft=$('menuScrollLeft');this.$menuScrollRight=$('menuScrollRight');this.$mainMenu=$('mainMenu');this.$mainMenuContainer=this.$mainMenu.up();this.$moduleDropDown=$('module-dropdown');this.$mainMenuArrowSprite=$('downarrow');this.menuObserverLoad();this.menuObserverResize();this.menuObserverBtnRight();this.menuObserverBtnLeft();},scrollBtnRight:function(){var new_pos_left=parseInt(this.$mainMenuContainer.offsetLeft)-80,new_pos_extra_menu=parseInt(((this.$moduleDropDown.getStyle('left'))?this.$moduleDropDown.getStyle('left').substring(0,this.$moduleDropDown.getStyle('left').length-2):0))-20,endRight=parseInt(document.body.clientWidth)-(parseInt(document.body.clientWidth)-new_pos_left-parseInt(this.$mainMenuContainer.getWidth())),searchBarLeft=parseInt($('searchBar').offsetLeft),arrowSprite=parseInt(this.$mainMenuArrowSprite.offsetLeft)-20;this.$mainMenuContainer.setStyle({left:new_pos_left+'px'});this.$moduleDropDown.setStyle({left:new_pos_extra_menu+'px'});this.$mainMenuArrowSprite.setStyle({left:arrowSprite+'px'});if(endRight<searchBarLeft){clearInterval(this.options.scrollingInterval);this.$menuScrollRight.hide();}},scrollBtnLeft:function(){var endLeft=parseInt(this.$mainMenuContainer.offsetLeft)-40,new_pos_extra_menu=parseInt(((this.$moduleDropDown.getStyle('left'))?this.$moduleDropDown.getStyle('left').substring(0,this.$moduleDropDown.getStyle('left').length-2):0))+20,arrowSprite=parseInt(this.$mainMenuArrowSprite.offsetLeft)+20;if(endLeft>0){clearInterval(this.options.scrollingInterval);this.$mainMenuContainer.setStyle({left:'0px'});this.$menuScrollLeft.hide();}
else{this.$moduleDropDown.setStyle({left:new_pos_extra_menu+'px'});this.$mainMenuContainer.setStyle({left:endLeft+'px'});this.$mainMenuArrowSprite.setStyle({left:arrowSprite+'px'});}},menuObserverLoad:function(){new Event.observe(window,'load',function(){var endLeft=parseInt(this.$mainMenuContainer.offsetLeft),endRight=parseInt(document.body.clientWidth)-(parseInt(document.body.clientWidth)-endLeft-parseInt(this.$mainMenuContainer.getWidth())),leftPosSearchBar=parseInt(document.body.clientWidth)-parseInt($('searchBar').getWidth());if(endRight>leftPosSearchBar){this.$menuScrollRight.show();}}.bind(this));},menuObserverResize:function(){new Event.observe(window,'resize',function(){var endLeft=parseInt(this.$mainMenuContainer.offsetLeft),endRight=parseInt(document.body.clientWidth)-(parseInt(document.body.clientWidth)-endLeft-parseInt(this.$mainMenuContainer.getWidth())),leftPosSearchBar=parseInt(document.body.clientWidth)-parseInt($('searchBar').getWidth());if(endRight>leftPosSearchBar){this.$menuScrollRight.show();}
else{this.$mainMenuContainer.setStyle({left:'0px'});this.$moduleDropDown.setStyle({left:$('mainMenu').down('.extras').offsetLeft+'px'});this.$menuScrollRight.hide();this.$menuScrollLeft.hide();move_arrow_to(this.$mainMenuContainer.down('.active'));}}.bind(this));this.calculateMainMenuWidth();},calculateMainMenuWidth:function(){var $menuItems=this.$mainMenu.select('li'),width;try{width=$menuItems.invoke('getWidth').sum()+$menuItems.length*10;}
catch(e){width=this.$mainMenu.getWidth();}
this.$mainMenu.setStyle({width:(60+width)+'px'});},menuObserverBtnRight:function(){this.$menuScrollRight.on('mousedown',function(){var endLeft=parseInt(this.$mainMenuContainer.offsetLeft),endRight=parseInt(document.body.clientWidth)-(parseInt(document.body.clientWidth)+endLeft-parseInt(this.$mainMenuContainer.getWidth())),searchBarLeft=parseInt($('searchBar').offsetLeft);if(searchBarLeft<=endRight){this.$menuScrollLeft.show();this.options.scrollingInterval=setInterval(this.scrollBtnRight.bind(this),50);}}.bind(this));this.$menuScrollRight.on('mouseup',function(){clearInterval(this.options.scrollingInterval);}.bind(this));},menuObserverBtnLeft:function(){this.$menuScrollLeft.on('mousedown',function(){if(parseInt(this.$mainMenuContainer.offsetLeft)<=0){this.$menuScrollRight.show();this.options.scrollingInterval=setInterval(this.scrollBtnLeft.bind(this),50);}}.bind(this));this.$menuScrollLeft.on('mouseup',function(){clearInterval(this.options.scrollingInterval);}.bind(this));}});var Tabs=Class.create({current_body:'',options:{},initTab:'',close:'_close',initialize:function(element,options){this.$element=$(element);if(this.$element){this.options={wrapperClass:'tabs',contentClass:'tab-content',activeBodyClass:'active-body',activeClass:'active',tabClass:'gradient text-shadow-white mouse-pointer',onTabSelect:Prototype.emptyFunction};this.options=Object.extend(this.options,options||{});this.$element.addClassName(this.options.wrapperClass);this.$menu=this.$element.select('li a');var preselection=document.location.href.match(/#(\w.+)/);if(preselection){this.initTab=this.$menu.find(function(value){return value.href.match(/#(\w.+)/)[1]==preselection[1];})||this.$menu.first();}
else{this.initTab=this.$menu.first();}
this.$menu.each(this.tab_initialize.bind(this));this.show(this.initTab);}
else{throw new Error('Element '+element+' does not exist.');}},show:function($tab){if($tab.up('li.disabled')){this.initTab=this.$element.down('li:not(.disabled) a');this.show(this.initTab);return;}
this.current_body=$(this.get($tab));$tab.addClassName(this.options.activeClass).blur();this.current_body.addClassName(this.options.contentClass).show();this.options.onTabSelect($tab);},hide:function($tab){this.current_body=$(this.get($tab));$tab.removeClassName(this.options.activeClass);this.current_body.removeClassName(this.options.activeBodyClass).hide();},close:function($tab){},tab_initialize:function($tab){$tab.addClassName(this.options.tabClass);if($(this.get($tab)))$(this.get($tab)).hide();if(!$tab.up('.disabled')){$tab.on('click',this.prepare.bindAsEventListener(this));}
else{$tab.on('click',this.prepareDisabled.bindAsEventListener(this));}},activate:function(tabIndex){if(this.$menu[tabIndex]){this.show(this.$menu[tabIndex]);this.$menu.without(this.$menu[tabIndex]).each(this.hide.bind(this));}},prepare:function(ev){var $tab=ev.findElement('a');ev.stop();this.show($tab);this.$menu.without($tab).each(this.hide.bind(this));},prepareDisabled:function(ev){ev.stop();},get:function($tab){var regex=$tab.href.match(/#([\S]+)/);if(regex){return regex[1];}
else{return'';}}});var dragBar=Class.create({options:{},initialize:function(options){this.options=Object.extend({dragContainer:'',leftContainer:'',rightContainer:'',moveInfoBox:false,dragType:'col-resize',dragActive:0,defaultTop:'',defaultWidth:'',minWidth:10},options||{});$(this.options.dragContainer).className='draggableBar';$(this.options.dragContainer).setStyle({'height':$(this.options.leftContainer).getHeight()+'px'});$(this.options.dragContainer).setStyle({'top':((this.options.defaultTop!='')?this.options.defaultTop+'px':$(this.options.leftContainer).getStyle('top'))});if(this.options.defaultWidth!=''){$(this.options.leftContainer).setStyle({'width':this.options.defaultWidth+'px'});if(this.options.rightContainer!=''){$(this.options.rightContainer).setStyle({'left':(parseInt(this.options.defaultWidth))+'px'})}
$(this.options.dragContainer).setStyle({'left':(this.options.defaultWidth-1)+'px'});if(this.options.moveInfoBox&&$('infoBox')){$('infoBox').setStyle({'left':(parseInt(this.options.defaultWidth)+1)+'px'});}}
var shadow_bar_ident='shadowBar_'+Math.floor((Math.random()*100)+1);while($(shadow_bar_ident)){shadow_bar_ident='shadowBar_'+Math.floor((Math.random()*100)+1);}
var shadow_bar=new Element('div',{'id':shadow_bar_ident,'style':'z-index:1000;display:none;background:#324;position:absolute;top:'+
$(this.options.dragContainer).getStyle('top')+';left:'+
$(this.options.dragContainer).getStyle('left')+';width:'+
$(this.options.dragContainer).getStyle('width')+';height:'+
$(this.options.dragContainer).getStyle('height')});$('content').insert(shadow_bar);$(this.options.dragContainer).on('mouseover',function(){if(shadow_bar.getHeight()!=$(this.options.leftContainer).getHeight()){shadow_bar.setStyle({'height':$(this.options.leftContainer).getHeight()+'px'});}
$(this.options.dragContainer).setStyle({height:(document.viewport.getHeight()-32)+'px'});$('content').style.cursor=this.options.dragType;}.bind(this));$(this.options.dragContainer).on('mouseout',function(){$('content').style.cursor='';});$(this.options.dragContainer).on('mousedown',function(e){this.options.dragActive=1;if(e.preventDefault){e.preventDefault();}
else{e.returnValue=false;}
shadow_bar.show();}.bind(this));$('content').on('mouseup',function(e){if(this.options.dragActive==1){var left_position=(e.pageX>this.options.minWidth)?(((document.body.offsetWidth-(this.options.minWidth*2))>e.pageX)?e.pageX:document.body.offsetWidth-(this.options.minWidth*2)):this.options.minWidth;var new_left_width=left_position;if(this.options.rightContainer!=''){$(this.options.rightContainer).setStyle({'left':left_position+'px'});}
$(this.options.dragContainer).setStyle({'left':(left_position-1)+'px'});$(this.options.leftContainer).setStyle({'width':new_left_width+'px'});if(this.options.moveInfoBox&&$('infoBox')){$('infoBox').setStyle({'left':(new_left_width+1)+'px'});}
shadow_bar.hide();this.callback_save();idoit.callbackManager.triggerCallback('idoit-dragbar-update');}
this.options.dragActive=0;$('content').style.cursor='';}.bind(this));$('content').on('mousemove',function(e){if(this.options.dragActive==1){$('content').style.cursor=this.options.dragType;shadow_bar.setStyle({'left':((e.pageX>this.options.minWidth)?(((document.body.offsetWidth-
(this.options.minWidth*2))>e.pageX)?e.pageX:document.body.offsetWidth-(this.options.minWidth*2)):this.options.minWidth)+'px'});}}.bind(this));},callback_save:function(){}});var DatePickerFormatter=Class.create();DatePickerFormatter.prototype={initialize:function(format,separator){if(Object.isUndefined(format)){format=["yyyy","mm","dd"];}
if(Object.isUndefined(separator)){separator="-";}
this._format=format;this.separator=separator;this._format_year_index=format.indexOf("yyyy");this._format_month_index=format.indexOf("mm");this._format_day_index=format.indexOf("dd");this._year_regexp=/^\d{4}$/;this._month_regexp=/^0\d|1[012]|\d$/;this._day_regexp=/^0\d|[12]\d|3[01]|\d$/;},match:function(str){var d=str.split(this.separator);if(d.length<3)return false;var year=d[this._format_year_index].match(this._year_regexp);if(year){year=year[0]}else{return false}
var month=d[this._format_month_index].match(this._month_regexp);if(month){month=month[0]}else{return false}
var day=d[this._format_day_index].match(this._day_regexp);if(day){day=day[0]}else{return false}
return[year,month,day];},current_date:function(){var d=new Date;return this.date_to_string(d.getFullYear(),d.getMonth()+1,d.getDate());},date_to_string:function(year,month,day,separator){if(Object.isUndefined(separator))
separator=this.separator;var a=[0,0,0];a[this._format_year_index]=year;a[this._format_month_index]=new Number(month).toPaddedString(2);a[this._format_day_index]=new Number(day).toPaddedString(2);return a.join(separator);}};var DatePicker=Class.create();DatePicker.prototype={Version:'0.9.4',_relative:null,_hidden:null,_time:null,_div:null,_zindex:1,_wrongFormatMessage:null,_keepFieldEmpty:false,_daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],_dateFormat:[["dd","mm","yyyy"],"."],_hiddenFormat:[["yyyy","mm","dd"],"-"],_language:'en',_language_month:$H({'fr':['Janvier','F&#233;vrier','Mars','Avril','Mai','Juin','Juillet','Aout','Septembre','Octobre','Novembre','D&#233;cembre'],'en':['January','February','March','April','May','June','July','August','September','October','November','December'],'sp':['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],'it':['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],'de':['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],'pt':['Janeiro','Fevereiro','Mar&#231;o','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],'hu':['Janu&#225;r','Febru&#225;r','M&#225;rcius','&#193;prilis','M&#225;jus','J&#250;nius','J&#250;lius','Augusztus','Szeptember','Okt&#243;ber','November','December'],'lt':['Sausis','Vasaris','Kovas','Balandis','Gegu&#382;&#279;','Bir&#382;elis','Liepa','Rugj&#363;tis','Rus&#279;jis','Spalis','Lapkritis','Gruodis'],'nl':['januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december'],'dk':['Januar','Februar','Marts','April','Maj','Juni','Juli','August','September','Oktober','November','December'],'no':['Januar','Februar','Mars','April','Mai','Juni','Juli','August','September','Oktober','November','Desember'],'lv':['Janv&#257;ris','Febru&#257;ris','Marts','Apr&#299;lis','Maijs','J&#363;nijs','J&#363;lijs','Augusts','Septembris','Oktobris','Novembris','Decemberis'],'ja':['1&#26376;','2&#26376;','3&#26376;','4&#26376;','5&#26376;','6&#26376;','7&#26376;','8&#26376;','9&#26376;','10&#26376;','11&#26376;','12&#26376;'],'fi':['Tammikuu','Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kes&#228;kuu','Hein&#228;kuu','Elokuu','Syyskuu','Lokakuu','Marraskuu','Joulukuu'],'ro':['Ianuarie','Februarie','Martie','Aprilie','Mai','Junie','Julie','August','Septembrie','Octombrie','Noiembrie','Decembrie'],'zh':['1&#32;&#26376;','2&#32;&#26376;','3&#32;&#26376;','4&#32;&#26376;','5&#32;&#26376;','6&#32;&#26376;','7&#32;&#26376;','8&#32;&#26376;','9&#32;&#26376;','10&#26376;','11&#26376;','12&#26376;'],'sv':['Januari','Februari','Mars','April','Maj','Juni','Juli','Augusti','September','Oktober','November','December'],'pl':['Stycze&#324;','Luty','Marzec','Kwiecie&#324;','Maj','Czerwiec','Lipiec','Sierpie&#324;','Wrzesie&#324;','Pa&#378;dziernik','Listopad','Grudzie&#324;'],'ru':['&#1071;&#1085;&#1074;&#1072;&#1088;&#1100;','&#1060;&#1077;&#1074;&#1088;&#1072;&#1083;&#1100;','&#1052;&#1072;&#1088;&#1090;','&#1040;&#1087;&#1088;&#1077;&#1083;&#1100;','&#1052;&#1072;&#1081;','&#1048;&#1102;&#1085;&#1100;','&#1048;&#1102;&#1083;&#1100;','&#1040;&#1074;&#1075;&#1091;&#1089;&#1090;','&#1057;&#1077;&#1085;&#1090;&#1103;&#1073;&#1088;&#1100;','&#1054;&#1082;&#1090;&#1103;&#1073;&#1088;&#1100;','&#1053;&#1086;&#1103;&#1073;&#1088;&#1100;','&#1044;&#1077;&#1082;&#1072;&#1073;&#1088;&#1100;'],'el':['&#921;&#945;&#957;&#959;&#973;&#945;&#961;&#953;&#959;&#962;',' &#934;&#949;&#946;&#961;&#959;&#965;&#940;&#961;&#953;&#959;&#962;',' &#924;&#940;&#961;&#964;&#953;&#959;&#962;',' &#913;&#960;&#961;&#943;&#955;&#953;&#959;&#962;',' &#924;&#940;&#953;&#959;&#962;',' &#921;&#959;&#973;&#957;&#953;&#959;&#962;',' &#921;&#959;&#973;&#955;&#953;&#959;&#962;',' &#913;&#973;&#947;&#959;&#965;&#963;&#964;&#959;&#962;',' &#931;&#949;&#960;&#964;&#941;&#956;&#946;&#961;&#953;&#959;&#962;',' &#927;&#954;&#964;&#974;&#946;&#961;&#953;&#959;&#962;',' &#925;&#959;&#941;&#956;&#946;&#961;&#953;&#959;&#962;',' &#916;&#949;&#954;&#941;&#956;&#946;&#961;&#953;&#959;&#962;']}),_language_day:$H({'fr':['Lun','Mar','Mer','Jeu','Ven','Sam','Dim'],'en':['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],'sp':['Lun','Mar','Mie','Jue','Vie','S&#225;b','Dom'],'it':['Lun','Mar','Mer','Gio','Ven','Sab','Dom'],'de':['Mon','Die','Mit','Don','Fre','Sam','Son'],'pt':['Seg','Ter','Qua','Qui','Sex','S&#225;b','Dom'],'hu':['H&#233;','Ke','Sze','Cs&#252;','P&#233;','Szo','Vas'],'lt':['Pir','Ant','Tre','Ket','Pen','&Scaron;e&scaron;','Sek'],'nl':['ma','di','wo','do','vr','za','zo'],'dk':['Man','Tir','Ons','Tor','Fre','L&#248;r','S&#248;n'],'no':['Man','Tir','Ons','Tor','Fre','L&#248;r','Sun'],'lv':['P','O','T','C','Pk','S','Sv'],'ja':['&#26376;','&#28779;','&#27700;','&#26408;','&#37329;','&#22303;','&#26085;'],'fi':['Ma','Ti','Ke','To','Pe','La','Su'],'ro':['Lun','Mar','Mie','Joi','Vin','Sam','Dum'],'zh':['&#21608;&#19968;','&#21608;&#20108;','&#21608;&#19977;','&#21608;&#22235;','&#21608;&#20116;','&#21608;&#20845;','&#21608;&#26085;'],'sv':['M&#229;n','Tis','Ons','Tor','Fre','L&#246;r','S&#246;n'],'pl':['Pn','Wt','&#346;r','Czw','Pt','Sob','Ndz'],'ru':['&#1055;&#1085;','&#1042;&#1090;','&#1057;&#1088;','&#1063;&#1090;','&#1055;&#1090;','&#1057;&#1073;','&#1042;&#1089;'],'el':['&#916;&#949;&#965;','&#932;&#961;&#953;','&#932;&#949;&#964;','&#928;&#949;&#956;','&#928;&#945;&#961;','&#931;&#945;&#946;','&#922;&#965;&#961;']}),_language_close:$H({'fr':'fermer','en':'close','sp':'cerrar','it':'fine','de':'schliessen','pt':'fim','hu':'bez&#225;r','lt':'udaryti','nl':'sluiten','dk':'luk','no':'lukk','lv':'aizv&#275;rt','ja':'&#38281;&#12376;&#12427;','fi':'sulje','ro':'inchide','zh':'&#20851;&#32;&#38381','sv':'st&#228;ng','pl':'zamknij','ru':'&#1047;&#1072;&#1082;&#1088;&#1099;&#1090;&#1100;','el':'&#954;&#955;&#949;&#943;&#963;&#953;&#956;&#959;'}),_todayDate:new Date(),_current_date:null,_clickCallback:Prototype.emptyFunction,_cellCallback:Prototype.emptyFunction,_id_datepicker:null,_disablePastDate:false,_disableFutureDate:true,_enableYearBrowse:false,_oneDayInMs:24*3600*1000,_topOffset:30,_leftOffset:0,_isPositionned:false,_relativePosition:true,_setPositionTop:0,_setPositionLeft:0,_bodyAppend:false,_contentAppend:'',_showEvent:'click',_showEffect:"appear",_showDuration:0.2,_closeOnBlurDelay:4,_enableShowEffect:true,_closeEffect:"fade",_closeEffectDuration:0.3,_enableCloseEffect:true,_closeTimer:null,_enableCloseOnBlur:false,_afterClose:Prototype.emptyFunction,getMonthLocale:function(month){return this._language_month.get(this._language)[month];},getLocaleClose:function(){return this._language_close.get(this._language);},_initCurrentDate:function(){this._df=new DatePickerFormatter(this._dateFormat[0],this._dateFormat[1]);this._hf=new DatePickerFormatter(this._hiddenFormat[0],this._hiddenFormat[1]);this._current_date=$F(this._relative);if(!this._df.match(this._current_date)){this._current_date=this._df.current_date();if(!this._keepFieldEmpty)
$(this._relative).value=this._current_date;}
var a_date=this._df.match(this._current_date);this._current_year=Number(a_date[0]);this._current_mon=Number(a_date[1])-1;this._current_day=Number(a_date[2]);},initialize:function(h_p){this._relative=h_p["relative"];this._hidden=h_p["hidden"];this._time=h_p["time"];this._zindex=(h_p["zindex"])?parseInt(Number(h_p["zindex"])):1;this._setPositionTop=(h_p["setPositionTop"])?parseInt(Number(h_p["setPositionTop"])):0;this._setPositionLeft=(h_p["setPositionLeft"])?parseInt(Number(h_p["setPositionLeft"])):0;if(h_p["language"])this._language=h_p["language"];if(!Object.isUndefined(h_p["keepFieldEmpty"]))this._keepFieldEmpty=h_p["keepFieldEmpty"];if(Object.isFunction(h_p["clickCallback"]))this._clickCallback=h_p["clickCallback"];if(!Object.isUndefined(h_p["leftOffset"]))this._leftOffset=parseInt(h_p["leftOffset"]);if(!Object.isUndefined(h_p["topOffset"]))this._topOffset=parseInt(h_p["topOffset"]);if(!Object.isUndefined(h_p["relativePosition"]))this._relativePosition=h_p["relativePosition"];if(!Object.isUndefined(h_p["showEvent"]))this._showEvent=h_p["showEvent"];if(!Object.isUndefined(h_p["showEffect"]))this._showEffect=h_p["showEffect"];if(!Object.isUndefined(h_p["contentAppend"]))this._contentAppend=h_p["contentAppend"];if(!Object.isUndefined(h_p["enableShowEffect"]))this._enableShowEffect=h_p["enableShowEffect"];if(!Object.isUndefined(h_p["showDuration"]))this._showDuration=h_p["showDuration"];if(!Object.isUndefined(h_p["closeEffect"]))this._closeEffect=h_p["closeEffect"];if(!Object.isUndefined(h_p["enableCloseEffect"]))this._enableCloseEffect=h_p["enableCloseEffect"];if(!Object.isUndefined(h_p["closeEffectDuration"]))this._closeEffectDuration=h_p["closeEffectDuration"];if(Object.isFunction(h_p["afterClose"]))this._afterClose=h_p["afterClose"];if(!Object.isUndefined(h_p["externalControl"]))this._externalControl=h_p["externalControl"];if(!Object.isUndefined(h_p["dateFormat"]))this._dateFormat=h_p["dateFormat"];if(Object.isFunction(h_p["cellCallback"]))this._cellCallback=h_p["cellCallback"];if(h_p["closeOnBlurDelay"])this._closeOnBlurDelay=parseInt(Number(h_p["closeOnBlurDelay"]));if(this._closeOnBlurDelay<2)this._closeOnBlurDelay=2;if(h_p["enableCloseOnBlur"])this._enableCloseOnBlur=true;if(!Object.isUndefined(h_p["disablePastDate"])&&h_p["disablePastDate"])this._disablePastDate=true;if(!Object.isUndefined(h_p["disableFutureDate"]))this._disableFutureDate=(h_p["disableFutureDate"])?true:false;if(!Object.isUndefined(h_p["enableYearBrowse"]))this._enableYearBrowse=true;if(!Object.isUndefined(h_p["wrongFormatMessage"]))this._wrongFormatMessage=h_p["wrongFormatMessage"];this._id_datepicker='datepicker-'+this._relative;this._id_datepicker_prev=this._id_datepicker+'-prev';this._id_datepicker_next=this._id_datepicker+'-next';this._id_datepicker_prev_year=this._id_datepicker_prev+'-year';this._id_datepicker_next_year=this._id_datepicker_next+'-year';this._id_datepicker_hdr=this._id_datepicker+'-header';this._id_datepicker_ftr=this._id_datepicker+'-footer';this._div=new Element('div',{id:this._id_datepicker,className:'datepicker',style:'display: none; z-index:'+this._zindex});this._div.innerHTML='<table cellpadding="0">'+'<thead>'+'<tr>'+
((this._enableYearBrowse)?'<th id="'+this._id_datepicker_prev_year+'" class="btn btn-small">&laquo;</th>':'')+'<th id="'+this._id_datepicker_prev+'" class="btn btn-small">&lsaquo;</th>'+'<th id="'+this._id_datepicker_hdr+'" colspan="'+((this._enableYearBrowse)?3:5)+'" class="btn btn-small"></th>'+'<th id="'+this._id_datepicker_next+'" class="btn btn-small">&rsaquo;</th>'+
((this._enableYearBrowse)?'<th id="'+this._id_datepicker_next_year+'" class="btn btn-small">&raquo;</th>':'')+'</tr>'+'</thead>'+'<tbody id="'+this._id_datepicker+'-tbody"></tbody>'+'<tfoot>'+'<td colspan="7" id="'+this._id_datepicker_ftr+'" class="btn btn-small"></td>'+'</tfoot></table>';$(this._relative).writeAttribute('placeholder',this._dateFormat[0].join(this._dateFormat[1]));Event.observe(this._relative,this._showEvent,this.click.bindAsEventListener(this),false);Event.observe(this._relative,'change',this.updateHidden.bindAsEventListener(this),false);if($(this._time)){Event.observe($(this._time),'change',this.updateHidden.bindAsEventListener(this),false);}
document.observe('dom:loaded',this.load.bindAsEventListener(this),false);if(this._enableCloseOnBlur){Event.observe(this._relative,'blur',function(e){this.updateHidden();this._closeTimer=this.close.bind(this).delay(this._closeOnBlurDelay);}.bindAsEventListener(this));Event.observe(this._div,'click',function(e){if(this._closeTimer){window.clearTimeout(this._closeTimer);this._closeTimer=null;}});}
document.observe('click',function(ev){if(this.visible()&&!ev.findElement('.datepicker')){this.close();}}.bind(this));},load:function(){if(this._externalControl)
Event.observe(this._externalControl,'click',this.click.bindAsEventListener(this),false);if(this._relativeAppend){if($(this._relative).parentNode){this._div.innerHTML=this._wrap_in_iframe(this._div.innerHTML);$(this._relative).parentNode.appendChild(this._div);}}else{var body=(this._contentAppend)?$(this._contentAppend):document.getElementsByTagName("body").item(0);if(body){this._div.innerHTML=this._wrap_in_iframe(this._div.innerHTML);body.appendChild(this._div);}
if(this._relativePosition){var scrollOffset=Element.cumulativeScrollOffset($(this._relative));var a_pos=Element.cumulativeOffset($(this._relative));this.setPosition(a_pos[1]-scrollOffset[1],a_pos[0]-scrollOffset[0]);}else{if(this._setPositionTop||this._setPositionLeft)
this.setPosition(this._setPositionTop,this._setPositionLeft);}}
this._initCurrentDate();$(this._id_datepicker_ftr).innerHTML=this.getLocaleClose();Event.observe($(this._id_datepicker_prev),'click',this.prevMonth.bindAsEventListener(this),false);Event.observe($(this._id_datepicker_next),'click',this.nextMonth.bindAsEventListener(this),false);if(this._enableYearBrowse){Event.observe($(this._id_datepicker_prev_year),'click',this.prevYear.bindAsEventListener(this),false);Event.observe($(this._id_datepicker_next_year),'click',this.nextYear.bindAsEventListener(this),false);}
Event.observe($(this._id_datepicker_ftr),'click',this.close.bindAsEventListener(this),false);},_wrap_in_iframe:function(content){return(Prototype.Browser.IE)?"<div style='height:180px;width:280px;background-color:white;align:left'><iframe width='100%' height='100%' marginwidth='0' marginheight='0' frameborder='0' src='about:blank' style='filter:alpha(Opacity=50);'></iframe><div style='position:absolute;background-color:white;top:2px;left:2px;'>"+content+"</div></div>":content;},visible:function(){return($(this._id_datepicker))?$(this._id_datepicker).visible():false;},click:function(){if($(this._id_datepicker)==null)this.load();if(this._relativePosition){var scrollOffset=Element.cumulativeScrollOffset($(this._relative));var a_pos=Element.cumulativeOffset($(this._relative));this.setPosition(a_pos[1]-scrollOffset[1],a_pos[0]-scrollOffset[0]);}
if(!this.visible()){this._initCurrentDate();this._redrawCalendar();}
eval(this._clickCallback());if(this._enableShowEffect){new Effect.toggle(this._id_datepicker,this._showEffect,{duration:this._showDuration,afterFinish:function(){$(this._id_datepicker).setStyle({opacity:1});}.bind(this)});}else{$(this._id_datepicker).show().setStyle({opacity:1});}
Element.makePositioned($(this._id_datepicker));if(this._closeTimer){window.clearTimeout(this._closeTimer);this._closeTimer=null;}},close:function(){if(this._enableCloseEffect){switch(this._closeEffect){case'puff':new Effect.Puff(this._id_datepicker,{duration:this._closeEffectDuration});break;case'blindUp':new Effect.BlindUp(this._id_datepicker,{duration:this._closeEffectDuration});break;case'dropOut':new Effect.DropOut(this._id_datepicker,{duration:this._closeEffectDuration});break;case'switchOff':new Effect.SwitchOff(this._id_datepicker,{duration:this._closeEffectDuration});break;case'squish':new Effect.Squish(this._id_datepicker,{duration:this._closeEffectDuration});break;case'fold':new Effect.Fold(this._id_datepicker,{duration:this._closeEffectDuration});break;case'shrink':new Effect.Shrink(this._id_datepicker,{duration:this._closeEffectDuration});break;default:new Effect.Fade(this._id_datepicker,{duration:this._closeEffectDuration});break;}}else{$(this._id_datepicker).hide();}
eval(this._afterClose());},updateHidden:function(){var _self=this,date=$F(_self._relative),matchedDate,time='';if(!_self.df)_self._initCurrentDate();if(_self._df){if(date!==''&&date!=='-'){matchedDate=_self._df.match(date);if(matchedDate){if($(_self._time)){time=' '+$F(_self._time);}
$(_self._hidden).setValue(_self._hf.date_to_string(matchedDate[0],matchedDate[1],matchedDate[2],_self._hf.separator)+time);$(_self._relative).setValue(_self._df.date_to_string(matchedDate[0],matchedDate[1],matchedDate[2],_self._df.separator));}else{if(_self._wrongFormatMessage){idoit.Notify.warning(date+': '+_self._wrongFormatMessage,{life:5});}}}
else{$(_self._hidden).setValue('');$(_self._relative).setValue('');}}},setDateFormat:function(format,separator){if(Object.isUndefined(format))
format=this._dateFormat[0];if(Object.isUndefined(separator))
separator=this._dateFormat[1];this._dateFormat=[format,separator];$(this._relative).writeAttribute('placeholder',this._dateFormat[0].join(this._dateFormat[1]));},setHiddenFormat:function(format,separator){if(Object.isUndefined(format))
format=this._dateFormat[0];if(Object.isUndefined(separator))
separator=this._dateFormat[1];this._hiddenFormat=[format,separator];},setPosition:function(t,l){var h_pos={'top':'0px','left':'0px'};if(!Object.isUndefined(t))
h_pos['top']=Number(t)+this._topOffset+'px';if(!Object.isUndefined(l))
h_pos['left']=Number(l)+this._leftOffset+'px';$(this._id_datepicker).setStyle(h_pos);this._isPositionned=true;},_getMonthDays:function(year,month){if(((0==(year%4))&&((0!=(year%100))||(0==(year%400))))&&(month==1))
return 29;return this._daysInMonth[month];},_buildCalendar:function(){var _self=this;var tbody=$(this._id_datepicker+'-tbody');try{while(tbody.hasChildNodes()){tbody.removeChild(tbody.childNodes[0]);}}catch(e){};var trDay=new Element('tr');this._language_day.get(this._language).each(function(item){var td=new Element('td');td.innerHTML=item;td.className='wday';trDay.appendChild(td);});tbody.appendChild(trDay);var a_d=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]];var d=new Date(this._current_year,this._current_mon,1,12);var startIndex=(!d.getDay())?6:d.getDay()-1;var nbDaysInMonth=this._getMonthDays(this._current_year,this._current_mon);var daysIndex=1;for(var j=startIndex;j<7;j++){a_d[0][j]={d:daysIndex,m:this._current_mon,y:this._current_year};daysIndex++;}
var a_prevMY=this._prevMonthYear();var nbDaysInMonthPrev=this._getMonthDays(a_prevMY[1],a_prevMY[0]);for(var j=0;j<startIndex;j++){a_d[0][j]={d:Number(nbDaysInMonthPrev-startIndex+j+1),m:Number(a_prevMY[0]),y:a_prevMY[1],c:'outbound'};}
var switchNextMonth=false;var currentMonth=this._current_mon;var currentYear=this._current_year;for(var i=1;i<6;i++){for(var j=0;j<7;j++){a_d[i][j]={d:daysIndex,m:currentMonth,y:currentYear,c:(switchNextMonth)?'outbound':(((daysIndex==this._todayDate.getDate())&&(this._current_mon==this._todayDate.getMonth())&&(this._current_year==this._todayDate.getFullYear()))?'today':null)};daysIndex++;if(daysIndex>nbDaysInMonth){daysIndex=1;switchNextMonth=true;if(this._current_mon+1>11){currentMonth=0;currentYear+=1;}else{currentMonth+=1;}}}}
for(var i=0;i<6;i++){var tr=new Element('tr');for(var j=0;j<7;j++){var h_ij=a_d[i][j];var td=new Element('td');var id=$A([this._relative,this._df.date_to_string(h_ij["y"],h_ij["m"]+1,h_ij["d"],'-')]).join('-');td.setAttribute('id',id);if(h_ij["c"])
td.className=h_ij["c"];var _curDate=new Date();_curDate.setFullYear(h_ij["y"],h_ij["m"],h_ij["d"]);if(this._disablePastDate||this._disableFutureDate){if(this._disablePastDate){var _res=(_curDate>=this._todayDate)?true:false;this._bindCellOnClick(td,true,_res,h_ij["c"]);}
if(this._disableFutureDate){var _res=(this._todayDate.getTime()+this._oneDayInMs>_curDate.getTime())?true:false;this._bindCellOnClick(td,true,_res,h_ij["c"]);}}else{this._bindCellOnClick(td,false);}
td.innerHTML=h_ij["d"];tr.appendChild(td);}
tbody.appendChild(tr);}
return tbody;},_bindCellOnClick:function(td,wcompare,compareresult,h_ij_c){var doBind=false;if(wcompare){if(compareresult){doBind=true;}else{td.className=(h_ij_c)?'nclick_outbound':'nclick';}}else{doBind=true;}
if(doBind){var _self=this;td.onclick=function(){$(_self._relative).value=String($(this).readAttribute('id')).replace(_self._relative+'-','').replace(/-/g,_self._df.separator);_self.updateHidden();if(_self._cellCallback)
_self._cellCallback(this);_self.close();};}},_nextMonthYear:function(){var c_mon=this._current_mon;var c_year=this._current_year;if(c_mon+1>11){c_mon=0;c_year+=1;}else{c_mon+=1;}
return[c_mon,c_year];},nextMonth:function(){var a_next=this._nextMonthYear();var _nextMon=a_next[0];var _nextYear=a_next[1];var _curDate=new Date();_curDate.setFullYear(_nextYear,_nextMon,1);var _res=(this._todayDate.getTime()+this._oneDayInMs>_curDate.getTime())?true:false;if(this._disableFutureDate&&!_res)
return;this._current_mon=_nextMon;this._current_year=_nextYear;this._redrawCalendar();},_prevMonthYear:function(){var c_mon=this._current_mon;var c_year=this._current_year;if(c_mon-1<0){c_mon=11;c_year-=1;}else{c_mon-=1;}
return[c_mon,c_year];},prevMonth:function(){var a_prev=this._prevMonthYear();var _prevMon=a_prev[0];var _prevYear=a_prev[1];var _curDate=new Date();_curDate.setFullYear(_prevYear,_prevMon,1);var _res=(_curDate>=this._todayDate)?true:false;if(this._disablePastDate&&!_res&&(_prevMon!=this._todayDate.getMonth()))
return;this._current_mon=_prevMon;this._current_year=_prevYear;this._redrawCalendar();},_prevYear:function(){var c_mon=this._current_mon;var c_year=(this._current_year-1);return[c_mon,c_year];},prevYear:function(){var a_next=this._prevYear();var _nextMon=a_next[0];var _nextYear=a_next[1];var _curDate=new Date();_curDate.setFullYear(_nextYear,_nextMon,1);var _res=(this._todayDate.getTime()+this._oneDayInMs>_curDate.getTime())?true:false;if(this._disableFutureDate&&!_res)
return;this._current_mon=_nextMon;this._current_year=_nextYear;this._redrawCalendar();},_nextYear:function(){var c_mon=this._current_mon;var c_year=(this._current_year+1);return[c_mon,c_year];},nextYear:function(){var a_next=this._nextYear();var _nextMon=a_next[0];var _nextYear=a_next[1];var _curDate=new Date();_curDate.setFullYear(_nextYear,_nextMon,1);var _res=(this._todayDate.getTime()+this._oneDayInMs>_curDate.getTime())?true:false;if(this._disableFutureDate&&!_res)
return;this._current_mon=_nextMon;this._current_year=_nextYear;this._redrawCalendar();},_redrawCalendar:function(){this._setLocaleHdr();this._buildCalendar();},_setLocaleHdr:function(){var a_next=this._nextMonthYear();$(this._id_datepicker_next).setAttribute('title',this.getMonthLocale(a_next[0])+' '+a_next[1]);var a_prev=this._prevMonthYear();$(this._id_datepicker_prev).setAttribute('title',this.getMonthLocale(a_prev[0])+' '+a_prev[1]);if(this._enableYearBrowse){var a_next_y=this._nextYear();$(this._id_datepicker_next_year).setAttribute('title',this.getMonthLocale(a_next_y[0])+' '+a_next_y[1]);var a_prev_y=this._prevYear();$(this._id_datepicker_prev_year).setAttribute('title',this.getMonthLocale(a_prev_y[0])+' '+a_prev_y[1]);}
$(this._id_datepicker_hdr).update('&nbsp;&nbsp;&nbsp;'+this.getMonthLocale(this._current_mon)+'&nbsp;'+this._current_year+'&nbsp;&nbsp;&nbsp;');}};"use strict";if(!idoit)var idoit={};idoit.Require={params:{paths:{},debug:false},loaded:[],config:function(config){this.params=config;return this;},addModule:function(moduleName,script){this.params.paths[moduleName]=script;return this;},require:function(modulesToLoad,onload){var i;if(typeof modulesToLoad==="string"){modulesToLoad=[modulesToLoad];}
for(i=0;i<modulesToLoad.length;++i){if(this.loaded.indexOf(modulesToLoad[i])!==-1){modulesToLoad.splice(i,1);i-=1;}}
if(!this.modulesLoaded(modulesToLoad,onload)){for(i=0;i<modulesToLoad.length;++i){var moduleName=modulesToLoad[i];if(this.params.paths.hasOwnProperty(moduleName)){var e=document.createElement("script");e.setAttribute('data-module',moduleName);e.src=this.params.paths[moduleName];e.async=true;e.onload=this.onLoad.bind(this,moduleName,i,modulesToLoad,onload);document.head.appendChild(e);}}}},requireQueue:function(modulesToLoad,onload){function load(queue,results){if(queue.length){idoit.Require.require([queue.shift()],function(result){results.push(result);load(queue,results);});}else{if(Object.isFunction(onload)){onload();}}}
load(modulesToLoad,[]);},onLoad:function(moduleName,moduleIndex,modulesToLoad,onload,ev){if(this.params.debug)console.log('Module loaded: '+moduleName+' ('+Math.round(ev.timeStamp / 1000)+'ms; '+ev.path[0].src+')');modulesToLoad.splice(modulesToLoad.indexOf(moduleName),1);this.loaded.push(moduleName);this.modulesLoaded(modulesToLoad,onload);},modulesLoaded:function(modulesToLoad,onloadCallback){if(modulesToLoad.length===0){if(this.params.debug)console.log('Modules loaded:',this.loaded);if(Object.isFunction(onloadCallback)){onloadCallback();}
return true;}
return false;}};;(function(){"use strict";var defaultOptions={separator:',',linefeed:'\r\n',header:[]},elementMatchers={'HTMLElements':/^(?:TABLE)$/};Element.addMethods({exportTableAsCSV:function(element,options){element=$(element);options=Object.extend(defaultOptions,options||{});options.separator='"'+options.separator+'"';options.linefeed='"'+options.linefeed+'"';if(elementMatchers.HTMLElements.test(element.tagName)){var tmpSeparator=String.fromCharCode(11),tmpLinefeed=String.fromCharCode(0),csvData='',headerSelector='';if(options.header.length>0){csvData=options.header.join(options.separator)+options.linefeed;}
else{headerSelector='tr:has(th),';}
csvData+='"'+element.select(headerSelector+'tr:has(td)').collect(function(row,i){return row.select('th,td').collect(function(col,j){var text=col.down("a")&&col.down("a").length>0?col.down("a")[0].innerHTML:col.innerHTML;return text.replace(/°/g," ").replace(/"/g,'""').stripTags().unescapeHTML();}).join(tmpSeparator);}).join(options.linefeed).split(tmpLinefeed).join(options.linefeed).split(tmpSeparator).join(options.separator)+'"';window.location='data:text/csv,'+encodeURIComponent(csvData);return csvData;}
return'';}});})();var isys_ajax_queue={_sim_requests:15,_urls:[],_targets:[],_options:[],set_sim_requests:function(reqs){if(!isNaN(reqs))this._sim_requests=reqs;},push:function(p_url,p_options,p_target){this._urls.push(p_url);this._options.push(p_options);if(p_target==null||typeof p_target=='undefined')this._targets.push("__REQUEST_ONLY");else this._targets.push(p_target);this._next();},clear:function(){this._urls=[];this._targets=[];this._options=[];},_next:function(){if(Ajax.activeRequestCount<isys_ajax_queue._sim_requests){if(isys_ajax_queue._targets.first()=="__REQUEST_ONLY"){var junk=isys_ajax_queue._targets.shift();return new Ajax.Request(isys_ajax_queue._urls.shift(),isys_ajax_queue._options.shift());}else
return new Ajax.Updater(isys_ajax_queue._targets.shift(),isys_ajax_queue._urls.shift(),isys_ajax_queue._options.shift());}}};isys_ajax_=Class.create(Ajax.Base,{_method:'get',_asynchronous:true,_form:'isys_form',_url:'',_last:'',_ajax:function(){return(this._url.match(/^.*[\?].*$/))?'&ajax=1':'?ajax=1';},initialize:function(p_method,p_encoding,p_async){if(p_method)this._method=p_method;if(p_async)this._asynchronous=p_async;this._url=String(document.location);},initOptions:function(p_options){var options={history:{cache:true,onStateChange:function(state){}},asynchronous:this._asynchronous,evalScripts:true,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this),onComplete:this.onComplete.bind(this)};Object.extend(options,p_options||{});return options;},method:function(p_method){_method=p_method;},add:function(p_url,p_target){this._url=p_url;if(!Object.isUndefined(History)){History.add([p_url,p_target,new Date()]);}},last:function(){if(!Object.isUndefined(History)){return History.last();}else return false;},_updater:function(p_target,p_url,p_options){if(!p_url||p_url==''){p_url=String(document.location);}
this._target=p_target;return isys_ajax_queue.push(p_url+this._ajax(),p_options,this._target);},_request:function(p_url,p_options){if(!p_url||p_url==''){p_url=String(document.location);}
return isys_ajax_queue.push(p_url+this._ajax(),p_options,null);},call:function(p_url,p_options){this._request(p_url,p_options);},_history:function(p_url,p_target,p_options){if(Object.isUndefined(p_options.history.id)){var id=(Object.isString(p_target))?p_target:p_target.id;}else{var id=p_options.history.id;}
var tmpOpt=Object.clone(Ajax.History.Features);Object.extend(tmpOpt,p_options.history);options.history=tmpOpt;options.history.__url=p_url+this._ajax();options.container=p_target;History.set(id,Ajax.History.observe('Updater',id,p_options.history.__url,p_options));},onSuccess:function(){if(p_reset_form&&$(p_form)){$(p_form).reset();}
if($(p_fade_out)){$(p_fade_out).disabled='disabled';new Effect.Fade($(p_fade_out),{duration:0.4});}},onComplete:Prototype.emptyFunction,onFailure:function(){$(this._target).update('Error.');}});Ajax.Submit=Class.create(isys_ajax_,{initialize:function(p_url,p_target,p_form,p_options){if(!p_url||p_url=='')p_url=this._url;this.add(p_url);if(!p_form||p_form=='')p_form=this._form;var l_params={};if(p_form&&$(p_form)){if(!p_options.parameters)p_options.parameters={};l_params=Object.extend(p_options.parameters,$(p_form).serialize(true));}
if(typeof p_options=='object'&&typeof p_options.method!='undefined'){Object.extend(p_options,{method:'post',history:false});}
var options=this.initOptions(p_options);options.parameters=l_params;return this._updater(p_target,p_url,options);}});Ajax.Call=Class.create(isys_ajax_,{initialize:function(p_url,p_options){var options=this.initOptions(p_options);this.add(p_url);options.history=false;return this._request(p_url,options);}});Ajax.Get=Class.create(isys_ajax_,{initialize:function(p_target,p_url,p_options){options=this.initOptions(p_options);Object.extend(options,p_options);this._url=p_url;if(options.history){return this._history(p_url,p_target,options);}
else{if(Object.isArray(p_target)){this._updater(p_target[1],p_target[0],options);if(!Object.isUndefined(History))History.back();}
else{return this._updater(p_target,p_url,options);}}}});Ajax.Effect=Class.create(isys_ajax_,{initialize:function(p_effect,p_target,p_url,p_options){this.add(p_url,p_target);this._options={duration:0.2};Object.extend(this._options,p_options||{});if(Object.isString(p_effect)){this._effect=p_effect;}
else return false;if(Object.isString(p_target)&&$(p_target))
this._target=p_target;options=this.initOptions(p_options);this._updater(p_target,p_url,options);},onComplete:function(transport){if(this._target){if(!$(this._target).visible()){new Effect[this._effect](this._target,this._options);}}}});var History={__altered:false,__currentHash:null,__previousHash:null,__iframe:false,__title:false,hash:new Hash(),maximum:25,setMaximum:function(p_max){if(Object.isNumber(p_max))
this.maximum=p_max;},back:function(){if(this._urls.length>2){this._urls.pop();this._urls.pop();return true;}else return false;},all:function(){return this._urls;},get:function(i){return this._urls[i];},go:function(i){var l_go=(this._urls.length>=i)?this._urls[this._urls.length+i]:false;if(l_go){return new Ajax.Get(l_go);}else return false;},prev:function(){return(this._urls.length>=2)?this._urls[this._urls.length-2]:false;},last:function(){return this._urls.last();},add:function(req){if(Object.isArray(req)&&Object.isString(req[0])){this._urls.push(req);if(this.maximum&&this.num()>this.maximum){this._urls.splice(0,1);}}},num:function(){return this._urls.size();},init:function(){var inst=this;var hash=location.hash.substring(1);this.hash=$H(hash.toQueryParams());this.__currentHash=hash;this.__previousHash=hash;this._urls=[];this.__title=document.title;if(Prototype.Browser.IE){document.observe('dom:loaded',function(e){if(!$('px-historyframe')){History.__iframe=new Element('iframe',{name:'px-historyframe',id:'px-historyframe',src:'',width:'0',height:'0',style:{visibility:'hidden'}});document.body.appendChild(History.__iframe);History.setHashOnIframe(inst.hash.toQueryString());}});}},add:function(){},set:function($name,$value){this.__previousHash=this.hash.toQueryString();this.hash.set($name,$value);this.apply();},get:function($name){return this.hash.get($name);},unset:function($name){this.hash.unset($name);this.apply();},update:function(){this.__previousHash=this.hash.toQueryString();var hash=window.location.hash.substring(1);if(Prototype.Browser.IE&&this.__iframe){var hashInFrame=this.getHashOnIframe();if(hashInFrame!=hash){hash=hashInFrame;}}
this.hash=$H(hash.toQueryParams());this.__currentHash=hash;},apply:function(){var newHash=this.hash.toQueryString();window.location.hash=newHash;if(Prototype.Browser.IE&&this.__iframe){if(this.__currentHash!=newHash){this.setHashOnIframe(newHash);}
else if(newHash!=this.getHashOnIframe()){this.setHashOnIframe(newHash);}}},isAltered:function(){if(this.__altered==true){return true;}
this.__altered=false;return(History.__currentHash!=History.__previousHash);},setHashOnIframe:function(hash){try{var doc=History.__iframe.contentWindow.document;doc.open();doc.write('<html><body id="history">'+hash+'</body></html>');doc.close();}catch(e){}},getHashOnIframe:function(){var doc=this.__iframe.contentWindow.document;if(doc&&doc.body.id=='history'){return doc.body.innerText;}else{return this.hash.toQueryString();}},setTitle:function(title){if(document.title){document.title=title;}},getTitle:function(){return this.__title;}};History.Registry={hash:new Hash(),set:function($config){if(typeof($config)!='object'){throw('History.Registry.set : $config must be a javascript object');}
if(!$config.id||!Object.isString($config.id)){throw('History.Registry.set : $config.id must be a string');}
if(!$config.onStateChange||!Object.isFunction($config.onStateChange)){throw('History.Registry.set : $config.onStateChange '
+'must be a javascript callback function');}
if(!$config.defaultValue||!Object.isString($config.defaultValue)){$config.defaultValue='';}
this.hash.set($config.id,$config);},get:function($id){return this.hash.get($id);},unset:function($id){this.hash.unset($id);}};History.Observer={delay:0.2,interval:null,started:false,start:function(){if(this.started)return;this.interval=new PeriodicalExecuter(History.Observer.dispatch,this.delay);this.started=true;},stop:function(){if(!this.started)return;this.interval.stop();this.started=false;},dispatch:function(){History.update();if(History.isAltered()){History.hash.each(function(pair){var registry=History.Registry.get(pair.key);if(registry){registry.onStateChange.bind(History)(pair.value);}});}}};Ajax.History={types:['Request','Updater','Appear'],observe:function($type,$id,$url,$options){var getter=Ajax.History.Registry.get($id);var currentVersion=0;var output=false;if(this.types.indexOf($type)==-1){throw('Ajax.History.observer() -> type '+$type+' is invalid !');}
if(getter==undefined){currentVersion=($options.history.state)?$options.history.state:0;var hash=new Hash();hash.set(currentVersion,$options);Ajax.History.Registry.set($id,hash);}else{currentVersion=($options.history.state)?$options.history.state:this.getCurrentVersion($id);getter.set(currentVersion,$options);}
this.addCallback($type,$id);return currentVersion;},addCallback:function($type,$id){History.Observer.start();History.__altered=true;if(!Object.isUndefined(History.Registry.get($id)))return;History.Registry.set({id:$id,onStateChange:function(state){var options=Ajax.History.Registry.get($id).get(state.toString());var request=null;if(Object.isUndefined(options))return;if(options.history.cache==true&&options.history.__request!=null){new Ajax.Cache(options.history.__request);}else{if($type=='Request'){request=isys_ajax_queue.push(options.history.__url,options,null);}else if($type=='Updater'){request=isys_ajax_queue.push(options.history.__url,options,options.container);}else if($type=='Appear'){request=new Ajax.Effect('appear',options.container,options.history.__url,options);}
options.history.__request=request;}
History.__altered=false;if(Object.isFunction(options.history.onStateChange)){options.history.onStateChange(state);}}});},getCurrentVersion:function($id){var getter=Ajax.History.Registry.get($id);return Object.isUndefined(getter)?0:getter.keys().length;}};Ajax.History.Registry=new Hash();Ajax.History.Features={id:null,state:false,cache:false,onStateChange:null,__url:null,__request:null};Ajax.Cache=Class.create(Ajax.Base,{_complete:false,initialize:function($super,request){$super(request.options);request._complete=false;this.transport=request.transport;this.request(request.url);return this;},request:function(url){this.url=url;this.method=this.options.method;var params=Object.clone(this.options.parameters);try{var response=new Ajax.Response(this);if(this.options.onCreate)this.options.onCreate(response);Ajax.Responders.dispatch('onCreate',this,response);if(this.options.asynchronous)this.respondToReadyState.bind(this).defer(1);this.onStateChange();}
catch(e){this.dispatchException(e);}}});Object.extend(Ajax.Cache.prototype,{respondToReadyState:Ajax.Request.prototype.respondToReadyState,onStateChange:Ajax.Request.prototype.onStateChange,success:Ajax.Request.prototype.getStatus,getStatus:Ajax.Request.prototype.getStatus,isSameOrigin:Ajax.Request.prototype.isSameOrigin,getHeader:Ajax.Request.prototype.getHeader,evalResponse:Ajax.Request.prototype.evalResponse,dispatchException:Ajax.Request.prototype.dispatchException});Ajax.Request=Class.create(Ajax.Request,{initialize:function($super,url,options){$super(url,options);return this;}});Ajax.Request.Events=['Uninitialized','Loading','Loaded','Interactive','Complete'];Ajax.Updater=Class.create(Ajax.Updater,{initialize:function($super,container,url,options){$super(container,url,options);return this;}});Ajax.Responders.register({onComplete:isys_ajax_queue._next});Ajax.Responders.register({onComplete:function(response){if(window.C__AUTHORIZED&&response.transport){var authorized=response.transport.getResponseHeader('i-doit-Authorized');if(authorized!==null&&!authorized){window.location='?timeout';return;}}}});function aj_submit(p_url,p_method,p_target,p_form,p_fade_out,p_reset_form,p_success,p_complete,p_failure){var l_params='';if(!p_url||p_url=='')p_url=String(document.location);if(!p_method)p_method='get';if($(p_form)||p_method=='get'){if($(p_form)){l_params=$(p_form).serialize(true);}
if(p_url.search('^.*[\?].*$')!=-1)l_ajax='&ajax=1';else l_ajax='?ajax=1';isys_ajax_queue.push(p_url+l_ajax,{method:p_method,evalScripts:true,evalJS:true,onComplete:p_complete,onSuccess:function(transport){if(typeof p_success!='undefined')p_success(transport);if(!$(p_target).visible())$(p_target).show();if(p_reset_form&&$(p_form)){$(p_form).reset();}
if($(p_fade_out)){$(p_fade_out).disabled='disabled';new Effect.Fade($(p_fade_out),{duration:0.4});}},onFailure:function(){if(p_failure!='undefined')p_failure();$(p_target).innerHTML='Error.';},parameters:l_params},p_target);}}
if(!Lists)var Lists={};Lists.Objects=Class.create(TableOrderer,{initialize:function(element,options){this.element=element;this.options=options;this.replaceTablePlaceholders=new ReplacePlaceholders();this.options=Object.extend({data:false,url:false,allowMultiselect:true,unsortedColumn:[],dateFormat:'d',filter:false,pageCount:5,paginate:false,search:false,classPrefix:'mainTable',draggable:false,checkboxes:true,checkedBoxes:[],instanceName:'',max_pages:0,ajax_pager:false,ajax_pager_url:'',ajax_pager_preload:10,tr_click:true,ndo_state_url:'',ndo_state_field:'',livestatus_state_url:'',livestatus_state_field:'',order_direction:'',order_field:'',filter_save_url:''},options||{});this.tools={page:1,pages:1,filterCol:'',filterData:'',searchData:'',requested_offsets:[]};this.msgs={loading:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__LOADING'),emptyResults:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__EMPTY_RESULTS'),errorURL:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__ERROR_URL'),errorData:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__ERROR_DATA'),searchLabel:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__SEARCH_LABEL'),filterLabel:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__FILTER_LABEL'),paginationOf:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__PAGINATEN_OF'),paginationPages:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__PAGINATEN_PAGES'),paginationFirst:'&nbsp;&nbsp;&nbsp;&nbsp;',paginationPrev:'&nbsp;&nbsp;&nbsp;&nbsp;',paginationNext:'&nbsp;&nbsp;&nbsp;&nbsp;',paginationLast:'&nbsp;&nbsp;&nbsp;&nbsp;'};this.cache=[];this.isCached=false;this.container=$(element);this.orderField=false;this.order='asc';this.thClickbfx=this.thClick.bindAsEventListener(this);this.thOverbfx=this.thOver.bindAsEventListener(this);this.thOutbfx=this.thOut.bindAsEventListener(this);this.ndo_loaded=[];this.livestatus_loaded=[];this.setData();},createTable:function(){this.container.update();this.container.insert({top:'<table cellspacing="0" cellpadding="0" id="data-grid-'+this.element+'" class="'+this.options.classPrefix+' mainTableHover"></table>'});this.table=$('data-grid-'+this.element);this.createTools();this.createRows();this.addToolsObserver();this.addTableObserver();this.makeUnsort();this.updateNDO();this.updateLivestatus();if(this.options.filter){$(this.table.id+'-filter-data').focus();}
if(this.options.tr_click){this.table.addClassName('mouse-pointer');}},addToolsObserver:function($super){var instance=this;$super();if(this.options.filter&&!this.options.filter_save_url.empty()){$(this.table.id+'-filter-data').on('change',this.filterData.bindAsEventListener(this));$(this.table.id+'-filter-data').on('blur',function(){instance.save_filter_to_session();});$(this.table.id+'-filter-column').on('change',function(){instance.save_filter_to_session();});}},save_filter_to_session:function(){new Ajax.Request(this.options.filter_save_url,{parameters:{field:$F(this.table.id+'-filter-column'),value:$F(this.table.id+'-filter-data')},onComplete:function(){}});},createRow:function(obj,index){var values=Object.values(obj);var tr=new Element('tr',{'class':'data line'+(index%2),id:this.table.id+'-'+index}).writeAttribute('data-objectid',values[0]).writeAttribute('data-listindex',index);var checkedStr=(this.options.checkedBoxes.indexOf(parseInt(values[0]))!==-1)?"checked='checked'":'';this.tableColumnsName.each(function(s,index){if(s=='__id__'&&this.options.checkboxes){var dragger='';if(this.options.draggable){dragger='<span class="drag-handle"></span>';}
tr.insert(new Element('td',{'className':this.table.id+'-column-'+s,'style':'width:30px; text-align:center;'}).update(dragger+'<input class="checkbox obj-selector" type="checkbox" value="'+values[index]+'" name="id[]" title="'+values[index]+'" '+checkedStr+'/>'));}else{tr.insert(new Element('td',{'className':this.table.id+'-column-'+s}).update(values[index]));}}.bind(this));if(Prototype.Browser.IE&&tr.outerHTML){return tr.outerHTML;}else{return tr;}},createFirstRow:function(obj){var row='<thead><tr class="no-drag">';this.tableColumnsName.each(function(i){if(i=='__id__'&&this.options.checkboxes){var checkbox_style='';if(this.options.draggable){checkbox_style='style="margin-left:12px;"';}
row+='<th id="'+this.table.id+'-'+i+'" class="no-sort" style="text-align:center;">'+'<input class="no-sort" id="complete-list-selector" type="checkbox" '+checkbox_style+' /></th>';}else{if(i=='__id__'){i='ID';}
row+='<th id="'+this.table.id+'-'+i+'">'+i+'</th>';}}.bind(this));row+='</tr></thead>';return row;},changePage:function(ev){var page=ev.element().value;if(page<=this.tools.pages&&page>0){this.tools.page=page;if(this.options.ajax_pager){this.load_data();}
this.updateTable();}else{if(page!=''){this.updatePager();}}
delete page;},load_data:function(){var offset=0;offset=parseInt((this.tools.page-1)/ this.options.ajax_pager_preload);if(!this.tools.requested_offsets.in_array(offset)&&offset>0){this.tools.requested_offsets.push(offset);new Ajax.Request(this.options.ajax_pager_url,{parameters:{'offset_block':offset},method:"post",onSuccess:function(transport){var json=transport.responseJSON,index_offset=(offset*this.options.pageCount*this.options.ajax_pager_preload);for(var i=0,len=json.length;i<len;++i){this.data[(index_offset+i)]=json[i];}
this.perform();}.bind(this)});}},createPager:function(){if($(this.table.id+'-pager')){$(this.table.id+'-pager').insert({bottom:new Element('a',{'id':this.table.id+'-page-first','class':'first-page-button'}).update(this.msgs.paginationFirst)}).insert({bottom:new Element('a',{'id':this.table.id+'-page-prev','class':'prev-page-button'}).update(this.msgs.paginationPrev)}).insert({bottom:'<span id="'+this.table.id+'-page-amount" style="margin-right:6px">'+'<input id="'+this.table.id+'-page-current'+'" class="currentpage input" value="'+this.tools.page+'" /> '+
this.msgs.paginationOf+' <span id="'+this.table.id+'-page-total'+'" class="totalpages">'+this.tools.pages+'</span> '+this.msgs.paginationPages+'</span>'}).insert({bottom:new Element('a',{'id':this.table.id+'-page-next','class':'next-page-button'}).update(this.msgs.paginationNext)}).insert({bottom:new Element('a',{'id':this.table.id+'-page-last','class':'last-page-button'}).update(this.msgs.paginationLast)});}
$(this.table.id+'-page-current').on('keydown',function(ev){if(ev.keyCode==Event.KEY_RETURN){ev.preventDefault();}});$(this.table.id+'-page-current').on('keyup',this.changePage.bindAsEventListener(this))},pagerData:function(e,element){var tid=this.table.id;var caller=element||Event.element(e);switch(caller.id){case tid+'-page-next':this.tools.page=((++this.tools.page)>this.tools.pages)?--this.tools.page:this.tools.page;break;case tid+'-page-prev':this.tools.page=((--this.tools.page)>this.tools.pages)?++this.tools.page:this.tools.page;break;case tid+'-page-last':this.tools.page=this.tools.pages;break;default:this.tools.page=1;}
if(this.options.ajax_pager){this.load_data();}
this.updateTable();},updatePager:function(){$(this.table.id+'-page-current').value=this.tools.page;},updateTable:function(){this.table=$('data-grid-'+this.element);$(this.table.id).update();this.createRows();this.addTableObserver();this.makeUnsort();this.updatePager();this.updateNDO();this.updateLivestatus();},updateNDO:function(){if($(this.table.id).down('span.ndo_state')){var obj_ids=$$('#'+this.table.id+' tr').invoke('readAttribute','data-objectid').compact();obj_ids=Array.prototype.without.apply(obj_ids,this.ndo_loaded);new Ajax.Request(this.options.ndo_state_url,{method:"post",parameters:{obj_ids:Object.toJSON(obj_ids)},onSuccess:function(transport){var json=transport.responseJSON,item,index,row_index,el;if(json.success&&json.data!==null){for(index in json.data){if(json.data.hasOwnProperty(index)){item=json.data[index];el=$$('tr[data-objectid="'+item.obj_id+'"]');if(el[0]){this.ndo_loaded.push(item.obj_id);row_index=(this.tools.page-1)*this.options.pageCount+parseInt(el[0].readAttribute('data-listindex'));el=el[0].down('.ndo_state');if(!el){continue;}
el=el.up().update(display_monitoring_state(item));this.data[row_index][this.options.ndo_state_field]=el.innerHTML;}}}
$(this.table.id).select('span.ndo_state.loading').invoke('addClassName','red').invoke('update','?');}else{$(this.table.id).select('span.ndo_state').invoke('addClassName','red').invoke('update',(json.message||''));}}.bind(this)});}},updateLivestatus:function(){if($(this.table.id).down('span.livestatus_state')){var obj_ids=$$('#'+this.table.id+' tr').invoke('readAttribute','data-objectid').compact();obj_ids=Array.prototype.without.apply(obj_ids,this.livestatus_loaded);new Ajax.Request(this.options.livestatus_state_url,{method:"post",parameters:{obj_ids:Object.toJSON(obj_ids)},onSuccess:function(transport){var json=transport.responseJSON,item,index,row_index,el;if(json.success&&json.data!==null){for(index in json.data){if(json.data.hasOwnProperty(index)){item=json.data[index];el=$$('tr[data-objectid="'+item.obj_id+'"]');if(el[0]){this.livestatus_loaded.push(item.obj_id);row_index=(this.tools.page-1)*this.options.pageCount+parseInt(el[0].readAttribute('data-listindex'));el=el[0].down('.livestatus_state');if(!el){continue;}
el=el.up().update(display_monitoring_state(item));this.data[row_index][this.options.livestatus_state_field]=el.innerHTML;}}}
$(this.table.id).select('span.livestatus_state.loading').invoke('addClassName','red').invoke('update','?');}else{$(this.table.id).select('span.livestatus_state').invoke('addClassName','red').invoke('update',(json.message||''));}}.bind(this)});}},createFilter:function(){var option='',objectlink_index;this.tableColumnsName.each(function(i){if(i!='__id__'){option+='\t<option value="'+i+'">'+i+'</option>\n';}});var inputFilter=new Element('input',{'id':this.table.id+'-filter-data',className:'input input-mini'});inputFilter.on('keydown',function(ev){if(ev.keyCode==Event.KEY_RETURN){ev.preventDefault();}});if(!this.options.ajax_pager){$(this.table.id+'-options').insert({bottom:this.msgs.filterLabel}).insert({bottom:'<select id="'+this.table.id+'-filter-column" class="input input-mini">'+option+'</select>'}).insert({bottom:inputFilter});}else{$(this.table.id+'-options').insert({bottom:this.msgs.filterLabel}).insert({bottom:'<select id="'+this.table.id+'-filter-column" disabled="disabled" class="input input-mini">'+option+'</select>'}).insert({bottom:new Element('input',{'id':this.table.id+'-filter-data',className:'input input-mini','disabled':'disabled'})});}
if(this.tableColumnsName.in_array(idoit.Translate.get('LC__UNIVERSAL__TITLE_LINK'))){objectlink_index=this.tableColumnsName.indexOf(idoit.Translate.get('LC__UNIVERSAL__TITLE_LINK'));if(this.tableColumnsName.in_array('__id__'))objectlink_index--;$(this.table.id+'-options').down('select').selectedIndex=objectlink_index;}
this.tools.filterCol=$F(this.table.id+'-filter-column');this.tools.filterData=$F(this.table.id+'-filter-data');},addTableObserver:function(){var tid=this.table.id,that=this;if(!this.options.ajax_pager){$(tid).select('th').invoke('observe','click',this.thClickbfx).invoke('observe','mouseover',this.thOverbfx).invoke('observe','mouseout',this.thOutbfx);}
$(tid).select('tr.data').invoke('observe','click',this.trClick.bindAsEventListener(this)).invoke('observe','mouseover',this.trOver.bindAsEventListener(this)).invoke('observe','mouseout',this.trOut.bindAsEventListener(this));if($('complete-list-selector')){$('complete-list-selector').observe('change',function(e){$(tid).select('tr input[name="id[]"]').each(function(es){es.checked=e.element().checked});that.options.checkedBoxes=[];if(e.target.checked){$(tid).select('tr.data').each(function(ele){that.options.checkedBoxes.push(parseInt(ele.down('.checkbox').value));});}});}
if(this.options.draggable){$(this.table.id).select('tr').each(function(el){if(el.hasClassName('no-drag')){return;}
new Draggable(el,{scroll:$('contentWrapper'),handle:el.down('span.drag-handle'),zindex:500,revert:true,onStart:function(){dragging=true;el.addClassName('draggable');if($('ghost')){$('ghost').remove();}
var ghost=new Element('table',{id:'ghost',className:that.options.classPrefix}).setStyle({position:'absolute',opacity:0.7,width:'50%',zIndex:1000}).update(el.clone(true).writeAttribute({id:'ghos-tr'}));$('body').insert(ghost);},onDrag:function(){if($('ghost')){$('ghost').setStyle({left:Position.xcomp+'px',top:Position.ycomp+'px'});}},onEnd:function(){dragging=false;el.removeClassName('draggable');if($('ghost')){$('ghost').remove();}}});});}},trClick:function(e){if(this.options.tr_click){var clicked_element=e.findElement(),clicked_tag=clicked_element.tagName,$tr=clicked_element.up('tr');if(clicked_tag!='A'&&clicked_tag!='INPUT'&&!clicked_element.hasClassName('drag-handle')){if($tr&&window.list_vars&&'tree_view'in window.list_vars){this.objectLink($tr.readAttribute('data-objectid'),window.list_vars.tree_view,window.list_vars.view_mode,'');}}}},thClick:function(e){if(e.element().hasClassName('no-sort')){return;}
this.defineOrderField(e);this.defineOrder();this.orderData(this.orderField);if(this.order=='desc'){this.cache=this.cache.reverse();}
this.updateTable();},removeDataItem:function(obj_id){var tmp_data=[];this.data.each(function(i){var arr=Object.values(i);if(arr[0]!=obj_id){tmp_data.push(i);}}.bind(this));this.data=tmp_data;this.clearCache();},objectLink:function(obj_id,treeview,view_mode,category_id){get_tree_by_object(obj_id,treeview);get_content_by_object(obj_id,view_mode,category_id);},createRows:function(){var line=1;var display,enddisplay,startdisplay,dataView,dat,col,searchStr,row,s;this.table.insert({top:this.createFirstRow()});dataView=this.cache;if(this.options.filter&&!this.isCached&&this.tools.filterData!==''){col=this.tools.filterCol;dat=this.tools.filterData;dataView=this.cache.inject([],function(array,rec){if(rec[col]){recTest=rec[col].toString().replace(/&nbsp;/gi,'');if((recTest.toUpperCase().include(dat.toUpperCase())||recTest.toUpperCase().include(dat.encodeHTML().toUpperCase()))){array.push(rec);}}
return array;});}
if(this.options.search&&!this.isCached&&this.tools.searchData!==''){dat=this.tools.searchData.toUpperCase();dataView=dataView.inject([],function(array,value){searchStr=Object.values(value).inject('',function(acc,n){return acc+" "+n;});if(searchStr.toUpperCase().include(dat)){array.push(value);}
return array;});}
display=dataView;if(this.options.paginate){this.tools.pages=Math.ceil(dataView.size()/ this.options.pageCount);if(this.tools.filterData.blank()&&this.options.max_pages>0){this.tools.pages=this.options.max_pages;}
if(this.tools.page>this.tools.pages){this.tools.page=this.tools.pages;}
if(this.tools.page<1){this.tools.page=1;}
if(this.tools.pages===0){this.tools.page=0;}
$(this.table.id+'-page-current').setValue(this.tools.page);$(this.table.id+'-page-total').update(this.tools.pages);startdisplay=this.options.pageCount*(this.tools.page-1);enddisplay=this.options.pageCount*this.tools.page;display=dataView.slice(startdisplay,enddisplay);}
display.each(function(i,index){this.table.insert({bottom:this.createRow(i,index)});line=(line==1)?2:1;if(this.options.checkboxes){$(this.table.id).select('input:last')[0].observe("change",function(e){this.checkListener(e);}.bind(this));}}.bind(this));if(display.size()===0){s=this.tableColumnsName.size();row='<tr class="data line0" id="'+this.table.id+'-0">\n';if(this.options.ajax_pager){if(typeof window.list_vars==='undefined'){window.list_vars={'image_dir':'images/'};}
row+='\t<td class="'+this.table.id+'-column" colspan="'+s+'"><img src="'+window.list_vars.image_dir+'ajax-loading.gif" class="vam" /> '+this.msgs.loading+'</td>\n';}else{row+='\t<td class="'+this.table.id+'-column" colspan="'+s+'">'+this.msgs.emptyResults+'</td>\n';}
row+='\n</tr>';this.table.insert({bottom:row});}
if(this.orderField){$(this.table.id+'-'+this.orderField).addClassName(this.order);}
if(!this.isCached){this.isCached=true;this.cache=dataView;}},checkListener:function(e){if(e.target.checked&&this.options.checkedBoxes.indexOf(parseInt(e.target.value))==-1){this.options.checkedBoxes.push(parseInt(e.target.value));}else{this.options.checkedBoxes.splice(this.options.checkedBoxes.indexOf(parseInt(e.target.value)),1);}},filterData:function(e){var tid=this.table.id;if($(tid)){if(e.keyCode==Event.KEY_LEFT||e.keyCode==Event.KEY_RIGHT){var l_element=(e.keyCode==Event.KEY_LEFT)?$(this.table.id+'-page-previous'):$(this.table.id+'-page-next');if(e.ctrlKey){this.pagerData(null,l_element);}
return false;}
if(e.keyCode==Event.KEY_RETURN||e.keyCode==Event.KEY_DOWN||e.keyCode==Event.KEY_UP){var l_selected=$(tid).select('tr.highlightLine');if(e.keyCode==Event.KEY_RETURN&&l_selected.length){if(l_selected[0]){if(window.list_vars&&'tree_view'in window.list_vars){this.objectLink(l_selected[0].readAttribute('data-objectid'),window.list_vars.tree_view,window.list_vars.view_mode,'');}
e.stop();}
return false;}
else{if(!l_selected.length){$(tid).select('tr.data')[0].addClassName('highlightLine');}
else{var data=false;l_selected[0].removeClassName('highlightLine');if(e.keyCode==Event.KEY_DOWN){data=l_selected[0].next('tr.data');}
else if(e.keyCode==Event.KEY_UP){data=l_selected[0].previous('tr.data');}
if(data){data.addClassName('highlightLine');}}}
return false;}}
delay(function(e){var caller=Event.element(e);this.tools.filterData=$F(tid+'-filter-data');this.tools.filterCol=$F(tid+'-filter-column');if(caller.id==tid+'-filter-column'&&this.tools.filterData.blank()){return;}
this.clearCache();if(this.options.paginate){this.tools.page=1;this.updateTable();return;}
$(tid).select('td.'+tid+'-column-'+this.tools.filterCol).each(function(i){var str=i.innerHTML.toUpperCase(),search=this.tools.filterData;if(!str.include(search.toUpperCase())&&!str.include(search.encodeHTML().toUpperCase())){i.ancestors()[1].hide();}else{i.ancestors()[1].show();}});}.bind(this,e),250);},orderRule:function(s){if(typeof(s)!='number'){var dateRE=/^(\d{2})[\/\-\. ](\d{2})[\/\-\. ](\d{4}|\d{2})/;var exp=new RegExp(dateRE);if(exp.test(s)){s=this.options.dateFormat=='d'?s.replace(dateRE,"$3$2$1"):s.replace(dateRE,"$3$1$2");}else{var ipRE=new RegExp(/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/g);if(ipRE.test(s)){s=IPv4.ip2long(s);}
else{var htmlRE=/<a[^>]*>(.*?)<\/a>/i;var matches=htmlRE.exec(s);if(matches!=null&&matches.length>1){return matches[1].toLowerCase();}}}}
return s;},overwriteIDs:function(){var l_length=this.options.checkedBoxes.length,l_selectorContainer=null,l_hiddenFields="";while(l_length--){l_selectorContainer=$$('input[type="checkbox"][value="'+this.options.checkedBoxes[l_length]+'"]');if(l_selectorContainer.length){l_selectorContainer[0].checked=false;}
l_hiddenFields+="<input type='hidden' name='id[]' value='"+this.options.checkedBoxes[l_length]+"' />";}
$('data-grid-'+object_list.element).select('input:checked').each(function(s){s.checked=false;});this.options.checkedBoxes=[];return l_hiddenFields;}});TableOrderer.prototype.addTableObserver=function(){var that=this,tid=this.table.id;this.table.select('th').invoke('observe','click',this.thClickbfx).invoke('observe','mouseover',this.thOverbfx).invoke('observe','mouseout',this.thOutbfx);this.table.select('tr.data').invoke('observe','click',this.trClick.bindAsEventListener(this)).invoke('observe','mouseover',this.trOver.bindAsEventListener(this)).invoke('observe','mouseout',this.trOut.bindAsEventListener(this));if($(tid+'-add_all')){$(tid+'-add_all').on('click',function(ev){ev.stopPropagation();ev.preventDefault();that.addAll();});}
if($(tid+'-add_page')){$(tid+'-add_page').on('click',function(ev){ev.stopPropagation();ev.preventDefault();that.addPage();});}};TableOrderer.prototype.addAll=function(){var i,data=this.cache||this.data;if(data){for(i in data){if(data.hasOwnProperty(i)&&data[i].hasOwnProperty('__checkbox__')){browserPreselection.select(data[i].__checkbox__);}}
this.updateTable();}};TableOrderer.prototype.addPage=function(){var $buttons=this.table.select('button[onclick*="browserPreselection.select"]');if($buttons.length){$buttons.invoke('simulate','click');}
this.updateTable();};TableOrderer.prototype.orderRule=function(s){var dateRE=/^(\d{2})[\/\.\- ](\d{2})[\/\.\- ](\d{4}|\d{2})/;var exp=new RegExp(dateRE);if(exp.test(s)){s=this.options.dateFormat=='d'?s.replace(dateRE,"$3$2$1"):s.replace(dateRE,"$3$1$2");}
return s;};TableOrderer.prototype.createPager=function(){if($(this.table.id+'-pager'))$(this.table.id+'-pager');$(this.table.id+'-pager').insert({bottom:new Element('a',{'id':this.table.id+'-page-first','class':'btn btn-small first-page-button mouse-pointer',style:'padding:2px 5px;'}).update(this.msgs.paginationFirst)}).insert({bottom:new Element('a',{'id':this.table.id+'-page-prev','class':'btn btn-small prev-page-button mouse-pointer',style:'padding:2px 5px;'}).update(this.msgs.paginationPrev)}).insert({bottom:'<span id="'+this.table.id+'-page-current'+'" class="currentpage">'+this.tools.page+'</span>'}).insert({bottom:new Element('a',{'id':this.table.id+'-page-next','class':'btn btn-small next-page-button mouse-pointer',style:'padding:2px 5px;'}).update(this.msgs.paginationNext)}).insert({bottom:new Element('a',{'id':this.table.id+'-page-last','class':'btn btn-small last-page-button mouse-pointer',style:'padding:2px 5px;'}).update(this.msgs.paginationLast)}).insert({bottom:this.msgs.paginationOf+' <span id="'+this.table.id+'-page-total'+'" class="totalpages">'+this.tools.pages+'</span> '+this.msgs.paginationPages});};TableOrderer.prototype.trClick=function(e){};TableOrderer.prototype.createFirstRow=function(obj){var row='<thead><tr>';this.tableColumnsName.each(function(i){if(i=='__checkbox__'){var all_button='';if(this.options.multiselection&&!this.options.secondSelection&&!this.options.secondSelectionExists){all_button='<a href="#" id="'+this.table.id+'-add_all" class="btn btn-small mr5" title="'+idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__ADD_ALL_BY_FILTER')+'">'+'<img src="'+window.dir_images+'icons/silk/add.png" style="margin-right:3px;" /><span>'+idoit.Translate.get('LC__UNIVERSAL__ALL')+'</span>'+'</a>'+'<a href="#" id="'+this.table.id+'-add_page" class="btn btn-small" title="'+idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__ADD_ALL_ON_PAGE')+'">'+'<img src="'+window.dir_images+'icons/silk/add.png" style="margin-right:3px;" /><span>'+idoit.Translate.get('LC__UNIVERSAL__PAGE')+'</span>'+'</a>';}
row+='<th id="'+this.table.id+'-id" style="width:80px; text-align:center;">'+all_button+'</th>';}else{row+='<th id="'+this.table.id+'-'+i+'">'+i+'</th>';}}.bind(this));row+='</tr></thead>';return row;};TableOrderer.prototype.updateTable=function(){this.table=$('data-grid-'+this.element);$(this.table.id).update();this.createRows();this.addTableObserver();this.makeUnsort();if(this.options.colgroup)this.table.insert({top:this.options.colgroup});};TableOrderer.prototype.radioButton=function(values,checked){return'<input type="radio" name="listSelection" '+(checked?'checked="checked" ':' ')+'onclick="'+this.options.objectSelectionCallback+'('+parseInt(values[0])+');" />';};TableOrderer.prototype.addButton=function(values,view){if((this.options.multiselection&&!this.options.secondSelectionExists)||(this.options.multiselection&&this.options.secondSelectionExists&&view==='r')){var func_string="browserPreselection.select("+parseInt(values[0])+");"+"this.up().update(window.browserList.removeButton("+parseInt(values[0])+", '"+view+"'));";return new Element('button',{type:'button',className:'btn btn-small btn-block',onClick:func_string}).update(new Element('img',{src:window.dir_images+'icons/silk/add.png',style:'margin-right:3px;'})).insert(new Element('span').update(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT__ADD')));}else{return this.radioButton(values,false);}};TableOrderer.prototype.removeButton=function(id,view){if((this.options.multiselection&&!this.options.secondSelectionExists)||(this.options.multiselection&&this.options.secondSelectionExists&&view==='r')){var func_string="browserPreselection.remove("+parseInt(id)+");"+"if (this.up()) {this.up().update(window.browserList.addButton("+parseInt(id)+", '"+view+"'));}";return new Element('button',{type:'button',className:'btn btn-small btn-block',onclick:func_string}).update(new Element('img',{src:window.dir_images+'icons/silk/delete.png',style:'margin-right:3px'})).insert(new Element('span').update(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT__REMOVE')));}
else{return this.radioButton(id,true);}};TableOrderer.prototype.createRow=function(obj,index){var values=Object.values(obj),tmpClassName,tmpContent;var tr=new Element('tr',{'class':'data line'+(index%2),id:this.table.id+'-'+index}).writeAttribute('data-objectid',values[0]);this.tableColumnsName.each(function(s,index){if(s=='__checkbox__'){if(!browserPreselection.exists(values[0])){tmpContent=this.addButton(values,'l');}else{tmpContent=this.removeButton(values,'l');}
tmpClassName=this.table.id+'-column-checkbox center';}else{tmpContent=values[index];if(index===1){tmpContent+='<span id="obj-browser-quickinfo-'+values[0]+'" class="fr quickinfo" data-obj-id="'+values[0]+'"><img src="'+window.dir_images+'icons/infoicon/info.png" class="vam" /></span>';}
tmpClassName=this.table.id+'-column-'+s;}
tr.insert(new Element('td',{className:tmpClassName}).update(tmpContent));$$('.browserContent table tr td span.quickinfo').each(function(element){var obj_id=element.readAttribute('data-obj-id');new Tip('obj-browser-quickinfo-'+obj_id,'',{"ajax":{"url":'?ajax=1&call=quick_info&objID='+obj_id},"delay":0,"style":'default',"effect":'appear',"className":'objectinfo'});});}.bind(this));if(Prototype.Browser.IE&&tr.outerHTML)return tr.outerHTML;else return tr;};TableOrderer.prototype.createFilter=function(){var option='';this.tableColumnsName.each(function(i){if(i!='__checkbox__'){option+='\t<option value="'+i+'">'+i.replace(/(_)/g,' ')+'</option>\n';}});$(this.table.id+'-options').insert({bottom:this.msgs.filterLabel}).insert({bottom:'<select id="'+this.table.id+'-filter-column" class="input input-mini">'+option+'</select>'}).insert({bottom:new Element('input',{id:this.table.id+'-filter-data',className:'input input-mini'})});this.tools.filterCol=$F(this.table.id+'-filter-column');this.tools.filterData=$F(this.table.id+'-filter-data');};TableOrderer.prototype.thClick=function(e){if((this.table.id+'-id')==(e.element().id)){return;}
this.defineOrderField(e);this.defineOrder();this.orderData(this.orderField);if(this.order=='desc'){this.cache=this.cache.reverse();}
this.updateTable();};if(!Browser)var Browser={};Browser.objectList=Class.create(TableOrderer,{parameters:{form:'browser',minLen:2},searchString:'',initialize:function(element,params){this.element=element;this.defaultSelection=new Hash({isys_obj__id:'__checkbox__',isys_obj__title:idoit.Translate.get('LC__CMDB__LOGBOOK__TITLE'),isys_obj_type__title:idoit.Translate.get('LC__CMDB__CATG__TYPE'),isys_obj__sysid:idoit.Translate.get('LC__CMDB__CATG__SYSID')});Object.extend(this.parameters,params||{cmdb_filter:'',browserFilter:{},urlBase:'/',returnElement:'',objectBrowserName:''});if(!this.parameters.jsonClient){this.parameters.jsonClient=new idoit.JSONClient();}
this.options=Object.extend({data:[],url:false,allowMultiselect:false,unsortedColumn:[],dateFormat:'d',filter:'top',pageCount:25,paginate:'top',search:false,objectSelectionCallback:'browserPreselection.select',firstSelection:false,secondSelection:false,secondSelectionExists:false,classPrefix:'prototools',instanceName:'objectList',useAuth:false,quickinfo:{active:true,delay:0.5}},this.parameters.listOptions||{});this.tools={page:1,pages:1,filterCol:'',filterData:'',searchData:''};this.msgs={loading:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__LOADING'),emptyResults:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__EMPTY_RESULTS'),errorURL:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__ERROR_URL'),errorData:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__ERROR_DATA'),searchLabel:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__SEARCH_LABEL'),filterLabel:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__FILTER_LABEL'),paginationOf:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__PAGINATEN_OF'),paginationPages:idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__PAGINATEN_PAGES'),paginationFirst:'&laquo;',paginationPrev:'&lsaquo;',paginationNext:'&rsaquo;',paginationLast:'&raquo;',minLen:'Bitte mehr als {0} Zeichen eingeben.'};this.cache=[];this.isCached=false;this.container=$(this.element);this.orderField=false;this.order='asc';this.thClickbfx=this.thClick.bindAsEventListener(this);this.thOverbfx=this.thOver.bindAsEventListener(this);this.thOutbfx=this.thOut.bindAsEventListener(this);if(this.options.useAuth){this.parameters.jsonClient.useAuth(this.options.useAuth);}},performDataMatch:function(header,data){var i,j,object,result=[],replaceTablePlaceholders=new ReplacePlaceholders({linkObjects:false});for(i in data){if(!data.hasOwnProperty(i)){continue;}
object={};for(j in data[i]){if(!data[i].hasOwnProperty(j)){continue;}
if(Object.isString(data[i][j])){data[i][j]=replaceTablePlaceholders.replacePlaceholders(data[i][j]||"");}
object[header[j]]=data[i][j];}
result.push(object);}
return result;},performRequest:function(url){if($('portList')){$('portList').update('');}
$(this.element).update(new Element('p',{className:'emptyPageMessage text-lightgrey'}).update(idoit.Translate.get('LC__UNIVERSAL__LOADING')));new Ajax.Request(this.parameters.urlBase+url,{parameters:{filter:JSON.stringify(this.parameters.browserFilter),output:'objects',key:(this.parameters.objectBrowserName||this.parameters.returnElement.replace(/__HIDDEN$/,''))},onComplete:function(xhr){var json=xhr.responseJSON;if(json.success){this.data=this.performDataMatch(json.data.header,json.data.data);if(this.data&&this.data.length>0){this.perform();if(this.options.colgroup){this.table.insert({top:this.options.colgroup});}}else{this.showError(this.msgs.emptyResults);}}else{this.showError(json.message||xhr.responseText);}}.bind(this)});},searchByType:function(objectTypeID){this.performRequest('cmdb/browse/objectType/'+objectTypeID);},searchByGroup:function(objID){this.performRequest('cmdb/browse/objectGroup/'+objID);},searchByPersonGroup:function(objID){this.performRequest('cmdb/browse/personGroup/'+objID);},searchByRelationType:function(relationType){this.performRequest('cmdb/browse/relationType/'+relationType);},searchByTimeCondition:function(condition){this.performRequest('cmdb/browse/date/'+condition);},searchByCategoryFilter:function(p_request,p_callFunction){if($('portList')){$('portList').update('');}
this.parameters.jsonClient.getObjectsByCustomBrowserRequest(new Hash({request:p_request,callFunction:p_callFunction}),this.initList.bind(this),{select:this.defaultSelection});},search:function($searchField){var searchString;if(!$searchField){return;}
searchString=$searchField.getValue();if(searchString.length>this.parameters.minLen){if(this.searchString===searchString){return;}
this.searchString=searchString;this.performRequest('cmdb/browse/search/'+encodeURIComponent(encodeURIComponent(this.searchString)));}else{this.showError(this.msgs.minLen.replace('{0}',this.parameters.minLen));}},showError:function(message){$(this.element).update(new Element('p',{className:'emptyPageMessage text-lightgrey'}).update(new Element('img',{src:window.dir_images+'outlet.png'})).insert(' '+message));},initList:function(r){if(r.responseJSON){this.data=r.responseJSON;if(this.data&&this.data.length>0){this.perform();if(this.options.colgroup){this.table.insert({top:this.options.colgroup});}}else{this.showError(this.msgs.emptyResults);}}}});Browser.preselection=Class.create({selectedObjects:[],options:{preselection:[],ajaxURL:'',afterRemove:Prototype.emptyFunction,afterFinish:Prototype.emptyFunction,instanceName:'preselection',urlBase:'',multiselection:false,$selectionCounter:null},initialize:function(element,options){this.$element=$(element);this.secondElement=('secondElement'in options)?$(options.secondElement):false;this.secondList=('secondList'in options)?options.secondList:false;Object.extend(this.options,options||{});this.options.$selectionCounter=$(this.options.$selectionCounter);},setSelection:function(selection){if(!Object.isArray(selection)){selection=[selection];}
if(!this.options.multiselection){selection=selection.slice(0,1);}
this.selectedObjects=selection.map(function(id){return parseInt(id);});this.updateCounter();this.renderTable();if(this.selectedObjects.length){this.log(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT__PRESELECTED_OBJECTS').replace('{0}',this.selectedObjects.length));}
return this;},getSelection:function(){return this.selectedObjects;},isMultiselection:function(){return!!this.options.multiselection;},select:function(id){id=parseInt(id);if(this.options.multiselection&&!this.exists(id)){this.selectedObjects.push(id);this.log(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__OBJECT_HAS_BEEN_ADDED').replace('{0}','#'+id));}else{this.selectedObjects=[id];this.log(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__OBJECT_SELECTED').replace('{0}','#'+id));}
this.updateCounter();delay(this.renderTable.bind(this),1000);return this;},exists:function(id){return this.selectedObjects.in_array(parseInt(id));},remove:function(id){var $row=this.$element.down('[data-id="'+id+'"]');this.selectedObjects=this.selectedObjects.without(parseInt(id));this.updateCounter();if(this.selectedObjects.length===0){this.renderTable();}else if($row){$row.remove();}
this.options.afterRemove();},remove_all:function(){this.selectedObjects=[];this.updateCounter();this.renderTable();this.options.afterRemove();},renderTable:function(){if(!(this.options.multiselection&&this.getSelection().length||!this.options.multiselection&&this.getSelection()>0)){this.log(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT__NO_PRESELECTION'));this.$element.update(new Element('p',{className:'box-blue p5 m5'}).update(new Element('img',{src:window.dir_images+'icons/silk/information.png',className:'mr5 vam'})).insert(new Element('span').update(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT__NO_PRESELECTION'))));if(this.options.afterFinish){this.options.afterFinish(this);}
return;}
this.$element.update(new Element('p',{className:'p5 m5 box-blue'}).update(new Element('img',{src:window.dir_images+'ajax-loading.gif',className:'mr5 vam'})).insert(new Element('span').update(idoit.Translate.get('LC__UNIVERSAL__LOADING'))));new Ajax.Request(this.options.urlBase+'cmdb/browse/get-'+(!this.options.secondListPreselectionCallback||this.options.secondListPreselectionCallback.empty()?'object':'selection')+'-data',{parameters:{objects:JSON.stringify(this.getSelection()),key:this.options.returnElement.replace(/__HIDDEN$/,''),secondListPreselectionCallback:this.options.secondListPreselectionCallback},onComplete:function(xhr){var json=xhr.responseJSON,$table=new Element('table',{className:'mainTable'}),$colgroup=new Element('colgroup').update(new Element('col',{style:'width:110px;'})).insert(new Element('col')),$thead=new Element('thead'),$tbody=new Element('tbody'),$tr=new Element('tr'),replaceTablePlaceholders=new ReplacePlaceholders({linkObjects:false}),$removeButton='',i,j;if(this.options.multiselection){$removeButton=new Element('button',{type:'button',id:'remove_all',className:'btn btn-small btn-block',onClick:'browserPreselection.remove_all();'}).update(new Element('img',{src:window.dir_images+'icons/silk/delete.png',style:'margin-right:3px;'})).insert(new Element('span').update(idoit.Translate.get('LC__UNIVERSAL__ALL')));}
for(i in json.data.header){if(!json.data.header.hasOwnProperty(i)){continue;}
if(i==='0'){$tr.update(new Element('th').update($removeButton));}else{$tr.insert(new Element('th').update(json.data.header[i]));}}
$thead.update($tr);for(i in json.data.data){if(!json.data.data.hasOwnProperty(i)){continue;}
$tr=new Element('tr',{'data-id':json.data.data[i][0]});for(j in json.data.data[i]){if(!json.data.data[i].hasOwnProperty(j)){continue;}
if(j==='0'){var onclick="browserPreselection.remove("+parseInt(json.data.data[i][j])+");";$tr.update(new Element('td').update(new Element('button',{className:'btn btn-small btn-block',type:'button',onclick:onclick}).update(new Element('img',{src:window.dir_images+'icons/silk/delete.png',style:'margin-right:3px'})).insert(new Element('span').update(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT__REMOVE')))));}else{$tr.insert(new Element('td').update(replaceTablePlaceholders.replacePlaceholders(json.data.data[i][j]||"")));}}
$tbody.insert($tr);}
$table.update($colgroup).insert($thead).insert($tbody);this.$element.update($table);if(this.options.afterFinish){this.options.afterFinish(this);}}.bind(this)});},updateCounter:function(){if(Object.isElement(this.options.$selectionCounter)){this.options.$selectionCounter.update(this.selectedObjects.length)}},log:function(string){if(this.options.latestLogElement){$(this.options.latestLogElement).update(string);}},getObjectMetaData:function(objId,callback){new Ajax.Request('?ajax=1&call=get_category_data&func=get_data',{parameters:{objID:objId,catgID:'C__CATG__GLOBAL'},onComplete:function(xhr){callback(xhr.responseJSON[0]);}});},getData:function(){return JSON.stringify(this.getSelection());},secondSelectionCall:function(id){this.secondElement.update(new Element('p',{className:'emptyPageMessage text-lightgrey'}).update(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__LOADING')));idoitJSON.call(this.options.ajaxURL+'&objID='+id,function(json){if(this.secondList){this.secondElement.update('');this.secondList.initList(json);}}.bind(this),{select:new Hash({isys_obj__id:'__checkbox__',isys_obj__port:idoit.Translate.get('LC__CMDB__CATG__CONNECTORS'),isys_obj__connected_with:idoit.Translate.get('LC__CMDB__CATG__UI_ASSIGNED_UI'),isys_obj__category:idoit.Translate.get('LC__CMDB__CATG__CATEGORY'),isys_obj__in_out:idoit.Translate.get('LC__CMDB__CATS__PRT_TYPE')})});},add:function(object,fromButton){this.select(object[0]);}});function vwa_autocalc($volt,$watt,$ampere){var vals={volt:$volt.getValue().toNumber(),watt:$watt.getValue().toNumber(),ampere:$ampere.getValue().toNumber()};if(vals.volt===0&&vals.watt!==0&&vals.ampere!==0){$volt.setValue((vals.watt / vals.ampere).roundWithDecimals(2));}
if(vals.volt!==0&&vals.watt===0&&vals.ampere!==0){$watt.setValue((vals.volt*vals.ampere).roundWithDecimals(2));}
if(vals.volt!==0&&vals.watt!==0&&vals.ampere===0){$ampere.setValue((vals.watt / vals.volt).roundWithDecimals(2));}}
Placeholder={counter_regex:/##COUNT(:-?\d+)?(:\d+)?##/g,iteration:0,process_counter_string:function(string,iteration){if(!this.counter_regex.test(string)){return string;}
if(!iteration){iteration=this.iteration++;}
iteration=parseInt(iteration);return string.replace(this.counter_regex,function(match,start,zeroes){var result,minus;if(!start){start=0;}else{start=parseInt(start.substr(1));}
result=iteration+start;minus=(result<0);if(zeroes){if(minus){result=Math.abs(result);}
zeroes=parseInt(zeroes.substr(1))+1;if(zeroes>(result+'').length){zeroes='0'.repeat(zeroes);result=(zeroes+result).slice(-zeroes.length);}
if(minus){result='-'+result;}}
return result;});}};var BrowserSelectionSorter=Class.create({initialize:function(element,options){if($(element+'_SELECTION_SORTER')){this.destruct(element);return null;}
this.element=$(element);this.hidden_element=this.element.next('input[type="hidden"]');if(options.hasOwnProperty('hidden')){this.hidden_element=$(options.hidden);}
this.options=Object.extend({values:[],ajax_url:'?ajax=1&call=json&action=load_object_data'},options||{});this.positions=this.element.positionedOffset();this.positions.height=this.element.getHeight();this.positions.width=this.element.getWidth();this.element.insert({after:new Element('div',{id:element+'_SELECTION_SORTER',className:'browser-selection-sorter border'}).setStyle({position:'absolute',left:this.positions.left+'px',top:(this.positions.top+this.positions.height-1)+'px',width:(this.positions.width-2)+'px',display:'none'})});this.sorting_div=this.element.next('#'+element+'_SELECTION_SORTER');this.load_selection();},load_selection:function(){new Ajax.Request(this.options.ajax_url,{parameters:{objects:this.options.values},method:'post',onSuccess:function(transport){var json=transport.responseJSON,objects=[],object;if(json.success){for(i in json.data){if(json.data.hasOwnProperty(i)){object=json.data[i];objects.push(new Element('li',{'data-obj-id':object.id}).update(new Element('span',{className:'handle mr5'}).update('&nbsp;&nbsp;&nbsp;')).insert(new Element('span').update(object.title+' ('+object.type_title+')')).outerHTML);}}
this.sorting_div.update(new Element('ul',{id:this.element.id+'_SELECTION_SORTABLE'}).update(objects.join(''))).insert(new Element('div',{className:'controls'}).update(new Element('button',{className:'btn btn-small m5 accept',type:'button'}).update(new Element('img',{src:window.dir_images+'icons/silk/tick.png'})).insert(' ').insert(new Element('span').update(idoit.Translate.get('LC_UNIVERSAL__ACCEPT')))).insert(new Element('button',{className:'btn btn-small m5 abort',type:'button'}).update(new Element('img',{src:window.dir_images+'icons/silk/cross.png'})).insert(' ').insert(new Element('span').update(idoit.Translate.get('LC_UNIVERSAL__ABORT')))));}else{this.sorting_div.update(new Element('div',{className:'p5 m5 box-red'}).update(json.message));}
Effect.BlindDown(this.sorting_div,{duration:0.4});this.set_observer();}.bind(this)});},set_observer:function(){Sortable.destroy(this.element.id+'_SELECTION_SORTABLE');Sortable.create(this.element.id+'_SELECTION_SORTABLE',{handle:'handle'});this.sorting_div.down('button.accept').on('click',function(){var view=[],hidden=[];this.sorting_div.select('li').each(function(el){view.push(el.down('span',1).innerHTML);hidden.push(parseInt(el.readAttribute('data-obj-id')));}.bind(this));this.element.setValue(view.join(', '));this.hidden_element.setValue(Object.toJSON(hidden));this.destruct(this.element.id);}.bind(this));this.sorting_div.down('button.abort').on('click',function(){this.destruct(this.element.id);}.bind(this));return this;},destruct:function(element){Effect.BlindUp(element+'_SELECTION_SORTER',{duration:0.4,afterFinish:function(){$(element+'_SELECTION_SORTER').remove();}});return this;}});window.Validation=Class.create({$label:null,$field:null,initialize:function($field,options){this.$field=$field;this.options={images_path:'images/',mandatory:false,unique_global:false,unique_obj_type:false,unique_obj:false};Object.extend(this.options,options||{});this.find_elements();},find_elements:function(){var id=this.$field,$label=$$('label[for="'+id+'"]');if($label.length>0){this.$label=$label[0];}},fail:function(message){new Tip(this.$field,new Element('p',{className:'p5',style:'font-size:12px;'}).update(message),{fixed:true,hook:{target:'topLeft',tip:'bottomLeft'},stem:false,offset:{x:1,y:-2},showOn:'mouseenter',hideOn:'mouseleave',effect:'appear',style:'darkgrey'});this.$field.addClassName('input-error').prototip.show();},success:function(){isys_glob_enable_save();Tips.remove(this.$field.removeClassName('input-error'));}});if(!Number.hasOwnProperty('roundWithDecimals')){Number.prototype.roundWithDecimals=function(decimals){return Number((Math.round(this+"e"+decimals)+"e-"+decimals));};}
window.Rack=Class.create({initialize:function($element,options){this.$element=$element;this.options=options;this.options=Object.extend({edit_right:true,objects:[],room_view:false,slots:24,verticalSlots:0,verticalSlotsMirrored:0,verticalSlotSorting:1,view:'front',slot_sort:'asc',object_link:false,objectReassign:false,objectReassignCallback:Prototype.emptyFunction,object_remove:false,objectRemoveCallback:Prototype.emptyFunction,slot_segment:false,slotSegmentCallback:Prototype.emptyFunction,slotDetach:false,slotDetachCallback:Prototype.emptyFunction,detailView:false,quickinfoCallback:Prototype.emptyFunction,OPTION_VERTICAL:4,OPTION_HORIZONTAL:3,INSERTION_FRONT:1,INSERTION_REAR:0,INSERTION_BOTH:2},options||{});this.create_rack();this.setObserver();},select:function(horizontal,from,to){var i;if(horizontal){if(this.options.slot_sort=='asc'){if(from>to){i=to;to=from;from=i;}
for(i=from;i<=to;i++){this.$element.down('.slot-'+i).addClassName('selected');}}
else{if(from<to){i=to;to=from;from=i;}
for(i=from;i>=to;i--){this.$element.down('.slot-'+i).addClassName('selected');}}}
else{this.$element.select('.left-slots .slot,.right-slots .slot').each(function($slot){if($slot.readAttribute('data-slot')==from){$slot.addClassName('selected');}});}},unselect:function(){this.$element.select('.selected').invoke('removeClassName','selected');},setObserver:function(){this.$element.on('click','.slot-options',this.slot_option.bindAsEventListener(this));},create_rack:function(){var left_slots='left-slots',right_slots='right-slots',spacing=0,table_class='';if(this.options.view=='rear'&&this.options.verticalSlotsMirrored){left_slots='right-slots';right_slots='left-slots';}
if(this.options.room_view){table_class='room-view';}
this.$element.update(new Element('table',{cellPadding:0,cellSpacing:0,width:'100%',className:table_class}).update(new Element('tbody').update(new Element('tr').update(new Element('td',{className:left_slots})).insert(new Element('td',{className:'main-slots'}).update(new Element('table',{cellPadding:0,cellSpacing:spacing}))).insert(new Element('td',{className:right_slots})))));this.createVerticalSlots().create_slots().createQuickinfos();this.updateChassisSizes();return this;},createQuickinfos:function(){var $rackObjects=this.$element.select('.object-title'),$segmentObjects=this.$element.select('.chassis .device[data-object-id]'),$link,i;for(i in $rackObjects){if(!$rackObjects.hasOwnProperty(i)){continue;}
this.options.quickinfoCallback($rackObjects[i],$rackObjects[i].up('[data-object-id]').readAttribute('data-object-id'));}
for(i in $segmentObjects){if(!$segmentObjects.hasOwnProperty(i)){continue;}
$link=new Element('a',{target:'_blank',href:'?objID='+$segmentObjects[i].readAttribute('data-object-id')}).update($segmentObjects[i].textContent||$segmentObjects[i].innerText||$segmentObjects[i].innerHTML);this.options.quickinfoCallback($segmentObjects[i].update($link),$segmentObjects[i].readAttribute('data-object-id'));}},createVerticalSlots:function(num){var fl='fl',fr='fr',sorting;switch(this.options.verticalSlotSorting){default:case 1:sorting=(this.options.slot_sort=='asc'?[1,7,3,9,5,11,2,8,4,10,6,12]:[5,11,3,9,1,7,6,12,4,10,2,8]);break;case 2:sorting=(this.options.slot_sort=='asc'?[1,2,5,6,9,10,4,3,8,7,12,11]:[9,10,5,6,1,2,12,11,8,7,4,3]);break;case 3:sorting=(this.options.slot_sort=='asc'?[1,2,3,4,5,6,7,8,9,10,11,12]:[5,6,3,4,1,2,11,12,9,10,7,8]);break;}
if(this.options.view=='rear'&&this.options.verticalSlotsMirrored){fl='fr';fr='fl';}
this.$element.down('.left-slots').update(new Element('div',{className:'slot '+fl,'data-slot':sorting[0],'data-vertical':1})).insert(new Element('div',{className:'slot '+fl,'data-slot':sorting[1],'data-vertical':1})).insert(new Element('br',{className:'clear'})).insert(new Element('div',{className:'slot '+fl,'data-slot':sorting[2],'data-vertical':1})).insert(new Element('div',{className:'slot '+fl,'data-slot':sorting[3],'data-vertical':1})).insert(new Element('br',{className:'clear'})).insert(new Element('div',{className:'slot last '+fl,'data-slot':sorting[4],'data-vertical':1})).insert(new Element('div',{className:'slot last '+fl,'data-slot':sorting[5],'data-vertical':1}));this.$element.down('.right-slots').update(new Element('div',{className:'slot '+fr,'data-slot':sorting[6],'data-vertical':1})).insert(new Element('div',{className:'slot '+fr,'data-slot':sorting[7],'data-vertical':1})).insert(new Element('br',{className:'clear'})).insert(new Element('div',{className:'slot '+fr,'data-slot':sorting[8],'data-vertical':1})).insert(new Element('div',{className:'slot '+fr,'data-slot':sorting[9],'data-vertical':1})).insert(new Element('br',{className:'clear'})).insert(new Element('div',{className:'slot last '+fr,'data-slot':sorting[10],'data-vertical':1})).insert(new Element('div',{className:'slot last '+fr,'data-slot':sorting[11],'data-vertical':1}));return this.updateVerticalSlots(num);},create_slots:function(){var i,cnt,num,$tbody=new Element('tbody'),object,rowspan=0,display_obj,className,last,$rackContent;for(i=1;i<=this.options.slots;i++){num=i;if(this.options.slot_sort!='asc'){num=(this.options.slots-num)+1;}
className='row slot-'+parseInt(num);num=((num<10)?'0'+num:num);object=null;display_obj=false;for(cnt in this.options.objects){if(this.options.objects.hasOwnProperty(cnt)){if(this.options.objects[cnt].option!=4&&this.options.objects[cnt].pos==i){if(this.options.objects[cnt].insertion==2||(this.options.view=='front'&&this.options.objects[cnt].insertion==1)||(this.options.view=='rear'&&this.options.objects[cnt].insertion==0)){object=this.options.objects[cnt];}}}}
$rackContent=new Element('td',{className:'slot'}).update(this.renderObjectOptionsButton());$tbody.insert(new Element('tr',{className:className,'data-slotnum':i,'data-object-id':(object!==null?object.id||null:null),'data-object-title':(object!==null?object.title||null:null),'data-object-height':(object!==null?object.height||null:null),'data-object-chassis':((object!==null&&object.isChassis)?1:null)}).update(new Element('td').update(num+'&nbsp;')).insert($rackContent).insert(new Element('td').update('&nbsp;'+num)));if(rowspan>0){$tbody.down('tr:last').down('td',1).remove();rowspan--;}
if(object!==null){if(this.options.view=='front'&&object.insertion==1){display_obj=true;}else if(this.options.view=='rear'&&object.insertion==0){display_obj=true;}else if(object.insertion==2){display_obj=true;}
if(display_obj){rowspan=(object.height-1);try{$rackContent.insert(this.renderObject(object)).writeAttribute({rowspan:(object.height>1?object.height:null)}).setStyle({backgroundColor:object.color,backgroundImage:'none'});}catch(e){$tbody.down('tr:last').previous('tr').down('td',1).removeAttribute('rowspan');$rackContent.update(new Element('div',{className:'box-red'}).update('Positioning error in ').insert(new Element('a',{href:'?objID='+object.id}).update(object.title)));}}}}
last=$tbody.down('td.slot:last');this.$element.down('.main-slots table').update($tbody);if(last){last.addClassName('last');}
return this;},updateVerticalSlots:function(slotNumber){var verticalSlots=this.options.verticalSlots;if(typeof slotNumber!='undefined'){verticalSlots=slotNumber;}
this.$element.select('.left-slots .slot,.right-slots .slot').each(function($slot){var displayObject=false,i,object,slotNumber=$slot.readAttribute('data-slot'),attributes;$slot.update(this.renderObjectOptionsButton());if(isNaN(verticalSlots)){$slot.hide();}else{for(i in this.options.objects){if(this.options.objects.hasOwnProperty(i)){if(this.options.objects[i].option==this.options.OPTION_VERTICAL&&this.options.objects[i].pos==slotNumber){if((this.options.view=='front'&&this.options.objects[i].insertion==this.options.INSERTION_FRONT)||(this.options.view=='rear'&&this.options.objects[i].insertion==this.options.INSERTION_REAR)){object=this.options.objects[i];displayObject=true;}}}}
if(displayObject){attributes={'data-slotnum':slotNumber,'data-object-id':(object!==null?object.id||null:null),'data-object-title':(object!==null?object.title||null:null),'data-object-height':(object!==null?object.height||null:null)};$slot.insert(this.renderObject(object).addClassName('rotated')).setStyle({backgroundColor:object.color,backgroundImage:'none'}).writeAttribute(attributes);$slot.down('.cmdb-marker').removeClassName('m5');}else{$slot.insert(new Element('span',{className:'rotated'}).update('Slot '+slotNumber)).writeAttribute('data-slotnum',slotNumber);}
if(parseInt($slot.readAttribute('data-slot'))>verticalSlots){$slot.hide();}else{$slot.show();}}}.bind(this));return this;},set_slot_sorting:function(sorting){sorting=sorting.toLowerCase();if(sorting=='asc'||sorting=='desc'){this.options.slot_sort=sorting;}
return this;},setObjects:function(objects){this.options.objects=objects;return this;},renderObject:function(object){var object_title=object.title+' ('+object.type+', FF: '+object.formfactor+')',$objectContainer=new Element('div',{className:'slot-object'});if(object.isChassis&&object.height>1){var rowHeight=(this.options.room_view?12:27);$objectContainer.setStyle({maxHeight:(object.height*rowHeight)+'px'});}
if(this.options.room_view){object_title=new Element('a',{href:'?objID='+object.id}).update(object_title);}
if(object.isChassis){new RackChassis($objectContainer,{x:object.chassis.x,y:object.chassis.y,matrix:object.chassis.matrix,devices:object.chassis.devices,mirrored:(object.insertion==this.options.INSERTION_BOTH&&this.options.view=='rear')});return $objectContainer.setStyle({margin:'-1px 0 0 -1px'});}else{return $objectContainer.update(new Element('img',{src:((object.icon!='')?object.icon:window.dir_images+'empty.gif'),alt:object.type,className:'object-icon'})).insert(new Element('p',{class:'object-title'}).update(object_title)).insert(new Element('div',{className:'cmdb-marker m5 mouse-help',style:'background-color:'+object.cmdb_color+';',title:object.cmdb_status}));}},updateRowSizes:function(expanded){var $rowspanRows=this.$element.select('tr.row>td.slot[rowspan]'),$objectContainer,rowHeight,rowSpan,i;if(expanded){rowHeight=(this.options.room_view?41:84);}else{rowHeight=(this.options.room_view?12:27);}
for(i in $rowspanRows){if(!$rowspanRows.hasOwnProperty(i)){continue;}
$objectContainer=$rowspanRows[i].down('.slot-object');if(!$objectContainer){continue;}
rowSpan=parseInt($rowspanRows[i].readAttribute('rowspan'));$objectContainer.setStyle({maxHeight:(rowSpan*rowHeight)+'px'});}
this.updateChassisSizes();},updateChassisSizes:function(){setTimeout(function(){this.$element.select('.slot-object').invoke('fire','update:fitToContainer');}.bind(this),500);},renderObjectOptionsButton:function(){if(this.options.edit_right&&!this.options.room_view&&(this.options.objectReassign||this.options.object_remove||this.options.link_objects)){return new Element('img',{className:'slot-options',src:window.dir_images+'icons/silk/cog.png'});}
return null;},slot_option:function(ev){var $contextWrapper=$('rackOptionsPopup'),x=Event.pointerX(ev)-10,y=Event.pointerY(ev)-10,$element=ev.findElement(),$objectElement=$element.up('[data-slotnum]'),$options=new Element('ul',{className:'list-style-none m0'}),objectId=$objectElement.readAttribute('data-object-id'),objectTitle=$objectElement.readAttribute('data-object-title'),objectSlotHeight=$objectElement.readAttribute('data-object-height'),objectIsChassis=$objectElement.readAttribute('data-object-chassis'),slotNumber=$objectElement.readAttribute('data-slotnum'),verticalSlots=!!$element.up('[data-vertical]');if($contextWrapper){$contextWrapper.remove();}
if(objectId&&this.options.object_link){$options.insert(new Element('li').update(new Element('a',{href:'?objID='+objectId,target:'_blank'}).update(new Element('img',{src:window.dir_images+'icons/silk/link.png',className:'mr5'})).insert(idoit.Translate.get("LC__UNIVERSAL__TITLE_LINK"))));}
if(objectId&&this.options.objectReassign){$options.insert(new Element('li',{'data-object-id':objectId,'data-object-title':objectTitle,'data-object-height':objectSlotHeight}).update(new Element('a',{href:'#'}).update(new Element('img',{src:window.dir_images+'icons/silk/arrow_switch.png',className:'mr5'})).insert(idoit.Translate.get('LC__CMDB__CATS__RACK__REASSIGN_OBJECT'))));$options.down('li:last').on('click',this.options.objectReassignCallback);}
if(objectId&&!objectIsChassis&&this.options.object_remove){$options.insert(new Element('li',{'data-object-id':objectId,'data-object-title':objectTitle,'data-object-height':objectSlotHeight}).update(new Element('a',{href:'#'}).update(new Element('img',{src:window.dir_images+'icons/silk/cross.png',className:'mr5'})).insert(idoit.Translate.get('LC__CMDB__CATS__RACK__REMOVE_OBJECT'))));$options.down('li:last').on('click',this.options.objectRemoveCallback);}
if(this.options.slot_segment&&!objectIsChassis&&!verticalSlots){$options.insert(new Element('li',{'data-slot-number':slotNumber}).update(new Element('a',{href:'#'}).update(new Element('img',{src:window.dir_images+'icons/silk/application_split.png',className:'mr5'})).insert(idoit.Translate.get('LC__CMDB__CATS__RACK__SEGMENT_SLOT'))));$options.down('li:last').on('click',this.options.slotSegmentCallback.bindAsEventListener(this));}
if(this.options.slotDetach&&objectIsChassis&&!verticalSlots){$options.insert(new Element('li',{'data-object-id':objectId,'data-object-title':objectTitle,'data-slot-number':slotNumber}).update(new Element('a',{href:'#'}).update(new Element('img',{src:window.dir_images+'icons/silk/application_delete.png',className:'mr5'})).insert(idoit.Translate.get('LC__CMDB__CATS__RACK__RESET_SLOT'))));$options.down('li:last').on('click',this.options.slotDetachCallback);}
if($options.select('li').length===0){idoit.Notify.info(idoit.Translate.get('LC__CMDB__CATS__RACK__SLOT_HAS_NO_OPTIONS'),{life:5});return;}
$contextWrapper=new Element('div',{id:'rackOptionsPopup',className:'rackOptionsPopup box-white',style:'top:'+(y+2)+'px; left:'+(x+2)+'px; opacity:0','data-slot-number':slotNumber}).update(new Element('h4',{className:'p5 gradient'}).update(objectTitle||idoit.Translate.get('LC__CMDB__CATS__RACK__CONFIGURE_SLOT'))).insert($options);$contextWrapper.on('mouseleave',function(){if($contextWrapper){new Effect.Morph($contextWrapper,{style:'top:'+(y+2)+'px; left:'+(x+2)+'px; opacity: 0;',duration:0.25,afterFinish:function(){$contextWrapper.remove();}});}});$('rackview').insert($contextWrapper);new Effect.Morph($contextWrapper,{style:'top:'+y+'px; left:'+x+'px; opacity: 1;',duration:0.25});},getChassisData:function(position){var $slots=this.$element.down('.slot-'+position).select('[data-slot-id]'),result=[],i;for(i in $slots){if($slots.hasOwnProperty(i)){result.push({id:$slots[i].readAttribute('data-slot-id'),title:$slots[i].readAttribute('data-slot-title')});}}
return result.sort(function(a,b){return a.title.localeCompare(b.title);});},selectChassis:function(chassisId){this.$element.select('.selected').invoke('removeClassName','selected');this.$element.down('[data-slot-id="'+chassisId+'"]').addClassName('selected');}});function $N(name,doc){return(doc||document).getElementsByName(name);}
Array.prototype.in_array=function(needle){for(var i=0;i<this.length;i++)if(this[i]===needle)return true;return false;};if(!Array.prototype.hasOwnProperty('sum')){Array.prototype.sum=function(){for(var total=0,l=this.length;l--;total+=this[l]);return total;}}
if(!Element.prototype.hasOwnProperty('getDataAttributes')){Element.prototype.getDataAttributes=function(){var i,attributes={};for(i in this.attributes){if(Object.isString(this.attributes[i].localName)&&this.attributes[i].localName.startsWith('data-')){attributes[this.attributes[i].localName.substring(5)]=this.attributes[i].nodeValue;}}
return attributes;}}
if(!String.prototype.hasOwnProperty('repeat')){String.prototype.repeat=function(count){if(count<1)return'';var result='',pattern=this.valueOf();while(count>1){if(count&1)result+=pattern;count>>=1,pattern+=pattern;}
return result+pattern;};}
if(!String.prototype.hasOwnProperty('encodeHTML')){String.prototype.encodeHTML=function(){return this.replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/ä/g,'&auml;').replace(/ö/g,'&ouml;').replace(/ü/g,'&uuml;').replace(/Ä/g,'&Auml;').replace(/Ö/g,'&Ouml;').replace(/Ü/g,'&Uuml;');};}
if(!String.prototype.hasOwnProperty('decodeHTML')){String.prototype.decodeHTML=function(){return this.replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&auml;/g,'ä').replace(/&ouml;/g,'ö').replace(/&uuml;/g,'ü').replace(/&Auml;/g,'Ä').replace(/&Ouml;/g,'Ö').replace(/&Uuml;/g,'Ü');};}
if(!String.prototype.hasOwnProperty('toInt')){String.prototype.toInt=function(base){return parseInt(this,base||10);};}
if(!String.prototype.hasOwnProperty('toFloat')){String.prototype.toFloat=function(){return parseFloat(this);};}
function move_arrow_to(element){if(element){$('downarrow').morph('left: '+parseInt((parseInt(element.positionedOffset().left)+parseInt($('mainMenu').up().offsetLeft))+(element.getWidth()/ 2)+5)+'px',{duration:0.2});}}
function load_ndo_state_in_list(el){var obj_id=el.up('tr').readAttribute('data-objectid'),url=el.readAttribute('data-url'),td=el.up('td').update(new Element('img',{className:'vam mr5',src:window.dir_images+'ajax-loading.gif'}));new Ajax.Request(url,{method:"post",parameters:{objID:obj_id},onSuccess:function(transport){var json=transport.responseJSON;if(json.success&&json.data){td.update(display_monitoring_state(json.data));}else{td.addClassName('text-red').update(json.message||'-');}}.bind(this)});}
function load_livestatus_state_in_list(el){var obj_id=el.up('tr').readAttribute('data-objectid'),url=el.readAttribute('data-url'),td=el.up('td').update(new Element('img',{className:'vam mr5',src:window.dir_images+'ajax-loading.gif'}));new Ajax.Request(url,{method:"post",parameters:{objID:obj_id},onSuccess:function(transport){var json=transport.responseJSON,img=new Element('img',{className:'ml5 vam'});if(json.success&&json.data){td.update(display_monitoring_state(json.data));}else{td.addClassName('text-red').update(json.message||'-');}}.bind(this)});}
function display_monitoring_state(data,el){var $el=el;if(Object.isUndefined($el)){$el=new Element('p');}
if(data===null){return $el}
if(data.hasOwnProperty('host_state')&&data.host_state!==null){$el.addClassName(data.host_state.color||'').update(new Element('span',{className:'vam'}).update(data.host_state.state));if(data.host_state.hasOwnProperty('icon')){$el.insert({top:new Element('img',{className:'vam mr5',src:window.dir_images+data.host_state.icon})});}}else if(data.hasOwnProperty('state')&&data.state!==null){$el.addClassName(data.state.color||'').update(new Element('span',{className:'vam'}).update(data.state.state));if(data.state.hasOwnProperty('icon')){$el.insert({top:new Element('img',{className:'vam mr5',src:window.dir_images+data.state.icon})});}}else if(data.state===null||data.host_state===null){$el.update(new Element('img',{className:'vam mouse-help',src:window.dir_images+'icons/silk/help.png',title:'No data found...'}));}
return $el;}
function is_json_response(response,notify){var is_json=response.hasOwnProperty('responseJSON')&&!Object.isUndefined(response.responseJSON);if(!!notify&&!is_json){idoit.Notify.error('The request did not answer with proper JSON:'+response.responseText,{sticky:true});}
return is_json;}
function onlyNumeric(sText){return sText.replace(/[^0-9:]/g,"");}
function isNumeric(x){return(x!=null&&!isNaN(x));}
function checkipv6(str){return(/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/.test(str));}
function isys_glob_disable_save(){var e=$('navbar_item_C__NAVMODE__SAVE');if(e){e.className='navbar_item_inactive';var onClick=e.readAttribute('onclick');if(onClick){e.writeAttribute('data-onclick',onClick);e.writeAttribute('onclick',null);}}}
function isys_glob_enable_save(){var e=$('navbar_item_C__NAVMODE__SAVE');if(e){var onClick=e.readAttribute('data-onclick');if(onClick){e.className='navbar_item';e.writeAttribute('onclick',onClick);e.writeAttribute('data-onclick',null);}}}
function ip2long(ip_address){var ip_arr=ip_address.split('.'),iplong=0;with(Math){iplong=ip_arr[0]*pow(256,3)+ip_arr[1]*pow(256,2)+ip_arr[2]*pow(256,1)+ip_arr[3]*pow(256,0);}
return iplong;}
function long2ip(iplong){with(Math){var ip1=floor(iplong / pow(256,3));var ip2=floor((iplong%pow(256,3))/ pow(256,2));var ip3=floor(((iplong%pow(256,3))%pow(256,2))/ pow(256,1));var ip4=floor((((iplong%pow(256,3))%pow(256,2))%pow(256,1))/ pow(256,0));}
return ip1+'.'+ip2+'.'+ip3+'.'+ip4;}
function validate_ipv4(ip){var parts=ip.split('.'),bad_ip=false;if(parts.length!=4)bad_ip=true;if(!(parts[0]>=0&&parts[0]<=255))bad_ip=true;if(!(parts[1]>=0&&parts[1]<=255))bad_ip=true;if(!(parts[2]>=0&&parts[2]<=255))bad_ip=true;if(!(parts[3]>=0&&parts[3]<=255))bad_ip=true;return!bad_ip;}
function purge_object(navmode,ajax,message){var objects=list_selection();if(objects.length==0){return false;}
var jsonClient=new idoit.JSONClient();jsonClient.getRelationsByObjectId(objects.join(';'),function(response){var json=response.responseJSON,output='';if(response.responseText!='[]'){output+="\n"+json.join("\n");if(confirm(message+"\n"+output)){document.isys_form.navMode.value=navmode;replace_listSelection();if(ajax){form_submit();}else{$('isys_form').submit();}}
else{if($('navbar_item_C__NAVMODE__QUICK_PURGE')){if($('navbar_item_C__NAVMODE__QUICK_PURGE').down('img')){$('navbar_item_C__NAVMODE__QUICK_PURGE').down('img').setAttribute('src',window.dir_images+"icons/silk/page_delete.png");}
$('navbar_item_C__NAVMODE__QUICK_PURGE').toggleClassName('navbar_item_inactive');}}}else{document.isys_form.navMode.value=navmode;replace_listSelection();if(ajax){form_submit();}else{$('isys_form').submit();}}},{});}
function updateDialogList(p_fromID,p_toID){$(p_toID).value=$(p_fromID).getValue().join(',');}
function list_selection(){return $A($N('table_ids[]')).filter(function($input){return $input.checked}).invoke('getValue');}
function replace_listSelection(id){var $container=$(id||'scroller'),selection=list_selection(),i;$container.select('.entry-selection').invoke('remove');for(i in selection){if(selection.hasOwnProperty(i)){$container.insert(new Element('input',{type:'hidden',className:'entry-selection',name:'id[]',value:selection[i]}));}}}
function get_listSelection4Submit(){var l_result=[];var l_selection=list_selection();var l_selection4Submit={};if(l_selection.length)l_result['id[]']=l_selection;return l_result;}
function get_current_page(){var queryParams=document.location.href.toQueryParams();if(queryParams.hasOwnProperty('page')){return parseInt(queryParams.page);}
if($('current_page')){return $F('current_page');}
if($('data-grid-mainList-page-current')){return $F('data-grid-mainList-page-current');}
return 1;}
function get_current_filter(){var filter={},filterFields=$$('[name^="tableFilter"]:not([readonly])'),i;if(typeof retrieveUrlPartsFiltered==='function'){var urlParts=retrieveUrlPartsFiltered();Object.keys(urlParts).forEach(function(index){if(index.indexOf('tableFilter[')>-1){filter[index]=urlParts[index];}});}
if(filterFields.length){for(i in filterFields){if(!filterFields.hasOwnProperty(i)){continue;}
if(!filterFields[i].getValue()||filterFields[i].getValue().blank()){continue;}
filter[filterFields[i].name]=filterFields[i].getValue().trim();}}
return Object.toQueryString(filter);}
var delay=(function(){var timer=0;return function(callback,ms){clearTimeout(timer);timer=setTimeout(callback,ms);};})();var queue=function(funcs,scope){(function next(){if(funcs.length>0){funcs.shift().apply(scope||{},[next].concat(Array.prototype.slice.call(arguments,0)));}})();};window.get_shares_from_object=function get_shares_from_object(obj_id,receiver){if(obj_id.blank()){$(receiver).update(new Element('option',{value:'-1',selected:true}).insert('-'));}
new Ajax.Request('?call=share&func=get_shares_by_obj&ajax=1',{parameters:{'objID':obj_id},method:"post",onComplete:function(response){var i,json=response.responseJSON,share=$(receiver).update(new Element('option',{value:'-1',selected:true}).insert('-'));if(json.success&&is_json_response(response)){for(i in json.data){if(json.data.hasOwnProperty(i)){share.insert(new Element('option',{value:json.data[i].id}).update(json.data[i].val));}}}else{idoit.Notify.error(json.message||response.responseText,{sticky:true});}}});};window.toggle_nagios_service_inheritance=function($button,host_obj_id,service_obj_id){$button.removeClassName('text-red').removeClassName('text-green').down('img').writeAttribute('src',window.dir_images+'ajax-loading.gif').next('span').update(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__LOADING'));new Ajax.Request('?call=nagios&func=toggle_inherited_service&ajax=1',{parameters:{"host":host_obj_id,"service":service_obj_id},method:"post",onComplete:function(response){var json=response.responseJSON;if(json.success&&is_json_response(response)){if(json.data.will_be_exported){$button.addClassName('text-green').down('img').writeAttribute('src',window.dir_images+'icons/silk/tick.png').next('span').update(idoit.Translate.get('LC__UNIVERSAL__YES'));}else{$button.addClassName('text-red').down('img').writeAttribute('src',window.dir_images+'icons/silk/cross.png').next('span').update(idoit.Translate.get('LC__UNIVERSAL__NO'));}}else{idoit.Notify.error(json.message||response.responseText,{sticky:true});}}});};window.toggle_primary_contact=function($button,cat_row_id,obj_id){$button.up('table').select('button.primary-button').invoke('removeClassName','text-green').invoke('addClassName','text-red').invoke('down','img').invoke('writeAttribute','src',window.dir_images+'icons/silk/cross.png').invoke('next','span').invoke('update',idoit.Translate.get('LC__UNIVERSAL__NO'));$button.removeClassName('text-red').removeClassName('text-green').down('img').writeAttribute('src',window.dir_images+'ajax-loading.gif').next('span').update(idoit.Translate.get('LC__CMDB__OBJECT_BROWSER__SCRIPT_JS__LOADING'));new Ajax.Request('?call=update_contact_primary&ajax=1',{parameters:{"id":cat_row_id,"objID":obj_id},method:'post',onSuccess:function(transport){var json=transport.responseJSON;if(json.success){if(json.data.is_primary){$button.removeClassName('text-red').addClassName('text-green').down('img').writeAttribute('src',window.dir_images+'icons/silk/tick.png').next('span').update(idoit.Translate.get('LC__UNIVERSAL__YES'));}else{$button.removeClassName('text-green').addClassName('text-red').down('img').writeAttribute('src',window.dir_images+'icons/silk/cross.png').next('span').update(idoit.Translate.get('LC__UNIVERSAL__NO'));}}else{$button.addClassName('text-red').down('img').writeAttribute('src',window.dir_images+'icons/silk/error.png').next('span').update('-');idoit.Notify.error(json.message);}}});};function run_prefix_method(obj,method){var p=0,m,t,browser_prefixes=["webkit","moz","ms","o",""];while(p<browser_prefixes.length&&!obj[m]){m=method;if(browser_prefixes[p]==""){m=m.substr(0,1).toLowerCase()+m.substr(1);}
m=browser_prefixes[p]+m;t=typeof obj[m];if(t!="undefined"){browser_prefixes=[browser_prefixes[p]];return(t=="function"?obj[m]():obj[m]);}
p++;}}
function request_fullscreen($el){if(run_prefix_method(document,"FullScreen")||run_prefix_method(document,"IsFullScreen")){run_prefix_method(document,"CancelFullScreen");}else{run_prefix_method($el,"RequestFullScreen");}}
function fillObject(obj,keys,value){var currentKey;if(Object.isString(keys)){keys=keys.split('.');}
currentKey=keys.shift();if(!obj.hasOwnProperty(currentKey)){obj[currentKey]={};}
if(keys.length>0){obj[currentKey]=fillObject(obj[currentKey],keys,value);}else{obj[currentKey]=value;}
return obj;}
function openFullscreenPopup(tpl,params){var $popup=$('popup'),$overlay=$('overlay'),width=$overlay.getWidth()-100,height=$overlay.getHeight()-100;if(width<200){width=200;}
if(height<200){height=200;}
if(!$popup.visible()){get_popup('fullscreen','',width,height,{tpl:tpl,parameters:Object.toJSON(params)},null);}}
var
rpool_callback=Prototype.emptyFunction,remove_from_pool=Prototype.emptyFunction,relpool_observer=Prototype.emptyFunction;SVGElement.prototype.exportToString=function(options){var $svgNode=Element.writeAttribute(Element.clone(this,true),{width:null,height:null}),svgData=(new XMLSerializer()).serializeToString($svgNode);if(options.hasOwnProperty('decode')&&options.decode){svgData=btoa(svgData);}
if(options.callback){options.callback(svgData);}
return svgData;};SVGElement.prototype.saveToSvg=function(options){var svg=this;idoit.Require.require('svgToPng',function(){var filename='exported-svg';if(options.hasOwnProperty('filename')&&Object.isString(options.filename)){filename=options.filename;}
saveSvg(svg,filename+'.svg',options);if(options.hasOwnProperty('callback')&&Object.isFunction(options.callback)){options.callback();}});};SVGElement.prototype.saveToPng=function(options){var svg=this;idoit.Require.require('svgToPng',function(){var filename='exported-png';if(options.hasOwnProperty('filename')&&Object.isString(options.filename)){filename=options.filename;}
saveSvgAsPng(svg,filename+'.png',options);if(options.hasOwnProperty('callback')&&Object.isFunction(options.callback)){options.callback();}});};window.paceOptions={startOnPageLoad:0};(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X=[].slice,Y={}.hasOwnProperty,Z=function(a,b){function c(){this.constructor=a}for(var d in b)Y.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},$=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};for(u={catchupTime:100,initialRate:.03,minTime:250,ghostTime:100,maxProgressPerFrame:20,easeFactor:1.25,startOnPageLoad:!0,restartOnPushState:!0,restartOnRequestAfter:500,target:"body",elements:{checkInterval:100,selectors:["body"]},eventLag:{minSamples:10,sampleCount:3,lagThreshold:3},ajax:{trackMethods:["GET"],trackWebSockets:!0,ignoreURLs:[]}},C=function(){var a;return null!=(a="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance.now():void 0)?a:+new Date},E=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,t=window.cancelAnimationFrame||window.mozCancelAnimationFrame,null==E&&(E=function(a){return setTimeout(a,50)},t=function(a){return clearTimeout(a)}),G=function(a){var b,c;return b=C(),(c=function(){var d;return d=C()-b,d>=33?(b=C(),a(d,function(){return E(c)})):setTimeout(c,33-d)})()},F=function(){var a,b,c;return c=arguments[0],b=arguments[1],a=3<=arguments.length?X.call(arguments,2):[],"function"==typeof c[b]?c[b].apply(c,a):c[b]},v=function(){var a,b,c,d,e,f,g;for(b=arguments[0],d=2<=arguments.length?X.call(arguments,1):[],f=0,g=d.length;g>f;f++)if(c=d[f])for(a in c)Y.call(c,a)&&(e=c[a],null!=b[a]&&"object"==typeof b[a]&&null!=e&&"object"==typeof e?v(b[a],e):b[a]=e);return b},q=function(a){var b,c,d,e,f;for(c=b=0,e=0,f=a.length;f>e;e++)d=a[e],c+=Math.abs(d),b++;return c/b},x=function(a,b){var c,d,e;if(null==a&&(a="options"),null==b&&(b=!0),e=document.querySelector("[data-pace-"+a+"]")){if(c=e.getAttribute("data-pace-"+a),!b)return c;try{return JSON.parse(c)}catch(f){return d=f,"undefined"!=typeof console&&null!==console?console.error("Error parsing inline pace options",d):void 0}}},g=function(){function a(){}return a.prototype.on=function(a,b,c,d){var e;return null==d&&(d=!1),null==this.bindings&&(this.bindings={}),null==(e=this.bindings)[a]&&(e[a]=[]),this.bindings[a].push({handler:b,ctx:c,once:d})},a.prototype.once=function(a,b,c){return this.on(a,b,c,!0)},a.prototype.off=function(a,b){var c,d,e;if(null!=(null!=(d=this.bindings)?d[a]:void 0)){if(null==b)return delete this.bindings[a];for(c=0,e=[];c<this.bindings[a].length;)e.push(this.bindings[a][c].handler===b?this.bindings[a].splice(c,1):c++);return e}},a.prototype.trigger=function(){var a,b,c,d,e,f,g,h,i;if(c=arguments[0],a=2<=arguments.length?X.call(arguments,1):[],null!=(g=this.bindings)?g[c]:void 0){for(e=0,i=[];e<this.bindings[c].length;)h=this.bindings[c][e],d=h.handler,b=h.ctx,f=h.once,d.apply(null!=b?b:this,a),i.push(f?this.bindings[c].splice(e,1):e++);return i}},a}(),j=window.Pace||{},window.Pace=j,v(j,g.prototype),D=j.options=v({},u,window.paceOptions,x()),U=["ajax","document","eventLag","elements"],Q=0,S=U.length;S>Q;Q++)K=U[Q],D[K]===!0&&(D[K]=u[K]);i=function(a){function b(){return V=b.__super__.constructor.apply(this,arguments)}return Z(b,a),b}(Error),b=function(){function a(){this.progress=0}return a.prototype.getElement=function(){var a;if(null==this.el){if(a=document.querySelector(D.target),!a)throw new i;this.el=document.createElement("div"),this.el.className="pace pace-active",document.body.className=document.body.className.replace(/pace-done/g,""),document.body.className+=" pace-running",this.el.innerHTML='<div class="pace-progress">\n  <div class="pace-progress-inner"></div>\n</div>\n<div class="pace-activity"></div>',null!=a.firstChild?a.insertBefore(this.el,a.firstChild):a.appendChild(this.el)}return this.el},a.prototype.finish=function(){var a;return a=this.getElement(),a.className=a.className.replace("pace-active",""),a.className+=" pace-inactive",document.body.className=document.body.className.replace("pace-running",""),document.body.className+=" pace-done"},a.prototype.update=function(a){return this.progress=a,this.render()},a.prototype.destroy=function(){try{this.getElement().parentNode.removeChild(this.getElement())}catch(a){i=a}return this.el=void 0},a.prototype.render=function(){var a,b,c,d,e,f,g;if(null==document.querySelector(D.target))return!1;for(a=this.getElement(),d="translate3d("+this.progress+"%, 0, 0)",g=["webkitTransform","msTransform","transform"],e=0,f=g.length;f>e;e++)b=g[e],a.children[0].style[b]=d;return(!this.lastRenderedProgress||this.lastRenderedProgress|0!==this.progress|0)&&(a.children[0].setAttribute("data-progress-text",""+(0|this.progress)+"%"),this.progress>=100?c="99":(c=this.progress<10?"0":"",c+=0|this.progress),a.children[0].setAttribute("data-progress",""+c)),this.lastRenderedProgress=this.progress},a.prototype.done=function(){return this.progress>=100},a}(),h=function(){function a(){this.bindings={}}return a.prototype.trigger=function(a,b){var c,d,e,f,g;if(null!=this.bindings[a]){for(f=this.bindings[a],g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(c.call(this,b));return g}},a.prototype.on=function(a,b){var c;return null==(c=this.bindings)[a]&&(c[a]=[]),this.bindings[a].push(b)},a}(),P=window.XMLHttpRequest,O=window.XDomainRequest,N=window.WebSocket,w=function(a,b){var c,d,e;e=[];for(d in b.prototype)try{e.push(null==a[d]&&"function"!=typeof b[d]?"function"==typeof Object.defineProperty?Object.defineProperty(a,d,{get:function(){return b.prototype[d]},configurable:!0,enumerable:!0}):a[d]=b.prototype[d]:void 0)}catch(f){c=f}return e},A=[],j.ignore=function(){var a,b,c;return b=arguments[0],a=2<=arguments.length?X.call(arguments,1):[],A.unshift("ignore"),c=b.apply(null,a),A.shift(),c},j.track=function(){var a,b,c;return b=arguments[0],a=2<=arguments.length?X.call(arguments,1):[],A.unshift("track"),c=b.apply(null,a),A.shift(),c},J=function(a){var b;if(null==a&&(a="GET"),"track"===A[0])return"force";if(!A.length&&D.ajax){if("socket"===a&&D.ajax.trackWebSockets)return!0;if(b=a.toUpperCase(),$.call(D.ajax.trackMethods,b)>=0)return!0}return!1},k=function(a){function b(){var a,c=this;b.__super__.constructor.apply(this,arguments),a=function(a){var b;return b=a.open,a.open=function(d,e){return J(d)&&c.trigger("request",{type:d,url:e,request:a}),b.apply(a,arguments)}},window.XMLHttpRequest=function(b){var c;return c=new P(b),a(c),c};try{w(window.XMLHttpRequest,P)}catch(d){}if(null!=O){window.XDomainRequest=function(){var b;return b=new O,a(b),b};try{w(window.XDomainRequest,O)}catch(d){}}if(null!=N&&D.ajax.trackWebSockets){window.WebSocket=function(a,b){var d;return d=null!=b?new N(a,b):new N(a),J("socket")&&c.trigger("request",{type:"socket",url:a,protocols:b,request:d}),d};try{w(window.WebSocket,N)}catch(d){}}}return Z(b,a),b}(h),R=null,y=function(){return null==R&&(R=new k),R},I=function(a){var b,c,d,e;for(e=D.ajax.ignoreURLs,c=0,d=e.length;d>c;c++)if(b=e[c],"string"==typeof b){if(-1!==a.indexOf(b))return!0}else if(b.test(a))return!0;return!1},y().on("request",function(b){var c,d,e,f,g;return f=b.type,e=b.request,g=b.url,I(g)?void 0:j.running||D.restartOnRequestAfter===!1&&"force"!==J(f)?void 0:(d=arguments,c=D.restartOnRequestAfter||0,"boolean"==typeof c&&(c=0),setTimeout(function(){var b,c,g,h,i,k;if(b="socket"===f?e.readyState<2:0<(h=e.readyState)&&4>h){for(j.restart(),i=j.sources,k=[],c=0,g=i.length;g>c;c++){if(K=i[c],K instanceof a){K.watch.apply(K,d);break}k.push(void 0)}return k}},c))}),a=function(){function a(){var a=this;this.elements=[],y().on("request",function(){return a.watch.apply(a,arguments)})}return a.prototype.watch=function(a){var b,c,d,e;return d=a.type,b=a.request,e=a.url,I(e)?void 0:(c="socket"===d?new n(b):new o(b),this.elements.push(c))},a}(),o=function(){function a(a){var b,c,d,e,f,g,h=this;if(this.progress=0,null!=window.ProgressEvent)for(c=null,a.addEventListener("progress",function(a){return h.progress=a.lengthComputable?100*a.loaded/a.total:h.progress+(100-h.progress)/2},!1),g=["load","abort","timeout","error"],d=0,e=g.length;e>d;d++)b=g[d],a.addEventListener(b,function(){return h.progress=100},!1);else f=a.onreadystatechange,a.onreadystatechange=function(){var b;return 0===(b=a.readyState)||4===b?h.progress=100:3===a.readyState&&(h.progress=50),"function"==typeof f?f.apply(null,arguments):void 0}}return a}(),n=function(){function a(a){var b,c,d,e,f=this;for(this.progress=0,e=["error","open"],c=0,d=e.length;d>c;c++)b=e[c],a.addEventListener(b,function(){return f.progress=100},!1)}return a}(),d=function(){function a(a){var b,c,d,f;for(null==a&&(a={}),this.elements=[],null==a.selectors&&(a.selectors=[]),f=a.selectors,c=0,d=f.length;d>c;c++)b=f[c],this.elements.push(new e(b))}return a}(),e=function(){function a(a){this.selector=a,this.progress=0,this.check()}return a.prototype.check=function(){var a=this;return document.querySelector(this.selector)?this.done():setTimeout(function(){return a.check()},D.elements.checkInterval)},a.prototype.done=function(){return this.progress=100},a}(),c=function(){function a(){var a,b,c=this;this.progress=null!=(b=this.states[document.readyState])?b:100,a=document.onreadystatechange,document.onreadystatechange=function(){return null!=c.states[document.readyState]&&(c.progress=c.states[document.readyState]),"function"==typeof a?a.apply(null,arguments):void 0}}return a.prototype.states={loading:0,interactive:50,complete:100},a}(),f=function(){function a(){var a,b,c,d,e,f=this;this.progress=0,a=0,e=[],d=0,c=C(),b=setInterval(function(){var g;return g=C()-c-50,c=C(),e.push(g),e.length>D.eventLag.sampleCount&&e.shift(),a=q(e),++d>=D.eventLag.minSamples&&a<D.eventLag.lagThreshold?(f.progress=100,clearInterval(b)):f.progress=100*(3/(a+3))},50)}return a}(),m=function(){function a(a){this.source=a,this.last=this.sinceLastUpdate=0,this.rate=D.initialRate,this.catchup=0,this.progress=this.lastProgress=0,null!=this.source&&(this.progress=F(this.source,"progress"))}return a.prototype.tick=function(a,b){var c;return null==b&&(b=F(this.source,"progress")),b>=100&&(this.done=!0),b===this.last?this.sinceLastUpdate+=a:(this.sinceLastUpdate&&(this.rate=(b-this.last)/this.sinceLastUpdate),this.catchup=(b-this.progress)/D.catchupTime,this.sinceLastUpdate=0,this.last=b),b>this.progress&&(this.progress+=this.catchup*a),c=1-Math.pow(this.progress/100,D.easeFactor),this.progress+=c*this.rate*a,this.progress=Math.min(this.lastProgress+D.maxProgressPerFrame,this.progress),this.progress=Math.max(0,this.progress),this.progress=Math.min(100,this.progress),this.lastProgress=this.progress,this.progress},a}(),L=null,H=null,r=null,M=null,p=null,s=null,j.running=!1,z=function(){return D.restartOnPushState?j.restart():void 0},null!=window.history.pushState&&(T=window.history.pushState,window.history.pushState=function(){return z(),T.apply(window.history,arguments)}),null!=window.history.replaceState&&(W=window.history.replaceState,window.history.replaceState=function(){return z(),W.apply(window.history,arguments)}),l={ajax:a,elements:d,document:c,eventLag:f},(B=function(){var a,c,d,e,f,g,h,i;for(j.sources=L=[],g=["ajax","elements","document","eventLag"],c=0,e=g.length;e>c;c++)a=g[c],D[a]!==!1&&L.push(new l[a](D[a]));for(i=null!=(h=D.extraSources)?h:[],d=0,f=i.length;f>d;d++)K=i[d],L.push(new K(D));return j.bar=r=new b,H=[],M=new m})(),j.stop=function(){return j.trigger("stop"),j.running=!1,r.destroy(),s=!0,null!=p&&("function"==typeof t&&t(p),p=null),B()},j.restart=function(){return j.trigger("restart"),j.stop(),j.start()},j.go=function(){var a;return j.running=!0,r.render(),a=C(),s=!1,p=G(function(b,c){var d,e,f,g,h,i,k,l,n,o,p,q,t,u,v,w;for(l=100-r.progress,e=p=0,f=!0,i=q=0,u=L.length;u>q;i=++q)for(K=L[i],o=null!=H[i]?H[i]:H[i]=[],h=null!=(w=K.elements)?w:[K],k=t=0,v=h.length;v>t;k=++t)g=h[k],n=null!=o[k]?o[k]:o[k]=new m(g),f&=n.done,n.done||(e++,p+=n.tick(b));return d=p/e,r.update(M.tick(b,d)),r.done()||f||s?(r.update(100),j.trigger("done"),setTimeout(function(){return r.finish(),j.running=!1,j.trigger("hide")},Math.max(D.ghostTime,Math.max(D.minTime-(C()-a),0)))):c()})},j.start=function(a){v(D,a),j.running=!0;try{r.render()}catch(b){i=b}return document.querySelector(".pace")?(j.trigger("start"),j.go()):setTimeout(j.start,50)},"function"==typeof define&&define.amd?define(["pace"],function(){return j}):"object"==typeof exports?module.exports=j:D.startOnPageLoad&&j.start()}).call(this);(function(){var AbstractChosen,SelectParser,a,b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),title:a.title?a.title:void 0,children:0,disabled:a.disabled,classes:a.className}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,title:a.title?a.title:void 0,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,group_label:null!=b?this.parsed[b].label:null,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&amp;"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0,this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1,this.max_shown_results=this.options.max_shown_results||Number.POSITIVE_INFINITY},AbstractChosen.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.choice_label=function(a){return this.include_group_label_in_selected&&null!=a.group_label?"<b class='group-name'>"+a.group_label+"</b>"+a.html:a.html},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(a){var b=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return b.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(a){var b=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return b.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f,g,h;for(b="",e=0,h=this.results_data,f=0,g=h.length;g>f&&(c=h[f],d="",d=c.group?this.result_add_group(c):this.result_add_option(c),""!==d&&(e++,b+=d),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(c))),!(e>=this.max_shown_results));f++);return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match&&this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.style.cssText=a.style,c.setAttribute("data-option-array-index",a.array_index),c.innerHTML=a.search_text,a.title&&(c.title=a.title),this.outerHTML(c)):""},AbstractChosen.prototype.result_add_group=function(a){var b,c;return(a.search_match||a.group_match)&&a.active_options>0?(b=[],b.push("group-result"),a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.innerHTML=a.search_text,a.title&&(c.title=a.title),this.outerHTML(c)):""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.reset_single_select_options=function(){var a,b,c,d,e;for(d=this.results_data,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.selected?e.push(a.selected=!1):e.push(void 0);return e},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(this.no_results_clear(),d=0,f=this.get_search_text(),a=f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i=new RegExp(a,"i"),c=this.get_search_regex(a),l=this.results_data,j=0,k=l.length;k>j;j++)b=l[j],b.search_match=!1,e=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(e=this.results_data[b.group_array_index],0===e.active_options&&e.search_match&&(d+=1),e.active_options+=1),b.search_text=b.group?b.label:b.html,(!b.group||this.group_search)&&(b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(d+=1),b.search_match?(f.length&&(g=b.search_text.search(i),h=b.search_text.substr(0,g+f.length)+"</em>"+b.search_text.substr(g+f.length),b.search_text=h.substr(0,g)+"<em>"+h.substr(g)),null!=e&&(e.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>d&&f.length?(this.update_results_content(""),this.no_results(f)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.get_search_regex=function(a){var b;return b=this.search_contains?"":"^",new RegExp(b+a,"i")},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:case 18:break;default:return this.results_search()}},AbstractChosen.prototype.clipboard_event_checker=function(a){var b=this;return setTimeout(function(){return b.results_search()},50)},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.prototype.search_results_touchstart=function(a){return this.touch_started=!0,this.search_results_mouseover(a)},AbstractChosen.prototype.search_results_touchmove=function(a){return this.touch_started=!1,this.search_results_mouseout(a)},AbstractChosen.prototype.search_results_touchend=function(a){return this.touch_started?this.search_results_mouseup(a):void 0},AbstractChosen.prototype.outerHTML=function(a){var b;return a.outerHTML?a.outerHTML:(b=document.createElement("div"),b.appendChild(a),b.innerHTML)},AbstractChosen.browser_is_supported=function(){return/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:/IEMobile/i.test(window.navigator.userAgent)?!1:/Windows Phone/i.test(window.navigator.userAgent)?!1:/BlackBerry/i.test(window.navigator.userAgent)?!1:/BB10/i.test(window.navigator.userAgent)?!1:"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),this.Chosen=function(b){function Chosen(){return a=Chosen.__super__.constructor.apply(this,arguments)}return c(Chosen,b),Chosen.prototype.setup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field.hasClassName("chosen-rtl")},Chosen.prototype.set_default_values=function(){return Chosen.__super__.set_default_values.call(this),this.single_temp=new Template('<a class="chosen-single chosen-default"><span>#{default}</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'),this.multi_temp=new Template('<ul class="chosen-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>'),this.no_results_temp=new Template('<li class="no-results">'+this.results_none_found+' "<span>#{terms}</span>"</li>')},Chosen.prototype.set_up_html=function(){var a,b;return a=["chosen-container"],a.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&a.push(this.form_field.className),this.is_rtl&&a.push("chosen-rtl"),b={"class":a.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(b.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=this.is_multiple?new Element("div",b).update(this.multi_temp.evaluate({"default":this.default_text})):new Element("div",b).update(this.single_temp.evaluate({"default":this.default_text})),this.form_field.hide().insert({after:this.container}),this.dropdown=this.container.down("div.chosen-drop"),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.chosen-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.chosen-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.chosen-search"),this.selected_item=this.container.down(".chosen-single")),this.results_build(),this.set_tab_index(),this.set_label_behavior()},Chosen.prototype.on_ready=function(){return this.form_field.fire("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.observe("touchstart",function(b){return a.container_mousedown(b),b.preventDefault()}),this.container.observe("touchend",function(b){return a.container_mouseup(b),b.preventDefault()}),this.container.observe("mousedown",function(b){return a.container_mousedown(b)}),this.container.observe("mouseup",function(b){return a.container_mouseup(b)}),this.container.observe("mouseenter",function(b){return a.mouse_enter(b)}),this.container.observe("mouseleave",function(b){return a.mouse_leave(b)}),this.search_results.observe("mouseup",function(b){return a.search_results_mouseup(b)}),this.search_results.observe("mouseover",function(b){return a.search_results_mouseover(b)}),this.search_results.observe("mouseout",function(b){return a.search_results_mouseout(b)}),this.search_results.observe("mousewheel",function(b){return a.search_results_mousewheel(b)}),this.search_results.observe("DOMMouseScroll",function(b){return a.search_results_mousewheel(b)}),this.search_results.observe("touchstart",function(b){return a.search_results_touchstart(b)}),this.search_results.observe("touchmove",function(b){return a.search_results_touchmove(b)}),this.search_results.observe("touchend",function(b){return a.search_results_touchend(b)}),this.form_field.observe("chosen:updated",function(b){return a.results_update_field(b)}),this.form_field.observe("chosen:activate",function(b){return a.activate_field(b)}),this.form_field.observe("chosen:open",function(b){return a.container_mousedown(b)}),this.form_field.observe("chosen:close",function(b){return a.input_blur(b)}),this.search_field.observe("blur",function(b){return a.input_blur(b)}),this.search_field.observe("keyup",function(b){return a.keyup_checker(b)}),this.search_field.observe("keydown",function(b){return a.keydown_checker(b)}),this.search_field.observe("focus",function(b){return a.input_focus(b)}),this.search_field.observe("cut",function(b){return a.clipboard_event_checker(b)}),this.search_field.observe("paste",function(b){return a.clipboard_event_checker(b)}),this.is_multiple?this.search_choices.observe("click",function(b){return a.choices_click(b)}):this.container.observe("click",function(a){return a.preventDefault()})},Chosen.prototype.destroy=function(){return this.container.ownerDocument.stopObserving("click",this.click_test_action),this.form_field.stopObserving(),this.container.stopObserving(),this.search_results.stopObserving(),this.search_field.stopObserving(),null!=this.form_field_label&&this.form_field_label.stopObserving(),this.is_multiple?(this.search_choices.stopObserving(),this.container.select(".search-choice-close").each(function(a){return a.stopObserving()})):this.selected_item.stopObserving(),this.search_field.tabIndex&&(this.form_field.tabIndex=this.search_field.tabIndex),this.container.remove(),this.form_field.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field.disabled,this.is_disabled?(this.container.addClassName("chosen-disabled"),this.search_field.disabled=!0,this.is_multiple||this.selected_item.stopObserving("focus",this.activate_action),this.close_field()):(this.container.removeClassName("chosen-disabled"),this.search_field.disabled=!1,this.is_multiple?void 0:this.selected_item.observe("focus",this.activate_action))},Chosen.prototype.container_mousedown=function(a){return this.is_disabled||(a&&"mousedown"===a.type&&!this.results_showing&&a.stop(),null!=a&&a.target.hasClassName("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!a||a.target!==this.selected_item&&!a.target.up("a.chosen-single")||this.results_toggle():(this.is_multiple&&this.search_field.clear(),this.container.ownerDocument.observe("click",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b;return b=a.deltaY||-a.wheelDelta||a.detail,null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop=b+this.search_results.scrollTop):void 0},Chosen.prototype.blur_test=function(a){return!this.active_field&&this.container.hasClassName("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return this.container.ownerDocument.stopObserving("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClassName("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClassName("chosen-container-active"),this.active_field=!0,this.search_field.value=this.search_field.value,this.search_field.focus()},Chosen.prototype.test_active_click=function(a){return a.target.up(".chosen-container")===this.container?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.select("li.search-choice").invoke("remove"):this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field.readOnly=!0,this.container.addClassName("chosen-container-single-nosearch")):(this.search_field.readOnly=!1,this.container.removeClassName("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;return this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClassName("highlighted"),d=parseInt(this.search_results.getStyle("maxHeight"),10),f=this.search_results.scrollTop,e=d+f,c=this.result_highlight.positionedOffset().top,b=c+this.result_highlight.getHeight(),b>=e?this.search_results.scrollTop=b-d>0?b-d:0:f>c?this.search_results.scrollTop=c:void 0},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClassName("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field.fire("chosen:maxselected",{chosen:this}),!1):(this.container.addClassName("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.value=this.search_field.value,this.winnow_results(),this.form_field.fire("chosen:showing_dropdown",{chosen:this}))},Chosen.prototype.update_results_content=function(a){return this.search_results.update(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClassName("chosen-with-drop"),this.form_field.fire("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(a){var b;return this.form_field.tabIndex?(b=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field.tabIndex=b):void 0},Chosen.prototype.set_label_behavior=function(){var a=this;return this.form_field_label=this.form_field.up("label"),null==this.form_field_label&&(this.form_field_label=$$("label[for='"+this.form_field.id+"']").first()),null!=this.form_field_label?this.form_field_label.observe("click",function(b){return a.is_multiple?a.container_mousedown(b):a.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.value=this.default_text,this.search_field.addClassName("default")):(this.search_field.value="",this.search_field.removeClassName("default"))},Chosen.prototype.search_results_mouseup=function(a){var b;return b=a.target.hasClassName("active-result")?a.target:a.target.up(".active-result"),b?(this.result_highlight=b,this.result_select(a),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(a){var b;return b=a.target.hasClassName("active-result")?a.target:a.target.up(".active-result"),b?this.result_do_highlight(b):void 0},Chosen.prototype.search_results_mouseout=function(a){return a.target.hasClassName("active-result")||a.target.up(".active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(a){var b,c,d=this;return b=new Element("li",{"class":"search-choice"}).update("<span>"+this.choice_label(a)+"</span>"),a.disabled?b.addClassName("search-choice-disabled"):(c=new Element("a",{href:"#","class":"search-choice-close",rel:a.array_index}),c.observe("click",function(a){return d.choice_destroy_link_click(a)}),b.insert(c)),this.search_container.insert({before:b})},Chosen.prototype.choice_destroy_link_click=function(a){return a.preventDefault(),a.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a.target)},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a.readAttribute("rel"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.value.length<1&&this.results_hide(),a.up("li").remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),"function"==typeof Event.simulate&&this.form_field.simulate("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){var a;return this.current_selectedIndex=this.form_field.selectedIndex,a=this.selected_item.down("abbr"),a?a.remove():void 0},Chosen.prototype.result_select=function(a){var b,c;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field.fire("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClassName("active-result"):this.reset_single_select_options(),b.addClassName("result-selected"),c=this.results_data[b.getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(this.choice_label(c)),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.show_search_field_default(),"function"!=typeof Event.simulate||!this.is_multiple&&this.form_field.selectedIndex===this.current_selectedIndex||this.form_field.simulate("change"),this.current_selectedIndex=this.form_field.selectedIndex,a.preventDefault(),this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClassName("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClassName("chosen-default")),this.selected_item.down("span").update(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),"function"==typeof Event.simulate&&this.form_field.simulate("change"),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.down("abbr")||this.selected_item.down("span").insert({after:'<abbr class="search-choice-close"></abbr>'}),this.selected_item.addClassName("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return this.search_field.value.strip().escapeHTML()},Chosen.prototype.winnow_results_set_highlight=function(){var a;return this.is_multiple||(a=this.search_results.down(".result-selected.active-result")),null==a&&(a=this.search_results.down(".active-result")),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(a){return this.search_results.insert(this.no_results_temp.evaluate({terms:a})),this.form_field.fire("chosen:no_results",{chosen:this})},Chosen.prototype.no_results_clear=function(){var a,b;for(a=null,b=[];a=this.search_results.down(".no-results");)b.push(a.remove());return b},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.next(".active-result"))?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a,b,c;return this.results_showing||this.is_multiple?this.result_highlight?(c=this.result_highlight.previousSiblings(),a=this.search_results.select("li.active-result"),b=c.intersect(a),b.length?this.result_do_highlight(b.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.down("a")),this.clear_backstroke()):(a=this.search_container.siblings().last(),a&&a.hasClassName("search-choice")&&!a.hasClassName("search-choice-disabled")?(this.pending_backstroke=a,this.pending_backstroke&&this.pending_backstroke.addClassName("search-choice-focus"),this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClassName("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.value.length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:this.results_showing&&a.preventDefault();break;case 32:this.disable_search&&a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var a,b,c,d,e,f,g,h,i;if(this.is_multiple){for(c=0,g=0,e="position:absolute; left: -1000px; top: -1000px; display:none;",f=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],h=0,i=f.length;i>h;h++)d=f[h],e+=d+":"+this.search_field.getStyle(d)+";";return a=new Element("div",{style:e}).update(this.search_field.value.escapeHTML()),document.body.appendChild(a),g=Element.measure(a,"width")+25,a.remove(),b=this.container.getWidth(),g>b-10&&(g=b-10),this.search_field.setStyle({width:g+"px"})}},Chosen}(AbstractChosen)}).call(this);function breadcrumb(p_url,suppressPushState){var l_url=p_url.replace(/#.*/g,''),pushUrl;l_url+=(l_url.match(/^.*[\?].*$/))?'&':'?';pushUrl=l_url.parseQuery();delete pushUrl.call;new Ajax.Updater('breadcrumb',l_url+'request=breadcrumb&ajax=1',{method:'get',onComplete:function(){document.title='i-doit '+
$('breadcrumb').innerHTML.replace(/\<li/g,' > <li').stripTags().unescapeHTML().substr(6);if(!suppressPushState){window.pushState({url:l_url,content:'main_content'},document.title,window.www_dir+'?'+Object.toQueryString(pushUrl));}}});}
(function(){"use strict";var ajaxOptions={method:'get',evalScripts:true};var options=ajaxOptions;window.onpopstate=function(event){if(event.state&&event.state.url){new Ajax.Updater(event.state.content,event.state.url+(event.state.url.match(/^.*[\?].*$/)?'&':'?')+'ajax=1',ajaxOptions);breadcrumb(event.state.url,true);}};window.pushState=function(data,title,url){if(window.history.pushState){url=url.replace('ajax=1','');window.history.pushState(data,title,url);}};})();var g_params=[];function glob(key){return g_params[key];}
function globalize(param,val){if(val){g_params[param]=val;}}
function change_action_parameter(p_key,p_value){"use strict";var l_new_action='',key='',query=$('isys_form').action.parseQuery();if($('isys_form').action.search(p_key)!=-1){Object.values(query).each(function(val,i){if(val){key=Object.keys(query)[i];if(key==p_key){val=p_value;}
l_new_action+=key+'='+val+'&';}});if(l_new_action!=''){$('isys_form').action=window.www_dir+'?'+l_new_action;}}
else if($('isys_form').action.search('\\?')!==-1){$('isys_form').action+='&'+p_key+'='+p_value;}}
function save_via_ajax(el){el=$(el);if(el){var btn=$('navbar_item_C__NAVMODE__SAVE');if(btn){if(btn.hasClassName('navbar_item_inactive')){return;}
btn.addClassName('navbar_item_inactive');}
$('contentArea').setOpacity(0.4);change_action_parameter('call','category_update');new Ajax.Updater(el.id,$('isys_form').action+($('isys_form').action.match(/^.*[\?].*$/)?'&ajax=1':'?ajax=1'),{method:'post',evalScripts:true,onComplete:function(response){$('contentArea').setOpacity(1);$('navMode').value='';reset_use_template_hidden_field();$('isys_form').fire('form:saved',{'response':response});if(btn){btn.removeClassName('navbar_item_inactive');}},parameters:$('isys_form').serialize(true)});}}
function form_submit(p_url,p_method,p_content,p_no_breadcrumb,successCallback,p_data){var addition,l_params=(!p_method||p_method=='post')?$('isys_form').serialize(true):{};document.isys_form.target='';if(p_data){for(var attrname in p_data){if(p_data.hasOwnProperty(attrname)){l_params[attrname]=p_data[attrname];}}}
if(!Object.isUndefined(p_url)&&p_url){$('isys_form').action=p_url;}
else{change_action_parameter('call','category');}
addition=(($('isys_form').action.search('\\?')!=-1)?'&ajax=1':'?ajax=1');new Ajax.Updater((!Object.isUndefined(p_content)&&p_content)?p_content:'main_content',$('isys_form').action+addition,{method:p_method?p_method:'post',evalScripts:true,onComplete:function(response){if(!p_no_breadcrumb){breadcrumb($('isys_form').action);}
if(successCallback&&typeof successCallback==='function'){successCallback(response);}else if(successCallback){setTimeout(function(){eval(successCallback);},500);}
delay(function(){Event.fire(document,'form:submitted',{'url':p_url,'method':p_method,'response':response,'data':p_data});},150);},parameters:l_params});}
function get_content_by_group(p_group_id,p_viewMode,successCallback){var l_link='?call=object_list&'+
C__CMDB__GET__OBJECTGROUP+'='+
p_group_id+'&'+
C__CMDB__GET__VIEWMODE+'='+
p_viewMode+'&ajax=1';if(window.object_list){delete window.object_list;}
new Ajax.Updater('main_content',l_link,{method:'get',evalScripts:true,onSuccess:function(){breadcrumb(l_link);if(successCallback){eval(successCallback);}}});}
function get_tree(p_link){close_mydoit();document.isys_form.target='';globalize(C__CMDB__GET__OBJECT,$H(p_link.parseQuery()).get(C__CMDB__GET__OBJECT));new Ajax.Updater('tree_content',p_link+((p_link.match(/^.*[\?].*$/))?'&ajax=1':'?ajax=1'),{method:'get',evalScripts:true,onComplete:function(response){$('tree_content').fire('cmdbObjectTree:retrieved',{"response":response});}});}
function get_tree_object_type(p_group_id,p_objecttype,p_treeMode){remove_drops();var l_link=window.www_dir+'?call=tree&'+C__CMDB__GET__OBJECTGROUP+'='+p_group_id;if(p_treeMode){l_link+='&'+C__CMDB__GET__TREEMODE+'='+p_treeMode;}
get_tree(l_link);if(p_objecttype){tree_obj_type_click(p_objecttype);}}
function get_tree_by_object(p_object_id,p_treemode,p_selected_catg,p_selected_cats){globalize(C__CMDB__GET__TREEMODE,p_treemode);globalize(C__CMDB__GET__OBJECT,p_object_id);var l_url=window.www_dir+'?call=tree_object&ajax=1&'+
C__CMDB__GET__OBJECT+'='+p_object_id+'&'+
C__CMDB__GET__TREEMODE+'='+p_treemode;if(p_selected_catg!==undefined&&p_selected_catg!==null){globalize('catgID',p_selected_catg);l_url+='&catgID='+p_selected_catg;}
else if(p_selected_cats!==undefined&&p_selected_cats!==null){globalize('catsID',p_selected_cats);l_url+='&catsID='+p_selected_cats;}
new Ajax.Updater('tree_content',l_url,{method:'get',evalScripts:true});}
function get_catd_by_object(p_object_id,p_viewmode,p_treemode){get_tree_by_object(p_object_id,p_treemode);get_content_by_object(p_object_id,p_viewmode);}
function get_content_by_object(p_object_id,p_viewmode,p_category,p_category_type,p_custom_category){if(window.object_list){delete window.object_list;}
change_action_parameter(C__CMDB__GET__VIEWMODE,p_viewmode);change_action_parameter(C__CMDB__GET__OBJECT,p_object_id);change_action_parameter('call','category');remove_action_parameter(['catgID','objTypeID','objGroupID','editMode','moduleID','catsID','cateID','cat1ID','cat2ID','cat3ID','cat4ID','cat5ID','ifaceID','subcatID','navPageStart','page']);reset_use_template_hidden_field();if(p_category){if(p_category_type){change_action_parameter(p_category_type,p_category);}
else{change_action_parameter('catgID',p_category);}}
if(p_custom_category){change_action_parameter('customID',p_custom_category);}
if(g_params[C__CMDB__GET__TREEMODE]||g_params[C__CMDB__GET__TREEMODE]=='undefined'){change_action_parameter(C__CMDB__GET__TREEMODE,g_params[C__CMDB__GET__TREEMODE]);}
form_submit($('isys_form').action,'get');}
function change_page(p_page,p_url,p_content,p_method){if(Object.isUndefined(p_url)){p_url=false;}
if(Object.isUndefined(p_method)){p_method='get';}
change_action_parameter('navPageStart',p_page);form_submit(p_url,p_method,p_content);}
function tree_obj_type_click(p_objtype,p_page,p_status){var url=window.www_dir+'?'+
C__CMDB__GET__VIEWMODE+'=1001&'+
C__CMDB__GET__OBJECTTYPE+'='+
p_objtype+'&call=object_list';$('contentArea').setStyle({'overflow':''});$('navPageStart').setValue((p_page)?p_page:0);$('isys_form').action=url;reset_template_hidden_field();form_submit(url,'get');}
function remove_action_parameter(key){var i,$form=$('isys_form'),formAction=$form.readAttribute('action').parseQuery();if(!Object.isArray(key)){key=[key];}
for(i in key){if(key.hasOwnProperty(i)){delete formAction[key[i]];}}
$form.writeAttribute('action',window.www_dir+'?'+Object.toQueryString(formAction));}
function reset_template_hidden_field(){"use strict";$N('template')[0].setValue('');}
function reset_use_template_hidden_field(){"use strict";$('useTemplate').setValue('');}
var IPv4={valid_ip:function(ip){if(Object.isString(ip)){var parts=ip.split('.'),bad_ip=false;if(parts.length!=4)bad_ip=true;if(!(parts[0]>=0&&parts[0]<=255))bad_ip=true;if(!(parts[1]>=0&&parts[1]<=255))bad_ip=true;if(!(parts[2]>=0&&parts[2]<=255))bad_ip=true;if(!(parts[3]>=0&&parts[3]<=255))bad_ip=true;return!bad_ip;}
return false;},long2ip:function(iplong){var pow=Math.pow,floor=Math.floor;return floor(iplong / pow(256,3))+'.'+
floor((iplong%pow(256,3))/ pow(256,2))+'.'+
floor(((iplong%pow(256,3))%pow(256,2))/ pow(256,1))+'.'+
floor((((iplong%pow(256,3))%pow(256,2))%pow(256,1))/ pow(256,0));},ip2long:function(ip_address){if(this.valid_ip(ip_address)){var ip_arr=ip_address.split('.');return(parseInt(ip_arr[0])*Math.pow(256,3))+(parseInt(ip_arr[1])*Math.pow(256,2))+(parseInt(ip_arr[2])*256)+parseInt(ip_arr[3]);}else{return 0;}}};function CheckAllBoxes(me,classname){if(typeof classname=='undefined')classname='checkbox';if($('savedCheckboxes')){$('savedCheckboxes').value="";var data_container=$('savedCheckboxes').readAttribute("data-container");eval(data_container+"=[];");$$('input.'+classname).each(function(el){if(me.checked==""){el.checked="";}
else{el.checked="checked";eval(data_container+".push('"+el.value+"');");}});$('savedCheckboxes').value=JSON.stringify(eval(data_container));}
else{$$('input.'+classname).each(function(el){if(me.checked=="")el.checked="";else el.checked="checked";});}}
if(!idoit)var idoit={};idoit.Translate=new Hash();idoit.callbackManager={callbacks:{},registerCallback:function(name,callback,context){if(Object.isFunction(callback)){this.callbacks[name]=[callback,context||null];}
return this;},triggerCallback:function(name){if(this.callbacks.hasOwnProperty(name)){try{this.callbacks[name][0].apply(this.callbacks[name][1],Array.prototype.slice.call(arguments,1));}catch(e){idoit.Notify.error(e.message);}}
return this;}};idoit.Suggest=Class.create({initialize:function(method,el,el_hidden,p_options){if(document.getElementsByName(el)[0]||$(el)){var element=($(el))?$(el):document.getElementsByName(el)[0];var rnd=Math.floor(Math.random()*9999),el_choices='l_choices'+rnd,url='?ajax=1&call=suggest&method='+method;element.up().insert('<div id="'+el_choices+'" class="autocomplete"></div>'+'<span id="indicator'+rnd+'" style="display:none;" class="indicator"><img src="'+window.dir_images+'ajax-loading.gif" alt="Working..." /></span>');var options={paramName:'search',minChars:2,indicator:'indicator'+rnd,afterUpdateElement:function(text,li){if(el_hidden&&document.getElementsByName(el_hidden)[0]){document.getElementsByName(el_hidden)[0].value=li.id;}
if(typeof p_options.selectCallback=='function'){p_options.selectCallback(text,li);}
else if(p_options.selectCallback){eval(p_options.selectCallback);}}};Object.extend(options,p_options||{});options.parameters=$H(options.parameters).toQueryString();new Ajax.Autocompleter(element,el_choices,url,options);}
else{throw new Error('Element '+el+' not found.')}}});idoit.JSONClient=Class.create({jsonGetString:'?call=json',initialize:function(parameters){this.parameters={};Object.extend(this.parameters,parameters||{useAuth:false});this.useAuth(this.parameters.useAuth);},useAuth:function(auth){this.parameters.useAuth=!!auth;this.jsonGetString=(this.parameters.useAuth?'?call=json&useAuth=1':'?call=json');},post:function(url,parameters,callback){return this.call(url,callback,{parameters:parameters,method:'post'});},call:function(url,callback,options){if(!callback)callback=Prototype.emptyFunction;Object.extend(this.parameters,options.parameters||{});this.options={method:'get',evalJSON:true,parameters:this.parameters,requestHeaders:{Accept:'application/json'},onSuccess:callback};Object.extend(this.options,options||{});if(options&&'select'in options){this.options.parameters.select=Object.toJSON(options.select);delete options.select;}
new Ajax.Call(url,this.options);return true;},getObjectsByCustomBrowserRequest:function(request,callback,options){return this.call(this.jsonGetString+'&action=getObjectsByCustomBrowserRequest&request='+Object.toJSON(request),callback,options);},getRelationsByObjectId:function(request,callback,options){if(request){Object.extend(options,{'request':request});}
return this.post(this.jsonGetString+'&action=getRelationsByObjectId',options,callback);},createObject:function(p_objectTitle,p_objectTypeID,p_callback){return this.post(this.jsonGetString+'&action=createObject',{objectTitle:p_objectTitle,objectTypeID:p_objectTypeID},p_callback);},createObjectGroup:function(p_objectGroupTitle,p_objectIDs,p_forceOverwrite,p_callback){return this.post(this.jsonGetString+'&action=createObjectGroup',{objectTitle:p_objectGroupTitle,forceOverwrite:p_forceOverwrite,objects:p_objectIDs},p_callback);},getRightsByObjectTypeId:function(p_objectTypeID,p_right,p_callback){return this.post(this.jsonGetString+'&action=hasEditRightsByObjectType',{objTypeID:p_objectTypeID,right:p_right},p_callback);}});idoit.Sanitizer=Class.create({initialize:function(parameters){this.parameters={};Object.extend(this.parameters,parameters||{});},stripTags:function(str,allow){allow=(((allow||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join('');var tags=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;var commentsAndPhpTags=/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;return str.replace(commentsAndPhpTags,'').replace(tags,function($0,$1){return allow.indexOf('<'+$1.toLowerCase()+'>')>-1?$0:'';});},sanitizeText:function(p_value){return this.sanitizeCall('text',p_value);},sanitizeFloat:function(p_value){return this.sanitizeCall('float',p_value);},sanitizeInt:function(p_value){return this.sanitizeCall('int',p_value);},sanitizeCall:function(p_type,p_value){var new_val='';new Ajax.Request('?ajax=1&call=sanitize_field',{parameters:{type:p_type,field_value:p_value},method:'post',asynchronous:false,onSuccess:function(transport){new_val=transport.responseJSON;}});return new_val;}});window.Sanitizer=new idoit.Sanitizer({});window.idoitJSON=new idoit.JSONClient({raw:true});if(!String.prototype.format){String.prototype.format=function(){var args=arguments;return this.replace(/{(\d+)}/g,function(match,number){return typeof args[number]!='undefined'?args[number]:match;});};}
document.observe('keydown',function(ev){window.keyPressed=ev.keyCode;if(ev.keyCode===16){window.keyPressedShift=true;}else if(ev.keyCode===13){window.keyPressedEnter=true;}});document.observe('keyup',function(ev){window.keyPressed=null;if(ev.keyCode===16){window.keyPressedShift=false;}else if(ev.keyCode===13){window.keyPressedEnter=false;}});document.observe('mousemove',function(ev){window.mouseX=ev.pageX;window.mouseY=ev.pageY;});var g_onload_callbacks=[];var g_droppables=[];var drags=[];var dragging=false;function remove_drops(){if(typeof drops=='object'){g_droppables.each(function(drop,k){if(drop){Droppables.remove(drop);drops.splice(k,1);}});drags=[];drops=[];g_droppables=[];}}
function remove_drags(){drags.each(function(drag,k){if(drag){drag.destroy();}});drags=[];}
function init_drops(options){if(typeof drops=='object'){drops.each(function(drop){if($('smenu_tree'+drop.nodeid)){g_droppables.push('smenu_tree'+drop.nodeid);Droppables.add('smenu_tree'+drop.nodeid,{accept:'draggable',hoverclass:'hover',onDrop:function(){var $dragGhost=$('body').down('.mainTableDragGhost'),draggedIDs=$dragGhost.readAttribute('data-ids').split(','),$originTable=$($dragGhost.readAttribute('data-table-id')),toElement=this.element.down('span:first');if(!$dragGhost){return;}
draggedIDs.filter(function(id){return!isNaN(parseInt(id));});if(!draggedIDs.length){idoit.Notify.error('Please try again!',{life:5});return;}
if(confirm(new Template(options.confirmMessage).evaluate({'count':draggedIDs.length,'to':toElement&&toElement.textContent}))){new Ajax.Request('?ajax=1&call=change_object_type',{parameters:{objTypeID:drop.id,objID:draggedIDs.join(',')},method:'post',onComplete:function(xhr){var json=xhr.responseJSON;if(json.success){if($originTable){$originTable.fire('remove:entriesByIds',{ids:$dragGhost.readAttribute('data-ids').split(',')});}
idoit.Notify.success(json.data);}
else{idoit.Notify.error(json.message,{sticky:true});}}.bind(this)});}else{return false;}}});}});}}
function onload_add_callback(p_functioncall){g_onload_callbacks.push(p_functioncall);}
function onload_process(){if(g_onload_callbacks){for(i=0;i<g_onload_callbacks.length;i++){eval(g_onload_callbacks[i]);}}
History.init();}
function eTree(treeName,treeDataSource,treeCaptionIcon,treeCaption,selectedNodes,imagesFolder,nodeCssClass,selectedNodeCssClass,ajaxAnimation,highlightLocationTypes){this.treeName=treeName;this.treeDataSource=treeDataSource;this.treeCaptionIcon=treeCaptionIcon?treeCaptionIcon:"";this.treeCaption=treeCaption?treeCaption:"";this.imagesFolder=imagesFolder?imagesFolder:"";this.nodeCssClass=nodeCssClass?nodeCssClass:"node";this.selectedNodeCssClass=selectedNodeCssClass?selectedNodeCssClass:"nodeSel";this.ajaxAnimation=ajaxAnimation?ajaxAnimation:this.imagesFolder+"../please_wait.gif";this.highlightLocationTypes=(Object.isUndefined(highlightLocationTypes)?false:highlightLocationTypes);this.selectedNodesArray=selectedNodes.split(",");this.prevSelectedNodeId=-1;this.loadedNodes=[];this.treeLevels=[];this.expandedNodes=[];this.expandedNodeBottom=[];this.parentNodes=[];this.expandingImage=null;this.callback_after_render=this.callback_before_render=this.callback_after_load=this.callback_before_load=Prototype.emptyFunction;this.LoadTree(-1);}
eTree.prototype.LoadTree=function(parentNodeId){var expander=$(this.treeName+"_Expand_"+parentNodeId);this.callback_before_load(parentNodeId);if(expander){this.expandingImage=this.imagesFolder+this.GetExpanderImage(this.expandedNodeBottom[parentNodeId],true);expander.src=this.ajaxAnimation;}
var url=this.treeDataSource.replace(/\{0\}/,parentNodeId);new Ajax.Request(url,{method:'post',parameters:$('isys_form').serialize(true),onSuccess:function(transport){this.callback_after_load(parentNodeId);this.LoadTreeComplete(transport.responseJSON,parentNodeId);}.bind(this),onFailure:function(){}});};eTree.prototype.LoadTreeComplete=function(treeData,parentNodeId){var expander=$(this.treeName+"_Expand_"+parentNodeId),treeLevel,parentNode;if(expander){if(this.expandingImage===null){this.expandingImage=this.imagesFolder+this.GetExpanderImage(true,true,false);}
expander.src=this.expandingImage;this.expandingImage=null;}
if(parentNodeId==-1){parentNode=$(this.treeName);treeLevel=0;if(this.treeCaptionIcon!=""||this.treeCaption!=""){var captionDiv=new Element("div",{className:'node-div root','data-object-id':parentNodeId});if(this.treeCaptionIcon!=''){captionDiv.insert(new Element("img",{src:this.treeCaptionIcon,className:'mr5'}));}
if(this.treeCaption!=''){captionDiv.insert(this.treeCaption);}
parentNode.insert(captionDiv);}}else{parentNode=$(this.treeName+"_ChildNodes_"+parentNodeId);treeLevel=this.treeLevels[parentNodeId];}
this.callback_before_render(parentNodeId,parentNode);for(var i=0;i<treeData.length;i++){if(parentNodeId!=-1){this.parentNodes[treeData[i].id]=parentNodeId;}
var nodeDiv=new Element("div",{id:this.treeName+"_Node_"+treeData[i].id,className:'node-div','data-object-id':treeData[i].id});var bottomNodes=[],nodeId=parentNodeId;if(this.highlightLocationTypes){if(treeData[i].is_logically_assigned){nodeDiv.insert(new Element('div',{className:'cmdb-marker',style:'background:#FFB85C;'}));}else if(treeData[i].is_physically_assigned){nodeDiv.insert(new Element('div',{className:'cmdb-marker',style:'background:#66C1FF;'}));}}
for(var k=0;k<treeLevel;k++){bottomNodes.push(nodeId);if(this.parentNodes[nodeId])nodeId=this.parentNodes[nodeId];else break;}
bottomNodes.pop();for(var j=0,k=bottomNodes.length-1;j<treeLevel;j++,k--){var isLastSibling=this.expandedNodeBottom[bottomNodes[k]]==true;var levelSpacer=new Element("img");levelSpacer.setAttribute("src",this.imagesFolder+this.GetSpacerIcon(isLastSibling,j,treeLevel,i,treeData.length));nodeDiv.insert(levelSpacer);}
var expansionIcon=new Element("img",{id:this.treeName+"_Expand_"+treeData[i].id});if(!treeData[i].is_leaf){expansionIcon.onclick=this.ExpandCollapse.bind(this,treeData[i].id);if(i==treeData.length-1){this.expandedNodeBottom[treeData[i].id]=true;expansionIcon.src=this.imagesFolder+this.GetExpanderImage(true,false,false);}else{this.expandedNodeBottom[treeData[i].id]=false;expansionIcon.src=this.imagesFolder+this.GetExpanderImage(false,false,false);}}else{expansionIcon.src=this.imagesFolder+this.GetExpanderImage(false,false,true);}
nodeDiv.insert(expansionIcon);nodeDiv.insert(new Element("img",{className:'nodeIcon',src:treeData[i].icon?treeData[i].icon:this.imagesFolder+"page.gif"}));var nodeLink=new Element("a",{id:this.treeName+"_Link_"+treeData[i].id,onClick:treeData[i].url,className:this.nodeCssClass});nodeDiv.insert(nodeLink.insert(treeData[i].text));var childNodeDiv=new Element("div",{id:this.treeName+"_ChildNodes_"+treeData[i].id});parentNode.insert(nodeDiv.insert(childNodeDiv));this.treeLevels[treeData[i].id]=treeLevel+1;}
this.loadedNodes[parentNodeId]=true;this.expandedNodes[parentNodeId]=true;if(this.selectedNodesArray.length>1){var expandNode=this.selectedNodesArray.pop();this.LoadTree(expandNode);}else{this.Select(this.selectedNodesArray.pop());}
this.callback_after_render(parentNodeId,(parentNodeId==-1)?parentNode:$(this.treeName+"_Node_"+parentNodeId));};eTree.prototype.ExpandCollapse=function(nodeId){if(this.expandingImage!=null){return;}
var expander=$(this.treeName+"_Expand_"+nodeId);expander.src=this.imagesFolder+this.GetExpanderImage(this.expandedNodeBottom[nodeId],!this.expandedNodes[nodeId]);if(this.expandedNodes[nodeId]){$(this.treeName+"_ChildNodes_"+nodeId).hide();this.expandedNodes[nodeId]=false;}else{if(!this.loadedNodes[nodeId]){this.LoadTree(nodeId);}else{$(this.treeName+"_ChildNodes_"+nodeId).show();this.expandedNodes[nodeId]=true;}}};eTree.prototype.Select=function(nodeId){var $node=$(this.treeName+"_Link_"+nodeId);if(this.prevSelectedNodeId!=-1&&nodeId!=undefined){$(this.treeName+"_Link_"+this.prevSelectedNodeId).removeClassName(this.selectedNodeCssClass);}
if($node){$node.removeClassName(this.nodeCssClass).addClassName(this.selectedNodeCssClass);}
this.prevSelectedNodeId=nodeId;};eTree.prototype.GetSpacerIcon=function(isLastSibling,x,xmax,y,ymax){if(x==xmax-1){if(y==ymax-1){return"joinbottom.gif";}else{return"join.gif";}}
if(isLastSibling){return"empty.gif";}else{return"line.gif";}};eTree.prototype.GetExpanderImage=function(isBottom,isExpanded,isLeaf){if(isLeaf){return"leaf.gif";}else{if(isBottom){if(isExpanded){return"minusbottom.gif";}else{return"plusbottom.gif";}}else{if(isExpanded){return"minus.gif";}else{return"plus.gif";}}}};var jscolor={dir:'images/jscolor/',bindClass:'jscolor',binding:true,preloading:true,install:function(){jscolor.addEvent(window,'load',jscolor.init);},init:function(){if(jscolor.binding){jscolor.bind();}
if(jscolor.preloading){jscolor.preload();}},getDir:function(){if(!jscolor.dir){var detected=jscolor.detectDir();jscolor.dir=detected!==false?detected:'jscolor/';}
return jscolor.dir;},detectDir:function(){var base=location.href;var e=document.getElementsByTagName('base');for(var i=0;i<e.length;i+=1){if(e[i].href){base=e[i].href;}}
var e=document.getElementsByTagName('script');for(var i=0;i<e.length;i+=1){if(e[i].src&&/(^|\/)jscolor\.js([?#].*)?$/i.test(e[i].src)){var src=new jscolor.URI(e[i].src);var srcAbs=src.toAbsolute(base);srcAbs.path=srcAbs.path.replace(/[^\/]+$/,'');srcAbs.query=null;srcAbs.fragment=null;return srcAbs.toString();}}
return false;},bind:function(){var matchClass=new RegExp('(^|\\s)('+jscolor.bindClass+')\\s*(\\{[^}]*\\})?','i');var e=document.getElementsByTagName('input');for(var i=0;i<e.length;i+=1){var m;if(!e[i].color&&e[i].className&&(m=e[i].className.match(matchClass))){var prop={};if(m[3]){try{prop=(new Function('return ('+m[3]+')'))();}catch(eInvalidProp){}}
e[i].color=new jscolor.color(e[i],prop);}}},preload:function(){for(var fn in jscolor.imgRequire){if(jscolor.imgRequire.hasOwnProperty(fn)){jscolor.loadImage(fn);}}},images:{pad:[181,101],sld:[16,101],cross:[15,15],arrow:[7,11]},imgRequire:{},imgLoaded:{},requireImage:function(filename){jscolor.imgRequire[filename]=true;},loadImage:function(filename){if(!jscolor.imgLoaded[filename]){jscolor.imgLoaded[filename]=new Image();jscolor.imgLoaded[filename].src=jscolor.getDir()+filename;}},fetchElement:function(mixed){return typeof mixed==='string'?document.getElementById(mixed):mixed;},addEvent:function(el,evnt,func){if(el){if(el.addEventListener){el.addEventListener(evnt,func,false);}else if(el.attachEvent){el.attachEvent('on'+evnt,func);}}},fireEvent:function(el,evnt){if(!el){return;}
if(document.createEvent){var ev=document.createEvent('HTMLEvents');ev.initEvent(evnt,true,true);el.dispatchEvent(ev);}else if(document.createEventObject){var ev=document.createEventObject();el.fireEvent('on'+evnt,ev);}else if(el['on'+evnt]){el['on'+evnt]();}},getElementPos:function(e){var e1=e,e2=e;var x=0,y=0;if(e1.offsetParent){do{x+=e1.offsetLeft;y+=e1.offsetTop;}while(e1=e1.offsetParent);}
while((e2=e2.parentNode)&&e2.nodeName.toUpperCase()!=='BODY'){x-=e2.scrollLeft;y-=e2.scrollTop;}
return[x,y];},getElementSize:function(e){return[e.offsetWidth,e.offsetHeight];},getRelMousePos:function(e){var x=0,y=0;if(!e){e=window.event;}
if(typeof e.offsetX==='number'){x=e.offsetX;y=e.offsetY;}else if(typeof e.layerX==='number'){x=e.layerX;y=e.layerY;}
return{x:x,y:y};},getViewPos:function(){if(typeof window.pageYOffset==='number'){return[window.pageXOffset,window.pageYOffset];}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){return[document.body.scrollLeft,document.body.scrollTop];}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){return[document.documentElement.scrollLeft,document.documentElement.scrollTop];}else{return[0,0];}},getViewSize:function(){if(typeof window.innerWidth==='number'){return[window.innerWidth,window.innerHeight];}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){return[document.body.clientWidth,document.body.clientHeight];}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){return[document.documentElement.clientWidth,document.documentElement.clientHeight];}else{return[0,0];}},URI:function(uri){this.scheme=null;this.authority=null;this.path='';this.query=null;this.fragment=null;this.parse=function(uri){var m=uri.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);this.scheme=m[3]?m[2]:null;this.authority=m[5]?m[6]:null;this.path=m[7];this.query=m[9]?m[10]:null;this.fragment=m[12]?m[13]:null;return this;};this.toString=function(){var result='';if(this.scheme!==null){result=result+this.scheme+':';}
if(this.authority!==null){result=result+'//'+this.authority;}
if(this.path!==null){result=result+this.path;}
if(this.query!==null){result=result+'?'+this.query;}
if(this.fragment!==null){result=result+'#'+this.fragment;}
return result;};this.toAbsolute=function(base){var base=new jscolor.URI(base);var r=this;var t=new jscolor.URI;if(base.scheme===null){return false;}
if(r.scheme!==null&&r.scheme.toLowerCase()===base.scheme.toLowerCase()){r.scheme=null;}
if(r.scheme!==null){t.scheme=r.scheme;t.authority=r.authority;t.path=removeDotSegments(r.path);t.query=r.query;}else{if(r.authority!==null){t.authority=r.authority;t.path=removeDotSegments(r.path);t.query=r.query;}else{if(r.path===''){t.path=base.path;if(r.query!==null){t.query=r.query;}else{t.query=base.query;}}else{if(r.path.substr(0,1)==='/'){t.path=removeDotSegments(r.path);}else{if(base.authority!==null&&base.path===''){t.path='/'+r.path;}else{t.path=base.path.replace(/[^\/]+$/,'')+r.path;}
t.path=removeDotSegments(t.path);}
t.query=r.query;}
t.authority=base.authority;}
t.scheme=base.scheme;}
t.fragment=r.fragment;return t;};function removeDotSegments(path){var out='';while(path){if(path.substr(0,3)==='../'||path.substr(0,2)==='./'){path=path.replace(/^\.+/,'').substr(1);}else if(path.substr(0,3)==='/./'||path==='/.'){path='/'+path.substr(3);}else if(path.substr(0,4)==='/../'||path==='/..'){path='/'+path.substr(4);out=out.replace(/\/?[^\/]*$/,'');}else if(path==='.'||path==='..'){path='';}else{var rm=path.match(/^\/?[^\/]*/)[0];path=path.substr(rm.length);out=out+rm;}}
return out;}
if(uri){this.parse(uri);}},color:function(target,prop){this.required=true;this.adjust=true;this.hash=false;this.caps=true;this.slider=true;this.valueElement=target;this.styleElement=target;this.onImmediateChange=null;this.hsv=[0,0,1];this.rgb=[1,1,1];this.minH=0;this.maxH=6;this.minS=0;this.maxS=1;this.minV=0;this.maxV=1;this.pickerOnfocus=true;this.pickerMode='HSV';this.pickerPosition='bottom';this.pickerSmartPosition=true;this.pickerButtonHeight=20;this.pickerClosable=false;this.pickerCloseText='Close';this.pickerButtonColor='ButtonText';this.pickerFace=10;this.pickerFaceColor='ThreeDFace';this.pickerBorder=1;this.pickerBorderColor='ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight';this.pickerInset=1;this.pickerInsetColor='ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow';this.pickerZIndex=10000;for(var p in prop){if(prop.hasOwnProperty(p)){this[p]=prop[p];}}
this.hidePicker=function(){if(isPickerOwner()){removePicker();}};this.showPicker=function(){if(!isPickerOwner()){var tp=jscolor.getElementPos(target);var ts=jscolor.getElementSize(target);var vp=jscolor.getViewPos();var vs=jscolor.getViewSize();var ps=getPickerDims(this);var a,b,c;switch(this.pickerPosition.toLowerCase()){case'left':a=1;b=0;c=-1;break;case'right':a=1;b=0;c=1;break;case'top':a=0;b=1;c=-1;break;default:a=0;b=1;c=1;break;}
var l=(ts[b]+ps[b])/2;if(!this.pickerSmartPosition){var pp=[tp[a],tp[b]+ts[b]-l+l*c];}else{var pp=[-vp[a]+tp[a]+ps[a]>vs[a]?(-vp[a]+tp[a]+ts[a]/2>vs[a]/2&&tp[a]+ts[a]-ps[a]>=0?tp[a]+ts[a]-ps[a]:tp[a]):tp[a],-vp[b]+tp[b]+ts[b]+ps[b]-l+l*c>vs[b]?(-vp[b]+tp[b]+ts[b]/2>vs[b]/2&&tp[b]+ts[b]-l-l*c>=0?tp[b]+ts[b]-l-l*c:tp[b]+ts[b]-l+l*c):(tp[b]+ts[b]-l+l*c>=0?tp[b]+ts[b]-l+l*c:tp[b]+ts[b]-l-l*c)];}
drawPicker(pp[a],pp[b]);}};this.importColor=function(){if(!valueElement){this.exportColor();}else{if(!this.adjust){if(!this.fromString(valueElement.value,leaveValue)){styleElement.style.backgroundImage=styleElement.jscStyle.backgroundImage;styleElement.style.backgroundColor=styleElement.jscStyle.backgroundColor;styleElement.style.color=styleElement.jscStyle.color;this.exportColor(leaveValue|leaveStyle);}}else if(!this.required&&/^\s*$/.test(valueElement.value)){valueElement.value='';styleElement.style.backgroundImage=styleElement.jscStyle.backgroundImage;styleElement.style.backgroundColor=styleElement.jscStyle.backgroundColor;styleElement.style.color=styleElement.jscStyle.color;this.exportColor(leaveValue|leaveStyle);}else if(this.fromString(valueElement.value)){}else{this.exportColor();}}};this.exportColor=function(flags){if(!(flags&leaveValue)&&valueElement){var value=this.toString();if(this.caps){value=value.toUpperCase();}
if(this.hash){value='#'+value;}
valueElement.value=value;}
if(!(flags&leaveStyle)&&styleElement){styleElement.style.backgroundImage="none";styleElement.style.backgroundColor='#'+this.toString();styleElement.style.color=0.213*this.rgb[0]+
0.715*this.rgb[1]+
0.072*this.rgb[2]<0.5?'#FFF':'#000';}
if(!(flags&leavePad)&&isPickerOwner()){redrawPad();}
if(!(flags&leaveSld)&&isPickerOwner()){redrawSld();}};this.fromHSV=function(h,s,v,flags){if(h!==null){h=Math.max(0.0,this.minH,Math.min(6.0,this.maxH,h));}
if(s!==null){s=Math.max(0.0,this.minS,Math.min(1.0,this.maxS,s));}
if(v!==null){v=Math.max(0.0,this.minV,Math.min(1.0,this.maxV,v));}
this.rgb=HSV_RGB(h===null?this.hsv[0]:(this.hsv[0]=h),s===null?this.hsv[1]:(this.hsv[1]=s),v===null?this.hsv[2]:(this.hsv[2]=v));this.exportColor(flags);};this.fromRGB=function(r,g,b,flags){if(r!==null){r=Math.max(0.0,Math.min(1.0,r));}
if(g!==null){g=Math.max(0.0,Math.min(1.0,g));}
if(b!==null){b=Math.max(0.0,Math.min(1.0,b));}
var hsv=RGB_HSV(r===null?this.rgb[0]:r,g===null?this.rgb[1]:g,b===null?this.rgb[2]:b);if(hsv[0]!==null){this.hsv[0]=Math.max(0.0,this.minH,Math.min(6.0,this.maxH,hsv[0]));}
if(hsv[2]!==0){this.hsv[1]=hsv[1]===null?null:Math.max(0.0,this.minS,Math.min(1.0,this.maxS,hsv[1]));}
this.hsv[2]=hsv[2]===null?null:Math.max(0.0,this.minV,Math.min(1.0,this.maxV,hsv[2]));var rgb=HSV_RGB(this.hsv[0],this.hsv[1],this.hsv[2]);this.rgb[0]=rgb[0];this.rgb[1]=rgb[1];this.rgb[2]=rgb[2];this.exportColor(flags);};this.fromString=function(hex,flags){var m=hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);if(!m){return false;}else{if(m[1].length===6){this.fromRGB(parseInt(m[1].substr(0,2),16)/ 255,parseInt(m[1].substr(2,2),16)/ 255,parseInt(m[1].substr(4,2),16)/ 255,flags);}else{this.fromRGB(parseInt(m[1].charAt(0)+m[1].charAt(0),16)/ 255,parseInt(m[1].charAt(1)+m[1].charAt(1),16)/ 255,parseInt(m[1].charAt(2)+m[1].charAt(2),16)/ 255,flags);}
return true;}};this.toString=function(){return((0x100|Math.round(255*this.rgb[0])).toString(16).substr(1)+
(0x100|Math.round(255*this.rgb[1])).toString(16).substr(1)+
(0x100|Math.round(255*this.rgb[2])).toString(16).substr(1));};function RGB_HSV(r,g,b){var n=Math.min(Math.min(r,g),b);var v=Math.max(Math.max(r,g),b);var m=v-n;if(m===0){return[null,0,v];}
var h=r===n?3+(b-g)/m:(g===n?5+(r-b)/m:1+(g-r)/m);return[h===6?0:h,m/v,v];}
function HSV_RGB(h,s,v){if(h===null){return[v,v,v];}
var i=Math.floor(h);var f=i%2?h-i:1-(h-i);var m=v*(1-s);var n=v*(1-s*f);switch(i){case 6:case 0:return[v,n,m];case 1:return[n,v,m];case 2:return[m,v,n];case 3:return[m,n,v];case 4:return[n,m,v];case 5:return[v,m,n];}}
function removePicker(){delete jscolor.picker.owner;document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB);}
function drawPicker(x,y){if(!jscolor.picker){jscolor.picker={box:document.createElement('div'),boxB:document.createElement('div'),pad:document.createElement('div'),padB:document.createElement('div'),padM:document.createElement('div'),sld:document.createElement('div'),sldB:document.createElement('div'),sldM:document.createElement('div'),btn:document.createElement('div'),btnS:document.createElement('span'),btnT:document.createTextNode(THIS.pickerCloseText)};for(var i=0,segSize=4;i<jscolor.images.sld[1];i+=segSize){var seg=document.createElement('div');seg.style.height=segSize+'px';seg.style.fontSize='1px';seg.style.lineHeight='0';jscolor.picker.sld.appendChild(seg);}
jscolor.picker.sldB.appendChild(jscolor.picker.sld);jscolor.picker.box.appendChild(jscolor.picker.sldB);jscolor.picker.box.appendChild(jscolor.picker.sldM);jscolor.picker.padB.appendChild(jscolor.picker.pad);jscolor.picker.box.appendChild(jscolor.picker.padB);jscolor.picker.box.appendChild(jscolor.picker.padM);jscolor.picker.btnS.appendChild(jscolor.picker.btnT);jscolor.picker.btn.appendChild(jscolor.picker.btnS);jscolor.picker.box.appendChild(jscolor.picker.btn);jscolor.picker.boxB.appendChild(jscolor.picker.box);}
var p=jscolor.picker;p.box.onmouseup=p.box.onmouseout=function(){target.focus();};p.box.onmousedown=function(){abortBlur=true;};p.box.onmousemove=function(e){if(holdPad||holdSld){holdPad&&setPad(e);holdSld&&setSld(e);if(document.selection){document.selection.empty();}else if(window.getSelection){window.getSelection().removeAllRanges();}
dispatchImmediateChange();}};if('ontouchstart'in window){var handle_touchmove=function(e){var event={'offsetX':e.touches[0].pageX-touchOffset.X,'offsetY':e.touches[0].pageY-touchOffset.Y};if(holdPad||holdSld){holdPad&&setPad(event);holdSld&&setSld(event);dispatchImmediateChange();}
e.stopPropagation();e.preventDefault();};p.box.removeEventListener('touchmove',handle_touchmove,false);p.box.addEventListener('touchmove',handle_touchmove,false)}
p.padM.onmouseup=p.padM.onmouseout=function(){if(holdPad){holdPad=false;jscolor.fireEvent(valueElement,'change');}};p.padM.onmousedown=function(e){switch(modeID){case 0:if(THIS.hsv[2]===0){THIS.fromHSV(null,null,1.0);}
break;case 1:if(THIS.hsv[1]===0){THIS.fromHSV(null,1.0,null);}
break;}
holdSld=false;holdPad=true;setPad(e);dispatchImmediateChange();};if('ontouchstart'in window){p.padM.addEventListener('touchstart',function(e){touchOffset={'X':e.target.offsetParent.offsetLeft,'Y':e.target.offsetParent.offsetTop};this.onmousedown({'offsetX':e.touches[0].pageX-touchOffset.X,'offsetY':e.touches[0].pageY-touchOffset.Y});});}
p.sldM.onmouseup=p.sldM.onmouseout=function(){if(holdSld){holdSld=false;jscolor.fireEvent(valueElement,'change');}};p.sldM.onmousedown=function(e){holdPad=false;holdSld=true;setSld(e);dispatchImmediateChange();};if('ontouchstart'in window){p.sldM.addEventListener('touchstart',function(e){touchOffset={'X':e.target.offsetParent.offsetLeft,'Y':e.target.offsetParent.offsetTop};this.onmousedown({'offsetX':e.touches[0].pageX-touchOffset.X,'offsetY':e.touches[0].pageY-touchOffset.Y});});}
var dims=getPickerDims(THIS);p.box.style.width=dims[0]+'px';p.box.style.height=dims[1]+'px';p.boxB.style.position='absolute';p.boxB.style.clear='both';p.boxB.style.left=x+'px';p.boxB.style.top=y+'px';p.boxB.style.zIndex=THIS.pickerZIndex;p.boxB.style.border=THIS.pickerBorder+'px solid';p.boxB.style.borderColor=THIS.pickerBorderColor;p.boxB.style.background=THIS.pickerFaceColor;p.pad.style.width=jscolor.images.pad[0]+'px';p.pad.style.height=jscolor.images.pad[1]+'px';p.padB.style.position='absolute';p.padB.style.left=THIS.pickerFace+'px';p.padB.style.top=THIS.pickerFace+'px';p.padB.style.border=THIS.pickerInset+'px solid';p.padB.style.borderColor=THIS.pickerInsetColor;p.padM.style.position='absolute';p.padM.style.left='0';p.padM.style.top='0';p.padM.style.width=THIS.pickerFace+2*THIS.pickerInset+jscolor.images.pad[0]+jscolor.images.arrow[0]+'px';p.padM.style.height=p.box.style.height;p.padM.style.cursor='crosshair';p.sld.style.overflow='hidden';p.sld.style.width=jscolor.images.sld[0]+'px';p.sld.style.height=jscolor.images.sld[1]+'px';p.sldB.style.display=THIS.slider?'block':'none';p.sldB.style.position='absolute';p.sldB.style.right=THIS.pickerFace+'px';p.sldB.style.top=THIS.pickerFace+'px';p.sldB.style.border=THIS.pickerInset+'px solid';p.sldB.style.borderColor=THIS.pickerInsetColor;p.sldM.style.display=THIS.slider?'block':'none';p.sldM.style.position='absolute';p.sldM.style.right='0';p.sldM.style.top='0';p.sldM.style.width=jscolor.images.sld[0]+jscolor.images.arrow[0]+THIS.pickerFace+2*THIS.pickerInset+'px';p.sldM.style.height=p.box.style.height;try{p.sldM.style.cursor='pointer';}catch(eOldIE){p.sldM.style.cursor='hand';}
function setBtnBorder(){var insetColors=THIS.pickerInsetColor.split(/\s+/);var pickerOutsetColor=insetColors.length<2?insetColors[0]:insetColors[1]+' '+insetColors[0]+' '+insetColors[0]+' '+insetColors[1];p.btn.style.borderColor=pickerOutsetColor;}
p.btn.style.display=THIS.pickerClosable?'block':'none';p.btn.style.position='absolute';p.btn.style.left=THIS.pickerFace+'px';p.btn.style.bottom=THIS.pickerFace+'px';p.btn.style.padding='0 15px';p.btn.style.height='18px';p.btn.style.border=THIS.pickerInset+'px solid';setBtnBorder();p.btn.style.color=THIS.pickerButtonColor;p.btn.style.font='12px sans-serif';p.btn.style.textAlign='center';try{p.btn.style.cursor='pointer';}catch(eOldIE){p.btn.style.cursor='hand';}
p.btn.onmousedown=function(){THIS.hidePicker();};p.btnS.style.lineHeight=p.btn.style.height;switch(modeID){case 0:var padImg='hs.png';break;case 1:var padImg='hv.png';break;}
p.padM.style.backgroundImage="url('"+jscolor.getDir()+"cross.gif')";p.padM.style.backgroundRepeat="no-repeat";p.sldM.style.backgroundImage="url('"+jscolor.getDir()+"arrow.gif')";p.sldM.style.backgroundRepeat="no-repeat";p.pad.style.backgroundImage="url('"+jscolor.getDir()+padImg+"')";p.pad.style.backgroundRepeat="no-repeat";p.pad.style.backgroundPosition="0 0";redrawPad();redrawSld();jscolor.picker.owner=THIS;document.getElementsByTagName('body')[0].appendChild(p.boxB);}
function getPickerDims(o){var dims=[2*o.pickerInset+2*o.pickerFace+jscolor.images.pad[0]+
(o.slider?2*o.pickerInset+2*jscolor.images.arrow[0]+jscolor.images.sld[0]:0),o.pickerClosable?4*o.pickerInset+3*o.pickerFace+jscolor.images.pad[1]+o.pickerButtonHeight:2*o.pickerInset+2*o.pickerFace+jscolor.images.pad[1]];return dims;}
function redrawPad(){switch(modeID){case 0:var yComponent=1;break;case 1:var yComponent=2;break;}
var x=Math.round((THIS.hsv[0]/6)*(jscolor.images.pad[0]-1));var y=Math.round((1-THIS.hsv[yComponent])*(jscolor.images.pad[1]-1));jscolor.picker.padM.style.backgroundPosition=(THIS.pickerFace+THIS.pickerInset+x-Math.floor(jscolor.images.cross[0]/2))+'px '+
(THIS.pickerFace+THIS.pickerInset+y-Math.floor(jscolor.images.cross[1]/2))+'px';var seg=jscolor.picker.sld.childNodes;switch(modeID){case 0:var rgb=HSV_RGB(THIS.hsv[0],THIS.hsv[1],1);for(var i=0;i<seg.length;i+=1){seg[i].style.backgroundColor='rgb('+
(rgb[0]*(1-i/seg.length)*100)+'%,'+
(rgb[1]*(1-i/seg.length)*100)+'%,'+
(rgb[2]*(1-i/seg.length)*100)+'%)';}
break;case 1:var rgb,s,c=[THIS.hsv[2],0,0];var i=Math.floor(THIS.hsv[0]);var f=i%2?THIS.hsv[0]-i:1-(THIS.hsv[0]-i);switch(i){case 6:case 0:rgb=[0,1,2];break;case 1:rgb=[1,0,2];break;case 2:rgb=[2,0,1];break;case 3:rgb=[2,1,0];break;case 4:rgb=[1,2,0];break;case 5:rgb=[0,2,1];break;}
for(var i=0;i<seg.length;i+=1){s=1-1/(seg.length-1)*i;c[1]=c[0]*(1-s*f);c[2]=c[0]*(1-s);seg[i].style.backgroundColor='rgb('+
(c[rgb[0]]*100)+'%,'+
(c[rgb[1]]*100)+'%,'+
(c[rgb[2]]*100)+'%)';}
break;}}
function redrawSld(){switch(modeID){case 0:var yComponent=2;break;case 1:var yComponent=1;break;}
var y=Math.round((1-THIS.hsv[yComponent])*(jscolor.images.sld[1]-1));jscolor.picker.sldM.style.backgroundPosition='0 '+(THIS.pickerFace+THIS.pickerInset+y-Math.floor(jscolor.images.arrow[1]/2))+'px';}
function isPickerOwner(){return jscolor.picker&&jscolor.picker.owner===THIS;}
function blurTarget(){if(valueElement===target){THIS.importColor();}
if(THIS.pickerOnfocus){THIS.hidePicker();}}
function blurValue(){if(valueElement!==target){THIS.importColor();}}
function setPad(e){var mpos=jscolor.getRelMousePos(e);var x=mpos.x-THIS.pickerFace-THIS.pickerInset;var y=mpos.y-THIS.pickerFace-THIS.pickerInset;switch(modeID){case 0:THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)),1-y/(jscolor.images.pad[1]-1),null,leaveSld);break;case 1:THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)),null,1-y/(jscolor.images.pad[1]-1),leaveSld);break;}}
function setSld(e){var mpos=jscolor.getRelMousePos(e);var y=mpos.y-THIS.pickerFace-THIS.pickerInset;switch(modeID){case 0:THIS.fromHSV(null,null,1-y/(jscolor.images.sld[1]-1),leavePad);break;case 1:THIS.fromHSV(null,1-y/(jscolor.images.sld[1]-1),null,leavePad);break;}}
function dispatchImmediateChange(){if(THIS.onImmediateChange){var callback;if(typeof THIS.onImmediateChange==='string'){callback=new Function(THIS.onImmediateChange);}else{callback=THIS.onImmediateChange;}
callback.call(THIS);}}
var THIS=this;var modeID=this.pickerMode.toLowerCase()==='hvs'?1:0;var abortBlur=false;var
valueElement=jscolor.fetchElement(this.valueElement),styleElement=jscolor.fetchElement(this.styleElement);var
holdPad=false,holdSld=false,touchOffset={};var
leaveValue=1<<0,leaveStyle=1<<1,leavePad=1<<2,leaveSld=1<<3;jscolor.addEvent(target,'focus',function(){if(THIS.pickerOnfocus){THIS.showPicker();}});jscolor.addEvent(target,'blur',function(){if(!abortBlur){window.setTimeout(function(){abortBlur||blurTarget();abortBlur=false;},0);}else{abortBlur=false;}});if(valueElement){var updateField=function(){THIS.fromString(valueElement.value,leaveValue);dispatchImmediateChange();};jscolor.addEvent(valueElement,'keyup',updateField);jscolor.addEvent(valueElement,'input',updateField);jscolor.addEvent(valueElement,'blur',blurValue);valueElement.setAttribute('autocomplete','off');}
if(styleElement){styleElement.jscStyle={backgroundImage:styleElement.style.backgroundImage,backgroundColor:styleElement.style.backgroundColor,color:styleElement.style.color};}
switch(modeID){case 0:jscolor.requireImage('hs.png');break;case 1:jscolor.requireImage('hv.png');break;}
jscolor.requireImage('cross.gif');jscolor.requireImage('arrow.gif');this.importColor();}};function isys_popup_open(p_url,p_name,p_centered,p_config){var cX,cY,strConf='';if(p_centered){if(document.all){cX=((document.body.offsetWidth / 2)-(p_config['width']/ 2));cY=((document.body.offsetHeight / 2)-(p_config['height']/ 2));}else{cX=((outerWidth / 2)-(p_config['width']/ 2));cY=((outerHeight / 2)-(p_config['height']/ 2));}}
for(var prop in p_config){if(prop=='top'&&p_centered)p_config['top']=cY;if(prop=='left'&&p_centered)p_config['left']=cX;strConf=strConf+prop+'='+p_config[prop]+',';}
if(p_centered){strConf=strConf+",left="+cX+",top="+cY;}else{while(strConf.substring(strConf.length-1,strConf.length)==','){strConf=strConf.substring(0,strConf.length-1);}}
strConf+=",dependant=yes";var objWnd=window.open(p_url,p_name,strConf);if(objWnd){objWnd.focus();}}
function isys_popup_receiver(p_data,p_form_submit){var l_destElement=document.getElementsByName('popupReceiver')[0];if(l_destElement){l_destElement.value=p_data;if(typeof C__GET__NAVMODE=="undefined"){alert('die js var C__GET__NAVMODE muss im Template bekannt gemacht werden');}
if(typeof C__NAVMODE__JS_ACTION=="undefined"){alert('die js var C__NAVMODE__JS_ACTION muss im Template bekannt gemacht werden');}
e=document.getElementsByName(C__GET__NAVMODE)[0];if(e){e.value=C__NAVMODE__JS_ACTION;if(p_form_submit==1){document.forms['isys_form'].submit();}}}}"use strict";window.TableComponent=Class.create({initialize:function(prefix,options){this.$table=$(prefix);this.$tableHeader=$(prefix+'-header');this.options={scoped:false,routeParams:{},columnWidth:150,defaultValueField:'',dragDrop:false,dragDropBoxContent:'%count% object(s)',checkboxes:false,resizeColumns:false,resizeColumnAjaxURL:'',columnSizes:[],order:false,orderColumns:[],currentOrderColumn:'',currentOrderDirection:'',rowClick:false,rowClickUrl:'?objID=%id%',keyboardCommands:false,orderAscendingMessage:'',orderDescendingMessage:'',loadingMessage:'',quickInfoActive:true,quickInfoDelay:0.5,replacerOptions:{},translation:{pager:{prompt:'Jump to the page',nanPage:'Invalid page number',notFound:'Page is not found'},filter:{and:' and '}},autocomplete:{active:0,baseUrl:'',placeholder:'Search...',options:{}},ajaxMethod:'get',ajaxParams:{},directEditMode:0};Object.extend(this.options,options||{});this.$context=$(prefix+'-container').up(1);this.replaceTablePlaceholders=new ReplacePlaceholders(this.options.replacerOptions);this.progressTablePlaceholders();this.initBase(prefix);this.subscribe('click','[data-column-role="reset"]',this.resetColumns.bind(this));this.subscribe('change','[data-filter-role="field"]',this.onFieldChange.bind(this));this.subscribe('change','select[data-filter-role="value"],[type=radio][data-filter-role="value"]',this.onFilterChange.bind(this));this.subscribe('keyup','input[data-filter-role="value"]',this.onFilterChange.bind(this));this.subscribe('click','.mainTablePager .dots',this.onPagerJump.bind(this));this.subscribe('click','.mainTablePager a',this.onPagerClick.bind(this));this.subscribe('click','[data-filter-role="filter"]',this.loadDataWithFilters.bind(this));this.subscribe('keyup','[data-filter-role="default"]',this.onDefaultFieldChange.bind(this));this.subscribe('click','[data-filter-role="default"]',this.onDefaultFieldClick.bind(this));this.subscribe('click','[data-order-field]',this.onOrderBy.bind(this));this.subscribe('keydown','[data-filter-role="value"], [data-filter-role="default"]',function(e){if(e.keyCode===13){e.preventDefault();this.loadDataWithFilters();}}.bind(this));this.subscribe('click','[data-filter-role="reset"]',this.resetFilters.bind(this));this.subscribe('click','[data-toggle-role="toggle"]',this.toggleFilterExpand.bind(this));this.subscribe('change','[name="id[]"]',this.onSelectionChanged.bind(this,'[name="id[]"]',$('navbar_item_C__NAVMODE__EDIT')));this.subscribe('change','[name="table_ids[]"]',this.onSelectionChanged.bind(this,'[name="table_ids[]"]',$('navbar_item_C__NAVMODE__DUPLICATE')));this.initAutocomplete();if(this.$table){this.$table.removeClassName('is-loading');}
if(this.$context.down('[data-filter-default]')&&!this.options.scoped){setTimeout(this.$context.down('[data-filter-default]').focus.bind(this.$context.down('[data-filter-default]')),0);}
this.onFilterChange();$$('.autocomplete.global-search').invoke('hide');this.subscribe("scroll",'.table-body',this.syncColumnSizes.bind(this));},subscribe:function(event,selector,callback){this.$context.select(selector).forEach(function(e){e.on(event,callback);});},initBase:function(prefix){this.$table=$(prefix);if(!this.$table){return;}
this.$cols=this.$table.down('colgroup').select('col');this.$head=this.$tableHeader.down('thead');this.$body=this.$table.down('tbody');this.$header=this.$head.select('th');this.$dragContainer=new Element('div',{className:'mainTableDragContainer'});this.$dragger=new Element('div',{className:'mainTableDragger hide'});this.$lastClickedCheckbox=null;this.$ghost=null;this.$tableHeader.setStyle({minWidth:(this.$cols.length*this.options.columnWidth+10)+'px'});this.$table.setStyle({minWidth:this.$cols.length*this.options.columnWidth+'px'});this.subscribe("scroll",'.table-body',function(){this.$context.down('.table-header').scrollLeft=this.$context.down('.table-body').scrollLeft;}.bind(this));if(this.options.resizeColumns&&this.options.resizeColumnAjaxURL){this.prepareColumnDrag();}
if(this.options.dragDrop){this.prepareDragDrop();}
if(this.options.order){this.prepareTableOrdering();}
if(!Object.isArray(this.options.columnSizes)){this.options.columnSizes=[];}
if(this.options.columnSizes.length===this.$header.length){this.setInitialColumnWidths(this.options.columnSizes);}
else{this.resetColumns();}
this.onFilterChange();this.callbackManager=new window.TableComponentCallbackManager(this.$head,this.$body,this.options);this.prepareObserver();if(!this.getCached(this.options.routeParams)){this.cache(this.options.routeParams,this.$context.innerHTML)}},initAutocomplete:function(){var autocomplete=this.options.autocomplete,defaultFilter=this.$context.down('[data-filter-default]'),defaultFilterField=this.options.defaultValueField,that=this;if(!autocomplete.active||!defaultFilter){return;}
var cachedBackend=new Autocompleter.Cache(function(searchString,suggest){var parameters={suggestion:1,rand:(new Date()).getTime()};parameters['tableFilter['+defaultFilterField+']']=defaultFilter?defaultFilter.getValue():'';new Ajax.Request(autocomplete.baseUrl,{method:'get',parameters:parameters,onSuccess:function(response){suggest(response.responseJSON);}});},autocomplete.options),cachedLookup=cachedBackend.lookup.bind(cachedBackend),rnd=Math.floor(Math.random()*9999),el_choices='theChoices'+rnd;$('body').insert(new Element('div',{id:el_choices,className:'autocomplete global-search'}));new Autocompleter.Json(defaultFilter,el_choices,cachedLookup,{frequency:.15,choices:85,searchPlaceHolder:autocomplete.placeholder,updateElement:function(li){var link=li.getAttribute('data-link'),search=li.getAttribute('data-search');if(link){that.redirect(encodeURI(link));this.selectedItem=li;}
if(search=='1'){that.loadDataWithFilters();return true;}}});},buildUrl:function(){var params={},i,j;for(i in arguments){Object.extend(params,arguments[i]);}
return window.location.pathname+'?'+Object.toQueryString(params);},loadData:function(params,force){var i,cached;for(i in this.options.routeParams){if(this.options.routeParams[i]==''||(force&&i.indexOf('tableFilter[')>-1)||['ajax','only_content','scoped'].in_array(i)){delete this.options.routeParams[i];}}
Object.extend(this.options.routeParams,params);if(!this.options.scoped){window.pushState({},'',this.buildUrl(this.options.routeParams));}
cached=this.getCached(this.options.routeParams);if(cached){this.$context.update(cached);}else{if(this.$table){this.$table.addClassName('is-loading');}
new Ajax.Request(this.buildUrl({call:'category'},this.options.routeParams,{ajax:1,only_content:1,scoped:this.options.scoped?1:0}),{method:this.options.ajaxMethod,parameters:this.options.ajaxParams,onComplete:function(xhr){var data=xhr.responseText.trim();this.cache(this.options.routeParams,data);this.$context.update(data);}.bind(this)});}},getCacheKey:function(params){var defaultParams={page:1};return JSON.stringify(Object.extend(defaultParams,params));},getCached:function(params){var key=this.getCacheKey(params);return window.tableCache&&window.tableCache[key];},cache:function(params,data){var key=this.getCacheKey(params);window.tableCache=window.tableCache||{};window.tableCache[key]=data;},loadDataWithFilters:function(){this.loadData(this.retrieveUrlPartsFiltered({page:1,filtered:1}),true);},retrieveUrlPartsFiltered:function(params){var values=this.$context.select('[data-filter-role="value"]:not([readonly])'),i,input,name,value,filter=params;for(i=0;i<values.length;++i){input=values[i];if(input){name=input.getAttribute('name');value=input.getValue();if(input.tagName==='SELECT'&&value<0){continue;}
if(value||this.options.routeParams[name]){filter[name]=value;}}}
return filter;},onPagerJump:function(){var page=prompt(this.options.translation.pager.prompt,'1');page=parseInt(page);if(isNaN(page)){idoit.Notify.warning(this.options.translation.pager.nanPage,{life:5});return;}
if(page<1||page>parseInt(this.options.pages)){idoit.Notify.warning(this.options.translation.pager.notFound.replace('%pages%',this.options.pages),{life:5});return;}
this.loadData({page:page});},onPagerClick:function(e){var $page=e.findElement('a'),page=($page.readAttribute('href').toQueryParams().page||1);e.preventDefault();$page.update(new Element('img',{src:window.dir_images+'ajax-loading.gif'}));this.loadData({page:page});},onFilterChange:function(){var fields=this.$context.select('[data-filter-role="value"]'),i,input,label,name,value,filter=this.$context.down('[data-role="search"]'),operationField=this.$context.down('[name="tableFilter[operation]"]:checked'),operationLabel=operationField?this.$context.down('label[for="'+operationField.getAttribute('id')+'"]'):null,operation=(operationLabel?operationLabel.textContent:this.options.translation.filter.and).trim(),key,re,texts={};if(!filter){return;}
if(this.$body){this.$body.select('.searchResult').invoke('removeClassName','searchResult');}
for(i=0;i<fields.length;++i){input=fields[i];if(input){name=input.getAttribute('name');label=this.$context.down('[for="'+name+'"]');key=name.substring('tableFilter['.length,name.length-1);if(!label||key=='operation'){continue;}
label=label.textContent||label.innerText||label.innerHTML;value=input.getValue();if(input.tagName==='SELECT'){if(value<0){continue;}
value=input.down(':selected')||{};value=value.textContent||value.innerText||value.innerHTML;}
if(value){texts[name]={text:label+' = "'+value+'"',value:input.getValue()};re=value.toLowerCase();this.$context.select('[data-property'+(key=='*'?'':'="'+key+'"')+']').filter(function(cell){return cell.textContent.toLowerCase().indexOf(re)>=0;}).invoke('addClassName','searchResult');}}}
var text=Object.values(texts).map(function(a){return a.text;}).join(' '+operation+' ');filter.parentElement.setStyle({display:text?'block':'none'});filter.setValue(text);},toggleFilterExpand:function(){var filterExpandButton=this.$context.down('[data-toggle-role="toggle"]'),id=filterExpandButton.getAttribute('data-toggle-id'),advancedFilter=this.$context.down('[data-toggle-role="area"][data-toggle-id="'+id+'"]'),toggleClass=advancedFilter&&advancedFilter.getAttribute('data-toggle-class');if(!advancedFilter){return;}
advancedFilter.toggleClassName(toggleClass);if(advancedFilter.hasClassName(toggleClass)){filterExpandButton.writeAttribute('src',window.dir_images+'icons/silk/bullet_arrow_down.png');}
else{filterExpandButton.writeAttribute('src',window.dir_images+'icons/silk/bullet_arrow_up.png');advancedFilter.down('input').focus();}},onSelectionChanged:function(selection,element){var isMultiple=$(this.$table).select(selection+':checked').length>1;if(element){element.toggleClassName('non-clickable',isMultiple).toggleClassName('navbar_item_inactive',isMultiple);}},onFieldChange:function(e){var field=e.findElement('[data-filter-role="field"]'),name=field.getAttribute('data-filter-field'),params={};try{params=JSON.parse(field.getAttribute('data-filter-params'));}
catch(e){}
params[name]=e.target.value;this.loadData(params);},onDefaultFieldChange:function(e){var input=e.findElement('input'),name=input.name;this.$context.select('[name="'+name+'"]').forEach(function(a){if(a!=input){a.setValue(input.getValue());}});},onDefaultFieldClick:function(){if(this.$context.down('[data-filter-default][readonly]')){this.toggleFilterExpand();}},onOrderBy:function(e){var field=e.findElement('[data-order-field]').getAttribute('data-order-field'),direction=e.findElement('[data-order-direction]').getAttribute('data-order-direction');direction=direction=='ASC'?'DESC':'ASC';this.options.currentOrderColumn=field;this.options.currentOrderDirection=direction;this.loadData({orderBy:field,orderByDir:direction});},resetFilters:function(){this.$context.select('input[data-filter-role="value"]').invoke('setValue','');this.$context.select('select[data-filter-role="value"]').invoke('setValue','-1');this.loadDataWithFilters();},setInitialColumnWidths:function(columnSizes){for(var i=0;i<columnSizes.length;++i){this.setColumnWidth(i,columnSizes[i]);}},progressTablePlaceholders:function(){if(this.$table){this.$table.innerHTML=this.replaceTablePlaceholders.replacePlaceholders(this.$table.innerHTML);}},prepareColumnDrag:function(){var that=this,i;for(i=that.options.checkboxes?1:0;i<that.$header.length;++i){that.$dragContainer.insert(new Element('div',{className:'handle'}).store('th',that.$header[i]));}
that.$tableHeader.insert({before:that.$dragContainer,after:that.$dragger});},prepareDragDrop:function(){this.$ghost=new Element('div',{className:'mainTableDragGhost box-white','data-table-id':this.$table.id}).hide();$('body').insert(this.$ghost);},prepareTableOrdering:function(){var that=this,i,j;for(i=0;i<that.$header.length;++i){var currentOrder;j=i-(this.options.checkboxes?1:0);if(!that.$header[i].down('.sort-arrow')){continue;}
if(that.options.orderColumns.hasOwnProperty(j)){currentOrder=(that.options.orderColumns[j]==that.options.currentOrderColumn);that.$header[i].down('.sort-arrow').writeAttribute({src:window.dir_images+'icons/silk/bullet_arrow_'+
((currentOrder&&that.options.currentOrderDirection=='DESC')?'down':'up')+'.png',className:'sort-arrow mouse-pointer'+(currentOrder?'':' opacity-30'),title:(currentOrder&&that.options.currentOrderDirection=='DESC'?that.options.orderAscendingMessage:that.options.orderDescendingMessage),'data-order-field':that.options.orderColumns[j],'data-order-direction':(currentOrder?that.options.currentOrderDirection:'ASC')}).next('.overflowable').addClassName('mouse-pointer').writeAttribute({'data-order-field':that.options.orderColumns[j],'data-order-direction':(currentOrder?that.options.currentOrderDirection:'ASC')});}}},isValidUrl:function(url){if(/^[\w_\d]+\.php/.test(url)||url.substr(0,1)=='?'){return true;}
try{new URL(url);return true;}catch(e){}
return false;},redirect:function(url){if(this.isValidUrl(url)){document.location.href=encodeURI(url);}else{eval(url);}},prepareObserver:function(){var that=this,i;Event.observe(window,'resize',that.responsive.bind(that));that.$table.on('remove:entriesByIds',function(ev){if(!Object.isArray(ev.memo.ids)){return;}
that.$body.select('tr[data-id]').filter(function($tr){return ev.memo.ids.in_array($tr.readAttribute('data-id'));}).invoke('remove');});if(that.options.keyboardCommands){document.on('keydown',function(ev){var $currentRow=that.$body.down('tr.highlightLine'),$checkbox;if($currentRow){$checkbox=$currentRow.down('.mainTableCheckbox input');}
if(!['input','textarea','select','a','button'].in_array(document.activeElement.tagName.toLowerCase())){if([13,32,38,40].in_array(ev.keyCode)){ev.preventDefault();}
switch(ev.keyCode){case 38:if($currentRow.previous('tr')){$currentRow.removeClassName('highlightLine').previous('tr').addClassName('highlightLine');}
break;case 40:if($currentRow.next('tr')){$currentRow.removeClassName('highlightLine').next('tr').addClassName('highlightLine');}
break;case 32:if(that.$lastClickedCheckbox!==null&&window.keyPressedShift){that._selectRange($checkbox,that.$lastClickedCheckbox).invoke('setValue',$checkbox.checked?1:0).invoke('simulate','change');}
$checkbox.simulate('click');break;case 13:$checkbox.setValue('1').simulate('click');$('navbar_item_C__NAVMODE__EDIT').simulate('click');break;}}});if(that.$body.down('tr')){that.$body.down('tr').addClassName('highlightLine');}}
if(that.options.rowClick){that.$body.addClassName('mouse-pointer');that.$body.on('click','tr',function(ev){var $tr=ev.findElement('tr'),$td=ev.findElement('td'),$trLink=$tr.getAttribute('data-link'),$linkTag,$linkInTd;$linkTag=$td.down('a');$linkInTd=!!$linkTag;if(that.options.checkboxes&&$tr.down('td')===$td){return;}
else if(that.options.directEditMode==1){var checkbox=$tr.down('input');checkbox.checked=true;ev.preventDefault();ev.stopPropagation();$('navbar_item_C__NAVMODE__EDIT').simulate('click');return;}
else if($linkInTd){if(!!$linkTag.readAttribute('data-object-id')===false){return;}}else if($trLink){that.redirect($trLink);return;}
if(that.options.rowClickUrl){that.redirect(that.options.rowClickUrl.replace('%id%',$tr.readAttribute('data-id')));}});}
if(that.options.checkboxes){that.$head.on('click','label.mainTableCheckbox input',function(ev){var $checkbox=ev.findElement('input');that.$body.select('label.mainTableCheckbox input').invoke('setValue',$checkbox.checked?1:0).invoke('simulate','change');that.$lastClickedCheckbox=null;});that.$body.on('click','label.mainTableCheckbox input',function(ev){var $checkbox=ev.findElement('input');if(that.$lastClickedCheckbox!==null&&window.keyPressedShift){that._selectRange($checkbox,that.$lastClickedCheckbox).invoke('setValue',$checkbox.checked?1:0).invoke('simulate','change');}
that.$lastClickedCheckbox=$checkbox;});that.$body.on('change','label.mainTableCheckbox input',function(ev){var $checkbox=ev.findElement('input');$checkbox.up('tr')[$checkbox.checked?'addClassName':'removeClassName']('tr-selected');});if(that.options.keyboardCommands){that.$body.on('mouseup','input',function(ev){ev.preventDefault();ev.findElement('input').blur();});}}
if(that.options.resizeColumns&&that.options.resizeColumnAjaxURL){var $handles=that.$dragContainer.select('.handle');for(i=0;i<$handles.length-1;++i){if(!$handles.hasOwnProperty(i)||!$handles[i]){continue;}
new Draggable($handles[i],{constraint:'horizontal',onStart:that._columnDragStart.bind(that),onDrag:that._columnDrag.bind(that),onEnd:that._columnDragEnd.bind(that)});}}
if(this.options.dragDrop){var $tr=that.$body.select('tr');for(i in $tr){if(!$tr.hasOwnProperty(i)){continue;}
new Draggable($tr[i],{handle:$tr[i].down('.drag-handle'),revert:true,ghosting:true,zindex:3,onStart:that._rowDragStart.bind(that),onDrag:that._rowDrag.bind(that),onEnd:that._rowDragEnd.bind(that)});}}
if(this.options.quickInfoActive){var $quickinfo=this.$body.select('.quickinfo');for(i in $quickinfo){if(!$quickinfo.hasOwnProperty(i)){continue;}
new Tip($quickinfo[i],'',{ajax:{url:window.www_dir+'?ajax=1&call=quick_info&objID='+$quickinfo[i].readAttribute('data-object-id')},delay:this.options.quickInfoDelay,stem:'leftMiddle',hook:{target:'rightMiddle',tip:'leftMiddle'},offset:{x:0,y:0},className:'objectinfo'});}}},_selectRange:function($checkboxA,$checkboxB){var inRange=false;return this.$body.select('label.mainTableCheckbox input').filter(function($checkbox){if(!inRange&&$checkbox!==$checkboxA&&$checkbox!==$checkboxB){return false;}
else if($checkbox===$checkboxA||$checkbox===$checkboxB){inRange=!inRange;return true;}
else if(inRange){return true;}})},_columnDragStart:function(drag){var that=this,$handle=drag.element,eOffset=$handle.viewportOffset(),pOffset=that.$table.viewportOffset(),offset=eOffset.relativeTo(pOffset);that.$dragger.removeClassName('hide').setStyle({position:'absolute',top:0,left:(6+offset.left)+'px',height:that.$tableHeader.getHeight()+that.$table.getHeight()+'px'});that.$table.store('leftOriginWidth',$handle.retrieve('th').getWidth()).store('rightOriginWidth',$handle.retrieve('th').next('th').getWidth());},_columnDrag:function(drag){var that=this,scrollOffset=this.$context.down('.table-body').scrollLeft,$handle=drag.element,$th=$handle.retrieve('th'),$thNext=$th.next('th'),left=parseInt($handle.getStyle('left'))+scrollOffset,delta;if(left<30||$th.positionedOffset().left>(left-30)){return;}
if(left>($thNext.positionedOffset().left+$thNext.getWidth()-30)){return;}
delta=(left-$th.positionedOffset().left);that.$table.store('delta',parseInt(delta));var eOffset=$handle.viewportOffset(),pOffset=that.$table.viewportOffset(),offset=eOffset.relativeTo(pOffset);that.$dragger.setStyle({left:(6+offset.left-scrollOffset)+'px'});},_columnDragEnd:function(drag){var that=this,$drag=drag.element;that._setColumnWidth(parseInt(that.$header.indexOf($drag.retrieve('th'))));that.$dragger.addClassName('hide');$drag.setStyle({zIndex:100});delay(function(){that.saveColumnWidths();},1000);},_rowDragStart:function(drag){var draggedIDs,that=this;drag.element.addClassName('draggable').addClassName('hide').previous().down('label.mainTableCheckbox input').setValue(1);drag.element.insert({before:new Element('tr',{className:'dummy'})});drag.element.store('wasChecked',drag.element.down('label.mainTableCheckbox input').checked).down('label.mainTableCheckbox input').setValue(1);draggedIDs=that.$body.select('label.mainTableCheckbox input:checked').invoke('getValue').uniq();that.$ghost.writeAttribute('data-ids',draggedIDs.join()).update(this.options.dragDropBoxContent.replace('%count%',draggedIDs.length)).appear({duration:0.5});},_rowDrag:function(){this.$ghost.setStyle({left:(12+window.mouseX)+'px',top:window.mouseY+'px'});},_rowDragEnd:function(drag){drag.element.removeClassName('draggable').removeClassName('hide').previous('.dummy').remove();if(!drag.element.retrieve('wasChecked')){drag.element.down('label.mainTableCheckbox input').setValue(0);}
this.$ghost.fade({duration:0.5});},saveColumnWidths:function(){var that=this;this.options.columnSizes=that.$cols.invoke('getStyle','width');new Ajax.Request(this.options.resizeColumnAjaxURL,{parameters:{columns:Object.toJSON(that.$cols.invoke('getStyle','width'))},onSuccess:function(xhr){var json=xhr.responseJSON;if(!json.success){idoit.Notify.error(json.message,{sticky:true});}}});},setColumnWidth:function(index,width){var col=this.$cols[index],style={width:width};if(col){col.setStyle(style);this.syncColumnSizes();}},syncColumnSizes:function(){if(this._syncColumnsTimeout){clearTimeout(this._syncColumnsTimeout);}
this._syncColumnsTimeout=setTimeout(function(){var td,handle,headerCol,left,i,offset=this.$context.down('.table-body').scrollLeft,width=this.$context.getWidth(),position;for(i=0;i<this.$cols.length;++i){td=this.$body.down('tr td:nth('+i+')');handle=this.$dragContainer.down('.handle:nth('+(i-1)+')');left=td.positionedOffset().left+td.getWidth();headerCol=this.$tableHeader.down('col:nth('+i+')'),headerCol.setStyle({width:td.getWidth()+'px'});if(handle){position=left-6-offset;handle.setStyle({left:position+'px',display:position>width?'none':'block'});}}}.bind(this),0);},_setColumnWidth:function(index){var leftOriginWidth=this.$table.retrieve('leftOriginWidth'),rightWidth=this.$table.retrieve('rightOriginWidth'),delta=this.$table.retrieve('delta'),sumWidth=(leftOriginWidth+rightWidth)-18;this.setColumnWidth(index,delta+'px');this.setColumnWidth(index+1,(sumWidth-delta)+'px');this.$table.store('leftOriginWidth',null).store('rightOriginWidth',null).store('delta',null);this.syncColumnSizes();},resetColumns:function(){var cols=this.$cols.length;if(this.options.checkboxes){--cols;}
for(var i=0;i<this.$cols.length;++i){this.setColumnWidth(i,(100 / cols)+'%');}
if(this.options.checkboxes){this.setColumnWidth(0,'40px');}
if(this.options.resizeColumns&&this.options.resizeColumnAjaxURL){this.saveColumnWidths();}
this.syncColumnSizes();},responsive:function(){this.syncColumnSizes();}});window.ReplacePlaceholders=Class.create({initialize:function(options){var that=this;that.options={memoryUnit:false,currencyUnit:'€',currencySeparator:'.',currencyDecimalSeparator:',',linkObjects:true};that.callbacks={mem:function(value,unit){if(!isFinite(value)||value<=0){return'-';}
var memoryFactors={B:8,KB:1024,MB:1048576,GB:1073741824,TB:1099511627776},factor=memoryFactors[unit],outputUnit=unit;if(memoryFactors[that.options.memoryUnit]){factor=memoryFactors[that.options.memoryUnit];outputUnit=that.options.memoryUnit;}
return(Math.round((value / factor*100))/ 100)+' '+outputUnit;},currency:function(value){if(!isFinite(value)||value<=0){return'-';}
var rawValue=(Math.round(value*100).floor()),roundValue=rawValue / 100,checkValue=roundValue.floor()+'',newValue=roundValue.toString().replace('.',that.options.currencyDecimalSeparator);if(checkValue.length>3){var $replaceValue=checkValue.replace(/\B(?=(\d{3})+(?!\d))/g,that.options.currencySeparator);newValue=newValue.replace(checkValue,$replaceValue);}
return newValue+' '+that.options.currencyUnit;}};Object.extend(that.options,options||{});},replacePlaceholders:function(html){var that=this;html=html.replace(/[\w- ]+ \{1\}/g,'<img class="vam" src="'+window.dir_images+'icons/silk/house.png">');html=html.replace(/([^\{\>]+) \{([0-9]+)\}/g,(this.options.linkObjects?' <a class="dynamic-replacement quickinfo" href="?objID=$2" data-object-id="$2">$1</a>':'$1'));html=html.replace(/\{([a-z]*)\,([0-9a-zA-Z\.]*)\,([0-9a-zA-Z\.]*)\}/g,function(match,param1,param2,param3){if(that.callbacks.hasOwnProperty(param1)){return that.callbacks[param1](param2,param3);}
return match;});html=html.replace(/((([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,}))/gi,'<a class="dynamic-replacement email-marker" href="mailto:$1">$1</a>')
return html.replace(/\{(#[0-9a-fA-F]{3,6})\}/g,'<div class="dynamic-replacement cmdb-marker" style="background-color: $1;"></div>');}});"use strict";function getWindowWidth(){return(self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0);}
function getWindowHeight(){return(self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0);}
function getDocumentWidth(){return Math.min(document.body.scrollWidth,getWindowWidth());}
function getDocumentHeight(){return Math.max(document.body.scrollHeight,getWindowHeight());}
function show_content_overlay(){}
function hide_overlay(){var $treeswitch=$('treeSwitch');$('overlay').hide();if($treeswitch){$treeswitch.show();}
if(window.Pace)window.Pace.stop();}
function show_overlay(){var $overlay=$('overlay');if($overlay){if(Prototype.Browser.IE){$overlay.show().writeAttribute('style','opacity:0.4;filter:alpha(opacity=40);');}else{$overlay.show().setStyle({opacity:0.4});}}}
var progressBarInit=function(animate){$$('[data-width-percent]').each(function($el){if($el!==null){var max_percent=parseFloat($el.readAttribute('data-width-percent'));if(animate){$el.setStyle({width:'0%',backgroundColor:Color.retrieve_color_by_percent(100)});new Effect.Morph($el,{style:'width:'+max_percent+'%',duration:2.5,afterUpdate:function(effect){var calc_percent=100-(effect.position*max_percent);$el.setStyle({backgroundColor:Color.retrieve_color_by_percent(calc_percent)});}});}
else{$el.setStyle({width:max_percent+'%',backgroundColor:Color.retrieve_color_by_percent(max_percent)});}}});};window.ChosenExtension=Class.create({$field:null,$chosen_div:null,initialize:function($field,options){var tmp;this.$field=$field;this.$chosen_div=$($field.id+'_chosen')||this.$field.next('.chosen-container');this.$chosen_div_buttons=new Element("div",{className:"border-top p5 bg-lightgrey"});this.options={disable_button_all:false,disable_button_invert:false,disable_button_none:false,chosenMaxHeight:null,additional_value_field:false};this.$chosen_div.down('.chosen-drop').insert(this.$chosen_div_buttons);Object.extend(this.options,options||{});if(!this.options.disable_button_all){this.add_btn_all();}
if(!this.options.disable_button_invert){this.add_btn_invert();}
if(!this.options.disable_button_none){this.add_btn_none();}
tmp=$(this.options.additional_value_field);this.options.additional_value_field=null;if(Object.isElement(tmp)){this.options.$additional_value_field=tmp;}else{this.options.$additional_value_field=false;}
if(this.options.chosenMaxHeight!==null){this.$chosen_div.down('.chosen-choices').setStyle({maxHeight:this.options.chosenMaxHeight,overflow:'auto'});}
if(this.options.disable_button_all&&this.options.disable_button_invert&&this.options.disable_button_none){this.$chosen_div_buttons.remove();}},add_btn_all:function(){var $btn_all=new Element("button",{type:"button",className:"btn mr5"}).update(new Element("img",{src:window.dir_images+"icons/silk/tick-double.png",className:"mr5"})).insert(new Element("span").update(this.options['chosen-btn-all']));$btn_all.on("click",function(){this.$field.setValue(this.$field.select("option").invoke("readAttribute","value")).fire("chosen:updated");this.$field.simulate('change');if(this.options.$additional_value_field){this.options.$additional_value_field.setValue(this.$field.getValue().join())}}.bind(this));this.$chosen_div_buttons.insert($btn_all);},add_btn_invert:function(){var $btn_invert=new Element("button",{type:"button",className:"btn mr5"}).update(new Element("img",{src:window.dir_images+"icons/silk/arrow_switch.png",className:"mr5"})).insert(new Element("span").update(this.options['chosen-btn-inverted']));$btn_invert.on("click",function(){var selection=this.$field.getValue();this.$field.setValue(this.$field.select("option").filter(function($el){return!selection.in_array($el.readAttribute("value"))}).invoke("readAttribute","value")).fire("chosen:updated");this.$field.simulate('change');if(this.options.$additional_value_field){this.options.$additional_value_field.setValue(this.$field.getValue().join())}}.bind(this));this.$chosen_div_buttons.insert($btn_invert);},add_btn_none:function(){var $btn_none=new Element("button",{type:"button",className:"btn"}).update(new Element("img",{src:window.dir_images+"icons/silk/cross.png",className:"mr5"})).insert(new Element("span").update(this.options['chosen-btn-none']));$btn_none.on("click",function(){this.$field.setValue([]).fire("chosen:updated");this.$field.simulate('change');if(this.options.$additional_value_field){this.options.$additional_value_field.setValue('')}}.bind(this));this.$chosen_div_buttons.insert($btn_none);}});"use strict";window.TableComponentCallbackManager=Class.create({initialize:function($head,$body,options){this.$head=$head;this.$body=$body;this.options={rowClick:false,loadingMessage:''};Object.extend(this.options,options||{});this.prepareObserver();this.$body.select('.autostart').invoke('simulate','click');},prepareObserver:function(){if(this.options.order){this.$head.on('click','[data-action]',this.dispatch.bindAsEventListener(this));}
if(this.options.rowClick){this.$body.select('[data-action]').invoke('on','click',this.dispatch.bindAsEventListener(this));}
else{this.$body.on('click','[data-action]',this.dispatch.bindAsEventListener(this));}},dispatch:function(ev){var $element=ev.findElement('[data-action]');ev.stopPropagation();switch($element.readAttribute('data-action')){case'order-by-column':this.orderByColumn($element);break;case'load-ndo-state':this.loadNDOState($element);break;case'load-livestatus-state':this.loadLivestatusState($element);break;}},orderByColumn:function($el){var urlParts=document.location.href.parseQuery();if($el.tagName=='IMG'){$el=$el.next();}
urlParts.orderBy=$el.readAttribute('data-order-field');urlParts.orderByDir=($el.readAttribute('data-order-direction')=='ASC'?'DESC':'ASC');document.location.href=window.www_dir+'?'+Object.toQueryString(urlParts);},loadNDOState:function($button){var $parent=$button.up(),objectID=$button.readAttribute('data-object-id');$button.disable().update(new Element('img',{src:window.dir_images+'ajax-loading.gif',className:'mr5'})).insert(new Element('span').update(this.options.loadingMessage));new Ajax.Request('?call=monitoring_ndo&ajax=1&func=load_ndo_state',{method:'post',parameters:{objID:objectID},onSuccess:function(xhr){var json=xhr.responseJSON;if(json.success){if(json.data){$parent.update(display_monitoring_state(json.data));}
else{$parent.addClassName('text-grey').update('-');}}
else{$parent.addClassName('text-red').update(json.message||'-');}}.bind(this)});},loadLivestatusState:function($button){var $parent=$button.up(),objectID=$button.readAttribute('data-object-id');$button.disable().update(new Element('img',{src:window.dir_images+'ajax-loading.gif',className:'mr5'})).insert(new Element('span').update(this.options.loadingMessage));new Ajax.Request('?call=monitoring_livestatus&ajax=1&func=load_livestatus_state',{method:'post',parameters:{objID:objectID},onSuccess:function(xhr){var json=xhr.responseJSON;if(json.success){if(json.data){$parent.update(display_monitoring_state(json.data));}
else{$parent.addClassName('text-grey').update('-');}}
else{$parent.addClassName('text-red').update(json.message||'-');}}.bind(this)});}});Color={calc_rgb_from_hex:function calc_rgb_from_hex(hex,alpha){hex=hex.replace(/#/,'');if(hex.length!==6){return false;}
if(Object.isUndefined(alpha)){alpha=0;}
var red=hex.slice(0,2),green=hex.slice(2,4),blue=hex.slice(4);return[parseInt(red,16),parseInt(green,16),parseInt(blue,16),(alpha / 100.0)];},calc_hex_from_rgb:function calc_hex_from_rgb(red,green,blue,prepend){if(Object.isUndefined(prepend)){prepend='#';}
return prepend+('0'+red.toString(16)).substr(-2)+('0'+green.toString(16)).substr(-2)+('0'+blue.toString(16)).substr(-2);},render_rgb_from_hex:function render_rgb_from_hex(hex,alpha){if(Object.isUndefined(alpha)){alpha=null;}
var rgba=this.calc_rgb_from_hex(hex,alpha);if(rgba===false){return'';}
if(alpha===null){return'rgb('+rgba[0]+', '+rgba[1]+', '+rgba[2]+')';}
return'rgba('+rgba[0]+', '+rgba[1]+', '+rgba[2]+', '+rgba[3]+')';},retrieve_color_by_percent:function retrieve_color_by_percent(percent,prepend){if(Object.isUndefined(prepend)){prepend='#';}
var hue=percent*1.2 / 360;var rgb=this.hsl_to_rgb(hue,1,.5);return this.calc_hex_from_rgb(rgb[0],rgb[1],rgb[2],prepend);},hsl_to_rgb:function hsl_to_rgb(hue,saturation,lightness){var r,g,b;if(saturation==0){r=g=b=lightness;}else{var q=lightness<0.5?lightness*(1+saturation):lightness+saturation-lightness*saturation;var p=2*lightness-q;r=this.hue_to_rgb(p,q,hue+1 / 3);g=this.hue_to_rgb(p,q,hue);b=this.hue_to_rgb(p,q,hue-1 / 3);}
return[Math.floor(r*255),Math.floor(g*255),Math.floor(b*255)];},get_random_by_spectrum:function get_random_by_spectrum(colorname,as_hex){var hue,rgb;if(Object.isUndefined(as_hex)){as_hex=true;}
switch(colorname){case'red':hue=0;break;case'orange':hue=30;break;case'yellow':hue=60;break;case'yellowgreen':hue=90;break;case'green':hue=120;break;case'cyan':hue=150;break;case'babyblue':hue=180;break;case'skyblue':hue=210;break;case'blue':hue=240;break;case'purple':hue=270;break;case'magenta':hue=300;break;case'orchid':hue=330;break;}
rgb=this.hsl_to_rgb((((hue-10)+Math.random()*20)/ 360),((Math.random()*0.25)+0.5),((Math.random()*0.25)+0.3));if(as_hex){return this.calc_hex_from_rgb.apply(null,rgb);}else{return rgb;}},hue_to_rgb:function hue_to_rgb(p,q,t){if(t<0)t+=1;if(t>1)t-=1;if(t<1 / 6)return p+(q-p)*6*t;if(t<1 / 2)return q;if(t<2 / 3)return p+(q-p)*(2 / 3-t)*6;return p;},calc_color_light:function calc_color_light(hex){var rgb=this.calc_rgb_from_hex(hex);if(rgb===false){return false;}
return(Math.max(rgb[0],rgb[1],rgb[2])+Math.min(rgb[0],rgb[1],rgb[2]))/ 5.1;},random_rgb:function random_rgb(prepend){if(Object.isUndefined(prepend)){prepend='#';}
return prepend+('0'+(Math.random()*255).toString(16)).substr(-2)+
('0'+(Math.random()*255).toString(16)).substr(-2)+
('0'+(Math.random()*255).toString(16)).substr(-2);}};function mydoit_trigger(){$('mydoitArea').setStyle('width:'+$('tree_content').getWidth()+'px');if(!$('mydoitArea').loaded){aj_submit('index.php?request=mydoit','get','mydoitArea');$('mydoitArea').loaded=true;}
new Effect.toggle('mydoitArea','blind',{duration:0.2});}
function close_mydoit(){if($('mydoitArea').loaded)$('mydoitArea').hide();}
function mydoit_addBookmark(){$('mydoitAction').setValue('add');var url_params=Object.toQueryString(String(document.location).parseQuery());new Ajax.Submit(window.www_dir+'?request=mydoit_addBookmark&call=mydoit'+'&'+url_params,'mydoitArea','isys_form',{'history':false});}
function mydoit_deleteBookmark(){$('mydoitAction').setValue('delete');aj_submit('?request=mydoit_deleteBookmark','post','mydoitArea','isys_form',null,null);}
function mydoit_openSearchModul(ModuleConst,ModuleID,Searchfavorites){if(ModuleConst&&ModuleConst.length>0&&ModuleID&&ModuleID.length>0){window.location.href="?"+ModuleConst+"="+ModuleID+"&searchfavorites="+Searchfavorites;}}
function mysearch_delCriterion(){aj_submit('?request=mysearch_delCriterion','post','mydoitArea','isys_form',null,null);}
if(!Prototype.Browser.IE){HTMLElement.prototype.click=function(){var evt=this.ownerDocument.createEvent('MouseEvents');evt.initMouseEvent('click',true,true,this.ownerDocument.defaultView,1,0,0,0,0,false,false,false,false,0,null);this.dispatchEvent(evt);};}
(function(){var eventMatchers={'HTMLEvents':/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,'MouseEvents':/^(?:click|mouse(?:down|up|over|move|out))$/},defaultOptions={pointerX:0,pointerY:0,button:0,ctrlKey:false,altKey:false,shiftKey:false,metaKey:false,bubbles:true,cancelable:true};Event.simulate=function(element,eventName){var options=Object.extend(defaultOptions,arguments[2]||{}),oEvent,eventType=null;element=$(element);for(var name in eventMatchers){if(eventMatchers[name].test(eventName)){eventType=name;break;}}
if(!eventType){throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');}
if(document.createEvent){oEvent=document.createEvent(eventType);if(eventType=='HTMLEvents'){oEvent.initEvent(eventName,options.bubbles,options.cancelable);}else{oEvent.initMouseEvent(eventName,options.bubbles,options.cancelable,document.defaultView,options.button,options.pointerX,options.pointerY,options.pointerX,options.pointerY,options.ctrlKey,options.altKey,options.shiftKey,options.metaKey,options.button,element);}
element.dispatchEvent(oEvent);}else{options.clientX=options.pointerX;options.clientY=options.pointerY;oEvent=Object.extend(document.createEventObject(),options);element.fireEvent('on'+eventName,oEvent);}
return element;};Element.addMethods({simulate:Event.simulate});})();var Chassis=Class.create({initialize:function(element,options){this.options=options;this.options=Object.extend({matrix:[],devices:[],view:'front',x:0,y:0,size:2,editmode:false,collision_callback:Prototype.emptyFunction,options_active:false,option_callback:Prototype.emptyFunction,info_active:false,info_callback:Prototype.emptyFunction,sizesInPercent:false,mirrored:false},options||{});var tbody=new Element('tbody',{id:'matrix-'+$(element).id});this.root_element=$(element).update(new Element('table').update(tbody));this.element=tbody;this.create_chassis();},add_observer:function(){$(this.element.id).select('input').invoke('on','click',this.checkbox_click.bindAsEventListener(this));$(this.element.id).select('img.option').invoke('on','click',this.options.option_callback);$(this.element.id).select('div.title img.info').invoke('on','click',this.options.info_callback);return this;},create_chassis:function(){var x,y,tr,td,devices,device,height,width,size=this.getGridSize(false),$objectDiv,$containerDiv;this.element.update();for(y=-1;y<this.options.y;y++){tr=new Element('tr');for((this.options.mirrored?x=(this.options.x-1):x=-1);(this.options.mirrored?x>=-1:x<this.options.x);(this.options.mirrored?x--:x++)){if(y>=0&&x>=0){if(typeof this.options.matrix[y]==='undefined'){this.options.matrix[y]=[];}
if(typeof this.options.matrix[y][x]==='undefined'){this.options.matrix[y][x]=null;}
if(this.options.matrix[y][x]!==false){td=new Element('td',this.options.matrix[y][x]);if(this.options.matrix[y][x]!==null){td.update(new Element('div',{className:'title',title:this.options.matrix[y][x]['data-slot-title']}).update(this.options.matrix[y][x]['data-slot-title']));}
if(this.options.editmode===true&&this.options.matrix[y][x]===null){td.insert(new Element('input',{type:'checkbox',id:x+'-'+y})).addClassName('edit');}else{if(devices=this.options.devices[x+'-'+y]){$containerDiv=new Element('div',{className:'device-container'});td.addClassName('device').writeAttribute('data-slot-id',devices[0].slotid).insert($containerDiv);for(var i in devices){if(devices.hasOwnProperty(i)){device=devices[i];$objectDiv=new Element('div',{className:'device',style:'background:'+device.object_color}).update(device.title);if(device.object_color===null){device.object_color='#FFFFFF';}
if(device.object_id!==null&&device.object_id>0){$objectDiv.writeAttribute('data-object-id',device.object_id).writeAttribute('data-object-type',device.object_type);}
$containerDiv.insert($objectDiv).setStyle({background:device.object_color});}}}}
if(this.options.options_active===true&&td.hasClassName('slot')){td.down('div.title').insert(new Element('img',{src:window.dir_images+'icons/silk/bullet_arrow_down.png',className:'option fr'}));}
if(this.options.info_active===true&&td.hasClassName('slot')){td.down('div.title').insert(new Element('img',{src:window.dir_images+'icons/silk/information.png',className:'info fr'}));}
tr.insert(td);}}else{if(y===-1&&x===-1){if(this.element.up('table').down('colgroup')){this.element.up('table').down('colgroup').remove();}
var colgroup=new Element('colgroup'),col_width=this.getGridSize(true),col_x;if(!this.options.mirrored){colgroup.insert(new Element('col',{width:0,style:'width:0;'}));}
for(col_x=0;col_x<this.options.x;col_x++){colgroup.insert(new Element('col',{width:col_width,style:'width:'+col_width+';'}))}
if(this.options.mirrored){colgroup.insert(new Element('col',{width:0,style:'width:0;'}));}
this.element.up('table').insert({top:colgroup});}
var className='edge-'+((y===-1)?((x===-1)?'first':'top'):'side'),style='';if(this.options.sizesInPercent&&this.options.x>0&&this.options.y>0){style=((y===-1)?((x===-1)?'':'width:'+(100 / this.options.x)+'%'):'height:'+(100 / this.options.y)+'%');}else{style=((y===-1)?((x===-1)?'':'width:'+size+'px'):'height:'+size+'px');}
tr.insert(new Element('td',{className:className,style:style}));}}
this.element.insert(tr);}
return this.add_observer();},checkbox_click:function(){var checkboxes=$$('#'+this.element.id+' input:checked');$(this.element.id).select('td').invoke('removeClassName','selected');$(this.element.id).select('input').invoke('enable');this.options.collision_callback(false);switch(checkboxes.length){case 0:break;case 1:checkboxes[0].up().addClassName('selected');break;case 2:[checkboxes[0].up(),checkboxes[1].up()].invoke('addClassName','selected');var check=[checkboxes[0].id.split('-'),checkboxes[1].id.split('-')];this.mark_rectangle(parseInt(check[0][0]),parseInt(check[1][0]),parseInt(check[0][1]),parseInt(check[1][1]));$$('#'+this.element.id+' input:not(:checked)').invoke('disable');break;}},mark_rectangle:function(x1,x2,y1,y2){var from_x=((x1>x2)?x2:x1),to_x=((x1>x2)?x1:x2),from_y=((y1>y2)?y2:y1),to_y=((y1>y2)?y1:y2),x,y,tmp,collision=false;for(y=from_y;y<=to_y;y++){for(x=from_x;x<=to_x;x++){tmp=$$('#'+this.element.id+' #'+x+'-'+y)[0];if(tmp){tmp.up().addClassName('selected');}else{collision=true;}}}
this.options.collision_callback(collision);return this;},reset_html:function(){this.element=$(this.element.id);return this.create_chassis();},set_editmode:function(editmode){this.options.editmode=!!editmode;return this;},set_devices:function(devices){this.options.devices=devices;return this;},set_matrix:function(matrix){this.options.matrix=matrix;return this;},set_x:function(x){this.options.x=parseInt(x);return this;},set_y:function(y){this.options.y=parseInt(y);return this;},set_size:function(size){if(size>=0&&size<=5){this.options.size=size;}
return this;},get_size:function(){return this.options.size;},getGridSize:function(unit){switch(parseInt(this.options.size)){case 0:return 25+(unit?'px':0);case 1:return 35+(unit?'px':0);default:case 2:return 45+(unit?'px':0);case 3:return 55+(unit?'px':0);case 4:return 70+(unit?'px':0);case 5:return 85+(unit?'px':0);}}});var RackChassis=Class.create(Chassis,{initialize:function(element,options){this.options=options;this.options=Object.extend({matrix:[],devices:[],view:'front',x:0,y:0,mirrored:false},options||{});this.options.editmode=false;this.options.collision_callback=Prototype.emptyFunction;this.options.options_active=false;this.options.option_callback=Prototype.emptyFunction;this.options.info_active=false;this.options.info_callback=Prototype.emptyFunction;this.options.sizesInPercent=true;this.element=new Element('tbody');this.root_element=$(element).update(new Element('table',{className:'chassis'}).update(this.element));this.create_chassis();this.root_element.on('update:fitToContainer',function(){this.fitToContainer();}.bind(this));},add_observer:function(){return this;},getGridSize:function(unit){return(100 / this.options.x)+(unit?'%':0);},fitToContainer:function(){var $container=this.root_element.up('td'),$chassisElements=[this.root_element,this.root_element.down('table')];$chassisElements.invoke('setStyle',{height:'0px'});setTimeout(function(){$chassisElements.invoke('setStyle',{height:$container.getHeight()+'px'});}.bind(this),250);}});if(!String.hasOwnProperty('linkMailtosInString')){String.prototype.linkMailtosInString=function(){return this.replace(/(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}\b)/ig,'<a href="mailto:$1">$1</a>');};}
if(!String.hasOwnProperty('clean')){String.prototype.clean=function(){return this.replace(/\W/ig,'');};}
if(!String.hasOwnProperty('stripNonNumeric')){String.prototype.stripNonNumeric=function(){return this.replace(/([^,\.\d])*/ig,'');};}
if(!String.hasOwnProperty('toNumber')){String.prototype.toNumber=function(){var number=this.trim(),minus=(number.substr(0,1)==='-');number=number.stripNonNumeric();if(number.empty()){return 0;}
if(number.split('.').length>2){number=number.replace(/\./g,'');}
if(number.split(',').length>2){number=number.replace(/,/g,'');}
if(number.indexOf('.')>=0||number.indexOf(',')>=0){if(number.indexOf('.')>number.indexOf(',')){number=number.replace(',','');}else if(number.indexOf('.')<number.indexOf(',')){number=number.replace('.','');number=number.replace(',','.');}else if(number.indexOf('.')===-1&&number.indexOf(',')>=0){number=number.replace(',','.');}}
number=parseFloat(number.replace(',','.'));if(isNaN(number)){return 0;}
if(minus){number*=-1;}
number=number.toFixed(4);return number;}}