/*
 * Copyright(c) 2011-2015, HCS Building Automation
 * http://www.hcs-ba.nl
 */
/* 
 * Build date: 2015-01-30T16:58:10+00:00
 */
function indexesToArray(a){var b=[];if(Utils.isDefinedAndNotNull(a)&&$.isObject(a))for(var c in a)$.isFunction(a[c])||b.push(c);return b}function javaEnabled(){return navigator.javaEnabled()&&!$.browser.android&&!$.browser.ipad&&!$.browser.iphone}function getDecimalSeperator(){var a;return a=(1.1).toLocaleString().substring(1,2)}function toTimeString(a){var b=parseString(a).match(/\d+/g);return b<2?a:b[0]+":"+b[1]}
function floatToString(a,b){return(Utils.isDefinedAndNotNull(b)?parseFloat(a).toFixed(b):""+a).replace(".",getDecimalSeperator())}function isBoolean(a){return a===!0||a===!1}function getPort(){var a=location.port;a==""&&(a=location.protocol==="https:"?443:80);return a}
function openLocation(a,b,c,d){Utils.isDefined(b)&&b===!0?(b="channelmode=0,directories=0,location=0,menubar=0,status=0,titlebar=0,personalbar=0,toolbar=0,dependent=1,resizable=1",c&&(b+=",width="+c),d&&(b+=",height="+d),window.open(a,"",b)):location.href=a}function download(a){var b=document.getElementById("hiddenDownloader");if(b===null)b=document.createElement("iframe"),b.id="hiddenDownloader",b.style.display="none",document.body.appendChild(b);b.src=a}
function objectsEqual(a,b){if($.isObject(a)!=$.isObject(b))return!1;if($.isObject(a)){for(var c in a){if(!Utils.isDefined(b[c]))return!1;if(!objectsEqual(a[c],b[c]))return!1}for(c in b)if(!Utils.isDefined(a[c]))return!1}else return a===b;return!0}function GetOption(a,b,c){return a&&a[b]?a[b]:c}
function clone(a){if(!a||"object"!==typeof a)return a;if("function"===typeof a.clone)return a.clone();var b="[object Array]"===Object.prototype.toString.call(a)?[]:{},c,d;for(c in a)a.hasOwnProperty(c)&&(d=a[c],b[c]=d&&"object"===typeof d?clone(d):d);return b}function arrayToString(a){var b="",c;for(c in a)if(isNumeric(c)){var d=a[c],e=parseInt(c);b+=""+e+"=>"+d+", "}b.length>0&&(b=b.substr(0,b.length-1));return b}function parseString(a){return Utils.isDefinedAndNotNull(a)?a+"":""}
function dumpObject(a,b,c,d){if(d>10)return c+b+": <Maximum Depth Reached>\n";if(typeof a=="object"){var e=null,b=c+b,f=0;if(a instanceof Array)f=a.length,b+=" (Array)\n";else{for(var g in a)f++;b+=" (Object)\n"}b+=c+"Total item: "+f+"\n";c+="\t";if(a instanceof Array)for(g=0;g<a.length;g++)e=a[g],b+=dumpObject(e,g,c,d+1);else for(g in a){try{e=a[g]}catch(j){e="<Unable to Evaluate>"}b+=typeof e=="object"?dumpObject(e,g,c,d+1):c+g+": "+e+"\n"}return b}else return a+" is not an object."}
function relativeToAbsoluteUrl(a){var b=document.createElement("a");b.href=a;return b.href}var htmlEncodeDiv=null;function htmlEncode(a){htmlEncodeDiv?htmlEncodeDiv.innerHTML="":htmlEncodeDiv=document.createElement("div");a=document.createTextNode(a);htmlEncodeDiv.appendChild(a);return htmlEncodeDiv.innerHTML}function hasOwnProperties(a){for(var b in a)if(a.hasOwnProperty(b))return!0;return!1}if(!Array.prototype.last)Array.prototype.last=function(){return this.length>0?this[this.length-1]:null};
if(!Array.prototype.clone)Array.prototype.clone=function(){for(var a=[],b=0;b<this.length;b++)a.push(clone(this[b]));return a};if(!Array.prototype.remove)Array.prototype.remove=function(a){a=this.indexOf(a);a!=-1&&this.splice(a,1);return this};String.prototype.count=function(a){if(!a)return!1;for(var b=0,c=0;;){b=this.indexOf(a,b);if(b==-1)break;b++;c++}return c};String.repeat=function(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")};
String.sprintf=function(){for(var a=0,b,c=arguments[a++],d=[],e,f,g;c;){if(e=/^[^\x25]+/.exec(c))d.push(e[0]);else if(e=/^\x25{2}/.exec(c))d.push("%");else if(e=/^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(c)){if((b=arguments[e[1]||a++])==null||b==void 0)throw"Too few arguments.";if(/[^s]/.test(e[7])&&typeof b!="number")throw"Expecting number but found "+typeof b;switch(e[7]){case "b":b=b.toString(2);break;case "c":b=String.fromCharCode(b);break;case "d":b=parseInt(b);
break;case "e":b=e[6]?b.toExponential(e[6]):b.toExponential();break;case "f":b=e[6]?parseFloat(b).toFixed(e[6]):parseFloat(b);break;case "o":b=b.toString(8);break;case "s":b=(b=String(b))&&e[6]?b.substring(0,e[6]):b;break;case "u":b=Math.abs(b);break;case "x":b=b.toString(16);break;case "X":b=b.toString(16).toUpperCase()}b=/[def]/.test(e[7])&&e[2]&&b>0?"+"+b:b;f=e[3]?e[3]=="0"?"0":e[3].charAt(1):" ";g=e[5]-String(b).length;f=e[5]?String.repeat(f,g):"";d.push(e[4]?b+f:f+b)}else throw"Huh ?!";c=c.substring(e[0].length)}return d.join("")};
String.leftPad=function(a,b,c){a=String(a);for(c||(c=" ");a.length<b;)a=c+a;return a};String.rightPad=function(a,b,c){a=String(a);for(c||(c=" ");a.length<b;)a+=c;return a};jQuery.isString=function(a){return typeof a==="string"};jQuery.isObject=function(a){return!!a&&Object.prototype.toString.call(a)==="[object Object]"};
jQuery.fn.visible=function(a,b){return Utils.isDefinedAndNotNull(a)?b==="visibility"?this.css("visibility",a?"visible":"hidden"):this.css("display",a?"":"none"):this.css("display")=="none"||this.css("visibility")=="hidden"};jQuery.SET_TEXT_MODE_CONVERT_ENTERS="convertEnters";jQuery.SET_TEXT_MODE_DONT_CONVERT_ENTERS="dontConvertEnters";
jQuery.fn.setText=function(a,b){this.html("");if(b===jQuery.SET_TEXT_MODE_CONVERT_ENTERS){for(var c=0,d="";;){var e=a.indexOf("\\n",c);if(e==-1)break;d+=htmlEncode(a.substring(c,e))+"<br>";c=e+2}d+=htmlEncode(a.substr(c));return this.html(d)}else return this.prepend(document.createTextNode(a))};jQuery.event.keyHooks._filterOrig=jQuery.event.keyHooks.filter;
jQuery.event.keyHooks.filter=function(a,b){a=jQuery.event.keyHooks._filterOrig(a,b);if(a.string==null)if(a.string=null,b.which==null)a.string=String.fromCharCode(b.keyCode);else if(b.which!=0&&b.charCode!=0)a.string=String.fromCharCode(b.which);return a};
Utils={simpleAjax:function(a){var b=Utils.isDefined(a.type)?a.type:"GET",c=Utils.isDefined(a.cache)?a.cache:!0,d=a.url;Utils.isDefined(a.timeout);var e=a.complete;c||(d+=d.indexOf("?")===-1?"?":"&",d+=(new Date).getTime());var f=new XMLHttpRequest;f.open(b,d,!0);f.onreadystatechange=function(){f.readyState==4&&e(!0,f)};f.ontimeout=function(){e(!1)};f.send()}};Utils.apply=function(a,b,c){c&&Utils.apply(a,c);if(a&&b&&typeof b=="object")for(var d in b)a[d]=b[d];return a};
Utils.extend=function(){var a=function(a){for(var b in a)this[b]=a[b]},b=Object.prototype.constructor;return function(c,d,e){$.isObject(d)&&(e=d,d=c,c=e.constructor!=b?e.constructor:function(){d.apply(this,arguments)});var f=function(){},g=d.prototype;f.prototype=g;f=c.prototype=new f;f.constructor=c;c.superclass=g;if(g.constructor==b)g.constructor=d;c.override=function(a){Utils.override(c,a)};f.superclass=f.supr=function(){return g};f.override=a;Utils.override(c,e);c.extend=function(a){return Utils.extend(c,
a)};return c}}();Utils.override=function(a,b){if(b){var c=a.prototype;Utils.apply(c,b);if($.browser.msie&&b.hasOwnProperty("toString"))c.toString=b.toString}};Utils._idPrefix="idgen";Utils._idSeed=1;Utils.id=function(){return Utils._idPrefix+ ++Utils._idSeed};Utils.getHost=function(){var a=location.protocol+"//"+location.host;location.port&&(a+=":"+location.port);a+="/";return a};Utils.isDefined=function(a){return typeof a!=="undefined"};
Utils.isDefinedAndNotNull=function(a){return Utils.isDefined(a)&&a!==null};Utils.isNonEmptyString=function(a){return parseString(a)!==""};Utils._pageVisible=!0;Utils._pageVisibleSet=!1;Utils._pageVisibilityChangeHandlers=[];Utils.setPageVisible=function(a){Utils._pageVisibleSet=!0;if(a!=Utils._pageVisible){Utils._pageVisible=a;for(a=0;a<Utils._pageVisibilityChangeHandlers.length;a++)(0,Utils._pageVisibilityChangeHandlers[a])()}};ns("Ext");Ext.setPageVisible=Utils.setPageVisible;
Utils.isPageVisible=function(){if(Utils._pageVisibleSet)return Utils._pageVisible;if(document.hidden!==void 0)return!document.hidden;else for(var a=["webkit","moz","ms","o"],b=0;b<a.length;b++)if(document[a[b]+"Hidden"]!=void 0)return!document[a[b]+"Hidden"];return!0};Utils.onPageVisibilityChanged=function(a){Utils._pageVisibilityChangeHandlers.indexOf(a)==-1&&Utils._pageVisibilityChangeHandlers.push(a)};
Utils.unPageVisibilityChanged=function(a){a=Utils._pageVisibilityChangeHandlers.indexOf(a);a>=0&&Utils._pageVisibilityChangeHandlers.splice(a,1)};Utils._onPageVisibilityChanged=function(){if(!Utils._pageVisibleSet)for(var a=0;a<Utils._pageVisibilityChangeHandlers.length;a++)(0,Utils._pageVisibilityChangeHandlers[a])()};
Utils.serializeXml=function(a,b,c,d){Utils.isDefinedAndNotNull(c)||(c='<?xml version="1.0" encoding="UTF-8"?>');var a=(new XMLSerializer).serializeToString(a),e="";if(Utils.isDefinedAndNotNull(b)){var a=a.replace(/(>)(<)(\/*)/g,"$1\r\n$2$3"),f=0;jQuery.each(a.split("\r\n"),function(a,c){var d=0;c.match(/.+<\/\w[^>]*>$/)?d=0:c.match(/^<\/\w/)?f!=0&&(f-=1):d=c.match(/^<\w[^>]*[^\/]>.*$/)?1:0;for(var h="",i=0;i<f;i++)h+=b;e+=h+c+"\r\n";f+=d})}else e=a;c+="\r\n";Utils.isDefinedAndNotNull(d)&&(c+='<?xml-stylesheet type="text/xsl" href="'+
d+'"?>\r\n');c+=e;return c};$(document).ready(function(){if(!Utils._pageVisibilityChangeEvent){var a=null;if(document.hidden!==void 0)a="visibilitychange";else for(var b=["webkit","moz","ms","o"],c=0;c<b.length;c++)if(document[b[c]+"Hidden"]!==void 0){a=b[c]+"visibilitychange";break}if(a!==null)$(document).on(a,Utils._onPageVisibilityChanged)}});Utils.Support={};Utils.Support._fixed=null;Utils.Support._touch=null;
Utils.Support.fixed=function(){if(Utils.Support._fixed==null)Utils.Support._fixed=!$.browser.ipad&&!$.browser.iphone&&!$.browser.android;return Utils.Support._fixed};Utils.Support.touch=function(){if(Utils.Support._touch===null){var a=document.createElement("div");a.setAttribute("ontouchstart","return;");Utils.Support._touch=typeof a.ontouchstart=="function"}return Utils.Support._touch};if(typeof window.console=="undefined")window.console={log:function(){}};Debug=function(){};Debug._categories=!0;
Debug._level=9;Debug.set=function(a,b){Debug._categories=a;if(Utils.isDefined(b))Debug._level=b};Debug.log=function(a,b,c){if(Debug._categories!==!1&&!(Utils.isDefined(c)&&c>Debug._level)&&(!Utils.isDefined(b)||!(Debug._categories.indexOf&&Debug._categories.indexOf(b)==-1))){var d="";Utils.isDefined(b)&&(d+=String.rightPad(b,17));d+=" ("+(Utils.isDefined(c)?c:"-")+")";d!=""&&(d+=": ");d+=a;console.log(d)}};
ns("Costerm");
Costerm.MessageBox=function(a,b,c){this.type=Utils.isDefined(c)?c:Costerm.MessageBox.TYPE_OK;this.onResultFunction=b;this.customMessageBox=!0;this.eventId=Utils.id();$(window).on("hashchange.Costerm.MessageBox."+this.eventId,this._onHashChange.bind(this));if(this.customMessageBox){this.messageBoxCenterer=document.createElement("div");this.messageBoxCenterer.className="messageBoxCenterer";b=document.createElement("div");this.messageBoxCenterer.appendChild(b);c=document.createElement("div");c.className=
"messageBox";$(c).setText(L(a));var a=document.createElement("div"),e=[];switch(this.type){case Costerm.MessageBox.TYPE_OK_CANCEL:e.push({Text:L("$OK$"),Value:Costerm.MessageBox.RESULT_OK});e.push({Text:L("$Cancel$"),Value:Costerm.MessageBox.RESULT_CANCEL});break;case Costerm.MessageBox.TYPE_OK:e.push({Text:L("$OK$"),Value:Costerm.MessageBox.RESULT_OK});break;case Costerm.MessageBox.TYPE_YES_NO:e.push({Text:L("$Yes$"),Value:Costerm.MessageBox.RESULT_YES}),e.push({Text:L("$No$"),Value:Costerm.MessageBox.RESULT_NO})}for(var f=
0;f<e.length;f++){var d=document.createElement("div");d.className="button";$(d).setText(e[f].Text).on("click",this._onResult.bind(this,e[f].Value));a.appendChild(d)}c.appendChild(a);b.appendChild(c);this.messageBoxBackground=document.createElement("div");this.messageBoxBackground.className="messageBoxBackground";if(!Utils.Support.fixed())this.messageBoxBackground.style.position="absolute",$(window).on("resize.Costerm.MessageBox."+this.eventId,this._resizeBackground.bind(this)),this._resizeBackground();
document.body.appendChild(this.messageBoxBackground);document.body.appendChild(this.messageBoxCenterer);document.body.style.overflow="hidden"}else{switch(this.type){case Costerm.MessageBox.TYPE_OK_CANCEL:result=confirm(L(a))?Costerm.MessageBox.RESULT_OK:Costerm.MessageBox.RESULT_CANCEL;break;case Costerm.MessageBox.TYPE_YES_NO:result=confirm(L(a))?Costerm.MessageBox.RESULT_YES:Costerm.MessageBox.RESULT_NO;break;case Costerm.MessageBox.TYPE_OK:alert(L(a)),result=Costerm.MessageBox.RESULT_OK}this._onResult(result)}};
Costerm.MessageBox.TYPE_OK_CANCEL="okcancel";Costerm.MessageBox.TYPE_OK="ok";Costerm.MessageBox.TYPE_YES_NO="yesno";Costerm.MessageBox.RESULT_OK="ok";Costerm.MessageBox.RESULT_CANCEL="cancel";Costerm.MessageBox.RESULT_YES="yes";Costerm.MessageBox.RESULT_NO="no";
Costerm.MessageBox.prototype={_onResult:function(a){this.close();this.onResultFunction(a)},close:function(){this.messageBoxBackground&&$(this.messageBoxBackground).remove();this.messageBoxCenterer&&$(this.messageBoxCenterer).remove();$(window).off("resize.Costerm.MessageBox."+this.eventId).off("hashchange.Costerm.MessageBox."+this.eventId);document.body.style.overflow=""},_onHashChange:function(){this.close()},_resizeBackground:function(){$(this.messageBoxBackground).visible(!1);this.messageBoxBackground.style.height=
document.body.scrollHeight+"px";$(this.messageBoxBackground).visible(!0)}};
Costerm.Hint=function(a,b){this.maxShowTime=5E3;var c;Costerm.Hint._currentHintTimer&&window.clearTimeout(Costerm.Hint._currentHintTimer);Costerm.Hint._currentHintControl===null?(c=document.createElement("div"),c.className="hint",$(c).on("click",this.remove.bind(this)),document.body.appendChild(c),Costerm.Hint._currentHintControl=c,$(window).on("orientationchange.Costerm.Hint",this.remove.bind(this))):c=Costerm.Hint._currentHintControl;var e=b.offsetTop-document.body.scrollTop;c.style.top="-1000px";
c.style.left="-1000px";$(c).setText(a,jQuery.SET_TEXT_MODE_CONVERT_ENTERS).visible(!0);var f=$(c).outerHeight(),d=$(c).outerWidth(),i=b.type=="select-one",g=$(b).outerWidth(),j=$(b).outerHeight(),k=$(b).offset(),h=$(document.body).width(),e=f>e?b.offsetTop+j+3:k.top-f;d<h-b.offsetLeft-g?(d=b.offsetLeft,i&&(d+=g)):d=h-d;c.style.top=e+"px";c.style.left=d+"px";if(this.maxShowTime>0)Costerm.Hint._currentHintTimer=window.setTimeout(this.remove.bind(this),this.maxShowTime)};
Costerm.Hint._currentHintControl=null;Costerm.Hint._currentHintTimer=null;Costerm.Hint.prototype={remove:function(){$(Costerm.Hint._currentHintControl).visible(!1)}};ns("Costerm");Costerm.Exception=function(a,b,c){this.message=a;this.code=b;this.innerException=c};Costerm.Exception.prototype={getMessage:function(){return this.message},getCode:function(){return this.code},getInnerException:function(){return this.innerException},toString:function(){return this.message}};ns("Costerm");Costerm.Language=function(){this.texts={};this.availableLanguages={};this.language=null};Costerm.Language._instance=null;Costerm.Language.getInstance=function(){if(!Costerm.Language._instance)Costerm.Language._instance=new Costerm.Language;return Costerm.Language._instance};
Costerm.Language.prototype={fromXML:function(a){a=XMLObjectifier.xmlToJSON(a);this.defaultLanguage=a.def[0].Text;for(var b=0;b<a.texts[0].text.length;b++){var c=a.texts[0].text[b],e=c.id,f={},d;for(d in c)if(!(d.indexOf("_")==0||d=="Text"||d=="id"))f[d]=c[d][0].Text,this.availableLanguages[d]=!0;this.texts[e]=f}},set:function(a){if(!Utils.isDefined(this.availableLanguages[a]))throw new Costerm.Exception("Language "+a+" not available!");localStorage.setItem("language",a);this.language=a},get:function(){this._setLanguage();
return this.language},_setLanguage:function(){if(!this.language){this.language=getUrlParameter("lang");if(!this.language)this.language=localStorage.getItem("language");if(!this.language)this.language=navigator.userLanguage?navigator.userLanguage:window.navigator.language,this.language=this.language.substr(0,2);if(!Utils.isDefined(this.availableLanguages[this.language]))this.language=this.defaultLanguage;localStorage.setItem("language",this.language)}},getText:function(){var a=arguments[0];if(!Utils.isDefinedAndNotNull(a))return"";
if($.isObject(a))return"";this._setLanguage();var b=this.texts[a];b&&((a=b[this.language])||(a=b[this.defaultLanguage]));if(arguments.length>1){b=[a];for(a=1;a<arguments.length;a++)b.push(Utils.isDefined(arguments[a])?arguments[a]:"");a=String.sprintf.apply(this,b)}return a},translate:function(a){for(a=parseString(a);;){var b=a.match(/L\((.+?)\)/m);if(!b)break;var c=b[0],b=this.getText(b[1]),a=a.replace(c,b)}return a}};
L=function(){return Costerm.Language.getInstance().getText.apply(Costerm.Language.getInstance(),arguments)};ns("Costerm");Costerm.Observable=function(){this.observers=[]};Costerm.Observable.prototype={addObserver:function(a){this.observers.indexOf(a)==-1&&this.observers.push(a)},removeObserver:function(a){this.observers.remove(a)},_notifyObservers:function(a,b){for(var c=0;c<this.observers.length;c++)this.observers[c]._update(this,a,b)},_removeAllObservers:function(){this.observers=[]}};Costerm.Observer=function(){};Costerm.Observer.prototype={_update:function(){}};ns("Costerm");Costerm.Property=function(a,b,c){this.name=a;this.getter=b;this.setter=c;this.value=null};Costerm.Property.prototype={getName:function(){return this.name},getValue:function(){return this.getter?this.getter():this.value},setValue:function(a){this.setter?this.setter(a):this.value=a},clone:function(){var a=new Costerm.Property(this.name,this.getter,this.setter);a.value=this.value;return a}};Costerm.PropertyBag=function(){this.bag={}};
Costerm.PropertyBag.prototype={addProperty:function(a,b,c){this._createProperty(a,b,c)},getValue:function(a){return!Utils.isDefined(this.bag[a])?null:this.bag[a].getValue()},setValue:function(a,b){this.bag[a]||this._createProperty(a);this.bag[a].setValue(b)},setValues:function(a){if(a)for(var b in a)this.setValue(b,a[b])},getProperties:function(){return this.bag},clone:function(){var a=new Costerm.PropertyBag;a.bag=clone(this.bag);return a},_createProperty:function(a,b,c){this.bag[a]=new Costerm.Property(a,
b,c)}};Costerm.PropertyProvider=Utils.extend(Costerm.Observable,{constructor:function(){Costerm.PropertyProvider.superclass.constructor.call(this)},set:function(){},get:function(){},getProperty:function(){}});
ns("Costerm.WebBeheer");Costerm.WebBeheer.Version="1.11.20";ns("Costerm.WebBeheer");Costerm.WebBeheer.AppConfig=function(){};Costerm.WebBeheer.AppConfig._instance=null;Costerm.WebBeheer.AppConfig.getInstance=function(){if(!Costerm.WebBeheer.AppConfig._instance)Costerm.WebBeheer.AppConfig._instance=new Costerm.WebBeheer.AppConfig;return Costerm.WebBeheer.AppConfig._instance};
Costerm.WebBeheer.AppConfig.prototype={fromXML:function(a){this.filterOptions=["id","root","elements"];a=XMLObjectifier.xmlToJSON(a);this.dictionary=this._buildDocument(a.elements[0]);this.dictionary.setEnums(this._getEnums(a.enums[0]));this.controller=new Costerm.WebBeheer.Controller(this._getControllerConfig(a.controllerConfig[0]))},getDictionary:function(){return this.dictionary},getController:function(){return this.controller},_getControllerConfig:function(a){var b=new Costerm.WebBeheer.ControllerConfig;
if(a.configItem)for(var c=0;c<a.configItem.length;c++){var d=a.configItem[c];b.addRule(d.rule[0].Text,d.refreshTime[0].Text)}return b},_getEnums:function(a){var b={};if(a["enum"])for(var c=0;c<a["enum"].length;c++){for(var d=a["enum"][c],e=d.id[0].Text,h={},f=0;f<d.items[0].item.length;f++){var g=d.items[0].item[f];h[g.id[0].Text]=g.name[0].Text}d=new Costerm.WebBeheer.Enum(e,h);b[e]=d}return b},_buildDocument:function(a){var b=new Costerm.WebBeheer.Document;this.rootElement=null;this._handleElement(b,
null,a);if(this.rootElement==null)throw new Costerm.Exception("No root element defined");b.setRootElement(this.rootElement);this.rootElement=null;return b},_handleElement:function(a,b,c){if(Utils.isDefined(c.element))for(var c=$.isArray(c.element)?c.element:[c.element],d=0;d<c.length;d++){var e=c[d],h=e.id?e.id[0].Text:Utils.id(),f=e.type,g=e.root?parseBool(e.root[0].Text):!1,i=this._getOptions(e),j=[];this._getExpressions(h,i,j);h=this._createElement(h,f,j,i);h.setDocument(a);if(g){if(this.rootElement!=
null)throw new Costerm.Exception("More than one root defined");this.rootElement=h}b&&b.appendChild(h);e.elements&&this._handleElement(a,h,e.elements[0])}},_createElement:function(a,b,c,d){try{var e=Costerm.WebBeheer.Elements.Factory.getInstance().create(b,a,c,d)}catch(h){throw new Costerm.Exception("Unknown element found. Id: "+a+", Type: "+b);}return e},_getExpressions:function(a,b,c){for(var d in b)if($.isObject(b[d]))if(b[d].getSet||b[d].get||b[d].set){var e=b[d].def;if(b[d].getSet){var h=new Costerm.WebBeheer.Expression(d,
Costerm.WebBeheer.Expression.TYPE_GET,b[d].getSet,e);c.push(h);h=new Costerm.WebBeheer.Expression(d,Costerm.WebBeheer.Expression.TYPE_SET,b[d].getSet.replace(/(;$)/g,"")+"=value",e);c.push(h)}else b[d].get&&(h=new Costerm.WebBeheer.Expression(d,Costerm.WebBeheer.Expression.TYPE_GET,b[d].get,e),c.push(h)),b[d].set&&(h=new Costerm.WebBeheer.Expression(d,Costerm.WebBeheer.Expression.TYPE_SET,b[d].set,e),c.push(h));delete b[d]}else this._getExpressions(a,b[d],c)},_getOptions:function(a){var b;if($.isArray(a))if(a.length>
1){b=[];for(var c=0;c<a.length;c++)b.push(this._getOptions(a[c]))}else b=this._getOptions(a[0]);else if($.isObject(a)){b={};var c=a.Text,d=0,e;for(e in a)d++,e.indexOf("_")==0||this.filterOptions.indexOf(e)>=0||e=="Text"||(b[e]=this._getOptions(a[e]));d==1&&(b=c)}else b=a;return b}};ns("Costerm.WebBeheer");Costerm.WebBeheer.AddressReverseKey=function(a,b,c){this.address=a;this.reverse=!!b;this.key=c};Costerm.WebBeheer.AddressReverseKey.prototype={toString:function(){return JSON.stringify(this)}};Costerm.WebBeheer.ControllerRequest=function(){this.requests=[]};
Costerm.WebBeheer.ControllerRequest.prototype={addGetArrayRequest:function(a){this.requests.push({method:"getArray",params:a})},addGetPlotRequest:function(a){this.requests.push({method:"getPlots",params:a})},addGetObjectRequest:function(a){this.requests.push({method:"getObject",params:a})},addGetValueRequest:function(a){this.requests.push({method:"getValue",params:a})},addGetValueOrArrayRequest:function(a){this.requests.push({method:"getValueOrArray",params:a})},addSetValueRequest:function(a,b){this.requests.push({method:"setValue",
address:a,value:b})},empty:function(){return this.requests.length==0},getRequests:function(){return this.requests},handle:function(a,b,c){var d={type:Costerm.WebBeheer.AppSettings.ControllerMethod,dataType:"json"},e;Costerm.WebBeheer.AppSettings.ProxyControllerURL?(e=Costerm.WebBeheer.AppSettings.ControllerURL,d.url=Costerm.WebBeheer.AppSettings.ProxyControllerURL):d.url=Costerm.WebBeheer.AppSettings.ControllerURL;var h={requests:this.getRequests(),sessionId:Costerm.WebBeheer.App.getInstance().getSessionId()},
h=JSON.stringify(h);d.data={params:h,url:e};d.timeout=2E4;d.cache=!Costerm.WebBeheer.AppSettings.DisableCaching;if(a)d.success=a.bind(null,d);if(b)d.error=b.bind(null,d);return!Utils.isDefinedAndNotNull(c)||c(d)?$.ajax(d):null}};
Costerm.WebBeheer.Controller=Utils.extend(Costerm.Observable,{constructor:function(a){Costerm.WebBeheer.Controller.superclass.constructor.call(this);this.config=a;this.currentAjaxRequests=[];this.params={};this.arrays={};this.plots={};this.plotsFromFiles={};this.objects={};this.paramsToRetrieve={};this.arraysToRetrieve={};this.plotsToRetrieve={};this.plotFilesToRetrieve={};this.objectsToRetrieve={};this.refreshTime=this.config.getMinRefreshTime();this._startRefreshTimer();$(window).on("unload",this._onUnload.bind(this));
if(Costerm.WebBeheer.AppSettings.CacheControllerParams){if((a=JSON.parse(localStorage.getItem("controllerCacheParams")))&&$.isObject(a))this.params=a;if((a=JSON.parse(localStorage.getItem("controllerCacheArrays")))&&$.isObject(a))this.arrays=a;if((a=JSON.parse(localStorage.getItem("controllerCacheObjects")))&&$.isObject(a))this.objects=a}Utils.onPageVisibilityChanged(this._onPageVisibilityChanged.bind(this))},_startRefreshTimer:function(){if(this.retrieveParamsTimer==null&&Utils.isPageVisible())this.retrieveParamsTimer=
window.setTimeout(this._retrieveParams.bind(this),this.refreshTime)},_refreshImmediate:function(){if(!this.refreshImmediate&&(window.clearTimeout(this.retrieveParamsTimer),this.retrieveParamsTimer=null,this.refreshImmediate=!0,Utils.isPageVisible()))this.retrieveParamsTimer=window.setTimeout(this._retrieveParams.bind(this),1)},_onPageVisibilityChanged:function(){Debug.log("Page visibility changed:"+Utils.isPageVisible(),"Controller");Utils.isPageVisible()&&this._refreshImmediate()},_onUnload:function(){Costerm.WebBeheer.AppSettings.CacheControllerParams&&
(localStorage.setItem("controllerCacheParams",JSON.stringify(this.params)),localStorage.setItem("controllerCacheArrays",JSON.stringify(this.arrays)),localStorage.setItem("controllerCacheObjects",JSON.stringify(this.objects)))},addArray:function(a,b,c,d,e){var h=Utils.isDefined(this.arraysToRetrieve[a]),d=!!d;if(h)for(h=0;h<this.arraysToRetrieve[a].length;h++){var f=this.arraysToRetrieve[a][h];if(f.index==b&&f.count==c&&f.reverse==d&&f.key==e)return}else this.arraysToRetrieve[a]=[];this.arraysToRetrieve[a].push({index:b,
count:c,reverse:d,key:e,refreshTime:this.config.getRefreshTimeArray(a),lastRetrieval:null});this._refreshImmediate()},addPlots:function(a,b,c,d,e,h,f,g){if(g){if(Utils.isDefined(this.plotFilesToRetrieve[g]))return;this.plotFilesToRetrieve[g]={refreshTime:this.config.getRefreshTimePlots(b,g),lastRetrieval:null}}else{if(Utils.isDefined(this.plotsToRetrieve[a])){var i=this.plotsToRetrieve[a];if(i.addresses==b&&i.startDate==c&&i.endDate==d&&i.period==e&&i.interval==h&&i.maxPlots==f)return}i=JSON.stringify({addresses:b,
startDate:c,endDate:d,period:e,interval:h,maxPlots:f});Debug.log("addPlots:"+i,"Controller");b={id:i,tag:a,addresses:b,startDate:c,endDate:d,period:e,interval:h,maxPlots:f,requestStartDate:c,requestEndDate:d,requestInterval:h,refreshTime:this.config.getRefreshTimePlots(b,g),lastRetrieval:null};if(this.plots[a]&&this.plots[a][i]&&(c=Object.keys(this.plots[a][i]),c.length>0))c=parseFloat(c[c.length-1]),b.requestStartDate=c+1;this.plotsToRetrieve[a]=b}this._refreshImmediate()},addObject:function(a){Utils.isDefined(this.objectsToRetrieve[a])||
(this.objectsToRetrieve[a]={refreshTime:this.config.getRefreshTimeObject(a),lastRetrieval:null},this._refreshImmediate())},removeArray:function(a,b,c,d,e){if(Utils.isDefined(this.arraysToRetrieve[a])){for(var d=!!d,h=0;h<this.arraysToRetrieve[a].length;h++){var f=this.arraysToRetrieve[a][h];if(f.index==b&&f.count==c&&f.reverse==d&&f.key==e){this.arraysToRetrieve[a].splice(h,1);break}}this.arraysToRetrieve[a].length==0&&delete this.arraysToRetrieve[a]}},removePlots:function(a,b,c,d,e,h,f,g){g?delete this.plotFilesToRetrieve[g]:
delete this.plotsToRetrieve[a]},removeObject:function(a){delete this.objectsToRetrieve[a]},addParam:function(a){Utils.isDefined(this.paramsToRetrieve[a])||(this.paramsToRetrieve[a]={refreshTime:this.config.getRefreshTime(a),lastRetrieval:null},this._refreshImmediate())},removeParam:function(a){delete this.paramsToRetrieve[a]},getParam:function(a){return Utils.isDefined(this.params[a])?this.params[a].value:null},getObject:function(a){return Utils.isDefined(this.objects[a])?this.objects[a]:null},getPlots:function(a,
b,c,d,e,h,f,g){if(g){if(!Utils.isDefined(this.plotsFromFiles[g]))return null;var a={},i;for(i in this.plotsFromFiles[g])if(!$.isFunction(i)){c=this.plotsFromFiles[g][i];a[i]=[];for(d=0;d<b.length;d++)e=parseFloat(b[d])-1,e=Utils.isDefined(c[e])&&!isNaN(c[e])?c[e]:null,a[i].push(e)}return a}else{if(!Utils.isDefined(this.plots[a]))return null;b=JSON.stringify({addresses:b,startDate:c,endDate:d,period:e,interval:h,maxPlots:f});return Utils.isDefined(this.plots[a][b])?clone(this.plots[a][b]):null}},setParam:function(a,
b){if(Utils.isDefined(this.params[a])){if(this.params[a].value==b)return;this.params[a].handle=!0}var c=new Costerm.WebBeheer.ControllerRequest;c.addSetValueRequest(a,b);this._doRequest(c,this._onParamSet.bind(this),this._onParamSetFailed.bind(this))},removeParamFromCache:function(a){Utils.isDefined(this.params[a])&&delete this.params[a]},getArray:function(a,b,c,d,e){a=new Costerm.WebBeheer.AddressReverseKey(a,d,e);if(!Utils.isDefined(this.arrays[a])||this.arrays[a].length<=b)return[];a=this.arrays[a];
if(b==0&&c==0)d=a.slice();else{d=[];for(c=c==0?a.length:Math.min(b+c,a.length);b<c;b++)d.push(a[b])}return d},_onParamSet:function(a,b){Debug.log("set param","Controller");this._removeAjaxRequest(a.data.params);this._handleRetrievedParams(a,b)},_onParamSetFailed:function(a){Debug.log("FAILED to set value TO CONTROLLER!","Controller");a&&this._removeAjaxRequest(a.data.params)},_retrieveParams:function(){this.retrieveParamsTimer=null;this.refreshImmediate=!1;var a=new Costerm.WebBeheer.ControllerRequest,
b=new Date,c=[],d;for(d in this.paramsToRetrieve)if(!$.isFunction(d)){var e=this.paramsToRetrieve[d],h=e.lastRetrieval;if(h===null||b.getTime()>h.getTime()+e.refreshTime)c.push(d),e.lastRetrieval=b}c.length>0&&a.addGetValueRequest(c);var c=[],f;for(f in this.objectsToRetrieve)if(!$.isFunction(f)&&(d=this.objectsToRetrieve[f],h=d.lastRetrieval,h===null||b.getTime()>h.getTime()+d.refreshTime))c.push(f),d.lastRetrieval=b;c.length>0&&a.addGetObjectRequest(c);var c=[],g;for(g in this.arraysToRetrieve)if(!$.isFunction(g)){d=
this.arraysToRetrieve[g];for(f=0;f<d.length;f++)if(e=d[f],h=e.lastRetrieval,h===null||b.getTime()>h.getTime()+e.refreshTime)c.push({param:g,index:e.index,count:e.count,reverse:e.reverse,key:e.key}),e.lastRetrieval=b}c.length>0&&a.addGetArrayRequest(c);f=[];for(var i in this.plotsToRetrieve)if(!$.isFunction(i)&&(g=this.plotsToRetrieve[i],h=g.lastRetrieval,(h===null||b.getTime()>h.getTime()+g.refreshTime)&&(!g.requestStartDate||!(g.requestEndDate&&g.requestStartDate>=g.requestEndDate))))f.push({tag:g.id,
addresses:g.addresses,startDate:g.requestStartDate,endDate:g.requestEndDate,interval:g.requestInterval,maxPlots:g.maxPlots}),g.lastRetrieval=b;f.length>0&&a.addGetPlotRequest(f);i=[];for(var j in this.plotFilesToRetrieve)if(!$.isFunction(j)&&(g=this.plotFilesToRetrieve[j],h=g.lastRetrieval,(h===null||b.getTime()>h.getTime()+g.refreshTime)&&(!g.requestStartDate||!(g.requestEndDate&&g.requestStartDate>=g.requestEndDate))))i.push(j),g.lastRetrieval=b;a.empty()?this._startRefreshTimer():this._doRequest(a,
this._onRetrieveParams.bind(this),this._onRetrieveParamsFailed.bind(this));for(f=0;f<i.length;f++)j=i[f],a={type:"GET",dataType:"text",url:j,cache:!1,timeout:3E4,success:this._onPlotFileRetrieved.bind(this,j)},$.ajax(a)},_testDoubleRequest:function(a){a=a.data.params;if(this.currentAjaxRequests.indexOf(a)==-1)return this.currentAjaxRequests.push(a),!0;Debug.log("double request detected!","Controller");return!1},_doRequest:function(a,b,c){a.handle(b,c,this._testDoubleRequest.bind(this))},_removeAjaxRequest:function(a){a=
this.currentAjaxRequests.indexOf(a);a>=0&&this.currentAjaxRequests.splice(a,1)},_onRetrieveParams:function(a,b){Debug.log("retrieve params","Controller");this._removeAjaxRequest(a.data.params);if(Costerm.WebBeheer.AppSettings.Debug===!0||Costerm.WebBeheer.AppSettings.Debug.indexOf&&Costerm.WebBeheer.AppSettings.Debug.indexOf("Controller")>=0){var c;this._handleRetrievedParams(a,b);this._startRefreshTimer()}else try{this._handleRetrievedParams(a,b),this._startRefreshTimer()}catch(d){this._onRetrieveParamsFailed()}},
_findPlotToRetrieveById:function(a){for(var b in this.plotsToRetrieve){var c=this.plotsToRetrieve[b];if(c.id==a)return c}return null},_onPlotFileRetrieved:function(a,b){for(var c=b.split("\n"),d={},e=0;e<c.length;e++){var h=c[e].split(";");if(h.length>=3){var f=h[0].split("-");if(f.length==3){var g=h[1].split(":");if(!(g.length!=2&&g.length!=3))try{var i=parseFloat(f[2]);i<100&&(i+=2E3);for(var j=parseFloat(f[1])-1,m=parseFloat(f[0]),l=parseFloat(g[0]),k=parseFloat(g[1]),n=g.length==3?parseFloat(g[2]):
0,o=new Date(i,j,m,l,k,n),f=[],g=2;g<h.length;g++)f.push(parseFloatInp(h[g]));var p=o.getTime()/1E3;d[p]=f}catch(q){}}}}this.plotsFromFiles[a]=d;this._notifyObservers("changePlots",["","","","","","","",a])},_handleRetrievedParams:function(a,b){var c=b.sessionId;c!=""&&Costerm.WebBeheer.App.getInstance().setSessionId(c);this.params.SessionId={value:c,handle:!1};var c=b.params,d;for(d in c){var e=c[d];if(!$.isFunction(e)&&!$.isObject(e)&&(!Utils.isDefined(this.params[d])||Utils.isDefined(this.params[d])&&
(this.params[d].value!=e||this.params[d].handle)))this.params[d]={value:e,handle:!1},this._notifyObservers("changeParam",[d])}c=b.objects;for(d in c)if(e=c[d],!$.isFunction(e)&&(!Utils.isDefined(this.objects[d])||!objectsEqual(this.objects[d],e)))this.objects[d]=e,this._notifyObservers("changeObject",[d]);var c=b.plots,h;for(h in c){var f=c[h];Debug.log("plotsRetrieved:"+h,"Controller");if(!$.isFunction(f)){var g=this._findPlotToRetrieveById(h);if(g){Debug.log("plotToRetrieve:"+g.tag+" "+g.requestStartDate,
"Controller");var e=g.tag,i=f.interval,j=f.plots;Utils.isDefined(this.plots[e])||(this.plots[e]={});Utils.isDefined(this.plots[e][h])||(this.plots[e][h]={});f=null;for(l in j){var m=j[l];$.isFunction(m)||(this.plots[e][h][l]=m,f=l)}if(f){f=parseFloat(f);j=null;g.period&&(j=f-g.period);if(g.startDate!==null&&g.startDate>j)j=g.startDate;if(j!==null)for(var l in this.plots[e][h]){if(l>=j)break;delete this.plots[e][h][l]}g.requestStartDate=f+1;g.requestInterval=i;this._notifyObservers("changePlots",[e,
g.addresses,g.startDate,g.endDate,g.period,g.interval,g.maxPlots,""])}}}}h=b.arrays;for(d in h)if(i=h[d],!$.isFunction(i)){l=i.reverse;c=i.key;f=new Costerm.WebBeheer.AddressReverseKey(d,l,c);Utils.isDefined(this.arrays[f])||(this.arrays[f]=[]);var g=[],k;for(k in i.values)if(isNumeric(k))if(e=i.values[k],j=parseInt(k),e===null){if(this.arrays[f].length>j)g.push(j),this.arrays[f].length=j}else if(j>=this.arrays[f].length||this.arrays[f][j]!==e)g.push(j),this.arrays[f][j]=e;if(g.length>0&&Utils.isDefined(this.arraysToRetrieve[d]))for(e=
0;e<this.arraysToRetrieve[d].length;e++)if(i=this.arraysToRetrieve[d][e],k=i.index,i=i.count,k==0&&i==0)this._notifyObservers("changeArray",[d,k,i,l,c]);else{f=i==0?Number.MAX_VALUE:k+i;i==0?(j=k,f=Number.MAX_VALUE):(j=k,f=k+i);for(m=0;m<g.length;m++)if(g[m]>=j&&g[m]<f){this._notifyObservers("changeArray",[d,k,i,l,c]);break}}}},_onRetrieveParamsFailed:function(a){Debug.log("FAILED to retrieve from Controller!","Controller");a&&this._removeAjaxRequest(a.data.params);this._startRefreshTimer()}});ns("Costerm.WebBeheer");Costerm.WebBeheer.ControllerConfig=function(){this.configItems=[];this.minRefreshTime=null};
Costerm.WebBeheer.ControllerConfig.prototype={addRule:function(a,b){b=parseInt(b);if(b<this.minRefreshTime||this.minRefreshTime===null)this.minRefreshTime=b;this.configItems.push({rule:a,refreshTime:b})},getRefreshTime:function(a){for(var b,c=0;c<this.configItems.length;c++)if(b=this.configItems[c],a.search(b.rule)!==-1)return b.refreshTime;return this.minRefreshTime},getRefreshTimeArray:function(a){return this.getRefreshTime(a+"[]")},getRefreshTimePlots:function(a,b){return b?6E4:this.minRefreshTime},
getRefreshTimeObject:function(a){return this.getRefreshTime(a+"{}")},getMinRefreshTime:function(){return this.minRefreshTime}};ns("Costerm.WebBeheer");
Costerm.WebBeheer.Document=Utils.extend(Costerm.Observer,{constructor:function(){this.references={};this.enums=this.rootElement=null},_update:function(a,b,c){switch(b){case "remove":delete this.references[a.getId()];break;case "changeProperty":var b=c[1],d=c[2];switch(c[0]){case "id":delete this.references[b],this.references[d]=a}}},register:function(a){var b=a.getId();if(b=="")b=Utils.id(),a.setId(b);else if(this.references[b]){if(this.references[b]==a)return;b=Utils.id();a.setId(b)}a.addObserver(this);
this.references[b]=a},setEnums:function(a){this.enums=a},getEnums:function(){return this.enums},getEnumItems:function(a){return this.enums[a]?this.enums[a].getItems():null},setRootElement:function(a){if(this.rootElement)throw new Costerm.Exception("Root already set");this.rootElement=a;this.rootElement.setDocument(this)},getRootElement:function(){return this.rootElement},setInvalidated:function(a){this.rootElement.setInvalidated(a,!0)},render:function(){this.rootElement.render()},getElementById:function(a){return this.references[a]}});ns("Costerm.WebBeheer");Costerm.WebBeheer.Enum=function(a,b){this.id=a;this.items=b};Costerm.WebBeheer.Enum.prototype={getItems:function(){return this.items}};ns("Costerm.WebBeheer");Costerm.WebBeheer.Expression=function(a,b,c,d,e){this.propName=a;this.type=b;this.expressionText=c;this.subject=e;this.def=d};Costerm.WebBeheer.Expression.TYPE_GET="get";Costerm.WebBeheer.Expression.TYPE_SET="set";
Costerm.WebBeheer.Expression.prototype={getPropName:function(){return this.propName},getExpressionText:function(){return this.expressionText},getType:function(){return this.type},getSubject:function(){return this.subject},getDefault:function(){return this.def},equals:function(a){return this.propName==a.propName&&this.expressionText==a.expressionText&&this.type==a.type&&this.subject==a.subject},clone:function(){return new Costerm.WebBeheer.Expression(this.propName,this.type,this.expressionText,this.def,
this.subject)}};ns("Costerm.WebBeheer");Costerm.WebBeheer.ParametersRetriever=function(a){this.progressCallback=a;this.paramsTree={};this.paramsByName={};this.requests=[];this.maxRequests=50;this.requestsStep=10;this.requestCount=this.maxRequests;this.disallowedParams="Alarm,Net,Buttons,Users,Readable,Writable,DescriptionWritable,Visible,MinValue,MaxValue,Blocked,SetDate,SetTime,Started,AlarmMailTest,PlotterMailTest,ResetEmails,RetryEmails,SmtpPassword,SmtpUserName,TestMailTest,EmailCount".split(",")};
Costerm.WebBeheer.ParametersRetriever.prototype={start:function(){this._addRequest("");this._handleNextRequest()},_addRequest:function(a){this.requests.push(a)},cancel:function(){},_handleNextRequest:function(){var a=this.requests.splice(0,this.requestCount);if(a.length>0){var b=new Costerm.WebBeheer.ControllerRequest;b.addGetValueOrArrayRequest(a);b.handle(this._onParamsRetrieved.bind(this,a),this._onParamsRetrievedFailed.bind(this,a))}else this._doProgressCallback(L("$ParameterbestandGereed$"),
100),this._createXml()},_createXml:function(){var a=this._createXMLELement("Parameters",this.paramsTree,document.implementation.createDocument(null,"xml",null)),b=null,b=window.navigator.msSaveOrOpenBlob?Utils.serializeXml(a,"\t",null):Utils.serializeXml(a,"\t",null,relativeToAbsoluteUrl("parameters.xsl")),a=new Blob([b],{type:"application/xml"}),c=URL.createObjectURL(a);window.navigator.msSaveOrOpenBlob?window.navigator.msSaveOrOpenBlob(a,"parameters.xml"):window.open(c,"_blank","menubar=yes,scrollbars=yes,resizable=yes");
console.log(b)},_isValidXmlText:function(a){if(!$.isString(a))return!0;return/[\x00-\x1F]/.test(a)?(console.log("INVALID XML TEXT: "+a),!1):!0},_createXMLELement:function(a,b,c){var d=Object.keys(b).sort();if(d.length==0)return null;var e=null;try{e=c.createElement(a)}catch(h){e=c.createElement("_"+a)}a=null;b.Description&&b.Description._&&this._isValidXmlText(b.Description._)&&(a=b.Description._+" ");b.Header&&b.Header._&&this._isValidXmlText(b.Header._)&&(a===null&&(a=""),a+=b.Header._);if(a!==
null){var f=c.createElement("Description");f.appendChild(c.createTextNode(a.trim()));e.appendChild(f)}for(var g=0;g<d.length;g++)if(f=d[g],f=="_")f=b[f],f!==null&&f!==""&&this._isValidXmlText(f)&&(isBoolean(f)&&(f=f?1:0),e.appendChild(c.createTextNode(f)));else if(a===null||f!="Header"&&f!="Description")(f=this._createXMLELement(f,b[f],c))&&e.appendChild(f);return e},_doProgressCallback:function(a,b,c){this.progressCallback&&this.progressCallback(a,b,c)},_handleIncomingParams:function(a,b,c){this._doProgressCallback(a,
-1);if(Utils.isDefined(c))if($.isArray(c))for(var d=0;d<c.length;d++){var e=c[d];if(e===null)break;if(!(this.disallowedParams.indexOf(e)>=0)){b[e]={};var h=a?a+"."+e:e;this.paramsByName[h]=b[e];this._addRequest(h,b[e])}}else b._=c},_onParamsRetrieved:function(a,b,c){if(c===null)this.requestCount-=this.requestsStep,this.requestCount<=0&&this._onParamsRetrievedFailed(),a.length>0&&this.requests.push.apply(this.requests,a);else{this.requestCount<this.maxRequests&&(this.requestCount+=this.requestsStep);
for(b=0;b<a.length;b++){var d=a[b];if(Utils.isDefined(c.params[d])){var e=c.params[d],h=Utils.isDefined(this.paramsByName[d])?this.paramsByName[d]:this.paramsTree;this._handleIncomingParams(d,h,e)}}}this._handleNextRequest()},_onParamsRetrievedFailed:function(){this._doProgressCallback(L("$ParameterbestandFout$"),100,!0)}};ns("Costerm.WebBeheer");Costerm.WebBeheer.Trigger=function(){};Costerm.WebBeheer.ElementTrigger=Utils.extend(Costerm.WebBeheer.Trigger,{constructor:function(a,b){this.elementId=$.isString(a)?a:a.getId();this.propName=b},setElement:function(a){this.elementId=a.getId()},getElementId:function(){return this.elementId},getPropName:function(){return this.propName},toString:function(){return"elements."+this.elementId+"."+this.propName}});
Costerm.WebBeheer.ControllerTrigger=Utils.extend(Costerm.WebBeheer.Trigger,{constructor:function(a){this.address=a},getAddress:function(){return this.address},toString:function(){return"controller."+this.address}});
Costerm.WebBeheer.ControllerArrayTrigger=Utils.extend(Costerm.WebBeheer.Trigger,{constructor:function(a,b,c,d,e){this.address=a;this.index=b;this.count=c;this.reverse=!!d;this.key=e},getAddress:function(){return this.address},getIndex:function(){return this.index},getCount:function(){return this.count},isReverse:function(){return this.reverse},getKey:function(){return this.key},toString:function(){return"controller."+this.address+"[],"+this.index+","+this.count+","+(this.reverse?1:0)+","+this.key}});
Costerm.WebBeheer.ControllerPlotsTrigger=Utils.extend(Costerm.WebBeheer.Trigger,{constructor:function(a,b,c,d,e,h,f,g){g?(this.maxPlots=this.interval=this.period=this.endDate=this.startDate=this.addresses=this.tag="",this.url=g):(this.tag=a,this.addresses=b,this.startDate=c,this.endDate=d,this.period=e,this.interval=h,this.maxPlots=f,this.url="")},getTag:function(){return this.tag},getAddresses:function(){return this.addresses},getStartDate:function(){return this.startDate},getEndDate:function(){return this.endDate},
getPeriod:function(){return this.period},getInterval:function(){return this.interval},getMaxPlots:function(){return this.maxPlots},getUrl:function(){return this.url},toString:function(){for(var a="controller.[",b=0;b<this.addresses.length;b++)b!=0&&(a+=","),a+=this.addresses[b]+"<plots>";a+="],"+this.tag+","+this.startDate+","+this.endDate+","+this.period+","+this.interval+","+this.maxPlots+","+this.url;return a}});
Costerm.WebBeheer.ControllerObjectTrigger=Utils.extend(Costerm.WebBeheer.Trigger,{constructor:function(a){this.address=a},getAddress:function(){return this.address},toString:function(){return"controller."+this.address+"{}"}});ns("Costerm.WebBeheer");Costerm.WebBeheer.App=function(){this.doc=null;this.sessionInited=!1};Costerm.WebBeheer.App._instance=null;Costerm.WebBeheer.App.getInstance=function(){if(!Costerm.WebBeheer.App._instance)Costerm.WebBeheer.App._instance=new Costerm.WebBeheer.App;return Costerm.WebBeheer.App._instance};
Costerm.WebBeheer.App.prototype={run:function(a){Debug.set(Costerm.WebBeheer.AppSettings.Debug,Costerm.WebBeheer.AppSettings.DebugLevel);this.isLoggedIn=!1;var b=document.createElement("style");b.type="text/css";var c,d="";if($.browser.android)c=20,d+="select {\t-webkit-appearance: listbox;\tpadding-left: 2px;\theight: "+c+"px;\tborder-radius: 0px; } input {\theight: "+c+"px; } ";else{if($.browser.iphone||$.browser.ipad)d+="html, body { -khtml-user-select: none; -webkit-touch-callout: none; -webkit-user-select: none; } ";
var e=document.createElement("input");document.body.appendChild(e);c=$(e).outerHeight();$(e).remove()}d+=".customControl, .regelButton { height: "+c+"px; } ";d+=".label { height: auto; min-height: "+c+"px; } ";window.innerWidth<400&&(d+=".menuButtons input[type=button] { width: "+(window.innerWidth-10)+"px; } ");$.browser.msie&&(d+="input[type=checkbox] { height: "+(c-2)+"px; } ");b.styleSheet?b.styleSheet.cssText=d:b.innerHTML=d;$("head").append(b);this.filesToLoad=3;b=Costerm.WebBeheer.AppSettings.XMLPacking;
Utils.simpleAjax({type:"GET",url:"XML/Language"+(b?".xmlp":".xml")+"?"+RELEASE,complete:this._onXMLComplete.bind(this,{store:"languageXML"}),cache:!Costerm.WebBeheer.AppSettings.DisableCachingXML});Utils.simpleAjax({type:"GET",url:"XML/"+a+(b?".xmlp":".xml")+"?"+RELEASE,complete:this._onXMLComplete.bind(this,{store:"documentXML"}),cache:!Costerm.WebBeheer.AppSettings.DisableCachingXML});a=new Costerm.WebBeheer.ControllerRequest;a.addGetValueRequest(["System.Login.Accesslevel","System.Login.MaxUsers",
"System.WebSecure.Value"]);a.handle(this._onStartupParamsRetrieved.bind(this,{store:"params"}),this._onFiledLoadFailed.bind(this))},_addOptionsToParamsRequest:function(a){a.store="params";return!0},_onXMLComplete:function(a,b,c){b?this._onFilesLoaded(a,Costerm.WebBeheer.AppSettings.XMLPacking?c.responseText:c.responseXML):this._onFiledLoadFailed()},_onStartupParamsRetrieved:function(a,b,c){return this._onFilesLoaded(a,c)},_onFilesLoaded:function(a,b){this.filesToLoad--;a.store=="params"?this.params=
b:this[a.store]=b;if(!(this.filesToLoad>0)){Costerm.Language.getInstance().fromXML(this.languageXML);Costerm.WebBeheer.AppConfig.getInstance().fromXML(this.documentXML);this.controller=Costerm.WebBeheer.AppConfig.getInstance().getController();this.dictionary=Costerm.WebBeheer.AppConfig.getInstance().getDictionary();this.doc=new Costerm.WebBeheer.Document;var c=this.dictionary.getRootElement().clone();this.doc.setEnums(this.dictionary.getEnums());this.doc.setRootElement(c);this.params.params["System.WebSecure.Value"]&&
this.params.params["System.Login.Accesslevel"]==0?(document.title=L("$Inloggen$"),$(document.body).html("<form id='secureLogin'><div><div><div id='loginMessage'></div><div><input type='text' name='username' id='usernameField'></div><div><input type='password' name='password' id='passwordField'></div><div><input type='submit' class='button' id='loginButton'></div></div></div></form>"),$("#secureLogin").on("submit",this._onLogin.bind(this)),this.loginMessage=document.getElementById("loginMessage"),
this.usernameField=document.getElementById("usernameField"),this.passwordField=document.getElementById("passwordField"),this.loginButton=document.getElementById("loginButton"),this.loginButton.value=L("$Inloggen$"),this.usernameField.setAttribute("placeholder",L("$Gebruikersnaam$")),this.passwordField.setAttribute("placeholder",L("Wachtwoord")),$(this.usernameField).placeholder(),$(this.passwordField).placeholder(),this.params.params["System.Login.MaxUsers"]==1&&$(this.loginMessage).setText(L("$MaxAantalGebruikersBereikt$"))):
this._goRun()}},_isLoggedIn:function(){return this.isLoggedIn},_onLogin:function(a){this.loginButton.disabled=!0;$(this.loginMessage).html("");var b=new Costerm.WebBeheer.ControllerRequest;b.addSetValueRequest("System.Login.User",this.usernameField.value+";"+this.passwordField.value);b.addGetValueRequest(["System.Login.MaxUsers"]);b.handle(this._onLoginSuccess.bind(this),this._onLoginFailed.bind(this));a.preventDefault();return!1},_onLoginSuccess:function(a,b){this.loginButton.disabled=!1;if(b.params["System.Login.User"]==
1){var c=b.sessionId;c!=""&&Costerm.WebBeheer.App.getInstance().setSessionId(c);this._goRun()}else b.params["System.Login.MaxUsers"]==1?$(this.loginMessage).setText(L("$MaxAantalGebruikersBereikt$")):$(this.loginMessage).setText(L("$GebruikersnaamWachtwoordOnjuist$"))},_onLoginFailed:function(){this.loginButton.disabled=!1},_goRun:function(){$(document.body).html("");this.doc.render();this.isLoggedIn=!0;window.setTimeout(function(){window.scrollTo(0,1)},1)},_onFiledLoadFailed:function(){alert("De applicatie kan niet geladen worden!\nThe app cannot be started!")},
getDictionary:function(){return this.dictionary},getDocument:function(){return this.doc},getController:function(){return this.controller},_initSession:function(){if(!this.sessionInited){var a=new Date,b=parseString(getUrlParameter("sessionId")),c=new Date(parseInt(getUrlParameter("sessionDate"))),d=b!=""&&c<=a,e=parseString(localStorage.getItem("sessionId")),h=new Date(parseInt(localStorage.getItem("sessionDate"))),a=e!=""&&h<=a,f="",g=new Date(0);d&&a?(f=h>c?e:b,g=h>c?h:c):d?(f=b,g=c):a&&(f=e,g=
h);this.sessionInited=!1;localStorage.setItem("sessionId",f);localStorage.setItem("sessionDate",g.getTime())}},setSessionId:function(a){this.sessionInited=!0;localStorage.setItem("sessionId",a);localStorage.setItem("sessionDate",(new Date).getTime())},getSessionId:function(){this._initSession();return localStorage.getItem("sessionId")},getSessionDate:function(){this._initSession();return new Date(parseInt(localStorage.getItem("sessionDate")))}};
ns("Costerm.WebBeheer.Elements");Costerm.WebBeheer.Elements.Factory=function(){this.elementTypes={}};Costerm.WebBeheer.Elements.Factory._instance=null;Costerm.WebBeheer.Elements.Factory.getInstance=function(){if(!Costerm.WebBeheer.Elements.Factory._instance)Costerm.WebBeheer.Elements.Factory._instance=new Costerm.WebBeheer.Elements.Factory;return Costerm.WebBeheer.Elements.Factory._instance};
Costerm.WebBeheer.Elements.Factory.prototype={add:function(b,a){this.elementTypes[b]=a},create:function(b,a,c,d){return new this.elementTypes[b](a,c,d)}};ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Element=Utils.extend(Costerm.PropertyProvider,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Element.superclass.constructor.call(this);this.propertyBag=new Costerm.PropertyBag;this.setId(b);this.doc=null;this.invalidate=Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_EVALUATE;this.isRendering=this.rendered=!1;this.parent=this.domElement=null;this.eventId=Utils.id();var b=GetOption(c,"cls","").trim(),d=" "+b.replace(" ","  ")+" ";this.set("enabled",!0);this.set("visible",
!0);this.setIfNotSet("visibilityMode",Costerm.WebBeheer.Elements.Element.VISIBILITY_MODE_DISPLAY);this.propertyBag.setValues(c);b.length>0&&this.set("cls",d);this.expressions=Utils.isDefinedAndNotNull(a)?a:[];this.hasHashChangeEvent=!1},clone:function(){var b=new this.constructor(this.getId());b.copy(this);return b},copy:function(b){this.propertyBag=b.propertyBag.clone();this.expressions=b.expressions.clone()},focus:function(){this.domElement&&this.domElement.focus()},addExpressions:function(b){for(var a=
0;a<b.length;a++)this.expressions.push(b[a])},setDocument:function(b){this.doc=b;b.register(this)},getDocument:function(){return this.doc},getParent:function(){return this.parent},getExpressions:function(){return this.expressions},setIfNotSet:function(b,a){this.get(b)===null&&this.set(b,a)},set:function(b,a,c){var d=this.propertyBag.getValue(b);d!==a&&(this.propertyBag.setValue(b,a),this.setInvalidated(),(!Utils.isDefinedAndNotNull(c)||c===!0)&&this._notifyChangeProperty(b,d,a))},get:function(b){return this.propertyBag.getValue(b)},
_notifyChangeProperty:function(b,a,c){this._notifyObservers("changeProperty",[b,a,c])},setId:function(b){var a=this.getId();b!=a&&(this.rendered&&Debug.log("Id changed! Should not happen after it's rendered.","Element"),this.set("id",b))},getId:function(){return this.get("id")},setEnabled:function(b){this.set("enabled",parseBool(b))},isEnabled:function(){return parseBool(this.get("enabled"))},setVisible:function(b){this.set("visible",parseBool(b))},isVisible:function(){return parseBool(this.get("visible"))},
addClass:function(b){var a=this.get("cls");a===null&&(a="");a.indexOf(" "+b+" ")==-1&&(a+=" "+b+" ",this.set("cls",a),this.setInvalidated())},removeClass:function(b){var a=this.get("cls");a!=null&&a.indexOf(" "+b+" ")!=-1&&(a=a.replace(" "+b+" ",""),this.set("cls",a),this.setInvalidated())},debug:function(b){var a=this.get("debug");a&&Debug.log(a+": "+b,"Element")},_showHint:function(){if(this.get("hint"))this.hintControl=new Costerm.Hint(L(this.get("hint")),this.domElement)},_closeHint:function(){this.hintControl&&
this.hintControl.remove()},getDomElement:function(){return!this.domElement?null:this.domElement},isRendered:function(){return this.rendered},_handleExpressions:function(b){if(b===!0&&((b=this.get("load"))&&this._handleCode(b),b=this.get("navigationChange")))if(this._handleCode(b),!this.hasHashChangeEvent)Debug.log(this.get("id")+": add hash event","Element"),this.hasHashChangeEvent=!0,$(window).on("hashchange.Costerm.WebBeheer.Elements.Element."+this.eventId,this._onHashChange.bind(this));Costerm.WebBeheer.ExpressionHandler.getInstance().handleExpressions(this)},
render:function(b){if(!this.isRendering)this.isRendering=!0,this._doHandleExpressions(),this._doRender(b),this.rendered=!0,this.setInvalidated(!1),this.isRendering=!1},_onHashChange:function(){this.hasHashChangeEvent&&(Debug.log(this.get("id")+": hash changed","Element"),this._handleCode(this.get("navigationChange")))},_doHandleExpressions:function(){if(!this.rendered||this.invalidate==Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_EVALUATE)this.invalidate=Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_RENDER,
this._handleExpressions(!this.rendered)},_doRender:function(){},_isInvalidated:function(){return this.invalidate!=Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_OK},setInvalidated:function(b){b=!Utils.isDefined(b)||b===!0?Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_RENDER:b===!1?Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_OK:b;if(!(b==Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_RENDER&&this.invalidate==Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_EVALUATE))this.invalidate=
b},triggerNavigationChange:function(){var b=this.get("navigationChange");b&&this._handleCode(b)},_doRemove:function(){},remove:function(){if(this.domElement)$(this.domElement).remove(),this.domElement=null;this.setInvalidated();this.rendered=!1;this.parent=null;if(this.hasHashChangeEvent)$(window).off("hashchange.Costerm.WebBeheer.Elements.Element."+this.eventId),this.hasHashChangeEvent=!1,Debug.log(this.get("id")+": remove hash event","Element");this._closeHint();var b=this.get("unload");b&&this._handleCode(b);
this._doRemove();this._notifyObservers("remove");this._removeAllObservers()},_handleCode:function(b){return Costerm.WebBeheer.ExpressionHandler.getInstance().handleCode(b,this)}});Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_OK="ok";Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_RENDER="render";Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_EVALUATE="evaluate";Costerm.WebBeheer.Elements.Element.VISIBILITY_MODE_DISPLAY="display";
Costerm.WebBeheer.Elements.Element.VISIBILITY_MODE_VISIBILITY="visibility";Costerm.WebBeheer.Elements.Element.getDomElement=function(b){return b?b.getDomElement():document.body};ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Button=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Button.superclass.constructor.call(this,b,a,c);this.get("image")||this.get("behaviour")=="imageButton"?this.addClass("imageButton"):this.get("behaviour")=="link"?this.addClass("link"):this.addClass("button")},_doRender:function(b){if(!this.isRendered()){this.get("behaviour")=="submit"?(this.domElement=document.createElement("button"),this.domElement.type="submit"):
this.domElement=document.createElement("div");var a=this.get("image");if(a)this.imgElement=document.createElement("img"),this.imgElement.src=a,this.domElement.appendChild(this.imgElement);this.get("click")&&($(this.domElement).on("click",this._onClick.bind(this)),$(this.domElement).on("keypress",this._onKeyPress.bind(this)))}if(this._isInvalidated()){var c=this.isEnabled(),a=this.get("cls");this.domElement.className=a===null?"":a;(a=this.get("image"))||$(this.domElement).setText(L(this.get("text")));
this.domElement.tabIndex=c?0:-1;this.isVisible();$(this.domElement).toggleClass("disabled",!c).visible(this.isVisible(),this.get("visibilityMode"));c=this.get("color");this.domElement.style.backgroundColor=c==null?"":c}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)},_onKeyPress:function(b){var a=b.string;(b.keyCode==13||a==" ")&&this._onClick()},_onClick:function(){if(this.isEnabled()){var b=this.get("confirm");b?new Costerm.MessageBox(b,this._onConfirmResult.bind(this),
Costerm.MessageBox.TYPE_OK_CANCEL):this._handleCode(this.get("click"))}},click:function(){this.focus();this._onClick()},_onConfirmResult:function(b){b==Costerm.MessageBox.RESULT_OK&&this._handleCode(this.get("click"))}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Button",Costerm.WebBeheer.Elements.Button.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Chart=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Chart.superclass.constructor.call(this,b,a,c);this.setIfNotSet("plots",[]);this.setIfNotSet("startDate",null);this.setIfNotSet("endDate",null);this.setIfNotSet("period",null);this.setIfNotSet("interval",null);this.setIfNotSet("maxPlots",1E3);this.addClass("chart");this.zoomState=Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_ZOOMED_OUT;this.maxTimestamp=null;this.mayResetExtremes=
!1;this.yExtremes=this.xExtremes=null;this.addObserver(this)},_setChartOptions:function(b){this.chart.axis_bottom.major_ticks.count=Math.round(b/140)},_doRender:function(b){if(!this.isRendered()){this.domElement=document.createElement("div");this.domElement.className="chart";this.chart=new EJSC.Chart(this.domElement,{show_messages:!1,legend_title:" ",title:" ",allow_mouse_wheel_zoom:!1,axis_bottom:{caption:"",crosshair:{show:!0},minor_ticks:{show:!1},major_ticks:{count:4},formatter:new EJSC.DateFormatter({format_string:"DD-MM<br>HH:NN:SS",
useUTC:!1})},axis_left:{caption:"",crosshair:{show:!0},formatter:new EJSC.NumberFormatter({decimal_separator:getDecimalSeperator(),variable_decimals:5})},show_titlebar:!1});this.chart.onAfterZoom=this._onChartAfterZoom.bind(this);this.chart.onUserEndZoom=this._onChartUserEndZoom.bind(this);this.chart.onBeforeDblClick=this._onChartDblClick.bind(this);var a=this.get("descriptions");a||(a=[]);for(var c=0;c<a.length;c++){var d=a[c];d==""&&(d=" ");this.chart.addSeries(new EJSC.LineSeries(new EJSC.ArrayDataHandler([]),
{title:d,lineWidth:2}))}}if(this._isInvalidated()&&(c=this.get("plots"))){var a=[],e;for(e in c)if(d=c[e],!$.isFunction(d))for(j=0;j<d.length;j++){var g=parseFloat(e)*1E3,f=[g,d[j]];a[j]||(a[j]=[]);a[j].push(f);if(g>this.maxTimestamp||this.maxTimestamp===null)this.maxTimestamp=g}Debug.log("chart render","Chart");a.length>0&&Debug.log("plots:"+a[0].length,"Chart");e=this.chart.getSeries();for(c=0;c<a.length;c++)e[c]&&(e[c].getDataHandler().setArray(a[c]),this.get("url")?(d=this.get("period"))&&this._setExtremes({min:this.maxTimestamp-
d*1E3,max:this.maxTimestamp},this.yExtremes):this._setExtremes({min:void 0,max:void 0},this.yExtremes),this._setChartExtremes(),e[c].reload());a=this.get("width");e=this.get("height");if(a)this.domElement.style.width=a;if(e)this.domElement.style.height=e;!a&&!e?this._startCheckResize():this._stopCheckResize();$(this.domElement).visible(this.isVisible(),this.get("visibilityMode"));this.mayResetExtremes=!0;this.chart.redraw()}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)},
_setZoomState:function(b){if(this.zoomState!=b)this.zoomState=b},_setExtremes:function(b,a){this.xExtremes=b;this.yExtremes=a;Debug.log("X-Extremes are now:"+(this.xExtremes?this.xExtremes.min+" ; "+this.xExtremes.max:"null"),"Chart");Debug.log("Y-Extremes are now:"+(this.yExtremes?this.yExtremes.min+" ; "+this.yExtremes.max:"null"),"Chart")},_setChartExtremes:function(){Debug.log("Extremes set","Chart");this.xExtremes?this.chart.axis_bottom.setExtremes(this.xExtremes.min,this.xExtremes.max):this.chart.axis_bottom.setExtremes(void 0,
void 0);this.yExtremes?this.chart.axis_left.setExtremes(this.yExtremes.min,this.yExtremes.max):this.chart.axis_left.setExtremes(void 0,void 0)},_onChartDblClick:function(){if(this.get("url")&&this.xExtremes){var b=this.chart.getMinMaxYInXRange(this.xExtremes.min,this.xExtremes.max);b.y_min!==b.y_max&&this._setExtremes(this.xExtremes,{min:b.y_min,max:b.y_max})}else this._setExtremes(this.xExtremes,null);this.mayResetExtremes&&(this._setChartExtremes(),this.chart.redraw());return!1},_onChartUserEndZoom:function(b,
a,c){if(a.x>=c.x||a.y>=c.y)if(this.zoomState==Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_ZOOMED_OUT)return!1;else this._setZoomState(Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_BUSY_ZOOMING_OUT);else this.zoomState!=Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_ZOOMED_IN&&this._setZoomState(Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_BUSY_ZOOMING_IN);b=!!this.get("url");if(!b)this.mayResetExtremes=!1;c=a=null;switch(this.zoomState){case Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_BUSY_ZOOMING_OUT:this._setZoomState(Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_ZOOMED_OUT);
this._setExtremes(null,null);b&&(this._setChartExtremes(),this.chart.redraw());period=c=a=null;break;case Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_BUSY_ZOOMING_IN:case Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_ZOOMED_IN:this._setZoomState(Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_ZOOMED_IN),b=this.chart.axis_bottom.getZoomBoxCoordinates(),a=this.chart.axis_bottom.getExtremes(),a=(b.max-a.min)/(this.maxTimestamp-a.min)>0.9,Debug.log("liveData:"+a,"Chart"),this._setExtremes(this.chart.axis_bottom.getZoomBoxCoordinates(),
this.chart.axis_left.getZoomBoxCoordinates()),a?(c=a=null,period=Math.floor((b.max-b.min)/1E3)):(a=Math.floor(b.min/1E3),c=Math.ceil(b.max/1E3),period=null)}this.prevEndDate=c;this.set("startDate",a);this.set("endDate",c);this.set("period",period)},_onChartAfterZoom:function(){},_update:function(b,a,c){if(!this.get("url")&&a=="changeProperty")switch(c[0]){case "startDate":case "endDate":case "period":this._handleExpressions()}},remove:function(){this._stopCheckResize();Costerm.WebBeheer.Elements.Chart.superclass.remove.call(this)},
_startCheckResize:function(){this._stopCheckResize();this.checkResizeFunction=window.setTimeout(this._checkResize.bind(this),500)},_stopCheckResize:function(){if(this.checkResizeFunction)window.clearTimeout(this.checkResizeFunction),this.checkResizeFunction=null},_checkResize:function(){var b=this.domElement.parentNode.clientWidth,a=this.domElement.parentNode.clientHeight;if(this.prevWidth!=b||this.prevHeight!=a)Debug.log(b,"Chart"),Debug.log(a,"Chart"),this.domElement.style.width=b-30+"px",this.domElement.style.height=
a-25+"px",this._setChartOptions(b,a),this.chart.redraw(),this.prevWidth=b,this.prevHeight=a;this._startCheckResize()}});Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_ZOOMED_OUT="zoomedOut";Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_BUSY_ZOOMING_IN="busyZoomingIn";Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_ZOOMED_IN="zoomedIn";Costerm.WebBeheer.Elements.Chart.ZOOM_STATE_BUSY_ZOOMING_OUT="busyZoomingOut";Costerm.WebBeheer.Elements.Factory.getInstance().add("Chart",Costerm.WebBeheer.Elements.Chart.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.CheckBox=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.CheckBox.superclass.constructor.call(this,b,a,c);this.setIfNotSet("format","number");this.addClass("checkBox customControl")},_doRender:function(b){if(!this.isRendered())this.domElement=document.createElement("div"),this.inputElement=document.createElement("input"),this.inputElement.type="checkbox",$(this.inputElement).on("mouseover",this._onFocus.bind(this)).on("mouseout",
this._onBlur.bind(this)).on("change",this._onChange.bind(this)),this.domElement.appendChild(this.inputElement);if(this._isInvalidated()){this.get("cls");this.domElement.className=this.get("cls");var a=this.isEnabled(),c=this.get("value");if(c!=this.inputElement.value)this.inputElement.checked=parseBool(c);this.inputElement.disabled=!a;$(this.inputElement).visible(this.isVisible(),this.get("visibilityMode"))}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)},
_onFocus:function(){this._showHint()},_onBlur:function(){this._closeHint()},_onChange:function(){this.isEnabled()&&(this.get("format")=="boolean"?this.set("value",this.inputElement.checked):this.set("value",this.inputElement.checked?1:0))}});Costerm.WebBeheer.Elements.Factory.getInstance().add("CheckBox",Costerm.WebBeheer.Elements.CheckBox.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Composite=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Composite.superclass.constructor.call(this,b,a,c);this.childElements=[];this.addClass("composite")},clone:function(){for(var b=new this.constructor(this.getId()),a=0;a<this.childElements.length;a++){var c=this.childElements[a].clone();b.appendChild(c)}b.copy(this);return b},set:function(b,a,c){if(c)for(var d=0;d<this.childElements.length;d++)this.childElements[d].set(b,a,
c);Costerm.WebBeheer.Elements.Composite.superclass.set.call(this,b,a)},setDocument:function(b){Costerm.WebBeheer.Elements.Composite.superclass.setDocument.call(this,b);for(var a=0;a<this.childElements.length;a++)this.childElements[a].setDocument(b)},setEnabled:function(b){for(var a=0;a<this.childElements.length;a++)this.childElements[a].setEnabled(b);Costerm.WebBeheer.Elements.Composite.superclass.setEnabled.call(this,b)},setVisible:function(b){for(var a=0;a<this.childElements.length;a++)this.childElements[a].setVisible(b);
Costerm.WebBeheer.Elements.Composite.superclass.setVisible.call(this,b)},setInvalidated:function(b,a){if(a)for(var c=0;c<this.childElements.length;c++)this.childElements[c].setInvalidated(b,a);Costerm.WebBeheer.Elements.Composite.superclass.setInvalidated.call(this,b,a)},addClass:function(b){for(var a=0;a<this.childElements.length;a++)this.childElements[a].addClass(b);Costerm.WebBeheer.Elements.Composite.superclass.addClass.call(this,b)},removeClass:function(b){for(var a=0;a<this.childElements.length;a++)this.childElements[a].removeClass(b);
Costerm.WebBeheer.Elements.Composite.superclass.removeClass.call(this,b)},_doHandleExpressions:function(){Costerm.WebBeheer.Elements.Composite.superclass._doHandleExpressions.call(this)},_doRender:function(b){if(!this.isRendered()&&(this.domElement=document.createElement("div"),this.get("click")))$(this.domElement).on("click",this._onClick.bind(this));if(this._isInvalidated()){var a=this.get("cls");this.domElement.className=a===null?"":a;$(this.domElement).visible(this.isVisible(),this.get("visibilityMode"));
(a=this.get("color"))?this.domElement.style.backgroundColor=a:this.domElement.style.removeProperty?this.domElement.style.removeProperty("background-color"):this.domElement.style.backgroundColor=""}for(a=0;a<this.childElements.length;a++)this.childElements[a].render(this);this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)},getChildren:function(){return this.childElements},appendChild:function(b){b.parent=this;b.addObserver(this);this.childElements.push(b)},
replaceChild:function(b,a){a.parent=this;this.childElements.splice(this.childElements.indexOf(b),1,a);b.remove();a.addObserver(this)},insertChild:function(b,a){a.parent=this;a.addObserver(this);b>=this.childElements.length?this.childElements.push(a):this.childElements.splice(b,0,a)},removeChildren:function(){for(;this.childElements.length>0;)this.childElements[0].remove();this.childElements=[]},remove:function(){this.removeChildren();Costerm.WebBeheer.Elements.Composite.superclass.remove.call(this)},
_update:function(b,a){a=="remove"&&this.childElements.remove(b)},_onClick:function(){this._handleCode(this.get("click"))}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Composite",Costerm.WebBeheer.Elements.Composite.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Dialog=Utils.extend(Costerm.WebBeheer.Elements.Composite,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Dialog.superclass.constructor.call(this,b,a,c);this.addClass("dialog")},_doRender:function(b){var a=this.domElement;Costerm.WebBeheer.Elements.Dialog.superclass._doRender.call(this,b);if(!a){b={title:L(this.get("title")),close:this._onClose.bind(this),closeText:L("$Sluiten$")};if(a=this.get("minWidth"))b.minWidth=a;if(a=this.get("minHeight"))b.minHeight=a;$(this.domElement).dialog(b).dialogExtend({minimizeLocation:"right",
maximizable:!0,minimizable:!0,closable:!0});$(".ui-dialog-titlebar-maximize").prop("title",L("$Maximaliseren$"));$(".ui-dialog-titlebar-minimize").prop("title",L("$Minimaliseren$"));$(".ui-icon-newwin").prop("title",L("$Herstellen$"))}},_onClose:function(){$(this.domElement).dialog("destroy").remove();this.remove()}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Dialog",Costerm.WebBeheer.Elements.Dialog.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Image=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Image.superclass.constructor.call(this,b,a,c);this.addClass("image");this.setIfNotSet("source","");this.setIfNotSet("error",!1);this.usedSrc=""},_doRender:function(b){if(!this.isRendered())this.domElement=document.createElement("img"),$(this.domElement).on("error",this._onError.bind(this));if(this._isInvalidated()){var a=this.get("cls");this.domElement.className=
a===null?"":a;var c=this.get("source"),a=this.get("error");if(Utils.isDefinedAndNotNull(c)){if(c!=this.usedSrc)this.set("error",!1),this.usedSrc=this.domElement.src=c}else this.setVisible(!1);var c=this.get("maxWidth"),d=this.get("maxHeight");this.domElement.style.maxWidth=c===null?"none":c+"px";this.domElement.style.maxHeight=d===null?"none":d+"px";$(this.domElement).visible(this.isVisible()&&!a,this.get("visibilityMode"))}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)},
_onError:function(){this.set("error",!0);$(this.domElement).visible(!1,this.get("visibilityMode"))}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Image",Costerm.WebBeheer.Elements.Image.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Input=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Input.superclass.constructor.call(this,b,a,c);this.hasFocus=!1;this.addClass("input");this.setIfNotSet("format","string");this.setIfNotSet("decimals",0);this.setIfNotSet("alwaysShowDecimals",!0);this.setIfNotSet("password",!1);switch(this.get("format")){case "string":case "ip":case "url":case "email":b=!0;break;default:b=!1}this.setIfNotSet("nullable",b)},_doRender:function(b){if(!this.isRendered()){var a=
this.get("format"),c=this.get("password");this.domElement=document.createElement("input");try{var d=!1;if(c)this.domElement.type="password",d=!0;if(!d)if(a=="number"){if(this.domElement.type="number",Utils.isDefined(this.domElement.step))this.domElement.step="any"}else this.domElement.type="text"}catch(e){this.domElement.type="text"}$(this.domElement).on("focus",this._onFocus.bind(this)).on("blur",this._onBlur.bind(this));if(c=this.get("name"))this.domElement.name=c;c=0;switch(a){case "number":$(this.domElement).on("keypress",
this._onKeyPress.bind(this));if(this.get("maxValue")&&this.get("minValue"))c=Math.max(parseString(this.get("maxValue")).length,parseString(this.get("minValue")).length),this.domElement.min=this.get("minValue"),this.domElement.max=this.get("maxValue");a=parseInt(this.get("decimals"));c>0&&a>0&&(c+=parseFloat(this.get("decimals"))+1);break;case "time":$(this.domElement).on("keypress",this._onKeyPress.bind(this));this.domElement.maxLength=6;break;case "date":$(this.domElement).on("keypress",this._onKeyPress.bind(this));
this.domElement.maxLength=5;break;case "dateYear":$(this.domElement).on("keypress",this._onKeyPress.bind(this));this.domElement.maxLength=10;break;case "ip":$(this.domElement).on("keypress",this._onKeyPress.bind(this));this.domElement.maxLength=15;break;case "email":case "string":if($(this.domElement).on("keypress",this._onKeyPress.bind(this)),this.get("maxLength")>0)this.domElement.maxLength=this.get("maxLength")}if(c>0)this.domElement.maxLength=c}if(this._isInvalidated())a=this.get("cls"),this.domElement.className=
a===null?"":a,a=this.isEnabled(),(!this.hasFocus||!a)&&!this.invalidInput&&this._putValueInInput(),this.domElement.disabled=!a,$(this.domElement).visible(this.isVisible(),this.get("visibilityMode"));this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)},_onKeyPress:function(b){var a=b.string;this.set("charCodePressed",b.charCode);this.set("keyCodePressed",b.keyCode);this.set("keyPressed",a);var c=!1;if(b.keyCode==13){if(b=this.get("defaultButton"))(b=
Costerm.WebBeheer.App.getInstance().getDocument().getElementById(b))&&b.click()}else{if(a!==null){this.keyPressed=!0;var d=this.domElement.value,e=this.get("format");switch(e){case "number":switch(a){case "-":c=this.get("minValue")!==null&&this.get("minValue")>=0||d.indexOf("-")>=0;break;case ".":case ",":c=this.get("decimals")==0||d.indexOf(".")>=0||d.indexOf(",")>=0;break;default:c=!a.match(/[\d]/g)}break;case "ip":switch(a){default:c=!a.match(/[\d\.]/g)}break;case "time":switch(a){case ".":case ":":case "h":case "m":case "s":c=
d.indexOf(a)>=0;break;default:c=!a.match(/[\d]/g)}break;case "date":case "dateYear":switch(a){case ".":case "-":case "/":a=d.split(a).length-1;c=e=="dateYear"?a>=2:a>=1;break;default:c=!a.match(/[\d]/g)}}}c||this.get("keypress")&&(c=this._handleCode(this.get("keypress")));c&&b.preventDefault()}},_putValueInInput:function(){var b=this.get("format"),a=this.get("value"),c=parseBool(this.get("alwaysShowDecimals"));Utils.isDefinedAndNotNull(a)&&a!==""?b=="number"?(b=c?parseFloatInp(a).toFixed(this.get("decimals")):
parseFloatInp(a),$.browser.chrome||$.browser.mozilla?this.domElement.value="":b=floatToString(b),this.domElement.value=b):this.domElement.value=b=="time"?toTimeString(a):a:this.domElement.value=""},_onFocus:function(){this.hasFocus=!0;this.keyPressed=!1;this.controlValueOnFocus=this.domElement.value;this.invalidInputOnFocus=this.invalidInput;this._clearInvalidInput();this._showHint()},_onBlur:function(b){this.hasFocus=this.invalidInput=!1;if((this.keyPressed||this.controlValueOnFocus!==this.domElement.value||
this.invalidInputOnFocus)&&this.isEnabled()){var a=this.get("format"),c=this.get("nullable");if(a=="string")this.set("value",this.domElement.value),this._onUserChange();else{var d=this.domElement.value,e=d,g=!0;switch(a){case "number":e=parseFloatInp(e);g=this.get("minValue");a=this.get("maxValue");g=!isNaN(e)&&(g===null||parseFloat(g)<=e)&&(a===null||parseFloat(a)>=e);break;case "ip":a=e.split(".");if(a.length!=4)g=!1;else for(var f=0;f<a.length;f++){var h=parseInt(a[f]);if(isNaN(h)||h<0||h>255){g=
!1;break}}break;case "url":g=e.match(/^(https?|ftp):\/\/[^\s\/$.?#].[^\s]*$/gi)!==null;break;case "email":g=e.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/gi)!==null;break;case "time":g=e.match(/^((([01]?[0-9]|2[0-3])[:hm\.][0-5][0-9][ms]?)|(24[:hm\.]00[ms]?))$/g)!==null;break;case "date":case "dateYear":if(a=a=="date"?e.match(/^(\d+)[\.\/-](\d+)$/):e.match(/^(\d+)[\.\/-](\d+)[\.\/-](\d+)$/),g=a!==null)if(f=parseInt(a[1]),a=parseInt(a[2]),f!=0||a!=0){switch(a){case 2:g=29;break;case 4:case 6:case 9:case 11:g=
30;break;default:g=31}g=f<=g}}a=!0;d===""&&(c?(e="",g=!0):(this._putValueInInput(),a=!1));if(a)g?(this.set("value",e),this._putValueInInput(),this._onUserChange()):(b.preventDefault(),$(this.domElement).addClass("inputError"),this.clearInvalidInputTimer=window.setTimeout(this._clearInvalidInput.bind(this),1E4),this.invalidInput=!0)}}this._closeHint()},_clearInvalidInput:function(){if(this.clearInvalidInputTimer)window.clearTimeout(this.clearInvalidInputTimer),this.clearInvalidInputTimer=null;this.invalidInput=
!1;$(this.domElement).removeClass("inputError");if(!this.hasFocus)this.domElement.value=this.get("value")},_onUserChange:function(){this._handleCode(this.get("userChange"))}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Input",Costerm.WebBeheer.Elements.Input.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Iterator=Utils.extend(Costerm.WebBeheer.Elements.Composite,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Iterator.superclass.constructor.call(this,b,a,c);this.refId=GetOption(c,"refId");this.setIfNotSet("startIndex",0);this.setIfNotSet("maxItemsCount",0);this.setIfNotSet("step",1);this.setIfNotSet("values",[]);this.setIfNotSet("hasPrevious",!1);this.setIfNotSet("hasNext",!1);this.setIfNotSet("restartOnNoValues",!1);this.setIfNotSet("reverse",!1);this.elementsValues=
[];this.elementsByIndex=[];this.noItemsControlShown=!1;this.addObserver(this);this.addClass("iterator")},copy:function(b){Costerm.WebBeheer.Elements.Iterator.superclass.copy.call(this,b)},next:function(){this.set("startIndex",parseInt(this.get("startIndex"))+parseInt(this.get("maxItemsCount")))},previous:function(){this.set("startIndex",Math.max(parseInt(this.get("startIndex"))-parseInt(this.get("maxItemsCount")),0))},_update:function(b,a,c){if(a=="changeProperty")switch(c[0]){case "reverse":case "startIndex":case "maxItemsCount":this.isRendered()&&
!isNaN(this.get("startIndex"))&&!isNaN(this.get("maxItemsCount"))&&this._handleExpressions()}Costerm.WebBeheer.Elements.Iterator.superclass._update.apply(this,arguments)},_doRender:function(b){if(!this.isRendered())this.domElement=document.createElement("div");if(this._isInvalidated()){var a=this.get("cls");this.domElement.className=a===null?"":a;$(this.domElement).visible(this.isVisible(),this.get("visibilityMode"));a=this.get("color");this.domElement.style.backgroundColor=a?a:"transparent"}a=this.get("values");
this.debug("iterator values:"+arrayToString(a));a===null&&(a=[]);var c=null,d=parseInt(this.get("startIndex")),e=parseInt(this.get("maxItemsCount")),g=parseInt(this.get("step"));this.set("hasPrevious",d!=0);this.set("hasNext",e!=0&&a.length>e);var f;a.length==0?f=0:(f=parseInt((a.length-1)/g+1),this.debug("values.length:"+a.length+" handlingvaluescount:"+f+" maxItemsCount:"+e),e>0&&e<f&&(f=e));if(this.noItemsControlShown&&f>0)this.noItemsControlShown=!1,this.removeChildren();if(!this.noItemsControlShown){for(var h=
e=0;h<f;h++){var l=a[h*g],i=this.elementsValues.indexOf(l),m=[];if(i==-1){var k=new Costerm.WebBeheer.Elements.Reference(this.getId());k.set("refId",this.get("refId"));k.set(this.get("value"),l);m.push(this.get("value"));k.setDocument(this.doc);this.insertChild(h,k);this.elementsValues.splice(h,0,l)}else i!==h&&(k=this.childElements[i],this.childElements.splice(i,1),this.childElements.splice(h,0,k),k.isRendered()&&(k=k.getDomElement(),c===null?$(this.domElement).prepend(k):$(c).after(k)),this.elementsValues.splice(i,
1),this.elementsValues.splice(h,0,l));k=this.childElements[h];l=h*g+d;this.get("index")!=null&&(k.set(this.get("index"),l),m.push(this.get("index")));this.get("index1Based")!=null&&(k.set(this.get("index1Based"),l+1),m.push(this.get("index1Based")));this.get("position")!=null&&(k.set(this.get("position"),e),m.push(this.get("position")));this.get("position1Based")!=null&&(k.set(this.get("position1Based"),e+1),m.push(this.get("position1Based")));k.isRendered()?k.render(this):(k instanceof Costerm.WebBeheer.Elements.Reference&&
k.set("copyMode",m),k.render(this),k=this.childElements[h].getDomElement(),c===null?$(this.domElement).prepend(k):$(c).after(k));c=this.childElements[h].getDomElement();e++}for(h=0;h<this.elementsValues.length-f;h++)this.childElements[f].remove()}this.elementsValues.splice(f,this.elementsValues.length-f);if(f==0&&this.get("noItemsRefId")&&!this.noItemsControlShown&&d==0)this.noItemsControlShown=!0,k=new Costerm.WebBeheer.Elements.Reference(this.getId()),k.set("refId",this.get("noItemsRefId")),k.setDocument(this.doc),
this.appendChild(k),k.render(this);parseBool(this.get("restartOnNoValues"))&&d>0&&f==0&&window.setTimeout(function(){this.set("startIndex",0)}.bind(this),1);this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Iterator",Costerm.WebBeheer.Elements.Iterator.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.JavaVisu=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.JavaVisu.superclass.constructor.call(this,b,a,c);this.setIfNotSet("width",1E3);this.setIfNotSet("height",600);this.addClass("javaVisu");this.addClass("customControl");this.initTimer=this.scrollContainer=this.currentVisu=null;this.removed=!1;Debug.log("javaVisu element "+b+" create","JavaVisu")},_doRender:function(b){if(!this.isRendered())if(javaEnabled()){this.domElement=document.createElement("div");
var a=document.createElement("span");$(a).setText(L("$JavaVisuWordtGeladen$")).addClass("noteEmphasize");var c=document.createElement("img");c.src="Resources/Img/Wait.gif";this.domElement.appendChild(c);this.domElement.appendChild(a);Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement);$(window).on("resize.Costerm.WebBeheer.Elements.JavaVisu."+this.eventId,this._onScrollResize.bind(this));this.container=Costerm.WebBeheer.App.getInstance().getDocument().getElementById(this.get("scroll")).getDomElement();
$(this.container).on("scroll.Costerm.WebBeheer.Elements.JavaVisu."+this.eventId,this._onScrollResize.bind(this));(this.hasNoClip=$(this.container).hasClass("noClip"))||$(this.container).addClass("noClip")}else this.domElement=document.createElement("div"),a=document.createElement("span"),$(a).setText(L("$GeenJavaSupport$")).addClass("noteEmphasize"),this.domElement.appendChild(a),Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement);if(this._isInvalidated()&&javaEnabled())this.initTimer=
window.setTimeout(this._init.bind(this),1)},_init:function(){var b=this.get("cls");this.domElement.className=b===null?"":b;var a=parseInt(this.get("width")),c=parseInt(this.get("height"));if(b=this.get("visu")){var d=Costerm.WebBeheer.Elements.JavaVisu.applet,e=Costerm.WebBeheer.Elements.JavaVisu.appletContainer;if(d==null)e=document.createElement("div"),e.className="appletContainer",this._changeAppletStatus(Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_PENDING_START),Costerm.WebBeheer.AppSettings.EnableJava&&
(d=loadApplet(e,"webvisu/WebVisu.class",".",a,c,Costerm.WebBeheer.Elements.JavaVisu.JARS,[{name:"STARTVISU",value:b},{name:"FORCEDLOAD",value:""},{name:"UPDATETIME",value:"300"},{name:"USECURRENTVISU",value:"FALSE"},{name:"COMPRESSEDFILES",value:"TRUE"},{name:"USEFIXSOCKETCONNECTION",value:"FALSE"},{name:"PLCSTATEINTERVAL",value:"2000"},{name:"USEURLCONNECTION",value:"TRUE"},{name:"AUTORELOAD",value:"FALSE"},{name:"MONITORINGPORT",value:getPort()}],null,L("$GeenJavaSupport$"))),Debug.log("applet created "+
b,"JavaVisu"),Costerm.WebBeheer.Elements.JavaVisu.applet=d,Costerm.WebBeheer.Elements.JavaVisu.appletContainer=e,this._moveAppletOffScreen(),document.body.appendChild(e),this.currentVisu=b,this._changeAppletStatus(Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_STARTED);if(this.isVisible()){if(Costerm.WebBeheer.Elements.JavaVisu.appletStatus==Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_STOPPED)try{Debug.log("applet start","JavaVisu"),Costerm.WebBeheer.AppSettings.EnableJava&&d.start()}catch(g){}this._changeAppletStatus(Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_STARTED);
if(this.currentVisu!=b){try{if(Debug.log("applet loadVisualisation "+b+" 2 times","JavaVisu"),Costerm.WebBeheer.AppSettings.EnableJava)for(a=0;a<2;a++){var f=Costerm.WebBeheer.Elements.JavaVisu.APPLET_VERSION>=2.0309035?d.A(b,null,null,null,!1,"",!0):d.loadVisualisation(b,null,null,null,!1,"");Debug.log("applet loadVisualisation result: "+f,"JavaVisu")}}catch(h){}this.currentVisu=b}}else this._stopApplet();this._onScrollResize()}},_changeAppletStatus:function(b,a){if(!(this.removed&&a!==!0)&&b!==
Costerm.WebBeheer.Elements.JavaVisu.appletStatus)Debug.log("applet status changed to "+b,"JavaVisu"),Costerm.WebBeheer.Elements.JavaVisu.appletStatus=b},_stopApplet:function(){if(Costerm.WebBeheer.Elements.JavaVisu.appletStatus==Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_STARTED||Costerm.WebBeheer.Elements.JavaVisu.appletStatus==Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_PENDING_START)Debug.log("applet pending stop","JavaVisu"),window.setTimeout(this._stopAppletHelp.bind(this),3E3),
this._moveAppletOffScreen(),this._changeAppletStatus(Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_PENDING_STOP)},_stopAppletHelp:function(){if(Costerm.WebBeheer.Elements.JavaVisu.appletStatus==Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_PENDING_STOP){var b=Costerm.WebBeheer.Elements.JavaVisu.applet;try{Debug.log("applet stop","JavaVisu"),Costerm.WebBeheer.AppSettings.EnableJava&&b.stop()}catch(a){}this._changeAppletStatus(Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_STOPPED,!0)}},
_onScrollResize:function(){if(!this.removed)if(Costerm.WebBeheer.Elements.JavaVisu.appletStatus==Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_STARTED){var b=Costerm.WebBeheer.Elements.JavaVisu.appletContainer,a=b.scrollHeight,c=b.scrollWidth;$(this.domElement).width(c).height(a);var a=$(this.container).offset(),d=a.left,e=a.top,g=parseFloat($(this.container).css("border-left-width")),f=parseFloat($(this.container).css("border-top-width")),c=$(this.domElement).offset(),a=c.left,c=c.top,h=$(this.domElement).outerWidth(),
l=$(this.domElement).outerHeight();d+=g;g=d+this.container.clientWidth;e+=f;var f=e+this.container.clientHeight,i=a+h,h=c+l;a<=g&&i>d&&c<=f&&h>e?(l=Math.max(d,a),g=Math.min(g,i),i=Math.max(e,c),f=Math.min(f,h),b.style.left=l+"px",b.style.top=i+"px",b.style.width=g-l+"px",b.style.height=f-i+"px",b.scrollLeft=Math.max(0,d-a),b.scrollTop=Math.max(0,e-c)):(this._moveAppletOffScreen(),Debug.log("Applet not visible","JavaVisu"));window.setTimeout(this._onScrollResize.bind(this),1E3)}else this._moveAppletOffScreen()},
_moveAppletOffScreen:function(){var b=Costerm.WebBeheer.Elements.JavaVisu.appletContainer;if(b)b.style.top="-10000px"},_doRemove:function(){this._stopApplet();Debug.log("javaVisu element "+this.getId()+" remove","JavaVisu");this.removed=!0;$(window).off("resize.Costerm.WebBeheer.Elements.JavaVisu."+this.eventId);this.container&&($(this.container).off("scroll.Costerm.WebBeheer.Elements.JavaVisu."+this.eventId),this.hasNoClip||$(this.container).removeClass("noClip"));window.clearTimeout(this.initTimer)}});
Costerm.WebBeheer.Elements.JavaVisu.JARS="hcsvisu.jar,hcsminml.jar";Costerm.WebBeheer.Elements.JavaVisu.APPLET_VERSION=2.0309035;Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_STARTED="started";Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_STOPPED="stopped";Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_PENDING_STOP="pendingStop";Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_PENDING_START="pendingStart";Costerm.WebBeheer.Elements.JavaVisu.applet=null;
Costerm.WebBeheer.Elements.JavaVisu.appletStatus=Costerm.WebBeheer.Elements.JavaVisu.APPLET_STATUS_STOPPED;Costerm.WebBeheer.Elements.JavaVisu.appletContainer=null;function javaNavigateTo(){Costerm.WebBeheer.ExpressionHandler.getInstance().setGlobalNavigation.apply(Costerm.WebBeheer.ExpressionHandler.getInstance(),arguments)}function javaDownload(){Costerm.WebBeheer.ExpressionHandler.getInstance().download.apply(Costerm.WebBeheer.ExpressionHandler.getInstance(),arguments)}
function javaOpenLocation(){Costerm.WebBeheer.ExpressionHandler.getInstance().openLocation.apply(Costerm.WebBeheer.ExpressionHandler.getInstance(),arguments)}Costerm.WebBeheer.Elements.Factory.getInstance().add("JavaVisu",Costerm.WebBeheer.Elements.JavaVisu.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Label=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Label.superclass.constructor.call(this,b,a,c);this.addClass("label");this.addClass("customControl");this.setIfNotSet("format","string");this.setIfNotSet("decimals",null)},_doRender:function(b){if(!this.isRendered())this.domElement=document.createElement("div");if(this._isInvalidated()){var a=this.get("cls");this.domElement.className=a===null?"":a;var a=this.get("text"),
c=this.get("hint"),d=this.get("format");if(Utils.isDefinedAndNotNull(a)){var e="";switch(d){default:e=L(a);break;case "time":e=toTimeString(a);break;case "number":e=floatToString(a,this.get("decimals"))}$(this.domElement).setText(e)}if(c){if(Utils.Support.touch())this.openHint=document.createElement("span"),$(this.openHint).setText("?"),this.openHint.className="openLabelHint",this.domElement.appendChild(this.openHint);$(this.domElement).on("click",this._onOpenHint.bind(this));this.domElement.style.cursor=
"help"}$(this.domElement).visible(this.isVisible(),this.get("visibilityMode"))}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)},_onOpenHint:function(){this._showHint()}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Label",Costerm.WebBeheer.Elements.Label.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Literal=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Literal.superclass.constructor.call(this,b,a,c);this.addClass("literal")},_doRender:function(b){if(!this.isRendered())this.domElement=document.createElement("div");if(this._isInvalidated()){var a=this.get("cls");this.domElement.className=a===null?"":a;var a=this.get("content"),c=this.get("hint");a!==null&&$(this.domElement).html(Costerm.Language.getInstance().translate(a));if(c){if(Utils.Support.touch())this.openHint=
document.createElement("span"),$(this.openHint).setText("?"),this.openHint.className="openLabelHint",this.domElement.appendChild(this.openHint);$(this.domElement).on("click",this._onOpenHint.bind(this));this.domElement.style.cursor="help"}$(this.domElement).visible(this.isVisible(),this.get("visibilityMode"))}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)},_onOpenHint:function(){this._showHint()}});
Costerm.WebBeheer.Elements.Factory.getInstance().add("Literal",Costerm.WebBeheer.Elements.Literal.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Progressbar=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Progressbar.superclass.constructor.call(this,b,a,c);this.addClass("progressbar");this.setIfNotSet("value",0);this.setIfNotSet("maxValue",100)},_doRender:function(b){if(!this.isRendered())this.domElement=document.createElement("div"),this.contentElement=document.createElement("div"),this.contentElement.className="caption",$(this.domElement).progressbar({value:this.get("value"),max:this.get("maxValue")}),
this.domElement.appendChild(this.contentElement);if(this._isInvalidated()){var a=this.get("caption");$(this.contentElement).html(Costerm.Language.getInstance().translate(a));$(this.domElement).visible(this.isVisible(),this.get("visibilityMode"));a=this.get("value");a==-1&&(a=!1);$(this.domElement).progressbar("option","value",a);$(this.domElement).progressbar("option","max",this.get("maxValue"))}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)}});
Costerm.WebBeheer.Elements.Factory.getInstance().add("Progressbar",Costerm.WebBeheer.Elements.Progressbar.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Reference=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Reference.superclass.constructor.call(this,b,a,c);this.setIfNotSet("copyMode",Costerm.WebBeheer.Elements.Reference.COPY_MODE_NO_COPY)},copy:function(b){Costerm.WebBeheer.Elements.Reference.superclass.copy.call(this,b)},_update:function(b,a,c){if(a=="changeProperty")switch(c[0]){case "refId":Debug.log("refId changed:"+this.get("refId"),"Reference")}Costerm.WebBeheer.Elements.Reference.superclass._update.apply(this,
arguments)},render:function(b){this.get("refId")||this._doHandleExpressions();if(this.get("refId")){var b=Costerm.WebBeheer.App.getInstance().getDictionary().getElementById(this.get("refId")).clone(),a=this.propertyBag.getProperties(),c=this.get("copyMode");if($.isArray(c)&&c.length>0||$.isString(c)&&c!=Costerm.WebBeheer.Elements.Reference.COPY_MODE_NO_COPY&&c!=""){var d=c===Costerm.WebBeheer.Elements.Reference.COPY_MODE_COPY,e;d||(e=$.isArray(c)?c:c.split(","));for(var g in a)c=a[g],c instanceof
Costerm.Property&&g!="id"&&g!="type"&&g!="copyMode"&&(d||e.indexOf(c.getName())>=0)&&b.propertyBag.setValue(c.getName(),c.getValue())}b.addExpressions(this.expressions);b.setId(this.getId());e=this.domElement?this.domElement.nextElementSibling:null;(g=this.parent)&&this.parent.replaceChild(this,b);b.setDocument(this.doc);b.render(g);e&&$(e).before(b.getDomElement())}else Costerm.WebBeheer.Elements.Reference.superclass.render.call(this,b)},_doRender:function(b){if(!this.isRendered()){this.domElement=
document.createElement("div");var a=this.get("cls");this.domElement.className=a===null?"":a;$(this.domElement).html("&nbsp;");$(this.domElement).visible(!1,this.get("visibilityMode"))}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)}});Costerm.WebBeheer.Elements.Reference.COPY_MODE_COPY="copy";Costerm.WebBeheer.Elements.Reference.COPY_MODE_NO_COPY="noCopy";Costerm.WebBeheer.Elements.Factory.getInstance().add("Reference",Costerm.WebBeheer.Elements.Reference.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Rotator=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Rotator.superclass.constructor.call(this,b,a,c);this.setIfNotSet("minValue",0);this.setIfNotSet("maxValue",1);this.setIfNotSet("step",1);this.setIfNotSet("format","number");this.addClass("rotator");this.addClass("customControl")},_doRender:function(b){if(!this.isRendered())this.domElement=document.createElement("div"),this.domElement.style.cursor="pointer",$(this.domElement).on("keypress",
this._onKeyPress.bind(this)).on("focus",this._onFocus.bind(this)).on("blur",this._onBlur.bind(this));if(this._isInvalidated()){var a=this.get("cls");this.domElement.className=a===null?"":a;var a=this.isEnabled(),c=this.get("text");c!==null&&$(this.domElement).setText(L(c));this.domElement.style.backgroundColor=this.get("color");this.domElement.style.cursor=a?"pointer":"";c=a?0:-1;if(c!=this.domElement.tabIndex)this.domElement.tabIndex=c;$(this.domElement).off("click");if(a)$(this.domElement).on("click",
this._onClick.bind(this));$(this.domElement).visible(this.isVisible(),this.get("visibilityMode"))}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)},_onKeyPress:function(b){b.string==" "&&this._onClick()},_onFocus:function(){this._showHint()},_onBlur:function(){this._closeHint()},_onClick:function(){if(this.isEnabled()){var b=this.get("value");isBoolean(b)&&(b=b===!0?1:0);b+=this.get("step");b>this.get("maxValue")&&(b=this.get("minValue"));this.get("format")==
"boolean"?this.set("value",b!=0):this.set("value",b);this._onUserChange()}},_onUserChange:function(){this._handleCode(this.get("userChange"))}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Rotator",Costerm.WebBeheer.Elements.Rotator.prototype.constructor);ns("Costerm.WebBeheer.Elements");
Costerm.WebBeheer.Elements.Select=Utils.extend(Costerm.WebBeheer.Elements.Composite,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Select.superclass.constructor.call(this,b,a,c);this.setIfNotSet("values",[]);this.elementsValues=[];this.elementsByIndex=[];this.addObserver(this);this.addClass("select")},_doRender:function(b){if(!this.isRendered())this.domElement=document.createElement("select"),$(this.domElement).on("touchstart",this._onTouch.bind(this)).on("change",this._onChange.bind(this)).on("focus",
this._onFocus.bind(this)).on("blur",this._onBlur.bind(this));var a=!!this.get("enum"),c=a?this.doc.getEnumItems(this.get("enum")):null,d=a?indexesToArray(c):this.get("values");this.debug("Select values:"+arrayToString(d));d===null&&(d=[]);for(var e=null,g=0,f=0;f<d.length;f++){var h=d[f],l=this.elementsValues.indexOf(h);if(l==-1){var i=new Costerm.WebBeheer.Elements.SelectOption(this.getId());if(a)l=L(c[h]),i.set("itemText",l);else for(l=0;l<this.expressions.length;l++){var m=this.expressions[l];
m.getPropName().indexOf("item")==0&&(m=m.clone(),i.addExpressions([m]))}i.set("itemValue",h);i.setDocument(this.doc);this.insertChild(f,i);this.elementsValues.splice(f,0,h)}else l!==f&&(i=this.childElements[l],this.childElements.splice(l,1),this.childElements.splice(f,0,i),i.isRendered()&&(i=i.getDomElement(),e===null?$(this.domElement).prepend(i):$(e).after(i)),this.elementsValues.splice(l,1),this.elementsValues.splice(f,0,h));i=this.childElements[f];i.set("index",f);i.isRendered()?i.render(this):
(i.render(this),i=this.childElements[f].getDomElement(),e===null?$(this.domElement).prepend(i):$(e).insertAfter(i));e=this.childElements[f].getDomElement();g++}for(f=0;f<this.elementsValues.length-d.length;f++)this.childElements[d.length].remove();this.elementsValues.splice(d.length,this.elementsValues.length-d.length);if(this._isInvalidated()){f=this.get("cls");this.domElement.className=f===null?"":f;h=this.get("value");a=this.isEnabled();if(h!=this.domElement.value&&Utils.isDefined(h)){c=!1;d=this.domElement.options.length;
for(f=0;f<d;f++)if(this.domElement.options[f].value==h){c=!0;break}c?this.domElement.value=h:d>0&&(Debug.log("INFO: id:"+this.getId()+" value:"+this.domElement.value,"Select"),this.set("value",this.domElement.value,!1))}this._setTextFromSelection();this.domElement.disabled=!a;$(this.domElement).visible(this.isVisible(),this.get("visibilityMode"))}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)},_setTextFromSelection:function(){this.domElement.selectedIndex>=
0&&this.set("text",this.domElement.options[this.domElement.selectedIndex].text)},_onChange:function(){this._setTextFromSelection();this.isEnabled()&&(this.set("value",this.domElement.value),this._handleCode(this.get("change")),this._handleCode(this.get("userChange")));this._closeHint()},_onTouch:function(){this._showHint()},_onFocus:function(){this._showHint()},_onBlur:function(){this._closeHint()},_update:function(b,a,c){this.debug("update:"+b.getId()+" "+c);Costerm.WebBeheer.Elements.Select.superclass._update.apply(this,
arguments)}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Select",Costerm.WebBeheer.Elements.Select.prototype.constructor);
Costerm.WebBeheer.Elements.SelectOption=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.SelectOption.superclass.constructor.call(this,b,a,c);this.addClass("selectOption")},_doRender:function(b){if(!this.isRendered())this.domElement=document.createElement("option");if(this._isInvalidated()){var a=this.get("itemCls");this.domElement.className=a===null?"":a;this.domElement.value=this.get("itemValue");a=this.get("itemText");Utils.isDefinedAndNotNull(a)&&
$(this.domElement).setText(L(a));$(this.domElement).visible(this.isVisible(),this.get("visibilityMode"))}this.isRendered()||Costerm.WebBeheer.Elements.Element.getDomElement(b).appendChild(this.domElement)}});ns("Costerm.WebBeheer.Elements");Costerm.WebBeheer.Elements.Title=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Title.superclass.constructor.call(this,b,a,c);this.addObserver(this)},_doRender:function(){},_update:function(b,a,c){if(a=="changeProperty")switch(c[0]){case "text":b=this.get("text"),document.title=b}}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Title",Costerm.WebBeheer.Elements.Title.prototype.constructor);ns("Costerm.WebBeheer.Elements");Costerm.WebBeheer.Elements.Variable=Utils.extend(Costerm.WebBeheer.Elements.Element,{constructor:function(b,a,c){Costerm.WebBeheer.Elements.Variable.superclass.constructor.call(this,b,a,c);this.setIfNotSet("value","");this.addObserver(this)},_doRender:function(){},_update:function(b,a,c){if(a=="changeProperty")switch(c[0]){case "value":this._handleCode(this.get("change"))}}});Costerm.WebBeheer.Elements.Factory.getInstance().add("Variable",Costerm.WebBeheer.Elements.Variable.prototype.constructor);
ns("Costerm.WebBeheer");Costerm.WebBeheer.ExpressionHandler=function(){this.doc=Costerm.WebBeheer.App.getInstance().getDocument();this.dictionary=Costerm.WebBeheer.App.getInstance().getDictionary();this.controller=Costerm.WebBeheer.App.getInstance().getController();this.expressionsByTrigger={};this.triggersByElement={};this.triggersByOwnerElement={};this.elementsToRender=[];this.handlingExpressions=false;this.controller.addObserver(this);this.lastNavigation=[];this.lastNavigationLevelChanged=0};
Costerm.WebBeheer.ExpressionHandler._instance=null;Costerm.WebBeheer.ExpressionHandler.CODE_ASSIGNMENT="assignment";Costerm.WebBeheer.ExpressionHandler.CODE_RETRIEVAL="retrieval";Costerm.WebBeheer.ExpressionHandler.CODE_REPLACE="replace";Costerm.WebBeheer.ExpressionHandler.getInstance=function(){if(!Costerm.WebBeheer.ExpressionHandler._instance)Costerm.WebBeheer.ExpressionHandler._instance=new Costerm.WebBeheer.ExpressionHandler;return Costerm.WebBeheer.ExpressionHandler._instance};
Costerm.WebBeheer.ExpressionHandler.MODE_HANDLING_EXPRESSIONS="handling";Costerm.WebBeheer.ExpressionHandler.MODE_RUNNING_EXPRESSIONS="running";
Costerm.WebBeheer.ExpressionHandler.prototype={handleExpressions:function(element){var doc=this;var elementExpressions=element.getExpressions();this._removeOwnerTriggers(element);for(var i=0;i<elementExpressions.length;i++){this.handlingExpressions=true;var elementExpression=elementExpressions[i];var expressionText=this._convertCode(elementExpression.getExpressionText(),element);this.generatedExpression=new Costerm.WebBeheer.Expression(elementExpression.getPropName(),elementExpression.getType(),expressionText,
elementExpression.getDefault(),element);this.ownerElement=element;if(this.generatedExpression.getType()==Costerm.WebBeheer.Expression.TYPE_SET)this._addElementTrigger(element,this.generatedExpression.getPropName());else eval(this.generatedExpression.getExpressionText());this.handlingExpressions=false;if(this.generatedExpression.getType()==Costerm.WebBeheer.Expression.TYPE_GET)this._runExpression(this.generatedExpression);this.generatedExpression=null}this._renderElementsToRender()},_renderElementsToRender:function(){while(this.elementsToRender.length>
0){var element=this.elementsToRender[0];this.elementsToRender.splice(0,1);if(element)this._renderIfRendered(element)}},_addElementToRender:function(element){if(!this.handlingExpressions&&this.elementsToRender.indexOf(element)===-1)this.elementsToRender.push(element)},_removeOwnerTriggers:function(element){var elementId=element.getId();if(!this.triggersByOwnerElement[elementId])return;for(var i=0;i<this.triggersByOwnerElement[elementId].length;i++){var trigger=this.triggersByOwnerElement[elementId][i];
this._removeTrigger(element,trigger)}delete this.triggersByOwnerElement[elementId]},_convertCode:function(code,element){var maxLoop=20;var convertedCode=code;for(var i=0;i<maxLoop;i++){var match=convertedCode.match(/(\$this\.([\w\.]+)\$)/m);var typeOfMatch;var expression;var target;var source;if(match){typeOfMatch=Costerm.WebBeheer.ExpressionHandler.CODE_REPLACE;expression=RegExp.$1;target=RegExp.$2}else{match=convertedCode.match(/(this\.([\w\.]+)\s*=([^=][^;]+))/m);if(match){typeOfMatch=Costerm.WebBeheer.ExpressionHandler.CODE_ASSIGNMENT;
expression=RegExp.$1;target=RegExp.$2;source=RegExp.$3}else{match=convertedCode.match(/(this\.([\w\.]+))/m);if(!match)break;typeOfMatch=Costerm.WebBeheer.ExpressionHandler.CODE_RETRIEVAL;expression=RegExp.$1;target=RegExp.$2}}var parts=target.split(/\./);var replace="";var usedElement=element;for(var j=0;j<parts.length-1;j++)if(parts[j]=="parent")usedElement=usedElement.getParent();else break;var prop=parts[j];switch(typeOfMatch){case Costerm.WebBeheer.ExpressionHandler.CODE_ASSIGNMENT:replace="doc.setElementProp('"+
usedElement.getId()+"','"+prop+"', "+source+")";break;case Costerm.WebBeheer.ExpressionHandler.CODE_RETRIEVAL:replace="doc.getElementProp('"+usedElement.getId()+"','"+prop+"')";break;case Costerm.WebBeheer.ExpressionHandler.CODE_REPLACE:replace=usedElement.get(prop);break}convertedCode=convertedCode.replace(expression,replace)}convertedCode=convertedCode.replace(/controller\.([\w\.:]+)\s*=([^=][^;]+)/gm,'doc.setControllerProp("$1", $2);');var maxItemsCount=element.get("maxItemsCount");var reverse=
parseBool(element.get("reverse"));var usedCount=!isNumeric(maxItemsCount)||maxItemsCount==0?0:parseInt(maxItemsCount)+1;var step=element.get("step");usedCount*=isNumeric(step)?parseInt(step):1;var startIndex=element.get("startIndex");startIndex=isNumeric(startIndex)?parseInt(startIndex):0;var startDate=element.get("startDate");var endDate=element.get("endDate");var period=element.get("period");var interval=element.get("interval");var maxPlots=element.get("maxPlots");maxPlots=isNumeric(maxPlots)?parseInt(maxPlots):
250;var url=element.get("url");if(!url)url="";convertedCode=convertedCode.replace(/controller\.([\w\.:]+\[(\w)*]\.Length)/gm,'doc.getControllerProp("$1")');convertedCode=convertedCode.replace(/controller\.([\w\.:]+)\[(\w)*]/gm,'doc.getControllerArray("$1", '+startIndex+","+usedCount+","+reverse+',"$2")');convertedCode=convertedCode.replace(/controller\.([\w\.:]+)\{\}/gm,'doc.getControllerObject("$1")');convertedCode=convertedCode.replace(/controller\.Plots\s*\((.+)\)/gm,'doc.getControllerPlots("'+
element.getId()+'",$1,'+startDate+","+endDate+","+period+","+interval+","+maxPlots+',"'+url+'")');convertedCode=convertedCode.replace(/controller\.([\w\.:]+)/gm,'doc.getControllerProp("$1")');if(i==maxLoop)throw new Costerm.Expression("Possible error in expression:"+code);return convertedCode},_addElementTrigger:function(element,propName){var trigger=new Costerm.WebBeheer.ElementTrigger(element,propName);this._addTrigger(trigger);var elementId=element.getId();var subjectId=this.generatedExpression.getSubject().getId();
if(elementId!=subjectId){if(!this.triggersByElement[elementId]){element.addObserver(this);this.triggersByElement[elementId]=[]}this.triggersByElement[elementId].push(trigger)}},_addControllerTrigger:function(address){var trigger=new Costerm.WebBeheer.ControllerTrigger(address);this._addTrigger(trigger);this.controller.addParam(address)},_addControllerArrayTrigger:function(address,index,count,reverse,key){var trigger=new Costerm.WebBeheer.ControllerArrayTrigger(address,index,count,reverse,key);this._addTrigger(trigger);
this.controller.addArray(address,index,count,reverse,key)},_addControllerPlotsTrigger:function(tag,addresses,startDate,endDate,period,interval,maxPlots,url){var trigger=new Costerm.WebBeheer.ControllerPlotsTrigger(tag,addresses,startDate,endDate,period,interval,maxPlots,url);this._addTrigger(trigger);this.controller.addPlots(tag,addresses,startDate,endDate,period,interval,maxPlots,url)},_addControllerObjectTrigger:function(address){var trigger=new Costerm.WebBeheer.ControllerObjectTrigger(address);
this._addTrigger(trigger);this.controller.addObject(address)},_addTrigger:function(trigger){var ownerId=this.ownerElement.getId();if(!this.triggersByOwnerElement[ownerId])this.triggersByOwnerElement[ownerId]=[];this.triggersByOwnerElement[ownerId].push(trigger);if(!this.expressionsByTrigger[trigger])this.expressionsByTrigger[trigger]=[this.generatedExpression];else{for(var i=0;i<this.expressionsByTrigger[trigger].length;i++)if(this.expressionsByTrigger[trigger][i].equals(this.generatedExpression))return;
this.expressionsByTrigger[trigger].push(this.generatedExpression)}var subject=this.generatedExpression.getSubject();var subjectId=subject.getId();if(!this.triggersByElement[subjectId]){subject.addObserver(this);this.triggersByElement[subjectId]=[]}this.triggersByElement[subjectId].push(trigger)},_runExpression:function(expression){var doc=this;var shouldRender=false;var element=expression.getSubject();if(expression.getType()==Costerm.WebBeheer.Expression.TYPE_GET){var value=eval(expression.getExpressionText());
if(!this.handlingExpressions){if(!Utils.isDefined(value)||value===null||typeof value=="number"&&isNaN(value))value=expression.getDefault();if(element.get(expression.getPropName())!==value){element.set(expression.getPropName(),value);shouldRender=true}}}else{var value=element.get(expression.getPropName());eval(expression.getExpressionText())}if(shouldRender)this._addElementToRender(element)},_runExpressions:function(trigger){if(!this.expressionsByTrigger[trigger])return;for(var i=0;i<this.expressionsByTrigger[trigger].length;i++){var expression=
this.expressionsByTrigger[trigger][i];this._runExpression(expression)}this._renderElementsToRender()},_removeTrigger:function(element,trigger){if(!this.expressionsByTrigger[trigger])return;var i=0;while(i<this.expressionsByTrigger[trigger].length){var subjExpression=this.expressionsByTrigger[trigger][i];if(subjExpression.getSubject()==element)this.expressionsByTrigger[trigger].splice(i,1);else i++}if(this.expressionsByTrigger[trigger].length==0){delete this.expressionsByTrigger[trigger];if(trigger instanceof
Costerm.WebBeheer.ControllerTrigger)this.controller.removeParam(trigger.getAddress());else if(trigger instanceof Costerm.WebBeheer.ControllerArrayTrigger)this.controller.removeArray(trigger.getAddress(),trigger.getIndex(),trigger.getCount(),trigger.isReverse(),trigger.getKey());else if(trigger instanceof Costerm.WebBeheer.ControllerObjectTrigger)this.controller.removeObject(trigger.getAddress());else if(trigger instanceof Costerm.WebBeheer.ControllerPlotsTrigger)this.controller.removePlots(trigger.getTag(),
trigger.getAddresses(),trigger.getStartDate(),trigger.getEndDate(),trigger.getPeriod(),trigger.getInterval(),trigger.getMaxPlots(),trigger.getUrl())}},_update:function(element,action,args){switch(action){case "remove":var elementId=element.getId();if(this.triggersByElement[elementId]){for(var i=0;i<this.triggersByElement[elementId].length;i++){var trigger=this.triggersByElement[elementId][i];this._removeTrigger(element,trigger)}delete this.triggersByElement[elementId]}if(this.triggersByOwnerElement[elementId])delete this.triggersByOwnerElement[elementId];
break;case "changeParam":var address=args[0];var trigger=new Costerm.WebBeheer.ControllerTrigger(address);this._runExpressions(trigger);break;case "changeArray":var address=args[0];var index=args[1];var count=args[2];var reverse=args[3];var key=args[4];var trigger=new Costerm.WebBeheer.ControllerArrayTrigger(address,index,count,reverse,key);this._runExpressions(trigger);break;case "changePlots":var tag=args[0];var addresses=args[1];var startDate=args[2];var endDate=args[3];var period=args[4];var interval=
args[5];var maxPlots=args[6];var url=args[7];var trigger=new Costerm.WebBeheer.ControllerPlotsTrigger(tag,addresses,startDate,endDate,period,interval,maxPlots,url);this._runExpressions(trigger);break;case "changeObject":var address=args[0];var trigger=new Costerm.WebBeheer.ControllerObjectTrigger(address);this._runExpressions(trigger);break;case "changeProperty":var propName=args[0];var oldValue=args[1];var newValue=args[2];switch(propName){case "id":if(this.triggersByElement[oldValue]){var triggers=
this.triggersByElement[oldValue];delete this.triggersByElement[oldValue];this.triggersByElement[newValue]=triggers;for(var i=0;i<this.triggersByElement[newValue].length;i++){var trigger=this.triggersByElement[newValue][i];var oldSubjectExpressions=this.expressionsByTrigger[trigger];delete this.expressionsByTrigger[trigger];trigger.setElement(element);this.expressionsByTrigger[trigger]=oldSubjectExpressions}}break}var trigger=new Costerm.WebBeheer.ElementTrigger(element,propName);this._runExpressions(trigger);
break}},handleCode:function(code,element){var doc=this;if(code==null)return;var convertedCode=this._convertCode(code,element);var result=eval(convertedCode);this._renderElementsToRender();return result},open:function(targetElementId,elementToOpenId,newId){if(this.handlingExpressions)return null;if(targetElementId){var targetElement=this.doc.getElementById(targetElementId);if(!targetElement)throw new Costerm.Exception("Kan target element niet vinden: "+targetElementId);targetElement.removeChildren()}else targetElement=
this.doc.getRootElement();var elementToOpen=this.dictionary.getElementById(elementToOpenId);if(!elementToOpen)throw new Costerm.Exception("Kan element niet vinden: "+elementToOpenId);var clonedElement=elementToOpen.clone();if(newId)clonedElement.setId(newId);clonedElement.setDocument(targetElement.getDocument());targetElement.appendChild(clonedElement);this._addElementToRender(targetElement);return clonedElement},clear:function(targetElementId){if(this.handlingExpressions)return;var targetElement=
this.doc.getElementById(targetElementId);if(!targetElement)throw new Costerm.Exception("Kan target element niet vinden: "+targetElementId);targetElement.removeChildren();this._addElementToRender(targetElement)},getElementProp:function(elementId,propName,defaultValue){var element=this.doc.getElementById(elementId);if(this.handlingExpressions){if(!element)return;this._addElementTrigger(element,propName)}else return element?element.get(propName):defaultValue},setElementProp:function(elementId,propName,
value){if(this.handlingExpressions)return;var element=this.doc.getElementById(elementId);if(element)element.set(propName,value);this._addElementToRender(element)},getControllerProp:function(address,defaultValue){if(this.handlingExpressions)this._addControllerTrigger(address);else{var value=this.controller.getParam(address);return value===null?defaultValue:value}},removeFromControllerCache:function(address){this.controller.removeParamFromCache(address)},setControllerProp:function(address,value){if(this.handlingExpressions)return;
this.controller.setParam(address,value)},getControllerArray:function(address,index,count,reverse,key){if(this.handlingExpressions)this._addControllerArrayTrigger(address,index,count,reverse,key);else{var value=this.controller.getArray(address,index,count,reverse,key);return value}},getControllerPlots:function(tag,addresses,startDate,endDate,period,interval,maxPlots,url){if(this.handlingExpressions)this._addControllerPlotsTrigger(tag,addresses,startDate,endDate,period,interval,maxPlots,url);else{var plots=
this.controller.getPlots(tag,addresses,startDate,endDate,period,interval,maxPlots,url);return plots}},getControllerObject:function(address){if(this.handlingExpressions)this._addControllerObjectTrigger(address);else{var value=this.controller.getObject(address);return value}},getVersion:function(){return Costerm.WebBeheer.Version},onInternalNetwork:function(){var osNr=this.getElementProp("osNr","value");var networkConfig=this.getElementProp("networkConfig","value");if(!osNr||!networkConfig||!Utils.isDefined(networkConfig[osNr]))return true;
var port=location.port;var defaultPort=port=="";if(defaultPort)port=location.protocol==="https:"?443:80;var host=location.hostname;var isIntern=networkConfig[osNr].InternAddress==host&&networkConfig[osNr].InternPort==port;return isIntern},getBaseUrl:function(destOsNr){var osNr=this.getElementProp("osNr","value");var baseUrl="";if(destOsNr=="local"||parseFloat(destOsNr)==parseFloat(osNr))baseUrl="";else{var networkConfig=this.getElementProp("networkConfig","value");var port=location.port;var defaultPort=
port=="";if(defaultPort)port=location.protocol==="https:"?443:80;var host=location.hostname;var isIntern=networkConfig[osNr].InternAddress==host&&networkConfig[osNr].InternPort==port;var destOsNetworkConfig=null;for(var iterOsNr in networkConfig){if(!isNumeric(iterOsNr))continue;if(parseFloat(iterOsNr)==parseFloat(destOsNr))destOsNetworkConfig=networkConfig[iterOsNr]}if(destOsNetworkConfig===null)return;var newHost=isIntern?destOsNetworkConfig.InternAddress:destOsNetworkConfig.ExternAddress;var newPort=
isIntern?destOsNetworkConfig.InternPort:destOsNetworkConfig.ExternPort;newHost=newHost.replace(/http(s)?:\/\//gi,"");var baseUrl=location.protocol+"//"+newHost;if(location.protocol==="http:"&&newPort!=80||location.protocol==="https:"&&newPort!=443)baseUrl+=":"+newPort}return baseUrl},download:function(osNr,filename){var url=this.getBaseUrl(osNr);if(url!="")url+="/";url+=filename;download(url)},openLocation:function(osNr,filename,newWindow){var url=this.getBaseUrl(osNr);if(url!="")url+="/";url+=filename;
openLocation(url,newWindow)},setGlobalNavigation:function(){var destOsNr=arguments[0];var osNr=this.getElementProp("osNr","value");var navItems=[];for(var i=1;i<arguments.length;i++)navItems.push(arguments[i]);if(destOsNr=="local"||parseFloat(destOsNr)==parseFloat(osNr))this.setNavigation.apply(this,navItems);else{var newUrl=this.getBaseUrl(destOsNr);newUrl+=location.pathname;newUrl+="?lang="+Costerm.Language.getInstance().get();var sessionId=Costerm.WebBeheer.App.getInstance().getSessionId();if(sessionId)newUrl+=
"&sessionId="+sessionId+"&sessionDate="+Costerm.WebBeheer.App.getInstance().getSessionDate().getTime();var hash=this._navItemsToHash(navItems);if(hash===""){var networkConfig=this.getElementProp("networkConfig","value");if(networkConfig[destOsNr].Alarm)hash+="#ActAlarms"}newUrl+=hash;location.href=newUrl}},_navItemsToHash:function(navItems){var hash;if(navItems.length==0||navItems[0]=="")hash="";else{hash="#";for(var i=0;i<navItems.length;i++){if(i!=0)hash+="_";hash+=navItems[i]}}return hash},triggerNavigationChange:function(elementId){if(this.handlingExpressions)return;
var element=this.doc.getElementById(elementId);element.triggerNavigationChange()},setNavigation:function(){location.hash=this._navItemsToHash.call(this,arguments)},_setNavigation:function(){var hash=location.hash;if(hash.length>0)hash=hash.substr(1);var navigation=hash.split("_");var navigationLevelChanged=-1;for(var i=0;i<Math.max(navigation.length,this.lastNavigation.length);i++){var itemHasChanged=false;if(this.lastNavigation.length>i&&navigation.length>i)itemHasChanged=this.lastNavigation[i]!==
navigation[i];else if(this.lastNavigation.length<=i)itemHasChanged=true;else itemHasChanged=this.lastNavigation!=="";if(itemHasChanged){navigationLevelChanged=i;break}}if(navigationLevelChanged>=0){this.lastNavigation=navigation;this.lastNavigationChangedLevel=navigationLevelChanged}},getNavigationItem:function(itemNo){this._setNavigation();return this.lastNavigation.length>itemNo?this.lastNavigation[itemNo]:""},hasNavigationItemChanged:function(itemNo){this._setNavigation();return itemNo>=this.lastNavigationChangedLevel},
setLanguage:function(language){Costerm.Language.getInstance().set(language);if(location.search=="")location.reload();else location.search=""},iteratorNext:function(elementId){if(this.handlingExpressions)return;var element=this.doc.getElementById(elementId);element.next()},iteratorPrevious:function(elementId){if(this.handlingExpressions)return;var element=this.doc.getElementById(elementId);element.previous()},iteratorToggleReverse:function(elementId){if(this.handlingExpressions)return;var element=
this.doc.getElementById(elementId);element.set("reverse",!element.get("reverse"))},toggleClass:function(elementIdToSearchIn,elementId,cls){if(this.handlingExpressions)return;var element=this.doc.getElementById(elementId);var elementToSearchIn=this.doc.getElementById(elementIdToSearchIn);elementToSearchIn.removeClass(cls);element.addClass(cls);this._addElementToRender(elementToSearchIn);this._addElementToRender(element)},addClass:function(elementId,className){if(this.handlingExpressions)return;var element=
this.doc.getElementById(elementId);if(element)element.addClass(className);this._addElementToRender(element)},removeClass:function(elementId,className){if(this.handlingExpressions)return;var element=this.doc.getElementById(elementId);if(element)element.removeClass(className);this._addElementToRender(element)},indexesToArray:function(obj){return indexesToArray(obj)},getNumericElements:function(array){var retArray=[];if($.isArray(array))for(var i=0;i<array.length;i++){if(isNumeric(array[i]))retArray.push(array[i])}else return array;
return retArray},strlen:function(value){return parseString(value).length},getBit:function(value,bitNo,radix){var temp=parseInt(value,radix);return(temp&Math.pow(2,bitNo))>0},setBit:function(value,bitNo,on,radix){var temp=parseInt(value,radix);var newValue=on?temp|Math.pow(2,bitNo):temp&~Math.pow(2,bitNo);return!Utils.isDefinedAndNotNull(radix)||radix==10?newValue:newValue.toString(radix)},leftPart:function(value){var str=parseString(value);var pos=str.indexOf(",");return pos==-1?null:str.substr(0,
pos)},rightPart:function(value){var str=parseString(value);var pos=str.indexOf(",");return pos==-1?null:str.substr(pos+1)},combineParts:function(left,right){return parseString(left)+","+parseString(right)},javaEnabled:function(){return javaEnabled()},setInvalidated:function(elementId){if(this.handlingExpressions)return;var element=this.doc.getElementById(elementId);if(element)element.setInvalidated(Costerm.WebBeheer.Elements.Element.VALIDATE_STATE_EVALUATE,true);this._addElementToRender(element)},
render:function(elementId){if(this.handlingExpressions)return;var element=this.doc.getElementById(elementId);if(element)this._renderIfRendered(element)},_renderIfRendered:function(element){if(element.isRendered())element.render()}};
