/* 
Copyright (c) 2009 Reinier Zevenhuijzen, Netherlands
http://www.framework-z.com

This file is available under the terms of the  MIT Licence: 
http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
*/

function $elm(a,b){if(typeof a==='object')return a instanceof Z?a.elm:a;var c=document.getElementById(a);if(b&&!c)throw new Error("Element with id '"+a+"' isn't found.");return c;}
$=$elm;function $style(a){return $(a,true).style;}
function $computedStyle(a,b){var c=$(a,true);return 'currentStyle' in c?c.currentStyle[b]:window.getComputedStyle(c,null)[b];}
function $show(a){var b=$(a,true);b.style.display=$show.blocks[b.tagName]?'block':'inline';}
$show.blocks={'DIV':1,'TABLE':1,'P':1,'TD':1,'TR':1,'BODY':1};function $hide(a){$style(a,true).display='none';}
function $display(a,b){(b?$show:$hide)(a);}
function $shown(a,b){var c=$(a,true);var d=!(c.style.display==='none'||(!c.style.display&&$computedStyle(c,'display')==='none'));	if(d&&b&&c.parentNode&&c.parentNode.nodeType==1)return $shown(c.parentNode,b);return d;}
function $undef(a){return typeof a==='undefined';}
function $def(a){return!$undef(a);}
function $null(a){return a===null||$undef(a);}
function $notnull(a){return!$null(a);}
function $ifnull(a,b){return $null(a)?b:a}
function $ifnot(a,b){return a?a:b;}
function $toStr(a,b){return $null(a)?$ifnot(b,''):(a+'');}
$str=$toStr;function $toHtml(a,b){a=$str(a).htmlEncode();if(b)a=a.replace(/\n/g,'<br />');return a;}
$html=$toHtml;function $toAttr(a){return $str(a).attributeEncode();}
$attr=$toAttr;function $generateID(){return '_z_generatedID_'+$generateID.c++;}
$generateID.c=0;function $pos(a,b){return a>=0?a:b;}
function $createNamespace(a){if(typeof a==='object')return a;var b=a.split('.');var c=window;for(var d=0;d<b.length;d++){var e=b[d];c=e in c?c[e]:(c[e]={});}
return c;}
function $namespace(a,b){var c=Array.prototype.slice.call(arguments,0);var b=arguments[arguments.length-1];if(typeof b==='function')c.pop();for(var d=0;d<c.length;d++){c[d]=$createNamespace(c[d]);}
if(typeof b==='function')b.apply(null,c);return c[0];}
function $event(a){return a?a:window.event;}
function $target(a){a=$event(a);return $ifnot(a.target,a.srcElement);}
function $ztarget(a){var b=$target(a);return b?Z(b):null;}
function $handle(a,b,c,d){if(d)c=c.bind(d);if(b instanceof Array){$foreacha(b,function(f){$handle(a,f,c)});return c;}
a=$(a);if(a.attachEvent)a.attachEvent('on'+b,c);else a.addEventListener(b,c,false);return c;}
function $dehandle(a,b,c){if(b instanceof Array){$foreacha(b,function(e){$dehandle(a,e,c)});return c;}
a=$(a);if(a.detachEvent)a.detachEvent('on'+b,c);else a.removeEventListener(b,c,false);return c;}
function $foreach(a,b,c){if(a instanceof Array)return $foreacha(a,b,c);for(var d in a){var e=b.call(c,a[d],d,a);if($notnull(e))return e};return null;}
function $foreacha(a,b,c){for(var d=0;d<a.length;d++){var e=b.call(c,a[d],d,a);if($notnull(e))return e};return null;}
function $where(a,b,c){var d=a instanceof Array?[]:{};for(var e in a)if(b.call(c,a[e],e,a))d[e]=a[e];return d;}
function $wherea(a,b,c){var d=[];for(var e=0;e<a.length;e++)if(e in a&&b.call(c,a[e],e,a))d.push(a[e]);return d;}
function $select(a,b,c,d){var e=a instanceof Array?[]:{};for(var f in array){var a=c.call(d,array[f],f,array);if(!b||$notnull(a))e.push(a);}
return e;}
function $selecta(a,b,c,d){var e=[];for(var f=0;f<a.length;f++){if(f in a){var g=c.call(d,a[f],f,a);if(!b||$notnull(g))e.push(g);}}
return e;}
function $clone(a,b){var c=a instanceof Array,d=c?[]:{};if(c)for(var e=0;e<a.length;e++)d[e]=b?$clone(a[e],true):a[e];else for(var e in a)d[e]=b?$clone(a[e],true):a[e];return d;}
$addTo=function(a,b){for(var c in b)a[c]=b[c];}
function $base(a,b,c){var d=Array.prototype.slice.call(arguments,3);var e=b.callee,f=c;var g=e.prototype,h=f.prototype;f.apply(a,d);var i={};for(var j in a)if(typeof a[j]==='function'&&a.hasOwnProperty(j))i[j]=a[j];for(var j in i)a[$basefuncID(j,e)]=i[j];if(g.__$baseConstr)return a;g.__$baseConstr=c;for(var j in h) {if(!h.hasOwnProperty(j)||typeof h[j]!=='function')continue;if(!g[j])g[j]=h[j];g[$basefuncID(j,e)]=h[j];}
return a;}
function $baseID(a){return!a.$baseID?a.$baseID=++$baseID.c:a.$baseID;}
$baseID.c=0;function $basefuncID(a,b){return '__$base_'+$baseID(b)+'_'+a;}
function $basefunc(a,b,c){var d=Array.prototype.slice.call(arguments,3);return a[$basefuncID(b,c)].apply(a,d);}
function $basefuncWithArgs(a,b,c,d){return a[$basefuncID(b,c)].apply(a,d);}
function $interface(a,b){var c=a.callee.prototype;if(c.__$interfaceConstrs)return;var d=Array.prototype.slice.call(arguments,1);c.__$interfaceConstrs=d;}
function $extends(a,b){for(var c=a.__$baseConstr;c;c=c.prototype.__$baseConstr)if(c==b)return true;return false;}
function $instanceof(a,b){if(a instanceof b||a.constructor==b)return true;return $extends(a,b);}
function $is(a,b){return $extends(a,b)||$implements(a,b);}
function $implements(a,b,c){if(c)return $checkInterface(a,b);if(typeof a!=='object'&&typeof a!=='function')return false;var d=a.__$interfaceConstrs;if(d&&Array.contains(d,b))return true;if(a.__$baseConstr)return $implements(a.__$baseConstr.prototype,b);return false;}
function $checkInterface(a,b,c){var d=b.__$staticInstance;if(!d){d=new b();b.__$staticInstance=d;}
if(!c)c=[];for(var e in d){var f=a[e],g=d[e];if(typeof f!==typeof g)c.push(e);else if(typeof f==='object' &&!$instanceof(f,g.constructor))c.push(e);}
return c.length==0;}
$console=new function(){var a=window.console,b,c;var d=this;d.debug=function(h){f(h,'debug');}
d.warn=function(h){f(h,'warn');}
d.error=function(h){f(h,'error');}
function f(h,i){if(a){if('log' in a&&!('debug' in a))a.log(h);else a[i](h);}
else if(b){g();c.append(Z.create('div').text(h).addClass(i));}}
d.clear=function(){c.remove();c=null;}
function g(){if(c)return;c=Z.create('div').addClass('z_console');Z(document.body).append(c,true);c.html('<div><b>Javascript console</b> <a href="" onclick="$console.clear();return false;">clear</a></div>');ZUtil.addCss('.z_console { background:white;color:black; border:1px solid red; padding:2px; } .z_console .warn { color:orange } .z_console .error { color:red }');}
d.enable=function(h){b=h;}}();Function.prototype.bind=function(a){var b=this;return function(){b.apply(a,arguments);}}
$addTo(String.prototype,{contains:function(a){return this.indexOf(a)>=0;},lastIndexOf:function(a,b){if($undef(b))b=this.length-1;for(var c=b;c>=0;c--)if(this.substr(c,a.length)==a)return c;return-1;},startsWith:function(a){return this.slice(0,Math.min(a.length,this.length))===a.toString();},endsWith:function(a){return this.slice(this.length-Math.min(a.length,this.length))===a.toString();},trim:function(){return this.replace(/^\s+/,'').replace(/\s+$/,'');},splitKeyValue:function(a){var b=this.indexOf(a);if(b<0)return{key:this,value:''};return{key:this.slice(0,b),value:this.slice(b+1)};},htmlEncode:function(){return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');},htmlDecode:function(){return this.replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');},extractTextFromHtml:function(){var a=document.createElement('div');a.innerHTML=this;return Z(a).text();},attributeEncode:function(a){return this.htmlEncode().replace(a?"'":'"',a?'&#39;':'&quot;');}});$addTo(Array,{indexOf:function(a,b){for(var c=0;c<a.length;c++)if(a[c]===b)return c;return-1;},contains:function(a,b){return Array.indexOf(a,b)>=0;},remove:function(a,b){var c=Array.indexOf(a,b);if(c<0)return false;a.splice(c,1);return true;}});function Z(a){if(this===window){var b=$(a,true);return b.z?b.z:new Z(b);}
this.elm=this.$=a;a.z=this;this.props={};}
Z.zify=function(a,b){var c=a instanceof Array||b;var d=c?[]:{};if(c)for(var e=0;e<a.length;e++)d[e]=Z(a[e]);else for(var e in a)d[e]=Z(a[e]);return d;}
Z.create=function(a,b){var c=document.createElement(a);if($def(b))c.id=b;return Z(c);}
Z.prototype={_:1,handle:function(a,b){$handle(this.elm,a,b);return this;},dehandle:function(a,b){$dehandle(this.elm,a,b);return this;},onClick:function(a,b){var c=this;return this.handle('click', function(e){var f;if(!b&&(c.tag()=='A'||(c.tag()=='INPUT'&&c.attribute('type')=='submit'))){f=ZUtil.preventDefault(e);}
a.apply(null,arguments);return f;});},onContextmenu:function(a,b){var c=this;return this.handle('contextmenu', function(e){a.apply(null,arguments);if(!b)return ZUtil.preventDefault(e);});},onBlur:function(a){return this.handle('blur',a)},onFocus:function(a){return this.handle('focus',a)},onChange:function(a){return this.handle('change',a)},onKeyup:function(a){return this.handle('keyup',a)},onKeydown:function(a){return this.handle('keydown',a)},onKeypress:function(a){return this.handle('keypress',a)},onMouseover:function(a){return this.handle('mouseover',a)},onMouseout:function(a){return this.handle('mouseout',a)},onMousemove:function(a){return this.handle('mousemove',a)},onMousedown:function(a){return this.handle('mousedown',a)},onMouseup:function(a){return this.handle('mouseup',a)},html:function(a,b){if($undef(a))return this.elm.innerHTML;if(!b)this.elm.innerHTML=a;else this.elm.innerHTML+=a;return this;},text:function(a,b){var c='innerText' in this.elm?'innerText':'textContent';if($undef(a))return this.elm[c];if(b)this.elm[c]+=a;else this.elm[c]=a;return this;},value:function(a){if($undef(a))return this.elm.value;this.elm.value=a;return this;},style:function(a,b){if(a==='opacity'&&this.elm.currentStyle){if($undef(b)){var c=this.elm.style.filter;if(c.startsWith('alpha(opacity='))return c.slice(14,c.length-1)/100;return 1;}
this.elm.style.filter='alpha(opacity='+(b*100)+')';this.elm.style.zoom=1;return this;}
if($undef(b))return this.elm.style[a];else this.elm.style[a]=b;return this;},styles:function(a){for(var b in a)this.style(b,a[b]);return this;},computedStyle:function(a){return $computedStyle(this,a);},attribute:function(a,b){if($undef(b))return this.elm.getAttribute(a);this.elm.setAttribute(a,b);return this;},classes:function(){return this.elm.className.split(/\s+/);},addClass:function(a,b){if(!$null(b)&&!b){this.removeClass(a);return this;}
var c=this.classes();if(Array.contains(c,a))return this;c.push(a);this.elm.className=c.join(' ');return this;},removeClass:function(a){var b=this.classes();var c=Array.indexOf(b,a);if(c<0)return this;b.splice(c,1);this.elm.className=b.join(' ');return this;},hasClass:function(a){return Array.contains(this.classes(),a);},parent:function(){var a=this.elm.parentNode;return a?Z(a):null;},children:function(){return Z.zify(this.elm.childNodes,true);},child:function(a){return Z(this.elm.childNodes[a]);},childCount:function(){return this.elm.childNodes.length;},clear:function(){this.html('');return this;},remove:function(){if(!this.elm.parentNode)return;this.elm.parentNode.removeChild(this.elm);return this;},moveTo:function(a){this.remove();$(a).appendChild(this.elm);return this;},append:function(a,b){if(b&&this.elm.firstChild){this.elm.insertBefore($(a),this.elm.firstChild);}
else this.elm.appendChild($(a));return this;},insertBefore:function(a){this.elm.parentNode.insertBefore($(a),this.elm);return this;},insertAfter:function(a){if(!this.elm.nextSibling)this.parent().append(a);else this.elm.parentNode.insertBefore($(a),this.elm.nextSibling)},clone:function(){var a=this.elm.cloneNode(true);a.z=null;a.id='';return Z(a);},contains:function(a){a=$(a);while(a){if(a==this.$)return true;a=a.parentNode;}
return false;},containsEvent:function(a){return this.contains($target(a));},tag:function(){return this.elm.tagName;},show:function(){$show(this);return this;},hide:function(){$hide(this);return this;},display:function(a){$display(this,a);return this;},shown:function(a){return $shown(this,a);},position:function(a){return ZUtil.position(this.elm,a);},dimension:function(){return ZUtil.dimension(this.elm);},property:function(a,b){if($undef(b))return this.properties?this.properties[a]:null;if(!this.properties)this.properties={};this.properties[a]=b;},getById:function(a,b){var c=this.getTemplateRoot();if(!c)return(!b&&!$(a))?null:Z(a);var d=c['_'+a];if(!d&&b)throw new Error("Z object with id '"+a+"' not found in applied template.");return d;},getId:function(){return this.attribute('_id')||this.elm.id;},getTemplateRoot:function(){var a=this;while(a&&!a.template)a=a.parent();return a&&a.template?a:null;},getTemplatePrefix:function(){if(!this.template)throw new Error("This Z-object isn't a template root");if(!this.templatePrefix)this.templatePrefix=$generateID()+'_';return this.templatePrefix;},getTemplate:function(){var a=this.getTemplateRoot();return a?a.template:null;}}
ZConfig=new function(){var a=this;var b='';a.setServer=function(m){b=m;}
a.getServer=function(){return b;}
a.isServer=function(m){return b==m;}
a.isLocalServer=function(){return a.isServer('local');}
a.isDevelopmentServer=function(){return a.isServer('development');}
a.isStagingServer=function(){return a.isServer('staging');}
a.isTestServer=function(){return a.isServer('test');}
a.isAcceptanceServer=function(){return a.isServer('acceptance');}
a.isProductionServer=function(){return a.isServer('production');}
var d={};a.setSetting=function(m,n){d[m]=n;}
a.getSetting=function(m){return d[m];}
var e=[];a.addCookieDomainRule=function(m,n){e.push({regex:m,domain:n});}
a.getCookieDomain=function(m){for(var n=e.length-1;n>=0;n--){var o=e[n];if(o.regex.test(m))return o.domain;}
var p=location.host;return/\..*\./.test(p)?p:'';}
var f=[];a.addCookieSecureRule=function(m,n){f.push({regex:m,secure:n});}
a.getSecureCookieRule=function(m){for(var n=f.length-1;n>=0;n--){var o=f[n];if(o.regex.test(m))return o.doSecure;}
return false;}
var g=null;a.setImagesPath=function(m){g=m;}
var h={};a.mapImagePath=function(m,n){h[m]=n;}
a.getImagesPath=function(){return $ifnull(g,ZUtil.combinePaths(a.frameworkPath(),'images'));}
a.getImagePath=function(m){var m=$ifnot(h[m],m);if(ZUtil.isAbsolutePath(m))return m;return ZUtil.combinePaths(a.getImagesPath(),m);}
var i='Not all data was entered correctly. Please try to correct these items:';var j=null;var k='<div class="z_summary_icon" style="float:left;"><img src="{icon}" border="0" /></div> <div class="z_summary_header" >{header}</div> <div class="z_summary_list">{list}</div> <div class="z_summary_footer">{footer}</div> <div style="clear:both" />';var l='.z_summary { background:#fdd;border:1px solid #b00; padding:8px; width:300px; } .z_summary_header { float:left; width:265px; padding-left:10px; padding-bottom:12px; } .z_summary_list { clear:left; } .z_summary_list ul { padding-left:10px; margin-top:0px; margin-left:5px;  } ';a.getSummaryFormat=function(){return k;}
a.setSummaryFormat=function(m){k=m;}
a.getSummaryCss=function(){return l;}
a.setSummaryCss=function(m){l=m;}
a.getSummaryHeader=function(){return i;}
a.setSummaryHeader=function(m){i=m;}
a.getSummaryFooter=function(){return j;}
a.setSummaryFooter=function(m){j=m;}
a.frameworkPath=function(m){if(!$undef(m))Z._frameworkPath=m;if(!$undef(Z._frameworkPath))return Z._frameworkPath;var n=document.getElementsByTagName('script');for(var o in n){var p=n[o].src;if(!p)continue;var q=p.toLowerCase();var r=q.indexOf('/z.js');if(r<0&&q.startsWith('z.js'))r=0;if(r<0)r=q.indexOf('/zcore.js');if(r<0&&q.startsWith('zcore.js'))r=0;if(r<0)r=q.indexOf('/zfull.js');if(r<0&&q.startsWith('zfull.js'))r=0;if(r<0)r=q.indexOf('/ztiny.js');if(r<0&&q.startsWith('ztiny.js'))r=0;if(r<0)continue;var m=p.slice(0,r);if(!ZUtil.isAbsolutePath(m)){m=document.location.pathname;var s=$pos(m.lastIndexOf('/'),m.length);m=location.protocol+'//'+location.host+m.slice(0,s);}
return Z._frameworkPath=m;}
alert("The path of Framework Z couldn't be found automaticly. Please set the path explicitly using ZConfig.frameworkPath(...)");}}();ZConfig.CultureInfo=function(){this.decimalPoint=',';this.digitGroupSeparator='.';this.digitGroupSize=3;this.shortDateOrder=ZConfig.CultureInfo.ShortDateOrder.DDMMYYYY;this.shortDateSeparator=ZConfig.CultureInfo.ShortDateSeparator.Dash;this.firstDay=0;this.lang={};$addTo(this.lang,{months:['January','February','March','April','May','June','July','August','September','October','November','December'],monthsShort:['Jan','Febr','Mar','Apr','May','June','July','Aug','Sept','Oct','Nov','Dec'],days:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],daysShort:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],today:'today',holdCtrToMoveDownAYearholdShiftToMoveDown10Years:'Hold [ctrl] to move down a year, hold [ctrl+shift] to move down 10 years.',holdCtrToMoveUpAYearholdShiftToMoveUp10Years:'Hold [ctrl] to move up a year, hold [ctrl+shift] to move up 10 years.'});this.create=function(b){var c=$clone(this);for(var d in b)c[d]=b[d];return c;}};ZConfig.CultureInfo.ShortDateOrder={DDMMYYYY:1,MMDDYYYY:2,YYYYMMDD:3};ZConfig.CultureInfo.ShortDateSeparator={Slash:'/',Dash:'-',Dot:'.'};ZConfig.CultureInfo.get=function(a){if(!a)return ZConfig.culture;if($instanceof(a,ZConfig.CultureInfo))return a;if(typeof a==='object'){return ZConfig.culture.create(a);}
return ZConfig.culture;}
ZConfig.culture=new ZConfig.CultureInfo();ZUtil={};$addTo(ZUtil,{position:function(a,b){var c=0,d=0;var a=$(a);var e=a;var f=a.style.position;if(!f||f==='static')a.style.position='relative';do{c+=a.offsetLeft;d+=a.offsetTop;a=a.offsetParent;}while(a!=null&&!b);e.style.position=f;return{x:c,y:d};},dimension:function(a){a=$(a);return{w:a.offsetWidth,h:a.offsetHeight};},containsPosition:function(a,b){var c=ZUtil.position(a);var d=ZUtil.dimension(a);return b.x>c.x &&b.x<c.x+d.w&&b.y>c.y&&b.y<c.y+d.h	;},combinePaths:function(a,b){if(a.endsWith('/'))a=a.slice(0,a.length-1);if(b.startsWith('/'))b=b.slice(1);return a+'/'+b;},isAbsolutePath:function(a){return a.startsWith('/')||a.startsWith('http://')||a.startsWith('https://');},key:function(a){a=$event(a);return 'which' in a?a.which:a.keyCode;},Keys:{Backspace:8,Tab:9,Enter:13,Shift:16,Ctrl:17,Alt:18,Esc:27,PageUp:33,PageDown:34,End:35,Home:36,Left:37,Up:38,Right:39,Down:40,Insert:45,Delete:46,Digit0:48,Digit1:49,Digit2:50,Digit3:51,Digit4:52,Digit5:53,Digit6:54,Digit7:55,Digit8:56,Digit9:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,WinLeft:91,WinRight:92,Select:93,Numpad0:96,Numpad1:97,Numpad2:98,Numpad3:99,Numpad4:100,Numpad5:101,Numpad6:102,Numpad7:103,Numpad8:104,Numpad9:105,Multiply:106,Add:107,Subtract:109,DecimalPoint:110,Divide:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,Semicolon:186,EqualSign:187,Comma:188,Dash:189,Period:190,ForwardSlash:191,GraveAccent:192,OpenBracket:219,BackSlash:220,CloseBracket:221,SingleQuot:222},isControlKey:function(a){var b=a;return!((b>=47&&b<=90)||(b>=96&&b<=123)||(b>=186&&b<=192)||(b>=220&&b<=222));},isRightClick:function(a){a=$event(a);return 'which' in a?a.which==3:a.button==2;}   ,toFullYear:function(a,b,c){var a=Math.round(a-0);if(a>=100||a<=-100)return a;var d=new Date().getFullYear();var e=Math.floor(d/100)*100;a+=e;if($null(b)){c=d-e;b=true;}
if($null(c)){c=b?d-e:0;}
if(b){if(a<d-c)a+=100;}
else{if(a>d+c)a-=100;}
return a;},getTextboxSelection:function(a){if(document.selection)return document.selection.createRange().text;if(a.setSelectionRange)return a.value.substring(a.selectionStart,a.selectionEnd);else return '';},preventDefault:function(a){a=$event(a);if(a.preventDefault)a.preventDefault();return false;},query:function(a,b){return ZUtil.queries(a,b)[0];},queries:function(a,b){if(!b)b=document.location.href;var c=b.indexOf('?');if(c<0)return [];var d=b.slice(c+1).split('&');var e=[];for(var f in d){var g=d[f];var h=g.indexOf('=');if(g.slice(0,h)==a)e.push(unescape(g.slice(h+1)));}
return e;},addQuery:function(a,b,c){if(!a)a=document.location.href;if(c instanceof Array)$foreacha(c,function(e){a=ZUtil.addQuery(a,b,e);});else{a+=a.indexOf('?')<0?'?':'&';a+=b+'='+$ifnot(window.encodeURIComponent,escape)(c);}
return a;},getCookie:function(a){var b=document.cookie.split(';');for(var c=0;c<b.length;c++){var d=b[c].split("=");if(d[0].trim()===a)return unescape(d[1]);}
return null;},setCookie:function(a,b,c,d,e,f,g){if($null(c)&&$null(d))d=20*60;if($null(d))d=0;if($null(c))c=0;if(!f)f=ZConfig.getCookieDomain(a);if($null(e))e=ZConfig.getSecureCookieRule(a);var h=(e===true||e==='always')||(e==='current'&&ZUtil.isSecure())?';secure':'';document.cookie=a+"="+b +";expires="+new Date(new Date().getTime()+(d*1000)+(c*24*60*60*1000)).toUTCString()+";path="+(!g?'/':g)+(!f?'':';domain='+f)+h;},deleteCookie:function(a){ZUtil.setCookie(a,'',-1,0);},isSecure:function(){return location.protocol=='https:';},addCss:function(a,b){var c=document.createElement('style');c.type='text/css';if(c.styleSheet)c.styleSheet.cssText=a;else c.appendChild(document.createTextNode(a));Z(document.getElementsByTagName('head')[0]).append(c,b);},formToObject:function(a,b){a=$(a);var c={};$foreacha(a.elements,function(e){var f=$str(e.tagName).toLowerCase();var g=$str(e.type).toLowerCase();var h=$ifnot(e.name,e.id);if(!h)return;if(f==='input'&&g==='radio'){if(e.checked)c[h]=e.value;}
else if(f==='input'&&g==='checkbox'){if(e.checked)c[h]='on';}
else if(f==='select'&&e.multiple){c[h]=$selecta(e.options,true,function(k){return k.selected?$ifnull(k.value,k.text):null;});}
else if(f==='select'){var j=e.selectedIndex<0?null:e.options[e.selectedIndex].value;c[h]=b?(e.selectedIndex<0?[]:[j]):j;}
else if(f==='input'&&(g==='submit'||g==='button')){}
else c[h]=e.value;});return c;},bodyDimension:function(a,b){b=b||window;var c=b.document.body;var d=b.document.documentElement;var e='clientWidth' in c?{w:c.clientWidth,h:c.clientHeight}:'clientWidth' in d?{w:d.clientWidth,h:d.clientHeight}:{w:b.innerWidth,h:b.innerHeight};if(a){var f=ZUtil.scrollDimension();return{h:Math.max(e.h,f.h),w:Math.max(e.w,f.w)};}
return e;},scrollDimension:function(a){a=a||window;var b=a.document.body;var c=a.document.documentElement;return 'innerWidth' in a?{w:a.innerWidth,h:a.innerHeight}:'clientWidth' in c?{w:c.clientWidth,h:c.clientHeight}:{w:b.clientWidth,h:b.clientHeight};},scrollPosition:function(a){a=a||window;var b=a.document.body;var c=a.document.documentElement;return 'pageXOffset' in a?{x:a.pageXOffset,y:a.pageYOffset}:{x:Math.max(b.scrollLeft,c.scrollLeft),y:Math.max(b.scrollTop,c.scrollTop)};},isIE6:function(){return/msie|MSIE 6/.test(navigator.userAgent);},isIE7:function(){return/msie|MSIE 7/.test(navigator.userAgent);}});$addTo(Date.prototype,{isBefore:function(a,b){var c=this,d=a;if(b){c=c.clone();c.truncate();d=d.clone();d.truncate();}
return c.getTime()<d.getTime();},isAfter:function(a,b){var c=this,d=a;if(b){c=c.clone();c.truncate();d=d.clone();d.truncate();}
return c.getTime()>d.getTime();},isSameDay:function(a){return this.getDate()==a.getDate()&&this.getMonth()==a.getMonth()&&this.getFullYear()==a.getFullYear();},isToday:function(){return this.isSameDay(new Date());},addYears:function(a){this.setFullYear(this.getFullYear()+a);return this;},addMonths:function(a){this.setMonth(this.getMonth()+a);return this;},addDays:function(a){this.addMilliseconds(a*1000*60*60*24);return this;},addHours:function(a){this.addMilliseconds(a*1000*60*60);return this;},addMinutes:function(a){this.addMilliseconds(a*1000*60);return this;},addMilliseconds:function(a){this.setTime(this.getTime()+a);return this;},truncate:function(){this.setHours(0);this.setMinutes(0);this.setMilliseconds(0);return this;},clone:function(){return new Date(this.getTime());},subtract:function(a){return new ZDateDifference(this,a);},format:function(a,b){b=b||ZConfig.culture;var c=b.lang;return a.replace(/\{/g,'{{').replace(/\}/g,'}}').replace(/DD/g,'{2}').replace(/D/g,'{3}').replace(/dd/g,this.getDate().format('D2')).replace(/d/g,this.getDate()).replace(/MMMM/g,'{0}').replace(/MMM/g,'{1}').replace(/MM/g,(1+this.getMonth()).format('D2')).replace(/M/g,(1+this.getMonth())).replace(/yyyy/g,this.getFullYear()).replace(/yy/g,(this.getFullYear()+'').slice(2)).replace(/mmmm/g,this.getMilliseconds().format('D4')).replace(/mm/g,this.getMinutes().format('D2')).replace(/ss/g,this.getSeconds().format('D2')).replace(/s/g,this.getSeconds()).replace(/hh/g,this.getHours().format('D2')).replace(/h/g,this.getHours()).format(c.months[this.getMonth()],c.monthsShort[this.getMonth()],b.lang.days[this.getDay()],b.lang.daysShort[this.getDay()]);}});Date.isValid=function(a,b,c){var d=new Date(a,b,c);return d.getFullYear()==a&&d.getMonth()==b&&d.getDate()==c;}
function ZDateDifference(a,b){this.date1=a;this.date2=b;}
$addTo(ZDateDifference.prototype,{round:function(a){return a>=0?Math.floor(a):Math.ceil(a)},totalMilliseconds:function(){return(this.date1.getTime()-(this.date1.getTimezoneOffset()*60*1000))-(this.date2.getTime()-(this.date2.getTimezoneOffset()*60*1000));},totalSeconds:function(){return this.totalMilliseconds()/(1000)},totalMinutes:function(){return this.totalMilliseconds()/(1000*60)},totalHours:function(){return this.totalMilliseconds()/(1000*60*60)},totalMonths:function(){return 12 *(this.date1.getFullYear()-this.date2.getFullYear())-(this.date2.getMonth()-this.date1.getMonth())-((this.date2.getDate()-this.date1.getDate())/31);},totalDays:function(){return this.totalMilliseconds()/(1000*60*60*24);},totalYears:function(){return this.totalMilliseconds()/(1000*60*60*24*365);},years:function(){return this.round(this.totalMilliseconds()/(1000*60*60*24*365));},months:function(){return this.round(this.totalMonths());},days:function(){return this.round(this.totalDays());},hours:function(){return this.round(this.totalHours()-(this.days()*24));},minutes:function(){return this.round(this.totalMinutes()-(this.days()*24*60)-(this.hours()*60));}});$addTo(String.prototype,{toNumber:function(a){a=ZConfig.CultureInfo.get(a);var b=this;b=b.replace(new RegExp('\\'+a.digitGroupSeparator,'g'),"");b=b.replace(new RegExp('\\'+a.decimalPoint),'.');return b-0;},pad:function(a,b){if(!b)b='0';var c=this;while(c.length<a)c=b+c;return c;},namedFormat:function(a){var b=this;for(var c in a){var d=$str(a[c]).replace(/\{/g,'{{').replace(/\}/g,'}}');var e=0;while((e=b.indexOf('{'+c+'}',e))>=0){if(e==0||b.charAt(e-1)!=='{'){b=b.slice(0,e)+d+b.slice(e+c.length+2);e+=d.length;}
else e+=c.length+2;}}
b=b.replace(/\{\{/g,'{');b=b.replace(/\}\}/g,'}');return b;},format:function(){for(var a=0,b={};a<arguments.length;a++)b[a]=arguments[a];return this.namedFormat(b);},capitalize:function(){var a=true,b=this;for(var c=0;c<b.length;c++){var d=b.charAt(c);if(a)b=b.slice(0,c)+d.toUpperCase()+b.slice(c+1);a=d==' '||d=='\t'||d=='\n'||d=='\f'||d=='\r';}
return b;}});Number.prototype.format=function(a,b){b=ZConfig.CultureInfo.get(b);var c=a.charAt(0);var d=c.toLowerCase();var e=a.slice(1)-0;if(a.length==1)e='a'-0;	var f=this;function g(o){return o.replace(/\./g,b.decimalPoint);}
if(d==='d')return f.toFixed(0).pad(isNaN(e)?0:e);if(d==='f')return g(f.toFixed(isNaN(e)?3:e));if(d==='g')return g(isNaN(e)?f.toString():f.toPrecision(e));if(d==='e')return g(f.toExponential(e>0?e:6));if(d==='n'){var h=f.toFixed(isNaN(e)?2:e);var i=e>0?h.slice(0,h.indexOf('.')):h;var j=e>0?h.slice(i.length+1):'';for(var k='',l=i.length-1,m=0;l>=0;l--,m++){if((m%b.digitGroupSize)==0&&m>0)k=b.digitGroupSeparator+k;k=i.charAt(l)+k;}
for(var n='',l=0,m=0;l<j.length;l++,m++){if((m%b.digitGroupSize)==0&&m>0)n=n+b.digitGroupSeparator;n=n+j.charAt(l);}
return k+(e>0?(b.decimalPoint+n):'');}
if(d==='y'){return ZUtil.toFullYear(this,c==='Y',isNaN(e)?null:e).toString();}}
ZUtil.addCss('.z_hidden { display:none; }');function ZEvent(a,b){this.handlers={};	this.host=a;this.parent=null;if(b)this.registerEvents(b);}
ZEvent.register=function(a,b){if(a.events instanceof ZEvent){a.events.registerEvents(b);return;}
a.events=new ZEvent(a,b);a.addEventListener=a.events.add.bind(a.events);a.removeEventListener=a.events.remove.bind(a.events);}
ZEvent.prototype={_:1,registerEvents:function(a){var b=this.host;$foreach(a,function(d){b['on'+d.charAt(0).toUpperCase()+d.slice(1)]=function(f){return $handle(b,d,f);};});},add:function(a,b){a=a.toLowerCase();if(this._find(a,b)>=0)return false;if(!this.handlers[a])this.handlers[a]=[b];else{this.handlers[a]=$clone(this.handlers[a]);this.handlers[a].push(b);}
return true;},remove:function(a,b){a=a.toLowerCase();var c=this._find(a,b);if(c!=-1){this.handlers[a]=$clone(this.handlers[a]);this.handlers[a].splice(c,1);}
return c!=-1;},_find:function(a,b){a=a.toLowerCase();var c=this.handlers[a];return!c?-1:Array.indexOf(c,b);},fire:function(a,b){a=a.toLowerCase();var c=this.handlers[a];if(!c)return;if(!b)b={};if(!b.type)b.type=a;if(!b.target)b.target=this.host;var d=false;b.cancelBubble=function(){d=true;}
for(var f in c)c[f].call(this.host,b);if(this.parent&&!d)this.parent.events.fire(a,b);}}
Function.prototype.ensureLoaded=function(a){var b=this;return function(){var d=Array.prototype.slice.call(arguments);var e=this;a.load(function(){b.apply(e,d);});}}
ZLoader=function(a,b,c,d){if(this==window){e.notify();return;}
var e=this;e.baseUrl=$str(a,'');e.htmlElms=[];var f=false,g=false;var h=[],i=[];var j=0;ZEvent.register(e,['finish','start','finishOne']);function k(){$foreach(b,function(n){e.addScript(n);});$foreach(c,function(n){e.addHtml(n);});$foreach(d,function(n){e.addCss(n);});e.addFunction(function(n){n.notify();});}
e.addFunction=function(m,n){j++;if(n||g||f)m(e);	
else h.push(m);}
e.addLoader=function(m,n){e.addFunction(function(p){m.load(p.notify);},n);}
e.addCss=function(m,n){e.addFunction(function(){ZTransport.get(e.resolve(m),'css',function(){e.notify({url:m});});},n);}
e.addScript=function(m,n){e.addFunction(function(){ZTransport.get(e.resolve(m),'eval',function(){e.notify({url:m});});},n);}
e.addHtml=function(m,n,o,p){var q=document.createElement('div');e.htmlElms.push(q);$display(q,p);if(!o)document.body.appendChild(q);else Z(o).append(q);e.addFunction(function(){ZTransport.get(e.resolve(m),'text',function(t){q.innerHTML=t;e.notify({url:m});});},n);return q;}
e.hookUpEvent=function(m,n){j++;$handle(m,n,function(){e.notify();});}
e.hookedUpSomething=function(){j++;}
e.setPreload=function(m){if(!m)m=10000+Math.floor(Math.random()* 10000);var n=setInterval(function(){if(!ZTransport.requestCount){clearInterval(n);e.load();}},m);return e;}
e.resolve=function(m){if(m.startsWith('/')||m.startsWith('http://')||m.startsWith('https://'))return m;var n=e.baseUrl;if(n&&!n.endsWith('/'))n+='/';return n+m;}
e.load=function(m){if(f){if(m)m();return;}
if(m)i.push(m);if(g)return;g=true;e.events.fire('start');$foreach(h,function(o){o(e);});}
e.notify=function(m){e.events.fire('finishOne',m);if(!--j)e.notifyFullyLoaded();}
e.isLoaded=function(){return f;}
e.isLoading=function(){return g;}
e.notifyFullyLoaded=function(){if(f)return;f=true;g=false;e.events.fire('finish');$foreach(i,function(n){n();});}
k();}
ZLoader.predefined={};$initializer=new ZLoader();$handle(window,'load',function(){$initializer.load()});ZTransport={};ZTransport.requestCount=0;ZTransport.submit=function(a,b,c,d,e){var f=!c;if(f)c=document.createElement('form');else{c=$(c);while(c&&c.tagName!='FORM')c=c.parentNode;}
c.action=$str(a,document.location.href);c.method=$str(b,(!f&&c.method)?c.method:'get');c.target=$str(e,(!f&&c.target)?c.target:'_self');var g=[];var h=function(k,l){var m=document.createElement('input');m.type='hidden';m.name=k;m.value=l;c.appendChild(m);g.push(m);};$foreach(d,function(k,l){if(k instanceof Array)$foreacha(k,function(n){h(l,n);});else h(l,k);});if(f)document.body.appendChild(c);var j=document.createElement('input');j.type='submit';$hide(j);c.appendChild(j);j.click();if(f)Z(c).remove();$foreach(g,function(k){Z(k).remove();});Z(j).remove();}
ZTransport.ajax=function(a,b,c,d,e,f,g,h){var i=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");i.onreadystatechange=function(){if(i.readyState!=4)return;if(i.status!=200){if(f)f(i);else if(ZTransport.errorFunction)ZTransport.errorFunction(i);return;}
ZTransport.requestCount--;var n=d=='json' ?JSON.parse(i.responseText,$ifnot(g,JSON_dateReviver)):d=='xml'?i.responseXML.documentElement:d=='text'?i.responseText:d=='request'?i:d=='eval'?eval(i.responseText):i.responseText;if(d=='css')ZUtil.addCss(n);if(e)e(n);}
var k='get';var l=a;var m=null;b=$str(b,'get').toLowerCase();if(b=='json'){k='post';m=JSON.stringify(c,h);}
else if(b=='post'){k='post';m='';if(c)$foreach(c,function(n,o){m=ZUtil.addQuery(m,o,n);});if(content.startsWith('?'))content=content.slice(1);}
else if(b=='get'){k='get';if(c)$foreach(c,function(n,o){l=ZUtil.addQuery(l,o,n);});}
i.open(k,l,true);if(b=='json')i.setRequestHeader("Content-Type","application/json");if(b=='post')i.setRequestHeader("Content-Type","application/x-www-form-urlencoded");ZTransport.requestCount++;i.send(m);}
ZTransport.get=function(a,b,c,d){return ZTransport.ajax(a,'get',null,b,c,d);}
ZTransport.errorFunction=function(){}
ZTransport.jsonp=function(a,b,c){if(b)$foreach(b,function(h,i){a=ZUtil.addQuery(a,i,h);});var e=a.lastIndexOf('?');if($pos(a.indexOf('?'),e)>=e)throw "No jsonp marker (?) was found in de baseUrl.";var f='jsonp_callback_'+ZTransport.jsonp.curID++;a=a.slice(0,e)+'ZTransport.'+f+a.slice(e+1);ZTransport[f]=function(){delete ZTransport[f];Z(g).remove();c.apply(null,arguments);};var g=document.createElement('script');g.src=a;g.type='text/javascript';document.body.appendChild(g);}
ZTransport.jsonp.curID=0;ZAjaxNetService=function(a,b){var c=this;c.url=a;c.version=b||ZAjaxNetService.version;c.applyTimezone=ZAjaxNetService.applyTimezone;if(c.version!="3.5"&&c.version!="2.0"){throw 'Unknown ajax.net version specified: '+c.version+'. Use "3.5" or "2.0"';}
c.call=function(h,i,j,k,l){var m=this.url+'/'+h;ZTransport.ajax(m,'json',i,'request',function(o){i=g(o.responseText);if(c.version=="3.5"&&i&&'d' in i)i=i.d;if(j)j(i,l);},function(o){var p=o.getResponseHeader('jsonerror')==='true';var q=!p?{Message:o.responseText,ExceptionType:'ServerError',StackTrace:''}:g(o.responseText);if(c.version=="3.5"&&q&&'d' in q)q=q.d;if(k)k(q,l);else if(c.onFailed)c.onFailed(q,l);else ZAjaxNetService.onFailed(q,l);},null,e);}
function e(h,i){if(this[h] instanceof Date){var j=this[h].getTime();if(c.applyTimezone&&j!=62135596800000)j-=ZAjaxNetService.timezoneOffset;return new ZAjaxNetDate("\"\\/Date("+j+")\\/\"");}
return i;}
function f(h){var i=/"\\\/Date\((-?\d+)\)\\\/"/;while(i.test(h)){var j=RegExp.lastParen-0;	
if(c.applyTimezone&&j!=62135596800000&&b=='2.0')j+=ZAjaxNetService.timezoneOffset;h=RegExp.leftContext+'new Date('+j+')'+RegExp.rightContext;}
return h;}
function g(h){h=f(h);return JSON.parse(h);}}
ZAjaxNetService.timezoneOffset=new Date().getTimezoneOffset()*60*1000;ZAjaxNetService.applyTimezone=true;ZAjaxNetService.minDate=new Date(62135596800000);ZAjaxNetService.version="3.5";ZAjaxNetService.onFailed=function(){};

//asd
if(!this.JSON){JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(value instanceof ZAjaxNetDate){return value.str}if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|new Date\(-?\d+\)|'[^'\\\n\r]*'|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?|[0-9a-zA-Z$]+\s*:/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}})();
JSON_dateReviver=function(a,b){var c;if(typeof b==='string'){c=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(b);if(c){return new Date(Date.UTC(+c[1],+c[2]-1,+c[3],+c[4],+c[5],+c[6]));}}
return b;}
function ZAjaxNetDate(a){this.str=a;};ZBack={};ZBack.add=function(a,b,c){var d=++ZBack.currentIndex;ZBack._backObjs[d]={redo:a,save:b,title:c};ZBack._backObjs.length=d+1;if(d>0){var e=ZBack._backObjs[d-1];e.state=e.save?e.save():null;}
var f=ZConfig.frameworkPath()+'/zback_frame.html?i='+d+'&t='+new Date().getTime();if(ZBack._wind){ZBack._wind.location=f;}
else{var g=document.createElement('iframe');g.src=f;document.body.appendChild(g);$hide(g);}
if(c)document.title=c;return a;}
ZBack.currentIndex=-1;ZBack._backObjs=[];ZBack._wind=null;ZBack._callback=function(a,b){ZBack._wind=b;if(a!=ZBack.currentIndex&&ZBack._backObjs[a]){if(a>ZBack.currentIndex&&ZBack._backObjs.length>a+1){var c=ZBack._backObjs[a-1];c.state=c.save?c.save():null;}
else if(a<ZBack.currentIndex&&ZBack._backObjs.length>0){var d=ZBack._backObjs[a+1];d.state=d.save?d.save():null;}
ZBack.currentIndex=a;var e=ZBack._backObjs[a];e.redo(e.state);if($notnull(e.title))document.title=backOj.title;}}
ZStyle={};ZStyle.colors={aqua:'#00FFFF',black:'#000000',blue:'#0000FF',fuchsia:'#FF00FF',gray:'#808080',green:'#008000',lime:'#00FF00',maroon:'#800000',navy:'#000080',olive:'#808000',purple:'#800080',red:'#FF0000',silver:'#C0C0C0',teal:'#008080',white:'#FFFFFF',yellow:'#FFFF00'};ZStyle.currentStyle=function(a,b,c){if(c&&c[b]){return c[b];}
var d=null;if(b==='opacity'&&a.currentStyle){d=a.currentStyle['filter'];if(d.startsWith('alpha(opacity=')){var e=ZStyle.parseStyle(d,b);e.unit='opacity';e.value/=100;return e;}
return{value:1,unit:'opacity'};}
if(b==='offsetHeight'||b==='offsetWidth'){var f=b==='offsetHeight';var g=a.style[f?'height':'width'];a.style[f?'height':'width']='100%';var h=a.style.display;$show(a);var i=ZStyle.parseStyle(f?a.offsetHeight:a.offsetWidth);a.style[f?'height':'width']=g;a.style.display=h;return i;}
if(b==='viewportHeight'||b==='viewportWidth'){var f=b==='viewportHeight';var i=ZStyle.currentStyle(a,f?'offsetHeight':'offsetWidth',c);var g=ZStyle.currentStyle(a,f?'height':'width',c).value;return{value:Math.round(g*100/i.value),unit:'%'};}
if(a.currentStyle)d=a.currentStyle[b];else d=window.getComputedStyle(a,null)[b];return ZStyle.parseStyle(d,b);}
ZStyle.parseStyle=function(a,b){if(typeof a==='undefined')return{value:null,unit:''};if(typeof a==='number')return{value:a,unit:''};if(a.slice(0,'alpha(opacity='.length)=='alpha(opacity='){return{value:a.slice('alpha(opacity='.length,a.length-1)-0,unit:'alpha(opacity='};}
var c=ZStyle;if(a.charAt(0)=='#')return{value:c.parseHexColor(a),unit:'rgb'};if(a.substr(0,4)=='rgba')return{value:c.parseRgbColor(a),unit:'rgba'};if(a.substr(0,3)=='rgb')return{value:c.parseRgbColor(a),unit:'rgb'};if(c.colors[a])return{value:c.parseHexColor(c.colors[a]),unit:'rgb'};var d=a.match(/^(\d+\.?\d*)(\D*)$/);if(!d)return{value:a,unit:''};return{value:d[1]-0,unit:d[2]};}
ZStyle.parseRgbColor=function(a){var b=a.substring(a.indexOf('(')+1,a.length-1).split(',');for(var c in b)b[c]=b[c]-0;return b;}
ZStyle.parseHexColor=function(a){var b=function(d,e){return parseInt('0x'+(e==2?a.substr(d,e):(a.substr(d,e)+a.substr(d,e))))}
return a.length==4?[ b(1,1),b(2,1),b(3,1)]:[ b(1,2),b(3,2),b(5,2)]}
ZStyle.allowFloats={'-moz-opacity':1,'opacity':1}
ZStyle.styleToString=function(a,b,c){if(c=='alpha(opacity=')return 'alpha(opacity='+b+')';if(c=='rgb'||c=='rgba')return c+'('+b.join(',')+')';return b+''+c;}
ZStyle.setStyle=function(a,b,c,d){var e=c.value,f=c.unit;if(b=='opacity'&&a.currentStyle){f='alpha(opacity=';e=e*100;b='filter';a.style.zoom=1;}
if(b==='viewportHeight'||b==='viewportWidth'){var g=b==='viewportHeight';var h=ZStyle.currentStyle(a,g?'offsetHeight':'offsetWidth',d);a.style[g?'height':'width']=e==100?'100%':Math.round(e*h.value/100)+'px';}
else a.style[b]=ZStyle.styleToString(b,e,f);}
function ZTimeline(a){this.frame=new ZTimeframe(this,a);this.isStopped=false;this.runningCount=0;this.playIndex=0;this.currentFrames={};this.thisObj=a;this.lastFrame=this.frame;ZEvent.register(this,['finish','play','stop']);}
ZTimeline.prototype={_:1,play:function(){this.stop();this.runningCount=0;this.isStopped=false;this.playIndex++
this.events.fire('play');this._frameStarted(this.frame);this.frame.notify();return this;},stop:function(){this.isStopped=true;this.events.fire('stop');return this;},execute:function(){return this.frame.execute.apply(this.frame,arguments);},sleep:function(){return this.frame.sleep.apply(this.frame,arguments);},_frameStarted:function(a){this.runningCount++;this.currentFrames[a.id]=a;},_frameEnded:function(a){this.runningCount--;delete this.currentFrames[a.id];if(!this.runningCount&&!a.tasks.length){this.events.fire('finish');}}}
ZTimeline.prototype.play.zTimelineNotifierIndex=0;ZTimeline.notifier={};ZTimeline.thisObj={};ZTimeline.rate=35;ZTimeline.callee=null;ZTimeline._timer=null;ZTimeline._timerFuncs={};ZTimeline._timerCount=0;ZTimeline._timerIDCount=0;ZTimeline.addListener=function(a){a._zTimeframeTimerID=++ZTimeline._timerIDCount;ZTimeline._timerFuncs[ZTimeline._timerIDCount]=a;if(!ZTimeline._timerCount++)ZTimeline._timer=setInterval(function(){for(var c in ZTimeline._timerFuncs)ZTimeline._timerFuncs[c]();},ZTimeline.rate);}
ZTimeline.removeListener=function(a){delete ZTimeline._timerFuncs[a._zTimeframeTimerID];if(!--ZTimeline._timerCount)clearInterval(ZTimeline._timer);}
function ZTimeframe(a,b){this.tasks=[];this.isNotified=false;this.notify=this.notify.bind(this);this.timeline=a;this.id=++ZTimeframe._idCount;this.thisObj=b;ZEvent.register(this,['finish']);if(b){var c=this;for(var d in b){var e=b[d];if(this[d])continue;if(typeof e!=='function')continue;var f=function(h){this[d]=function(){var j=Array.prototype.slice.call(arguments);j.unshift(h);j.unshift(b);return c.executeWithThis.apply(c,j);}}.call(this,e);if(e.zTimelineNotifierIndex)this[d].zTimelineNotifierIndex=e.zTimelineNotifierIndex;}}}
ZTimeframe._idCount=0;ZTimeframe._taskCount=0;ZTimeframe.__task={};ZTimeframe.prototype={_:1,_callFunc:function(a){if(this.isStopped)return;this.timeline._frameStarted(this);ZTimeline.current=this.timeline;this._prepareTask(a);	
if(typeof a.func==='object'){ZTimeframe.__task[++ZTimeframe._taskCount]=a;var b='ZTimeframe.__task['+ZTimeframe._taskCount+'].func(';for(var c=0;c<a.args.length;c++){if(c>0)b+=',';b+='ZTimeframe.__task['+ZTimeframe._taskCount+'].args['+c+']';}
b+=')';eval(b);delete ZTimeframe.__task[ZTimeframe._taskCount];}
else a.func.apply(a.obj,a.args);ZTimeline.current=null;if(!a.hasNotifier)a.notifier();},notify:function(){this.timeline._frameEnded(this);this.events.fire('finish');if(this.timeline.isStopped)return;for(var a=0;a<this.tasks.length;a++){this._callFunc(this.tasks[a]);}},executeWithThis:function(a,b){var c=[];for(var d=2;d<arguments.length;d++){c.push(arguments[d]);}
if(a==ZTimeline.thisObj)obj=this.thisObj;if(typeof b==='string')b=a[b];var e=new ZTimeframe(this.timeline,$ifnot(this.nextThisObj,this.thisObj));var f={obj:a,func:b,args:c,frame:e};this.tasks.push(f);return e;},execute:function(a){var b=Array.prototype.slice.call(arguments);b.unshift(null);return this.executeWithThis.apply(this,b);},subject:function(a){if($undef(a))return this.thisObj;if(typeof a==='string')a=Z(a);this.nextThisObj=a;var b=this.execute(function(){});this.nextThisObj=null;return b;},_prepareTask:function(a){var b=this.timeline.playIndex;var c=this;a.notifier=function(){if(c.timeline.playIndex==b)a.frame.notify();}
var e=false;for(var f=0;f<a.args.length;f++){if(a.args[f]==ZTimeline.notifier){a.args[f]=a.notifier;e=true;}}
if(typeof a.func.zTimelineNotifierIndex==='number'){a.args[a.func.zTimelineNotifierIndex]=a.notifier;e=true;}
a.hasNotifier=e;},sleep:function(a){return this.execute(setTimeout,ZTimeline.notifier,a);}}
Function.prototype.execOnZTimeframe=function(a){var b=this;var c=function(){if(ZTimeline.current&&arguments.length>a){b.apply(this,arguments);}
else{var e=new ZTimeline(this);var f=Array.prototype.slice.call(arguments);f.unshift(b);f.unshift(this);var g=e.frame.executeWithThis.apply(e.frame,f).sleep(0);e.play();return g;}}
b.zTimelineNotifierIndex=c.zTimelineNotifierIndex=a;return c;}
Z.prototype.sleep=function(a,b){setTimeout(b,a);}.execOnZTimeframe(1);Z.prototype.timeframe=function(a){var b=new ZTimeline(this);var c=b.frame.sleep(0);if(!a)b.play();return c;};function ZTween(a,b,c,d){this.rate=window.ZTimeline?ZTimeline.rate:20;if(!c)c=200;b=$clone(b);var e={};var f=false;var g=0;var h=Math.ceil(c/this.rate);if(!d)d=new ZTween.PowerInterpolator(1);var i=d.calcFrames(h);var j=ZStyle.colors;var k=null;var l={};m();function m(){	
if(!ZStyle.currentStyle(a,'left').unit)a.style.left='0px';if(!ZStyle.currentStyle(a,'top').unit)a.style.top='0px';if($def(b.viewportHeight)&&(ZStyle.currentStyle(a,'paddingTop').value ||ZStyle.currentStyle(a,'paddingBottom').value)){throw "There are paddings on the element for which you want to tween the viewport. Tweening can't work with paddings. Try to put the paddings in an inner div.";}
if('viewportHeight' in b){l['offsetHeight']=ZStyle.currentStyle(a,'offsetHeight');}
for(var s in b){var t=(b[s]+'').trim();var u=t.length>=2?t.substr(0,2):'';if(u=='+='||u=='-='||u=='%='||u=='/='){u=t.substr(0,2);t=t.substr(2);}else u='';if(!u&&t.indexOf('-',1)>=0){var v=t.split('-');t=v[1];e[s]=ZStyle.parseStyle(v[0]);ZStyle.setStyle(a,s,e[s]);}
t=ZStyle.parseStyle(t,s);var w=ZStyle.currentStyle(a,s,l);var x=w.value;if(u){if(u=='+=')t.value=x+t.value;if(u=='-=')t.value=x-t.value;if(u=='*=')t.value=x * t.value;if(u=='/=')t.value=Math.round(x/t.value);}
t.start=x;t.end=t.value;t.name=s;b[s]=t;if(w.unit==='pt'||t.unit==='pt')throw "ZTween doens't work with point units, please work with pixels for "+s;if(s==='viewportWidth' &&(ZStyle.currentStyle(a,'paddingLeft').value ||ZStyle.currentStyle(a,'paddingRight').value)){throw "There are left or right paddings on the element you want to tween the viewport off. Tweening can't work with paddings.";}
if(s==='viewportHeight' &&(ZStyle.currentStyle(a,'paddingTop').value ||ZStyle.currentStyle(a,'paddingBottom').value)){throw "There are top or bottom paddings on the element you want to tween the viewport off. Tweening can't work with paddings.";}}}
this.play=function n(s){if(!f)g=0;if(g>=h)return;this.timelineStopped=false;var t=this;if(window.ZTimeline&&ZTimeline.current){this.timeline=ZTimeline.current;stopFunc=function(){t.timelineStopped=true;};this.timeline.onStop(stopFunc);}
var v=(t.timeline?ZTimeline.addListener:setInterval)(function(){if(!t.timelineStopped){g+=1;p(g);}
if(t.timelineStopped||g>=h||k){t.timeline?ZTimeline.removeListener(arguments.callee):clearInterval(v);if(t.timeline)$dehandle(t.timeline,'end',stopFunc);if(s)s();}},this.rate);}
this.play.zTimelineNotifierIndex=0;this.frame=function(){return g;}
function p(s){for(var t in b){var u=b[t];q(u,s);}}
function q(s,t){var u=s.name;var v=ZStyle.currentStyle(a,u,l);var w=h-t;var x;if(v.value instanceof Array){x=[];for(var y=0;y<v.value.length;y++){x[y]=r(u,s.start[y],s.end[y],t);}}
else{var z=s.end-v.value;x=r(u,s.start,s.end,t);}
try{ZStyle.setStyle(a,u,{value:x,unit:v.unit},l);}catch(err){alert('Kon '+u+' niet instellen. Wellicht moet je eerst een beginwaarde in de html/css instellen.');k=err;}}
function r(s,t,u,v){var w=u-t;var x=i[v] * w+t;if(!ZStyle.allowFloats[s])x=Math.round(x);if(u>t)return Math.min(Math.max(x,t),u);return Math.min(Math.max(x,u),t);}}
ZTween.PowerInterpolator=function(a){this.calcFrames=function(c){var d=[];var e=Math.pow(c,a);for(var f=0;f<=c;f++){d[f]=Math.pow(f,a)/e;}
return d;}}
ZTween.BounceInterpolator=function(a,b,c){this.calcFrames=function(e){var f=[];var g=(!g&&g!==0)?15:g;g=Math.floor(e*b);c=(!c&&c!==0)?.1:c;var h=Math.pow(e-g,a);var i=0;for(;i<=e-g;i++){f[i]=Math.pow(i,a)/h;}
for(var j=0,k=1;i<e;i++,j++){f[i]=1-(k/g*c);if(j<g/2)k++;else k--;}
f[e]=1;return f;}}
ZTween.bounce=new ZTween.BounceInterpolator(2,.2,.2);ZTween.speedUp=new ZTween.PowerInterpolator(2);ZTween.slowDown=new ZTween.PowerInterpolator(.5);Z.prototype.tween=function(a,b,c,d){new ZTween(this.elm,a,b,c).play(d);}.execOnZTimeframe(3);Z.prototype.wipe=function(a,b,c,d,e){if(!c)c={};c.viewportHeight=a?0:100;if(a!=$shown(this)){if(e)e();return;}
this.style('height',a?'100%':'0px');this.style('overflow','hidden');this.show();var f=this;this.tween(c,b,d||ZTween.speedUp,function(){if(a)f.hide();if(e)e();});}.execOnZTimeframe(4);ZTemplate=function(a){this.id=a;this.elm=$(a,true);this.elm.normalize();this.paths={};this.namePaths=[];this.forLabels=[];this.precompile();this.compile();}
ZTemplate.instances={};ZTemplate.get=function(a){var b=ZTemplate.instances[a];if(!b)return ZTemplate.instances[a]=new ZTemplate(a);return b;}
ZTemplate.fillVars=function(a,b){for(var c in b){a['_'+c].text(b[c]);}}
ZTemplate.prototype={_:1,compile:function(){var a=this.paths;var b=this.namePaths;var c=this.forLabels;var d=function e(f,g){if(!f.getAttribute)return;var h;if(h=f.getAttribute('_id')){if(g)a[h]=g.toArray();Z(f).addClass(h);f.z=null;}
if(f.name&&g){b.push(g.toArray());}
if(f.htmlFor&&f.tagName==='LABEL'){c.push(g.toArray());}
for(var i=0;i<f.childNodes.length;i++){e(f.childNodes[i],new ZTemplate.Path(g,i));}}(this.elm,null);},precompile:function(){this.elm.innerHTML=this._replaceVars(this._replaceVars(this.elm.innerHTML,'$','span'),'#','div');},_replaceVars:function(a,b,c){var d=new RegExp('\\'+b+'[\\w_]+\\'+ b);var e=0;while(e++<1000){var f=d.exec(a);if(!f)break;a=a.slice(0,f.index)+'<'+c+' _id="' +f[0].slice(1,f[0].length-1)+'"></'+c+'>'+a.slice(f.index+f[0].length);}
if(e>=1000)throw 'Overflow in template: too many variables.';return a;},apply:function(a,b){var c=this.elm.cloneNode(true);c.id=$ifnot(b,'');c.className=c.getAttribute('_class');var d=Z(c);d.template=this;if(this.elm.id)d.addClass(this.elm.id);d.elms={};var e=null;var f={};for(var b in this.paths){var g=this.paths[b];var h=this._walkPath(c,g,f);d['_'+b]=Z(h);d['$'+b]=h;}
for(var i=0;i<this.namePaths.length;i++){if(!e)e=d.getTemplatePrefix();var g=this.namePaths[i];var h=this._walkPath(c,g,f);h.name=e+h.name;}
for(var i=0;i<this.forLabels.length;i++){var g=this.forLabels[i];var h=this._walkPath(c,g,f);var j=d['_'+h.htmlFor];if(!j)continue;if(!j.elm.id)j.elm.id=$generateID();h.htmlFor=j.elm.id;}
if(a)ZTemplate.fillVars(d,a);d.templateNamePrefix=e?e:'';return d;},_walkPath:function(a,b,c){var d=a;var e='';for(var f=0;f<b.length;f++){var g=b[f];e+=g+'_';var h=c[e];d=h?h:(c[e]=d.childNodes[g]);}
return d;}}
ZTemplate.Path=function(a,b){this.parent=a;this.index=b;this.toArray=function(){var d=[];var e=this;while(e!=null){d.push(e.index);e=e.parent;}
return d.reverse();}}
ZTemplate.apply=function(a,b,c,d){var e=ZTemplate.get(a);if(!e)throw 'ZTemplate'+a+" doesn't exist.";var f=e.apply(d);f.data=c;if(b)$(b).appendChild(f.elm);return f;}
ZTemplate.create=function(a,b,c){if($(b))return ZTemplate.get(b);var d=Z.create('div').addClass('z_hidden').html(a);d.elm.id=b||$generateID();Z(document.body).append(d,true);if(c)ZUtil.addCss(c,true);d.elm.z=null;return ZTemplate.get(d.elm.id);}
ZControl=function(a,b){var c=this;a.ctrl=c;c.z=a;c.elm=c.$=a.elm;c.controls=[];c.isValid=false;c.isValidated=false;c.isActive;	c.isValidating=false;c.noMatchCondition=null;c.currentCondition=null;c.name=$ifnot($ifnot(c.elm.name,c.elm.id),c.elm+'');var d=[];ZEvent.register(c,['blur','focus','change','validationstart','validationend','active','inactive']);c.isPrimitive=false;	c.isChild=false;c.hasFocus=false;function e(){p(c.attribute("feedback"));c.showFeedback(c.attribute('showfeedback')!=='false');j();c.events.parent=c.group;if(!b)i(c.elm);if(c.isPrimitive)c.z.handle('focus',function(){c.group.setFocusControl(c);var r=c;while(r){if(!r.hasFocus){r.hasFocus=true;r.events.fire('focus');}
r=r.parent;}});if(c.isPrimitive)c.z.handle('blur',function(r){c.group.setFocusControl(null);setTimeout(c.checkBlurred,0);});if(c.attribute('on_focus_show'))c.setOnFocusShowElement(c.attribute('on_focus_show'));if(c.attribute('on_active_show'))c.setOnActiveShowElement(c.attribute('on_active_show'));$handle(c,['focus','blur','validationend'],function(r){var s=c.getOnFocusShowElement();if(s&&r.type!='validationend')$display(s,r.type=='focus');var s=c.getOnActiveShowElement();if(s)$display(s,r.type!='blur'||c.isValidated);if(!c.isActive&&r.type!='blur'){c.isActive=true;c.events.fire('active');}
if(c.isActive&&r.type=='blur'&&!c.isValidated){c.isActive=false;c.events.fire('inactive');}})}
var f;c.setOnFocusShowElement=function(q){f=$(q);}
c.getOnFocusShowElement=function(){return f;}
var h;c.setOnActiveShowElement=function(q){h=$(q);}
c.getOnActiveShowElement=function(){return h;}
c.checkBlurred=function(){var q=c.isInHierarchie(c.group.focusControl);if(!q){c.hasFocus=false;c.events.fire('blur');}
if(c.parent)c.parent.checkBlurred();}
$handle(c,'blur',function(){c.validateIfAuto('blur');});c.isInHierarchie=function(q){var r=false;while(q){if(q==c)r=true;q=q.parent;}
return r;}
function i(q){for(var r=0;r<q.childNodes.length;r++){var s=q.childNodes[r];if(s.nodeType!==1)continue;var t=$ctrl(s,true);if(t){c.addChildControl(t);}
else {i(s);}}
c.isPrimitive=!c.controls.length;}
c.addChildControl=function(q){var r=$ctrl(q);r.parent=c;r.isChild=true;r.events.parent=null;c.controls.push(r);r.showFeedback(false);r.notifyAddedToParent(c);}
c.notifyAddedToParent=function(q){}
function j(){c.group=null;var q=c.elm;while(q&&q.nodeType===1){var r=null;if(r=$ctrlgroup(q,true)){c.group=r;break;}
if(q.z&&q.z.ctrl&&q.z.ctrl.group){c.group=q.z.ctrl.group;break;}
q=q.parentNode;}
if(!c.group)c.group=ZControlgroup.getDefault();c.group.addControl(c);}
c.attribute=function(q,r){return a.attribute('z_'+q,r);}
c.isAutoValidate=function(){return c.attribute('autovalidate')!=='false';}
c.setAutoValidate=function(q){c.attribute('autovalidate',q?'true':'false');}
c.getAutoValidateAfter=function(){return $ifnull(c.attribute('autovalidateafter'),1500)-0;}
c.setAutoValidateAfter=function(q){return c.attribute('autovalidateafter',q);}
c.addValidator=function(q,r,s,t,u){if(typeof q==='function'){q=new ZValidators.Custom(q);}
var v={validator:q,text:r,summary:s,isWarning:t,waitText:u};d.push(v);q.init(c);$initializer.addFunction(function(x){n();x.notify();});return q;}
c.hasValidators=function(){return d.length>0;}
c.lastValidateTime=0;	
c.validate=function(q,r){var s=$clone(d);	
var t=-1;var u=null;c.events.fire('validationstart');c.lastValidateTime=new Date().getTime();function v(){t++;if(t>=s.length||u){x();return;}
var y=s[t];if(!y.validator.isEnabled()){v();return;}
var z={isValid:true,ctrl:c,reason:q,text:y.text,summary:y.summary,waitText:y.waitText,usesCallback:false,callback:function(){w(z);}}
c.isValidating=true;c.currentCondition=z;y.validator.validate(z);if(!z.usesCallback)w(z);else n();}
function w(y){c.isValidating=false;c.currentCondition=null;if(!y.isValid){u=y;}
v();}
function x(){c.isValid=!u;c.isValidated=true;c.noMatchCondition=u;c.events.fire('validationend');if(s.length)n();if(r)r();}
v();}
c.validateIfAuto=function(q){if(c.isAutoValidate())c.validate(q);}
var k=null;c.notifyValidateAfterEvent=function(){clearTimeout(k);var q=c.getAutoValidateAfter();var r=new Date().getTime();if(q>0){k=setTimeout(function(){if(!c.lastValidateTime||(c.lastValidateTime-r<0)){c.validateIfAuto(ZControl.ValidateReason.ValidateAfter);}},q);}
if(c.parent)c.parent.notifyValidateAfterEvent();}
var l={};c.getFeedbackInsertAfterElement=function(){return c.elm;}
c.getFeedbackInsertBeforeElement=function(){return c.elm;}
c.getFeedbackElement=function(q){	
if(typeof l[q]==='object'||l[q]===null)return l[q];var r=null;if(!(q in l)){r=a.getById(a.getId()+'_'+q);if(!r&&q==='text')l[q]='after-block';else if(!r&&q==='icon')l[q]='after';else return l[q]=r;}
var s=l[q];if(s==='none'){}
else if(s.startsWith('id(')&&s.endsWith(')')){r=a.getById(s.slice(3,s.length-1).trim()).elm;}
else{var t=s=='before'||s=='before-block'||s=='before-label';var u=s=='after'||s=='after-block'||s=='after-label'||s=='after-icon';var v=s=='after-icon';if((!u&&!t)||(v&&q=='icon')){alert('The feedback element '+s+' is not recognized.');return;}
var w=s.endsWith('-block');var x=s.endsWith('-label')||(s=='after'&&(ZControl.isCheckbox(c.z)||ZControl.isRadio(c.z)));var y=u?c.getFeedbackInsertAfterElement():c.getFeedbackInsertBeforeElement();if(w){var z={'DIV':1,'TABLE':1,'P':1,'TD':1,'TR':1,'BODY':1,'FORM':1};while(y&&y.style&&!((z[y.tagName]&&!y.style.display)||y.style.display==='block')){y=y.parentNode;}
if(y==document.body){alert('No block element for the feedback element is found for control {0}, feedback \'{1}\'.\nTry enclosing it in a <div> element'.format(c.name,q));return;}}
if(x){var ab=document.getElementsByTagName('label');for(var bb=0;bb<ab.length;bb++){var cb=ab[bb];if(cb.htmlFor===c.elm.id){y=cb;break;}}}
if(v){y=c.getFeedbackElement('icon');}
r=document.createElement('span');Z(y)[t?'insertBefore':'insertAfter'](r);}
return l[q]=r;}
c.setFeedbackElement=function(q,r){l[q]=r;}
var m;c.showFeedback=function(q){if($undef(q))return m;m=q;}
function n(){if(!c.showFeedback())return;var q=c.noMatchCondition;ZControl.addFeedbackCss();var r=null;if(c.isValidating)r='wait';else if(!q&&!c.isValidated)r='prevalidate'
else if(!q&&c.isValidated)r='success';else if(q&&q.isWarning)r='warning';else if(q&&!q.isWarning)r='error';var s=null;if(r=='error'||r=='warning')s=q.text;if(r=='wait')s=c.currentCondition.waitText;var s=$ifnull(s,c.attribute('text_'+r));var t='z_fb_text_'+r;var u='validation_'+r+'_16.gif';var v='z_fb_icon_'+r;var w='<img src="{0}" border="0" style="position:relative" />'.format(ZConfig.getImagePath(u));o('text',s,t);o('icon',w,v);}
function o(q,r,s){var t=c.getFeedbackElement(q);if(!t)return;$(t).className='z_fb_'+q+' '+s;Z(t).html($str(r));}
function p(q){if(!q)return;var r=q.split(';');for(var s=0;s<r.length;s++){var t=r[s].splitKeyValue(':');l[t.key]=t.value;}}
e();}
ZControl.ValidateReason={Group:'group',Blur:'blur',Keyup:'keyup',ValidateAfter:'validateafter'};$addTo(ZControl,new function(){var a=this;a._currentID=0;a.focusControl=null;a.get=function(f,g){if($instanceof(f,ZControl))return f;var h=Z(f);if(!h){alert('Element '+f+' doesn\'t seem to exist.');return;}
if(h.ctrl)return h.ctrl;var i=a.getType(h);if(!i){if(g)return null;alert('Type of element '+(h.elm.id?h.elm.id:'?')+' is unknown');return;}
var j=ZControls[i];if(!j||typeof j!='function'){if(g)return null;alert('Type of element '+(h.elm.id?h.elm.id:'?')+' has no constructor');return;}
h.addClass('ZControls_'+i);if(h.tag()=='INPUT')h.addClass('input_'+h.attribute('type'));return new j(h);}
a.get.write=function(f,g,h){if(!h)h={};h.id=f;var i=d(g)(h);var j='<'+i.tag+c(g,h)+'>'+i.html+'</'+i.tag+'>';document.write(j);return $ctrl(f);}
a.get.create=function(f,g,h,i){if(!h)h={};f=Z(f);var j=d(g)(h);var k=f.tag().toLowerCase();var l=j.tag.toLowerCase();if(!i&&k!=l){alert('The tag of the container doesn\'t match the tag of the control.\nUse a '+l+'-tag or set the doAppend argument to true.');return;}
var m=f;if(i){m=Z.create(l);f.append(m);}
h.z_ctrl=g;$foreach(h,function(o,p){m.attribute(p,o);});m.html(j.html);return $ctrl(m);}
function c(f,g){g.z_ctrl=f;var h='';$foreach(g,function(j,k){h+=' '+$attr(k)+'="'+$attr(j)+'"';});return h;}
function d(f){if(!f)f='ZControl';var g=ZControls[f];if(!g){alert('Type {0} isn\'t found.'.format(f));return;}
if(typeof g.create!='function'){alert('Type {0} can\'t be dynamicly created.'.format(f));return;}
return g.create;}
function e(f,g,h){var i=typeClass.create(g);if(!i.tag)i.tag='span';var j='<'+i.tag+attrStr+'>'+i.html+'</'+i.tag+'>';return j;}
a.getType=function(f){var g=f.attribute('z_ctrl');if(!g)g=a.getPrimitiveType(f);if(!g)return null;		
return g;}
a.getPrimitiveType=function(f){var g=null;if(a.isTextbox(f))g='Textbox';if(a.isFile(f))g='File';if(a.isRadio(f))g='Radio';if(a.isCheckbox(f))g='Checkbox';if(a.isSelect(f))g='Select';if(a.isButton(f))g='Button';if(a.isHidden(f))g='Hidden';return g;}
a.isRadio=function(f){return f.tag()=='INPUT'&&f.attribute('type')=='radio';}
a.isCheckbox=function(f){return f.tag()=='INPUT'&&f.attribute('type')=='checkbox';}
a.isFile=function(f){return f.tag()=='INPUT'&&f.attribute('type')=='file';}
a.isTextbox=function(f){return(f.tag()=='INPUT'&&(f.attribute('type')=='text'||f.attribute('type')=='password'))||f.tag()=='TEXTAREA';}
a.isButton=function(f){return(f.tag()=='INPUT' &&(f.attribute('type')=='button'||f.attribute('type')=='submit'));}
a.isHidden=function(f){return(f.tag()=='INPUT'&&f.attribute('type')=='hidden');}
a.isSelect=function(f){return(f.tag()=='SELECT');}		
a.isInput=function(f){var g=f.tag();return g=='INPUT'||g=='SELECT'||g=='TEXTAREA';}
a.delayEvent=function(f,g){f=$clone($event(f));setTimeout(function(){g(f);},0);}
a.addFeedbackCss=function(){if(a.addedFeedbackCss)return;a.addedFeedbackCss=true;ZUtil.addCss('.z_fb_text_error { color:red; } .z_fb_text_prevalidate { color:#888; } .z_fb_text_success { color:green; font-weight:bold;} .z_fb_text_warning { color:orange; } '+'.z_fb_icon { padding-left:5px; padding-right:5px; vertical-align:-20%; } ',true);}}());ZControls={};ZControls.Control=ZControl;ZControls.Textbox=function(a){var b=$base(this,arguments,ZControl,a);var c=b.elm;b.isNumber=function(){return b.attribute('numberformat')||b.attribute('number')=='true';}
b.getNumberformat=function(){return $ifnull(b.attribute('numberformat'),'N0');}
b.setNumberformat=function(n){return b.attribute('numberformat',n);}
b.getDefaultValue=function(){var n=b.attribute('defaultvalue');if($notnull(n))return n;if(b.isNumber())return '0';return '';}
b.setDefaultValue=function(n){if(b.isNumber()&&!isNaN(n-0))n=(n-0).format(b.getNumberformat());b.attribute('defaultvalue',n);}
b.isSelectOnFocus=function(){if(b.attribute('select_on_focus')=='true')return true;if($null(b.attribute('select_on_focus')))return b.isNumber();}
b.setSelectOnFocus=function(n){b.attribute('select_on_focus',n?'true':($null(n)?'':'false'));}
b._autoTabTime=0;	
var e={};b.z.handle('keydown',function(n){n=$event(n);var o=ZUtil.key(n);e[o]=true;if(o==ZUtil.Keys.DecimalPoint&&b.isNumber()){var p=ZConfig.culture.decimalPoint;if(p==ZUtil.Keys.DecimalPoint)return;if('selectionStart' in c){var q=c.selectionStart;c.value=c.value.slice(0,q)+p+c.value.slice(c.selectionEnd);c.selectionStart=c.selectionEnd=q+1;}
else{var r=document.selection.createRange();r.text=p;r.collapse(false);r.select();}
return ZUtil.preventDefault(n);}
if(o==ZUtil.Keys.Tab&&(new Date().getTime()-b._autoTabTime<400)){if(n.preventDefault)n.preventDefault();return false;}
if(o==ZUtil.Keys.Enter){b.validateIfAuto('enter');}});b.format=function(n){if(!c.value||c.value==b.getDefaultValue()){if(!n){c.value=b.getDefaultValue();b.handleDefaultValue();}
return;}
a.removeClass('z_text_default');if(b.isNumber()&&(!n||b.getNumberformat().toLowerCase()=='n0')){var o=c.value.toNumber();if(!isNaN(o))c.value=o.format(b.getNumberformat());}}
var f;var g=null;b.getMaxLength=function(){if('maxlength' in c)return c.maxlength;return c.getAttribute('maxlength')-0;}
b.z.handle('keyup',function(n){n=$event(n);var o=ZUtil.key(n);if(!ZUtil.isControlKey(o)&&e[o]){b.format(true);if(i&&c.value.length==b.getMaxLength()){if(i==b&&b.parent){var p=b.parent.controls;var q=Array.indexOf(p,b);if(q+1<p.length)i=p[q+1];}
i.elm.focus();if($instanceof(i,ZControls.Textbox))i.elm.select();i._autoTabTime=new Date().getTime();}}
if(f!=c.value){b.notifyValidateAfterEvent();}
f=c.value;delete e[o];});b.z.handle('blur',function(n){b.format(false);h=true;b.z.removeClass('z_text_focus');});var h=true;b.z.handle('click',function(n){if(b.isSelectOnFocus()&&h&&!ZUtil.getTextboxSelection(c))c.select();h=false;});b.z.handle('focus',function(n){b.z.addClass('z_text_focus');if(b.getValue()===b.getDefaultValue()){b.setValue('');}});b.setValue=function(n){b.elm.value=n;b.handleDefaultValue();}
b.getValue=function(n){if(n&&b.elm.value==b.getDefaultValue())return '';return b.elm.value;}
b.setNumber=function(n){var o=b.attribute('numberformat');b.setValue((n-0).format(b.getNumberformat()));}
b.getNumber=function(){var n=b.attribute('numberformat');return b.elm.value.toNumber(b.getNumberformat());}
var i=null;b.onCompleteFocusOn=function(n){i=$ctrl(n);}
b.handleDefaultValue=function(){var n=b.getDefaultValue();if(n&&c.value==n)a.addClass('z_text_default');else a.removeClass('z_text_default');}
b.validate=function(){b.format(false);$basefuncWithArgs(b,'validate',ZControls.Textbox,arguments);}
b.getFeedbackInsertAfterElement=function(){if(l&&l.getArrowUI()){return l.getArrowUI();}
return b.elm;}
b.setAutoIndent=function(n){k.enableAutoIndent(b.elm,n);}
b.setTabspaces=function(n){k.registerTabspaces(b.elm,n);}
b.setDefaultValue(b.getDefaultValue());if(!c.value)b.format();$initializer.addFunction(function(n){b.handleDefaultValue();n.notify();});if(b.attribute('on_complete_focus_on')){b.onCompleteFocusOn(b.attribute('on_complete_focus_on'));}
else if(b.attribute('jump')=="true"){b.onCompleteFocusOn(b);}
function j(){if(l)return;l=new ZControl.TextboxList(b);}
b.setAutocomplete=function(n){j();l.setAutocomplete(n);}
b.setSelect=function(n){j();l.setSelect(n);}
b.getSelect=function(){if(!l)return null;return l.getSelect();}
b.getTextboxList=function(){return l;}
b.setSelectMaxHeight=function(n){j();l.setMaxHeight(n);}
var k=ZControl.TextareaUtil;b.insertText=function(n,o,p,q,r,s,t){k.insertText(b.elm,n,o,p,q,r,s,t);}
b.getSelectionPosition=function(n){return k.getSelectionPosition(b.elm,n);}
b.select=function(n,o){if($undef(n))b.elm.select();else k.select(b.elm,n,o);}
b.getSelection=function(){return ZUtil.getTextboxSelection(b.elm);}
var l=null;if(b.attribute('select')){b.setSelect($(b.attribute('select')));}
if(b.attribute('autocomplete')){b.setAutocomplete(b.attribute('autocomplete'));}
if(b.attribute('width')){var m=b.attribute('width');if(!m.endsWith('%')&&!m.endsWith('px'))m+='px';b.z.style('width',m);}
if(b.attribute('selectmaxheight')){b.setSelectMaxHeight(b.attribute('selectmaxheight')-0);}
if(b.attribute('autoindent')){b.setAutoIndent(b.attribute('autoindent')=='true');}
if(b.attribute('tabspaces')){b.setTabspaces(b.attribute('tabspaces')-0);}
f=c.value;}
ZControl.TextboxList=function(a){var b=this;a=$ctrl(a);var c=null;var d;var e;b.setSelect=function(v){g();e=$(v);}
b.getSelect=function(){return e;}
b.getArrowUI=function(){return d;}
function g(){if(d)return;d=new Image();d.src=ZConfig.getImagePath('dropdownarrowbox.gif');Z(d).styles({position:'relative',verticalAlign:'top'});a.z.insertAfter(d);Z(d).onMousedown(function(w){setTimeout(l,0);});Z(d).onClick(function(w){w.cancelBubble=true;a.z.elm.focus();});}
function h(){}
b.setAutocomplete=function(v){if(typeof(v)!='function'){var w=$(v);v=function(y){var z=y.value.toLowerCase();$foreacha($(w).options,function(bb){if(bb.value.toLowerCase().startsWith(z)){b.add(bb.text,bb.value);}});};}
c=v;}
$initializer.addFunction(function(v){i=a.getValue(true);v.notify();});var i;var j=null;var k=Z(a.elm);if(k.attribute('autocomplete')!='off'){$handle(window,'unload',function(){k.attribute('autocomplete','on');});}
k.attribute('autocomplete','off');var l=function(){b.clear();$foreacha($(e).options,function(w){b.add(w.text,w.value);});t();}
$handle(a.elm,['keydown','click','focus'],function(v){v=$event(v);var w=a.getValue();var x=v.type=='keydown'?ZUtil.key(v):-1;if(x==ZUtil.Keys.Enter){o(null,true);}
else if(x==ZUtil.Keys.Down||x==ZUtil.Keys.Up){q(x==ZUtil.Keys.Up?1:-1);}
if(x!=-1){setTimeout(function(){w=a.getValue();if(w.length<b.minimumLength||x==ZUtil.Keys.Esc){s();}
else if(i!=w){b.clear();if(c)c({target:b,list:b,value:w,ctrl:a,oldValue:i});}
i=w;},0);}
if(x==ZUtil.Keys.Enter||x==ZUtil.Keys.Esc){return ZUtil.preventDefault(v);}});$handle(a.elm,'blur',function(){s();});b.minimumLength=0;var m=0;var n=-1;function o(v,w){if($notnull(v))n=v;if(n==-1)return;a.setValue(b.getValue(j.child(n)));i=a.getValue();if(w)s();setTimeout(function(){a.elm.focus();},0);}
function p(v){var w=n;n=v;if(w<m&&w>=0){j.child(w).removeClass('z_autocomplete_selected');}
if(n<m&&n>=0){j.child(n).addClass('z_autocomplete_selected');}}
function q(v){var w;if(m==0)return;if(n==-1&&!j.shown()){t();return;}
if(n==-1){w=v>=0?m-1:0;}
else {w=(n-v)%m;if(w<0)w+=m;}
p(w);o();r(w,v>0);}
function r(v,w){var x=0,y=0;for(var z=0;z<v;z++){y+=j.child(v).dimension().h;}
x=y+j.child(v).dimension().h;var ab=j.elm.scrollTop;if(y<ab){j.elm.scrollTop=y;}
else{var bb=j.dimension().h;if(x>(ab+bb)){j.elm.scrollTop=x-bb;}}}
b.add=function(v,w,x){t();var y;if(typeof v!='object'){y=Z.create('div')[x?'html':'text']($str(v));if($null(w))w=$str(v);}
else {y=Z(v);if($null(w))w=y.text();}
var z=m;y.onMouseover(function(){p(z);});y.onMousedown(function(){o(z);a.validateIfAuto();});y.addClass('z_autocomplete_item');b.setValue(y,w);j.append(y);m++;}
b.remove=function(v){$foreacha(j.children(),function(x){if(b.getValue(x)==v){x.remove();m--;}});n=n%m;if(n<0)n+=m;}
b.clear=function(){j.clear();	
m=0;n=-1;s();}
b.getValue=function(v){return v.props.z_autocompleteValue;}
b.setValue=function(v,w){v.props.z_autocompleteValue=w;}
function s(){j.hide();p(-1);}
function t(){var v=k.position(true);var w=k.dimension();j.styles({position:'absolute',width:w.w+'px',top:(v.y+w.h)+'px',left:(v.x)+'px'}).show();}
function u(){j=Z.create('div').addClass('z_autocomplete');k.insertAfter(j);if(!ZControl.TextboxList.cssAdded){ZControl.TextboxList.cssAdded=true;ZUtil.addCss('.z_autocomplete { background:white; border:1px solid black; z-index:999; overflow:auto; } '+'.z_autocomplete_item { cursor:default; border: 0px solid #ddd; border-top:0; padding:1px; padding-left:4px; padding-right:4px; } '+'.z_autocomplete_selected { background:#0A246A; color:white;  } ',true);}
j.hide();}
b.setMaxHeight=function(v){j.style('maxHeight',v+'px');}
b.getUI=function(){return j;}
u();}
ZControl.TextboxList.cssAdded=false;ZControls.TextboxSelect=function(a){var b=$base(this,arguments,ZControl,a);}
ZControls.File=function(a){var b=$base(this,arguments,ZControl,a);$handle(a,'change',function(){b.validateIfAuto('change');});b.getValue=function(){return b.elm.value;}}
ZControls.Radio=function(a){var b=$base(this,arguments,ZControl,a);b.getValue=function(){return b.elm.value;}
b.isChecked=function(){return b.elm.checked;}
b.setChecked=function(d){b.elm.checked=d;}
b.getName=function(){return b.attribute('name')||b.elm.name||b.elm.getAttribute('name');}}
ZControls.Checkbox=function(a){var b=$base(this,arguments,ZControl,a);b.getValue=function(){return b.elm.value;}
b.isChecked=function(){return b.elm.checked;}
b.setChecked=function(d){b.elm.checked=d;}
$handle(b.elm,'click',function(){b.validateIfAuto('click');});}
ZControls.Select=function(a){var b=$base(this,arguments,ZControl,a);function c(){$handle(b.elm,'keydown',function(){var f=b.elm.value;setTimeout(function(){if(f!=b.elm.value)b.validateIfAuto();},0);});$handle(b.elm,'change',b.validateIfAuto);$handle(b.elm,'blur',b.validateIfAuto);}
b.getValue=function(){return b.elm.value;}
b.getValues=function(){var e=[],f=b.elm.options;for(var g=0;g<f.length;g++){if(f[g].selected)e.push(f[g].value);}
return e;}
b.setValue=function(e){b.elm.value=e;}
b.hasValue=function(e){for(var f=0;f<b.elm.options.length;f++){if(b.elm.options[f].value==e)return true;}
return false;}
b.getOptions=function(){return b.elm.options;}
b.getSelectedOption=function(){if(b.elm.selectedIndex<0)return null;return b.elm.options[b.elm.selectedIndex];}
b.getSelectedOptions=function(){var e=[];for(var f=0;f<b.elm.options.length;f++){if(b.elm.options[f].value==v)e.push(b.elm.options[f]);}
return e;}
b.clear=function(){b.elm.options.length=0;}
b.add=function(e,f){if($null(f))f=e;return b.elm.options[b.elm.options.length]=new Option(e,f);}
b.remove=function(e){var f=b.elm.options;var g=$wherea(f,function(j){return j.value!=e});if(g.length==f.length)return false;f.length=0;for(var i=0;i<g.length;i++){f[f.length]=g[i]}
return true;}
b.sort=function(e){var f=[];var g=b.elm.options;for(var h=0;h<g.length;h++){f.push(g[h])}
if(!e){e=function(j,k){return j.text<k.text?-1:j.text==k.text?0:1}}
f.sort(e);g.length=0;for(var h=0;h<f.length;h++){g[g.length]=f[h]}}
b.isMultiple=function(){return b.elm.multiple;}
b.setMultiple=function(e){b.elm.multiple=e;}
c();}
ZControls.Button=function(a){$base(this,arguments,ZControl,a);}
ZControls.Hidden=function(a){var b=$base(this,arguments,ZControl,a);b.getValue=function(){return b.elm.value;}
b.setValue=function(d){b.elm.value=d;}}
ZControls.Radiolist=function(a){var b=$base(this,arguments,ZControl,a,true);b.name='';function c(){b.name=b.attribute('name')||a.getId();		
var e=a.getTemplateRoot();if(e&&b.name)b.name=e.getTemplatePrefix()+b.name;var f=b.elm.getElementsByTagName('input');for(var g=0;g<f.length;g++){var h=f[g];var i=$ctrl(h);if(!$instanceof(i,ZControls.Radio))continue;var j=i.getName();if(!j)i.elm.name=j=b.name;if(b.name===j){b.addChildControl(i);}}
$handle(b,'blur',b.validateIfAuto);}
b.addChildControl=function(e){$basefunc(b,'addChildControl',ZControls.Radiolist,e);$handle(e.elm,'click',function(g){b.validateIfAuto('change');});}
b.clear=function(){$foreacha(b.controls,function(f){f.setChecked(false);});}
b.getValue=function(){var e=b.getSelectedControl();return e?e.getValue():null;}
b.setValue=function(e){$foreacha(b.controls,function(g){g.setChecked(g.getValue()==e);});}
b.hasValue=function(e){return!!$wherea(b.controls,false,function(g){return g.getValue()==e;}).length;}
b.getSelectedControl=function(){return $ifnull($wherea(b.controls,function(f){return f.isChecked()})[0],null);}
c();}
ZControls.IDate=function(){_this.getDate=function(){return null;}
_this.setDate=function(b){}
_this.isEmpty=function(){return false;}}
ZControls.Date=function(a){var b=$base(this,arguments,ZControl,a);$interface(arguments,ZControls.IDate);if(b.controls.length!=3){alert('Expected 3 controls inside the Date control, but found {0}. ({1})'.format(b.controls.length,b.name));return;}
var c=ZConfig.culture.shortDateOrder;b.day=b.controls[0];b.month=b.controls[1];b.year=b.controls[2];if(c==ZConfig.CultureInfo.ShortDateOrder.MMDDYYYY){b.day=b.controls[1];b.month=b.controls[0];}
if(c==ZConfig.CultureInfo.ShortDateOrder.YYYYMMDD){b.day=b.controls[2];b.year=b.controls[0];}
b.getDate=function(){var h=b.year.getNumber();h=h.format(b.getYearformat())-0;var i=b.month.getNumber()-1;var j=b.day.getNumber();if(!Date.isValid(h,i,j))return null;return new Date(h,i,j);	}
b.setDate=function(h){if(!h){b.year.setValue('');b.month.setValue('');b.day.setValue('');}
else{b.year.setNumber(h.getFullYear());b.month.setNumber(h.getMonth()+1);b.day.setNumber(h.getDate());}}
b.setYearformat=function(h){h=$str(h);if(h===true)h='Y';if(h===false)h='y';if(!h)h='y';b.year.setNumberformat(h);}
b.getYearformat=function(){return b.year.getNumberformat();}
b.isEmpty=function(){return!b.getDate();}
b.day.z.addClass('z_date_day');b.month.z.addClass('z_date_month');b.year.z.addClass('z_date_year');b.day.attribute('numberformat','d2');b.month.attribute('numberformat','d2');b.setYearformat($ifnull(b.attribute('yearformat'),'y'));b.day.attribute('defaultvalue','');b.month.attribute('defaultvalue','');b.year.attribute('defaultvalue','');b.day.elm.setAttribute('maxlength','2');b.month.elm.setAttribute('maxlength','2');b.year.elm.setAttribute('maxlength','4');b.controls[0].onCompleteFocusOn(b.controls[1]);b.controls[1].onCompleteFocusOn(b.controls[2]);b.getFeedbackInsertAfterElement=function(){return e?e:b.elm;}
b.getArrowUI=function(){return e;}
var e,f;function g(){if(e)return;e=new Image();e.src=ZConfig.getImagePath('dropdownarrowbox.gif');Z(e).styles({position:'relative',verticalAlign:'top',paddingLeft:'2px'});a.insertAfter(e);Z(e).onMousedown(function(i){if(f)return;i.cancelBubble=true;var j=a.position(true);var k=a.dimension();var l=Z.create('div').styles({position:'absolute',zIndex:ZComponent.Dialog.count++,top:(4+j.y+k.h)+'px',left:(j.x)+'px'});a.insertAfter(l);f=new ZCalendar(l);if(b.attribute('z_calendar_class'))f.addClass(b.attribute('z_calendar_class'));var m=b.getDate();if(m)f.setDate(b.getDate());$handle(document,['mousedown','keydown'],n);function n(q){if((q.type=='mousedown'&&!l.containsEvent(q))||(q.type=='keydown'&&ZUtil.key(q)==ZUtil.Keys.Esc)){o();}}
function o(){$dehandle(document,['mousedown','keydown'],n);f.dispose();l.remove();f=null;}
f.onSelect(function(){b.setDate(f.getDate());o();b.validateIfAuto('change');});},true);}
if(b.attribute('calendar')=='true'){g();}
if(!ZControls.Date._addedCss&&ZControls.Date.AddCss){ZControls.Date._addedCss=true;ZUtil.addCss('.z_date_day { width:19px; } .z_date_month { width:19px; } .z_date_year { width:33px; }',true);}}
ZControls.Date.AddCss=true;ZControls.Date.create=function(a){var b=a.name||a.id||$generateID();var c=a.dayName||b+'_day';var d=a.monthName||b+'_month';var e=a.yearName||b+'_year';var f=ZConfig.culture.shortDateOrder;var g=$attr(c),h=$attr(d),i=$attr(e);if(f==ZConfig.CultureInfo.ShortDateOrder.MMDDYYYY){g=d;h=c;}
if(f==ZConfig.CultureInfo.ShortDateOrder.YYYYMMDD){g=e;i=c;}
return{html:'<input name="{1}" type="text" /> {0} <input name="{2}" type="text" /> {0} <input name="{3}" type="text" /></span>'.format(ZConfig.culture.shortDateSeparator,g,h,i,a.z_yearformat),tag:'span'};}
ZControls.Calendar=function(a){var b=$base(this,arguments,ZControl,a);$interface(arguments,ZControls.IDate);b.calendar=new ZCalendar(a);function c(){var e=b.controls[0].getValue()-0;if(e)b.calendar.setDate(new Date(e));}
$handle(b.calendar,['select','browse'],function(e){b.controls[0].setValue(b.calendar.getDate().getTime());b.validateIfAuto('change');});b.getDate=function(){return b.calendar.getDate();}
b.setDate=function(e){return b.calendar.setDate(e);}
b.isEmpty=function(){return false;}
b.elm.style.float='left';$handle(window,'load',c);}
ZControls.Calendar.create=function(a){return{tag:'span',html:'<input type="hidden" name="{0}" />'.format(a.name||a.id)};}
ZControlgroup=function(a,b){var c=this;c.elm=c.$=a;c.z=Z(a);c.name=$ifnull(b,$ifnull(a.getAttribute('z_groupname'),$ifnot(a.name,a.id)));var d=[];c.isValid=false;c.focusControl;ZEvent.register(c);function e(){if(c.attribute('summary_header'))k=c.attribute('summary_header');if(c.attribute('summary_footer'))l=c.attribute('summary_footer');if(c.attribute('summary_format'))m=c.attribute('summary_format');c.showSummary(c.attribute('summary_show')!=='false');$handle(c,'validationend',function(){var q=c.getStatistics();validControls=q.validControls;validatedControls=q.validatedControls;if(f.validControls!=q.validControls||f.validatedControls!=q.validatedControls){c.events.fire('statschanged',{stats:q});if(q.validControls== q.validatingControls)c.z.addClass('z_group_valid');else c.z.removeClass('z_group_valid');}
f=q;});	}
var f={};c.addControl=function(p){d.push(p);}
c.removeControl=function(p){Array.remove(d,p);}
c.getControls=function(){return $clone(d);}
c.setFocusControl=function(p){c.focusControl=p;c.events.fire('focuschange',{focusControl:p});}
c.attribute=function(p,q){return c.z.attribute('z_'+p,q);}
c.updateSummary=function(){if(!c.showSummary())return;var p=c.getSummaryElement();if(!p)return;if(c.isValid){$hide(p);return;}
var q='<ul>';for(var r=0;r<d.length;r++){var s=d[r];var t=s.noMatchCondition;var u=t?$ifnull(t.summary,$ifnull(s.attribute('summary'),t.text)):'';if(s.isValid||!u)continue;q+='<li>{0}</li>'.format(u);}
q+='</ul>';var v=c.getSummaryFormat();var w=v.namedFormat({icon:ZConfig.getImagePath('validation_error_16.gif'),header:c.getSummaryHeader(),list:q,footer:c.getSummaryFooter()});Z(p).html(w);$show(p);h();if(c.attribute('summary_scroll')!='false'){var x=Z(p).position();var y=ZUtil.scrollPosition();var z=ZUtil.scrollDimension();if(y.y>x.y||(y.y+z.h)<x.y)window.scrollTo(0,x.y);}}
function h(){if(ZControlgroup.summaryCssAdded)return;ZControlgroup.summaryCssAdded=true;ZUtil.addCss(c.getSummaryCss(),true);}
var i=null;var j=false;var k=null;var l=null;var m=null;var n=null;c.getSummaryFormat=function(){if(m===null)m=ZConfig.getSummaryFormat();return m;}
c.setSummaryFormat=function(p){m=p;}
c.getSummaryCss=function(){if(n===null)n=ZConfig.getSummaryCss();return n;}
c.setSummaryCss=function(p){n=p;}
c.getSummaryHeader=function(){if(k===null)k=ZConfig.getSummaryHeader();return k;}
c.setSummaryHeader=function(p){k=p;}
c.getSummaryFooter=function(){if(l===null)l=ZConfig.getSummaryFooter();return l;}
c.setSummaryFooter=function(p){l=p;}
c.getSummaryElement=function(){if(i&&j)return i;if(c.attribute('z_summary')==='false')return null;i=document.createElement('div');i.className='z_summary';j=true;var p=c.elm.getElementsByTagName('z_summary');if(p.length){Z(p[0]).insertBefore(i);}
else{c.z.append(i,true);}	
return i;}
c.setSummaryElement=function(p){i=p;j=true;}
var o;c.showSummary=function(p){if($undef(p))return o;o=p;}
c.validate=function(p,q){var r=$clone(d);var s=-1;var t=true;c.events.fire('validationstart');function u(){s++;if(s>=r.length){v();return;}
var w=r[s];if(w.attribute('validateifhidden')!="true"&&!$shown(w.elm,true)){u();return;}
w.validate(ZControl.ValidateReason.Group,function(){if(!w.isValid)t=false;u();});}
function v(){c.isValid=t;c.updateSummary();c.events.fire('validationend');if(p &&(q ||c.isValid))p();}
u();}
c.getStatistics=function(){var p={controls:d.length,validatingControls:0,validatedControls:0,validControls:0};for(var q=0;q<d.length;q++){var r=d[q];if(r.hasValidators()){p.validatingControls++;if(r.isValid)p.validControls++;if(r.isValidated)p.validatedControls++;}}
return p;}
e();}
ZControlgroup.getDefault=function(){if(ZControlgroup._default)return ZControlgroup._default;return ZControlgroup._default=new ZControlgroup(document.body,'default');}
ZControlgroup.get=function(a,b){if(!a)return ZControlgroup.getDefault();var c=Z(a);if(c.ctrlgroup)return c.ctrlgroup;if(c.attribute('z_group')=='true'||(c.attribute('z_group')!='false'&&c.tag()=='FORM')){var d=new ZControlgroup(c.elm);c.ctrlgroup=d;return d;}
if(b)return null;alert('No control group was found at the given element. '+c.elm.id);}
$ctrl=ZControl.get;$ctrlgroup=ZControlgroup.get
ZValidator=function(a){var b=this;var c=true;b.validate=function(e){}
b.init=function(e){if(!a)return;var f=false;$foreacha(a,function(h){if($instanceof(e,h)||$implements(e,h))f=true;});if(f)return;alert('This validator isn\'t supported for this element. Check the validators of element '+e.name);}
b.isEnabled=function(e){if($undef(e))return c;c=e;}}
ZValidators={};ZValidators.RequiredText=function(a){var b=$base(this,arguments,ZValidator,[ZControls.Textbox]);b.validate=function(d){d.isValid=d.ctrl.getValue(!a).trim().length>0;}}
ZValidators.RequiredFile=function(){var a=$base(this,arguments,ZValidator,[ZControls.File]);a.validate=function(c){c.isValid=c.ctrl.getValue().trim().length>0;}}
ZValidators.RequiredFileExtension=function(){var a=$base(this,arguments,ZValidator,[ZControls.File]);a.extensions=Array.prototype.slice.call(arguments);a.validate=function(c){var d=c.ctrl.getValue().trim();c.isValid=$wherea(a.extensions,function(f){return(!f&&!d)||(!!f&&d.endsWith(f))}).length>0;}}
ZValidators.RegExp=function(a,b){var c=$base(this,arguments,ZValidator,[ZControls.Textbox]);if(typeof(a)==='string')a=new RegExp(a);c.regexp=a;c.validate=function(e){var f=e.ctrl.getValue();if(b&&(f==''||f==e.ctrl.getDefaultValue()))e.isValid=true;else e.isValid= c.regexp.test(e.ctrl.getValue());}}
ZValidators.ValidNumber=function(a){var b=$base(this,arguments,ZValidator,[ZControls.Textbox]);b.validate=function(d){var e=d.ctrl.getNumber();d.isValid=!isNaN(e);if(!a){var f=d.ctrl.getDefaultValue();		
if(isNaN(f-0)&&d.ctrl.getValue()==f)d.isValid=false;if(!d.ctrl.getValue().trim())d.isValid=false;}}}
ZValidators.MinimumNumber=function(a,b){var c=$base(this,arguments,ZValidator,[ZControls.Textbox]);c.minimum=a;c.isExclusive=b;c.validate=function(e){var f=e.ctrl.getNumber();e.isValid=!isNaN(f)&&(c.isExclusive?f>c.minimum:f>=c.minimum);}}
ZValidators.MaximumNumber=function(a,b){var c=$base(this,arguments,ZValidator,[ZControls.Textbox]);c.maximum=a;c.isExclusive=b;c.validate=function(e){var f=e.ctrl.getNumber();e.isValid=!isNaN(f)&&(c.isExclusive?f<c.maximum:f<=c.maximum);}}
ZValidators.DateValidator=function(){var a=$base(this,arguments,ZValidator);a.init=function(c){$basefunc(a,'init',ZValidators.DateValidator,c);if(!$implements(c,ZControls.IDate)){alert('Can\'t use this validator. The control doesn\'t implement interface ZControls.IDate. '+c.name);}}}
ZValidators.RequiredDate=function(){var a=$base(this,arguments,ZValidators.DateValidator);a.validate=function(c){var d=c.ctrl;c.isValid=!!d.year.getValue()&&!!d.month.getValue()&&!!d.day.getValue();}}
ZValidators.ValidDate=function(a){var b=$base(this,arguments,ZValidators.DateValidator);b.validate=function(d){d.isValid=(a&&d.ctrl.isEmpty())||!!d.ctrl.getDate();}}
ZValidators.MinimumDate=function(a,b){var c=$base(this,arguments,ZValidators.DateValidator);c.minimumDate=a;c.validate=function(e){var f=e.ctrl.getDate();e.isValid=f&&!f.isBefore(c.minimumDate,true)&&(!b||!f.isSameDay(c.minimumDate));}}
ZValidators.MaximumDate=function(a,b){var c=$base(this,arguments,ZValidators.DateValidator);c.maximumDate=a;c.validate=function(e){var f=e.ctrl.getDate();e.isValid=f&&!f.isAfter(c.maximumDate,true)&&(!b||!f.isSameDay(c.maximumDate));}}
ZValidators.DayOfWeek=function(a,b,c){var d=$base(this,arguments,ZValidators.DateValidator);d.days=Array.prototype.slice.call(arguments);d.validate=function(f){var g=f.ctrl.getDate();f.isValid=g&&Array.contains(d.days,g.getDay());}}
ZValidators.RequiredRadio=function(){var a=$base(this,arguments,ZValidator,[ZControls.Radiolist]);a.validate=function(c){c.isValid=c.ctrl.getValue()!==null;}}
ZValidators.RequiredCheckbox=function(a){var b=$base(this,arguments,ZValidator,[ZControls.Checkbox]);b.validIfNotChecked=!!a;b.validate=function(d){d.isValid=d.ctrl.isChecked()!=b.validIfNotChecked;}}
ZValidators.RequiredSelect=function(){var a=$base(this,arguments,ZValidator,[ZControls.Select]);a.disallowed=Array.prototype.slice.call(arguments);a.validate=function(c){c.isValid=!!c.ctrl.getValue()&&!Array.contains(a.disallowed,c.ctrl.getValue());}}
ZValidators.Custom=function(a,b){var c=$base(this,arguments,ZValidator,b);c.validate=function(e){a(e);}}
$namespace('ZControl.TextareaUtil',function(a){function b(f){return 'selectionStart' in f;}
a.getSelection=ZUtil.getTextboxSelection;a.getSelectionPosition=function(f,g){if(b(f)){var h={};h.start=f.selectionStart;h.length=f.selectionEnd-h.start;if(g)h.startNormalized=h.start;return h;}
var i="\001";var j=document.selection.createRange();var k=j.duplicate();k.moveToElementText(f);j.text=i;var l=k.text;var m=l.indexOf(i);if(g){var n=l.replace(/\r\n/g,'\n');var o=n.indexOf(i);}
j.moveStart('character',-1);j.text="";var h={};h.start=m<0?f.value.length:m;h.length=j.text.length;if(g){h.startNormalized=o<0?f.value.replace(/\r\n/g,'\n').length:o;}
return h;}
a.startNewlineKeepSpaces=function(f,g){var h=a.getSelectionPosition(f);var i=f.value;for(var j=h.start-1;j>=0;j--){var k=i.charAt(j);if(k=='\n')break;}
var l='';for(j++;j<i.length;j++){var k=i.charAt(j);if(k!=' '&&k!='\t')break;l+=k;}
var m='\n'+l;if(g&&l){a.insertText(f,m,m.length,0);}
return l;}
a.select=function(f,g,h){if(b(f)){f.selectionStart=g;f.selectionEnd=g+h;}
else{var i=document.selection.createRange();i.moveToElementText(f);	
i.moveStart('character',g);i.collapse();i.moveEnd('character',h);i.select();}}	
a.insertText=function(f,g,h,i,j,k,l,m){var n=a.getSelection(f);f.focus();var o=a.getSelectionPosition(f,true);if(o.start!=0&&j){var p=d(f,o.start);if(p==0){g='\n\n'+g;h+=2;}
if(p==1){g='\n'+g;h++;}}
if(o.start!=0&&k){var q=e(f,o.start);if(q==0){g+='\n\n';}
if(q==1){g+='\n';}}
if(l&&n){if(m){while(n.length){var r=n.charAt(n.length-1);if(r!=' '&&r!='\t')break;n=n.slice(0,n.length-1);g+=r;}}
g=g.slice(0,h)+n+g.slice(h+i);i=n.length;}
var s=f.scrollTop;if(b(f)){var t=f.value;f.value=t.slice(0,o.start)+g+t.slice(o.start+o.length);}
else{var u=document.selection.createRange();u.text=g;}
if($notnull(h))a.select(f,o.startNormalized+h,i);if(b(f)){f.scrollTop=s;var v=g.trim()?g.trim().length:g.length;a.scrollIntoView(f,o.start+v);}}
a.scrollIntoView=function(f,g){var h=ZStyle.currentStyle(f,'lineHeight').value;if(isNaN(h))h=ZStyle.currentStyle(f,'fontSize').value+3;if(isNaN(h))h=16;var i=f.value;for(var j=1,k=0;k<g;k++){if(i.charAt(k)=='\n')j++;}
var l=(f.scrollTop+f.clientHeight)/h;if(j>l){f.scrollTop+=Math.ceil((j-l)* h);}}
a.registerTabspaces=function(f,g){if(!g){if(f.__ztabspacer)$dehandle(f,'keydown',f.__ztabspacer);f.__ztabspacer=null;return;}
if(f.__ztabspacer)return;f.__ztabspacer=function(i){if(ZUtil.key(i)==ZUtil.Keys.Tab){var j=''.pad(g,' ');ZControl.TextareaUtil.insertText(f,j,j.length,0);return ZUtil.preventDefault(i);}}
$handle(f,'keydown',f.__ztabspacer);}
a.enableAutoIndent=function(f,g){if(!g){if(f.__zautoindenter)$dehandle(f,'keydown',f.__zautoindenter);f.__zautoindenter=null;return;}
if(f.__zautoindenter)return;f.__zautoindenter=function(i){if(ZUtil.key(i)==ZUtil.Keys.Enter){var j=ZControl.TextareaUtil.startNewlineKeepSpaces(f,true);if(j)return ZUtil.preventDefault(i);}}
$handle(f,'keydown',f.__zautoindenter);}
function d(f,g){var h=f.value;var i=0;for(var j=g-1;j>=0&&h.charAt(j)=='\n';j--){i++;if(h.charAt(j-1)=='\r')j--;}
return i;}
function e(f,g){var h=f.value;var i=0;for(var j=g+1;j<h.length&&h.charAt(j)=='\n';j++){i++;if(h.charAt(j+1)=='\r')j++;}
return i;}});ZUtil.addCss('.z_text_default { color:#888; } ',true);ZCalendar=function(a){var b=this;var c;var d=Z(a);var e=new Date(2099,1,1),f=new Date(2099,1,1);var g=[];var h=-1;var i=false;var j=false;ZEvent.register(this,['select','browse']);b.firstDay=ZConfig.culture.firstDay;b.getDate=function(){return e;}
b.setDate=function(t){r(t);}
b.getShowDate=function(){return e;}
b.setShowDate=function(t){q(t);}
b.dispose=function(){}
function l(){s();c=ZTemplate.apply('ZCalendar',d);g=[];for(var t=0;t<42;t++)g.push(t);$foreacha(g,function(v){var w=c['_day'+v];function x(){  
var z=n.clone();z.addDays(v);return z;}
w.onMousedown(function(){b.setDate(x());});w.onMouseup(function(){j=true;b.events.fire('select',{date:e});});});c._arrowLeft.onMousedown(function(v){var w=f.clone();w.addMonths(v.ctrlKey?v.shiftKey?-120:-12:-1);r(w);});c._arrowLeft.onClick(function(){b.events.fire('browse',{date:e});});c._arrowRight.onMousedown(function(v){var w=f.clone();w.addMonths(v.ctrlKey?v.shiftKey?120:12:1);r(w);b.events.fire('browse',{date:e});});c._arrowRight.onClick(function(){b.events.fire('browse',{date:e});});c._today.onMousedown(function(){b.setDate(new Date());});c._today.onMouseup(function(v){j=true;b.events.fire('browse',{date:e});});c._today.onClick(function(){});r(new Date());}
function m(t){if(h>=0){c['_day'+h].removeClass('z_select');}
if(t>=0){var u=c['_day'+t];u.addClass('z_select');}
h=t;}
var n;function o(t){var u=n.clone();u.addDays(t);return u;}
function p(t){var u=n.clone();for(var v=0;v<42;v++){if(u.isSameDay(t))return v;u.addDays(1);}
return-1;}
function q(t){if(t.getMonth()!=f.getMonth()||t.getFullYear()!=f.getFullYear()){       
var u=t.clone();u.addDays(-u.getDate());var v=u.getDay();u.addDays((!v?-7:-v)+b.firstDay);n=u.clone();$foreacha(g,function(x){var y=c['_day'+x];y.text(u.getDate());y[u.getMonth()!=t.getMonth()?'addClass':'removeClass']('passive');u.addDays(1);});c._dateText.text(ZConfig.culture.lang.monthsShort[t.getMonth()]+' '+t.getFullYear());f=t;}       }
function r(t){e=t;q(e);m(p(e));}
function s(){if(ZCalendar.htmlAdded)return;ZCalendar.htmlAdded=true;var t='';for(var u=0;u<6;u++){t+='<div class="rows">';for(var v=0;v<7;v++)t+='<div _id="day{0}"></div>'.format(u*7+v);t+='</div>'}
var w=ZConfig.culture.lang;var x=w.days;var y=b.firstDay;var z=ZCalendar.htmlFormat.format(ZConfig.getImagePath('arrow_left_small.gif'),ZConfig.getImagePath('arrow_right_small.gif'),t,x[y%7].slice(0,1),x[++y%7].slice(0,1),x[++y%7].slice(0,1),x[++y%7].slice(0,1),x[++y%7].slice(0,1),x[++y%7].slice(0,1),x[++y%7].slice(0,1),w.today.capitalize(),w.holdCtrToMoveDownAYearholdShiftToMoveDown10Years,w.holdCtrToMoveUpAYearholdShiftToMoveUp10Years);Z(document.body).append(Z.create('div').html(z),true);ZUtil.addCss(ZCalendar.css,true);}
l();}
ZCalendar.htmlAdded=false;ZCalendar.htmlFormat='<div id="ZCalendar" class="z_hidden" style="float:left">'+'<div _id="body" class="body"  style="position:relative">'+'<div _id="date" class="z_windowbar date">'+'<a href="" title="{11}" style="cursor:default;position:absolute;left:0px;" _id="arrowLeft"><img style="border:0;vertical-align:bottom"  src="{0}" /></a>'+' <a href=""title="{12}"  style="cursor:default;position:absolute;right:0px;" _id="arrowRight"><img style="border:0;vertical-align:bottom" src="{1}" /></a>'+'<span _id="dateText"></span>'+'</div>' +'<div _id="days" class="rows days">' +'<div>{3}</div>' +'<div>{4}</div>'+'<div>{5}</div>'+'<div>{6}</div>'+'<div>{7}</div>'+'<div>{8}</div>'+'<div>{9}</div>'+'</div>'+'<div class="dayDivider"></div>'+'{2}'+'<div style="clear:left;"></div>'+'<a _id="today" href="">{10}</a>'+'</div>'+'<div style="clear:left;"></div>'+'</div>';ZCalendar.css='.ZCalendar .rows div'+'{'+'width:17px;'+'float:left;'+'text-align:right;'+'cursor:default;'+'padding-right:4px;'+'}'+'.ZCalendar { font-size:8pt; line-height: 10pt; }'+'.ZCalendar .body'+'{'+'float:left;'+'background:white;'+'border:1px solid #999;'+'}'+'.ZCalendar .dayDivider'+'{'+'clear:left;'+'border-bottom:1px solid #999;'+'}'+'.ZCalendar .rows'+'{'+'clear:left;'+'}'+'.ZCalendar .passive'+'{'+'color:#999;'+'}'+'.ZCalendar .date'+'{'+'text-align:center;'+'padding-bottom:2px;'+'}'+'.ZCalendar .today'+'{'+'	border-top:1px solid #999;'+'	text-align:center;'+'	padding-bottom:2px;'+' display:block;'+'}';$namespace('ZComponent',function(a){a.Dialog=function(c,d){var e=$base(this,arguments,ZComponent.Component);var f;var g;if(!d)d={};e.isModal=!!d.isModal;e.referrer=d.referrer;e.window=null;e.windowBody;ZEvent.register(e,['show','dispose','beforeDispose']);function h(){if(typeof c==='string'){e.windowBody=ZTemplate.apply(c);}
else{e.windowBody=c.apply();}
f=Z.create('div');if(d.title){var m=ZTemplate.create('<div class="z_window"><div class="z_windowbar" style="position:relative"><img src="{0}" _id="z_closebutton" style="position:absolute;right:0px;;vertical-align:top" />$title$</div><div _id="z_windowbody"></div></div>'.format(ZConfig.getImagePath('close.gif')),'ZComponent_Dialog_Window');var n=ZTemplate.apply('ZComponent_Dialog_Window',f);n._title.text(d.title);n._z_windowbody.append(e.windowBody);n._z_closebutton.display(!!(d.defaultClose||d.closeHandler));n._z_closebutton.onClick(d.closeHandler||e.dispose);}
else{f.append(e.windowBody);}
e.window=e.body=f;if(e.isModal){g=Z.create('div').styles({zIndex:a.Dialog.count++,width:'100%',height:'100%',background:d.backgroundColor||'#eee',position:'absolute',top:'0px',left:'0px',opacity:'0'});}
if(!e.referrer)e.referrer=Z(document.body);else e.referrer=Z(e.referrer);	
if(d.host)e.setHost(d.host);}
e.show=function(){var m=document.body;if(g){var n=ZUtil.bodyDimension(true);g.styles({width:n.w+'px',height:n.h+'px'});Z(m).append(g);}
var o=d.align||(e.isModal?'center':'left');if(!d.inplace){f.styles({position:'absolute',zIndex:a.Dialog.count++});Z(m).append(f,true);}
else{e.referrer.append(f);}
if(d.width)f.styles({width:d.width+'px'});if(!d.inplace){var p=f.dimension(),q=f.position();var r=e.referrer==Z(document.body);var s=ZUtil.scrollDimension(),t=ZUtil.scrollPosition();var u=r?s:e.referrer.dimension();var v=r?t:e.referrer.position();var w=v.x,x=v.y;if(o!='left'){var y=o=='right'?1:2;w+=Math.round((u.w/y)-(p.w/y));x+=Math.round((u.h/y)-(p.h/y));}
w+=d.offsetX||0;x+=d.offsetY||0;if(w<0)w=0;if(w+p.w>s.w)w=s.w-p.w;if(x<0)x=0;if(x+p.h>(s.h+t.y))x=(s.h+t.y)-p.h;f.styles({top:x+'px',left:w+'px'});}
$handle(d.inplace?e.referrer:document,'keydown',j);if(d.closeOnClick)$handle(document,'mousedown',k);if(e.isModal){var z=d.backgroundOpacity||'0.8';g.tween({opacity:'0-'+z},100).timeline.onFinish(ab);}
else if(d.inplace){f.wipe(false,100,{opacity:'0-1'}).timeline.onFinish(ab);}
else ab();function ab(){if(e.isModal){f.show();e.events.fire('show');}
else{f.tween({opacity:'0-1'},100).timeline.onFinish(function(){e.events.fire('show');});}}}
function j(m){if(ZUtil.key(m)==ZUtil.Keys.Esc){m.cancelBubble=true;e.dispose();}}
function k(m){if(!f.containsEvent(m))e.dispose();}
var l=false;e.dispose=function(){if(l)return;var m={cancelDispose:false};e.events.fire('beforeDispose',m);if(m.cancelDispose)return;l=true;$dehandle(document,'keydown',j);$dehandle(document,'mousedown',k);if(e.isModal)g.tween({opacity:'0'},100).timeline.onFinish(function(){g.remove();});if(d.inplace){f.wipe(true,100,{opacity:'0'}).timeline.onFinish(function(){e.events.fire('dispose');f.remove();});}
else{f.tween({opacity:'0'},100).timeline.onFinish(function(){e.events.fire('dispose');f.remove();});}}
h();}
a.Dialog.Align={center:'center',left:'left',right:'right'};a.Dialog.count=9999;a.tooltipDialog=null;a.Dialog.registerTooltip=function(c,d,e,f){c=Z(c);if(!f)f={};if($undef(f.timeout))f.timeout=250;c.onMouseout(function(h){clearTimeout(c.props.dialogTimer);c.props.dialogTimer=null;});c.onMouseover(function(h){if(c.props.dialogTimer)return;var i=h.clientX,j=h.clientY;c.onMousemove(k);function k(m){i=m.clientX,j=m.clientY;}
c.props.dialogTimer=setTimeout(function(){c.dehandle('mousemove',k);if(a.tooltipDialog)a.tooltipDialog.dispose();if(ZUtil.isIE7()||ZUtil.isIE6()){j-=ZStyle.currentStyle(document.body,'marginTop').value;i-=ZStyle.currentStyle(document.body,'marginLeft').value;}
var m=a.tooltipDialog=new a.Dialog(d,{offsetX:i,offsetY:j+15});m.window.addClass('z_tooltip');if(e)e(m);m.onDispose(function(){c.props.dialogTimer=null;$dehandle(document,'mousemove',o);});m.show();	
$handle(document,'mousemove',o);function o(p){if(!c.containsEvent(p))m.dispose();}},f.timeout);});}
a.Dialog.registerTooltipHtml=function(c,d,e,f){var g=ZTemplate.create('$content$','ZComponent_Dialog_TooltipHtml');a.Dialog.registerTooltip(c,g,function(i){i.windowBody._content.html(d);if(e)e(i);},f);}
ZUtil.addCss('.z_tooltip { padding-left:2px;padding-right:2px;background:#FFFFE1;color:black;border:1px solid black; } .z_select { background:#000080; color:white; } .z_window { background:white; border:1px solid #999; } .z_windowbody { padding:4px; } .z_closebutton { cursor:pointer;padding-left:5px; color:white; text-decoration:underline; font-size:8pt; } .z_windowbar { padding-left:2px;padding-right:2px;background:#000080; font-weight:bold; color:white; }',true);});$namespace('ZComponent',function(a){a.IDispose=function(){this.dispose=function(){};this.onDispose=function(d){};}
a.Component=function(c){var d=this;$interface(arguments,a.IDispose);d.body;ZEvent.register(d,['dispose']);function e(){if(c)d.setHost(c);}
d.getBody=function(){return d.body;}
d.setBody=function(h){d.body=h;}
d.getHost=function(){return c;}
d.setHost=function(h){if(c)$dehandle(c,'dispose',d.dispose);c=h;$handle(c,'dispose',g);}
function g(){d.dispose();}
d.dispose=function(){if(c)$dehandle(c,'dispose',g);d.events.fire('dispose');d.getBody().remove();}
e();}
a.Template=function(c,d,e){var f=$base(this,arguments,a.Component,c);function g(){f.body=ZTemplate.apply(d,e);}
g();}});Z.prototype.drag=function(a,b,c,d,e,f){new ZDrag(a,this,null,true,new ZDrag.ControllerBase(),b,true,c,d,e,f);}
Z.prototype.dragDrop=function(a,b){if($null(b))b=new IZDataHost.Z(this);else if(typeof b==='string')b=new IZDataHost.Text(b);var c=$implements(b,IZDataHost)?b:new IZDataHost.Basic(b);new ZDrag(a,this,c,false,new ZDrag.ShadowCopyController(),null,true);}
ZDrag=function(a,b,c,d,e,f,g,h,i,j,k){var l=this;l.draggedObject=b;l.draggedObjectSource=b;ZDrag.currentDrag=l;if(!e)e=new ZDrag.ControllerBase();e=$ifnull(e.init(l),e);function m(jb){if(jb&&jb.preventDefault){jb.preventDefault();}return false;}
e.startDrag();var n=l.draggedObject.elm.style;var o=l.draggedObject.elm;var p;var q=0;var r,s,t;l.option=ZDrag.TargetOptions.None;l.currentTargetHelper=null;if(n.position!=='absolute'){o.left=o.offsetLeft+'px';o.top=o.offsetTop+'px';}
n.position='absolute';n.cursor='default';if(!ZDrag.addedCss){ZUtil.addCss('.zdrag_noselect { -moz-user-select: none; -khtml-user-select: none; user-select: none; }');ZDrag.addedCss=true;}
b.addClass('zdrag_noselect');$handle(document,'selectstart',m);$handle(document,'mouseup',w);	
$handle(document,'mousemove',z);$handle(document,['keydown','keyup','keypress'],v);p={x:0,y:0};if(g){var u=ZUtil.position(o);p={x:a.clientX-u.x,y:a.clientY-u.y};}
fb(a);function v(jb){if(jb.type=='keypress'){if(jb.preventDefault)jb.preventDefault();return false;}
if(jb.type=='keydown'){if(ZUtil.key(jb)==ZUtil.Keys.Esc)w(jb);}
if(jb.ctrlKey!=r){r=jb.ctrlKey;fb(jb);}
if(jb.altKey!=t){t=jb.altKey;fb(jb);}
if(jb.shiftKey!=s){s=jb.shiftKey;fb(jb);}}
function w(jb){bb(jb);e.endDrag(jb);$dehandle(document,['keydown','keyup','keypress'],v);$dehandle(document,'mousemove',z);$dehandle(document,'mouseup',w);	
$dehandle(document,'selectstart',m);if(d)return;if(l.currentTargetHelper&&jb.type!=='keydown'){var kb=hb(jb,'dragdrop',l.currentTargetHelper);kb.option=l.option;l.currentTargetHelper.handler(kb);}
ZDrag.currentDrag=null;}
var x=null;var y=null;function z(jb){x={clientX:jb.clientX,clientY:jb.clientY,ctrlKey:jb.ctrlKey,altKey:jb.altKey,shiftKey:jb.shiftKey};if(y)return;y=setInterval(ab,ZDrag.dragUpdateInterval);ab();}
function ab(){if(x){bb(x);x=null;}
else {clearInterval(y);y=null;}	}
function bb(jb){ib(jb);cb(jb);if(!d)db(jb);}
function cb(jb){if(!f)return;jb.dragRatioX=null;jb.dragRatioY=null;if($notnull(h)&&$notnull(j)&&h!=j){jb.dragRatio=jb.dragRatioX=(o.offsetLeft-h)/(j-h);}
if($notnull(i)&&$notnull(k)&&i!=k){jb.dragRadio=jb.dragRadioY=(o.offsetTop-i)/(k-i);}
if($notnull(jb.dragRadioX)&&$notnull(jb.dragRadioY)){jb.dragRadio=(jb.dragRadioY+jb.dragRadio.X)/2;}
f(jb);}
function db(jb){var kb=null;var lb=l.currentTargetHelper;var mb={x:jb.clientX,y:jb.clientY};var nb=null;for(var ob in ZDrag.targetHelpers){var pb=ZDrag.targetHelpers[ob];if(!pb.noBoundaries){if(!gb(pb.target,mb))continue;}
var qb=hb(jb,'dragmove',pb);pb.handler(qb);if(qb.options!=ZDrag.TargetOptions.None||$null(qb.options)){if(!nb||eb(nb)>=eb(pb)){nb=pb;nb.options=qb.options;}}}
if(nb){if(!lb||lb!==nb){if(lb&&lb!=nb){lb.handler(hb(jb,'dragout',lb));}
l.currentTargetHelper=nb;var rb=hb(jb,'dragover',nb);rb.options=nb.options;nb.handler(rb);q=rb.options;fb(jb);}}
else{q=0;if(lb)lb.handler(hb(jb,'dragout',lb));var sb=!!l.currentTargetHelper;l.currentTargetHelper=null;if(sb)fb(jb);}}
function eb(jb){var kb=jb.target.style.zIndex;if(kb)return kb-0;return 0;}
function fb(jb){if(d)return;l.option=ZDrag.TargetOptions.None;var kb=q&ZDrag.TargetOptions.Copy;var lb=q&ZDrag.TargetOptions.Move;var mb=q&ZDrag.TargetOptions.Link;if(l.currentTargetHelper){if(kb&&jb.ctrlKey){l.option=ZDrag.TargetOptions.Copy;}
else if(mb&&jb.shiftKey){l.option=ZDrag.TargetOptions.Link;}
else if(!lb&&kb){l.option=ZDrag.TargetOptions.Copy;}
else if(!lb&&mb){l.option=ZDrag.TargetOptions.Link;}
else if(lb){l.option=ZDrag.TargetOptions.Move;}}
l.draggedObject.style('cursor',l.option==ZDrag.TargetOptions.Copy?'url('+ZConfig.getImagePath('cursor_copy.cur')+'),copy':l.option==ZDrag.TargetOptions.Link?'url('+ZConfig.getImagePath('cursor_alias.cur')+'),alias':l.option==ZDrag.TargetOptions.Move?'default':'no-drop');}
function gb(jb,kb){return ZUtil.containsPosition(jb.elm,kb);};function hb(jb,kb,lb){var mb=ZUtil.position(lb.target);return{type:kb,options:null,target:lb.target,subtarget:lb.subtarget,dataHost:c,draggedObject:l.draggedObjectSource,clientX:jb.clientX,clientY:jb.clientY,objectX:jb.clientX-p.x,objectY:jb.clientY-p.y,targetX:mb.x,targetY:mb.y,relativeX:jb.clientX-mb.x,relativeY:jb.clientY-mb.y,ctrlKey:jb.ctrlKey,altKey:jb.altKey,shiftKey:jb.shiftKey};}
function ib(jb){var kb=ZUtil.position(o.offsetParent);var lb=jb.clientX-kb.x-p.x;if($notnull(h))lb=Math.max(lb,h);if($notnull(j))lb=Math.min(lb,j);var mb=jb.clientY-kb.y-p.y;if($notnull(i))mb=Math.max(mb,i);if($notnull(k))mb=Math.min(mb,k);var nb=ZUtil.position('aap');n.left=lb+'px';n.top=mb+'px';}};ZDrag.TargetOptions={None:0,Copy:2,Move:4,Link:8,Scroll:16,All:2|4|16};ZDrag.targetHelpers={};ZDrag.dragUpdateInterval=20;ZDrag._targetID=0;Z.prototype.enableDragTarget=function(a,b){this.disableDragTarget();if(!a)a=function(){};var d={target:this,handler:a,noBoundaries:!!b,id:ZDrag._targetID++};this.property('zdrag_target',d);ZDrag.targetHelpers[d.id]=d;}
Z.prototype.disableDragTarget=function(){var a=this.property('zdrag_target');if(a)delete ZDrag.targetHelpers[a.id];}
function IZDataHost(){this.getData=function(b){return null;}
this.setData=function(b){return null;}
this.supportsType=function(b){return false;}}
IZDataHost.Formats={Html:'html',Text:String,Z:Z,Element:'element'};IZDataHost.Basic=function(a){$interface(arguments,IZDataHost);this.value=a;this.getData=function(c){if($notnull(c)&&!this.supportsType(c))return null;return a;}
this.setData=function(c){this.value=c;}
this.supportsType=function(c){if(c!=='function')return false;return $instanceof(a,c);}}
IZDataHost.Z=function(a){$interface(arguments,IZDataHost);this.value=a;this.getData=function(c){if(c===Z)return this.value;if(c==='element')return this.value.elm;if(c===String)return this.value.text();if(c==='html')return this.value.html();return null;}
this.setData=function(c){this.value=c;}
this.supportsType=function(c){return c===Z||c===String||c=='html'||c=='element';}}
IZDataHost.Text=function(a){$interface(arguments,IZDataHost);this.value=a;this.getData=function(c){if(c===Z||c==='element'){var d=document.createElement('div');d.innerHTML=this.value.htmlEncode();return c===Z?Z(d):d;}
if(c===String)return a;if(c==='html')return this.value.htmlEncode();return null;}
this.setData=function(c){this.value=c;}
this.supportsType=function(c){return c===Z||c===String||c=='html'||c=='element';}}
IZDataHost.Html=function(a){$base(this,arguments,IZDataHost.Text,a);this.getData=function(c){if(c===Z||c==='element'||c===String){var d=document.createElement('div');d.innerHTML=this.value;return c===Z?Z(d):c===String?Z(d).text():d;}
if(c==='html')return this.value;return null;}}
ZDrag.ControllerBase=function(){this.init=function(b){this.zDrag=b;}
this.startDrag=function(){}
this.endDrag=function(){}}
ZDrag.ShadowCopyController=function(){$base(this,arguments,ZDrag.ControllerBase);this.startDrag=function(){var b=this.zDrag.draggedObject;var c=b.clone();c.style('opacity',.5);c.style('position','absolute');var d=ZUtil.position(b,true);c.style('left',d.x+'px');c.style('top',d.y+'px');b.insertAfter(c);this.zDrag.draggedObject=c;}
this.endDrag=function(){this.zDrag.draggedObject.remove();}};
