
Object.extend=function(destination,source){if(destination&&source&&typeof source=='object'){for(var property in source){destination[property]=source[property];}}
return destination;};window.Class={create:function(){var parent=null,properties=Object.toArray(arguments);if(GUI.isFunction(properties[0])){parent=properties.shift();}
function klass(){this.initialize.apply(this,arguments);}
Object.extend(klass,Class.Methods);if(parent){klass.superclass=parent.prototype;var subclass=function(){};subclass.prototype=parent.prototype;klass.prototype=new subclass;}else{klass.superclass=null;}
for(var i=0;i<properties.length;i++){klass.addMethods(properties[i]);}
if(!klass.prototype.initialize){klass.prototype.initialize=GUI.emptyFunction;}
klass.prototype.constructor=klass;return klass;},Methods:{addMethods:function(source){var ancestor=this.superclass&&this.superclass.prototype;var properties=Object.keys(source);for(var i=0,length=properties.length;i<length;i++){var property=properties[i],value=source[property];this.prototype[property]=value;}
return this;}}};Object.extend(Object,{extendIf:function(destination,source){if(destination&&source&&typeof source=='object'){for(var property in source){if(typeof destination[property]=='undefined'){destination[property]=source[property];}}}
return destination;},clone:function(object){return Object.extend({},object);},toJson:function(object){},toArray:function(object){var length=object.length||0,results=new Array(length);while(length--){results[length]=object[length];}
return results;},keys:function(object){var keys=[];for(var property in object){keys.push(property);}
return keys;},values:function(object){var values=[];for(var property in object){values.push(object[property]);}
return values;}});(function(){function _toQueryString(uri,object,prepend){switch(typeof object){case'number':case'string':case'boolean':if(prepend===''){throw new Error("At first object must be passed!");}
uri.push(prepend+'='+encodeURIComponent(object));break;case'object':if(object!==null&&object.constructor===Array){if(prepend===''){throw new Error("At first object must be passed!");}
for(var i=0,len=object.length;i<len;i++){_toQueryString(uri,object[i],prepend+'['+i+']');}}else{for(var key in object){var value=object[key];if(typeof value==='function')continue;_toQueryString(uri,value,prepend===''?key:(prepend+'['+key+']'));}}
break;}}
Object.extend(Object,{toQueryString:function(object){var uri=[];_toQueryString(uri,object,'');return uri.join('&');},fromQueryString:function(str){var i,pair,res={},pairs=str.split('&'),len=pairs.length;for(i=0;i<len;i++){pair=pairs[i].split('=');res[decodeURIComponent(pair[0])]=pair[1];}
return res;}});}());Object.extend(Function.prototype,{bind:function(object){var notPartial=arguments.length<2,__method=this;if(notPartial){if(typeof object!='undefined'){return function(){return arguments.length!==0?__method.apply(object,arguments):__method.call(object);};}else{return this;}}else{var ap=Array.prototype,args=ap.slice.call(arguments,1);concat=ap.concat;return function(){return __method.apply(object,(arguments.length===0)?args:concat.apply(args,arguments));}}},bindAsEventListener:function(){return this.bind.apply(this,arguments);},defer:function(){var __method=this,args=Object.toArray(arguments),timeout=args.shift(),object=args.shift();return window.setTimeout(function(){return __method.apply(object,args);},timeout);},methodize:function(){if(this._methodized){return this._methodized;}
var __method=this,concat=Array.prototype.concat;this._methodized=function(){return __method.apply(null,concat.apply([this],arguments));}
return this._methodized;}});Object.extend(Date.prototype,{toJson:function(){return'"'+this.getUTCFullYear()+'-'+
(this.getUTCMonth()+1).toPaddedString(2)+'-'+
this.getUTCDate().toPaddedString(2)+'T'+
this.getUTCHours().toPaddedString(2)+':'+
this.getUTCMinutes().toPaddedString(2)+':'+
this.getUTCSeconds().toPaddedString(2)+'Z"';},formatDate:function(format){var o='';for(var i=0,len=format.length;i<len;i++){var ch=format.charAt(i);var re='';switch(ch){case'd':re=this.getDate();re=(re<10)?'0'+re.toString():re.toString();break;case'm':re=this.getMonth()+1;re=(re<10)?'0'+re.toString():re.toString();break;case'Y':re=this.getFullYear();break;default:re=ch;break;}
o+=re;}
return o;}});Object.extend(String.prototype,{times:function(number){return(number<1)?'':(new Array(number+1)).join(this);},camelize:function(){var parts=this.split('-'),len=parts.length;if(len==1)return parts[0];var camelized=this.charAt(0)=='-'?parts[0].charAt(0).toUpperCase()+parts[0].substring(1):parts[0];for(var i=1;i<len;i++){camelized+=parts[i].charAt(0).toUpperCase()+parts[i].substring(1);}
return camelized;},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase();},include:function(subString){return this.indexOf(subString)>-1;},isEmpty:function(){return this=='';},startsWith:function(pattern){return this.indexOf(pattern)===0;},endsWith:function(pattern){var d=this.length-pattern.length;return d>=0&&this.lastIndexOf(pattern)===d;},evalJSON:function(sanitize){if(window.JSON&&JSON.Parse){try{return JSON.parse(this);}catch(e){return null;}}
try{return eval('('+this+')');}catch(e){return null;}},htmlentities:function(){var div=document.createElement('div'),text=document.createTextNode(this);div.appendChild(text);var res=div.innerHTML;div=null;return res;}});(function(){var _trimRe=/^\s+|\s+$/g,_formatRe=/\{(\d+)\}/g;Object.extend(String.prototype,{trim:function(){return this.replace(_trimRe,"");},format:function(){var args=arguments;return this.replace(_formatRe,function(m,i){return args[i];});},formatArr:function(args){return this.replace(/\{(\d+)\}/g,function(m,i){return args[i];});},escapeRe:function(){return this.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1");}});}());Object.extend(Number.prototype,{toPaddedString:function(length,radix){var string=Math.abs(this).toString(radix||10);string='0'.times(length-string.length)+string;return(this<0)?('-'+string):string;},constrain:function(min,max){if(min===undefined)min=null;if(typeof max=='number'){return Math.min(Math.max(this,min),max);}else{return Math.max(this,min);}}});Object.extend(Array.prototype,{fill:function(value){var len=this.length;while(len--){this[len]=value;}
return this;},indexOf:function(object){var len=this.length;while(len--){if(this[len]===object){return len;}}
return-1;},remove:function(o){var index=this.indexOf(o);if(index!=-1){this.splice(index,1);return true;}
return false;},clone:function(){return[].concat(this);},include:function(o){var len=this.length;while(len--){if(this[len]===o){return true;}}
return false;},each:function(fn){var len=this.length;while(len--){if(fn(this[len])===false){break;}}
return this;},compact:function(){var i,len=this.length,out=[],item,outlen=0;for(i=0;i<len;i++){item=this[i];if(!out.include(item)){out[outlen++]=item;}}
return out;}});

if(!window.GUI){window.GUI={};}
(function(){var
currentId=0,preloadedImages={},undoCache={},_rgbRe=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i,_hexRe=/^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,_alphaRe=/alpha\([^\)]*\)/gi,ua=navigator.userAgent.toLowerCase(),isOpera=!!window.opera,isIE=!!(window.attachEvent&&!window.opera),isIE6,isIE7,isIE8;if(isIE){if(ua.indexOf("msie 8")>-1){isIE8=true;}else if(ua.indexOf("msie 7")>-1){isIE7=true;}else if(ua.indexOf("msie 6")>-1){isIE6=true;}}
var
isChrome=(/chrome/).test(ua),isSafari=!isChrome&&(/webkit|khtml/).test(ua),isSafari3=isSafari&&ua.indexOf('webkit/5')>-1,isGecko=!isChrome&&!isSafari&&ua.indexOf('gecko')>-1,isGecko3=isGecko&&ua.indexOf('rv:1.9')>-1,isMobileSafari=!!ua.match(/apple.*mobile.*safari/),isStrict=document.compatMode=="CSS1Compat",isBorderBox=isIE&&!isStrict,ElementExtensions=!!window.HTMLElement,libPath=(window.libPath)?window.libPath:'',debug=!!window.debug;if(!window.JSGUI_THEME){window.JSGUI_THEME='default';}
if(!window.JSGUI_IMAGES_PATH){window.JSGUI_IMAGES_PATH=libPath+'img/'+window.JSGUI_THEME+'/';}
if(window.autoDestroy===undefined){window.autoDestroy=true;}
function getDim(str){str=String(str);if(str==''){return 0;}else{var res=parseInt(str,10);if(isNaN(res)){alert(typeof str+','+str+arguments.callee.caller.toString());}
return res;}}
var blockSelectionHandler=function(e){GUI.preventDefault(e);GUI.stopEvent(e);};Object.extend(GUI,{emptyImageUrl:window.JSGUI_IMAGES_PATH+'s.gif',emptyFunction:function(){},preloadedImages:preloadedImages,debug:debug,Constants:{libPath:libPath},isOpera:isOpera,isIE:isIE,isIE6:isIE6,isIE7:isIE7,isIE8:isIE8,isChrome:isChrome,isSafari:isSafari,isSafari3:isSafari3,isWebkit:isSafari,isGecko:isGecko,isGecko3:isGecko3,isMobileSafari:isMobileSafari,isStrict:isStrict,isBorderBox:isBorderBox,ElementExtensions:ElementExtensions,SpecificElementExtensions:document.createElement('div')['__proto__']&&document.createElement('div')['__proto__']!==document.createElement('form')['__proto__'],getBody:function(){return GUI.Dom.extend(document.body||document.documentElement);},getUniqId:function(prefix){currentId++;if(!GUI.isSet(prefix)){prefix='';}
return prefix+currentId;},onDOMReady:function(handler){document.on('dom:loaded',handler);},preloadImage:function(){return;var len=arguments.length;if(len==1){var src=arguments[0],img;if(!GUI.isString(src)){throw new Error('GUI.preloadImage(), src is undefined:',src);}
if(!preloadedImages[src]){preloadedImages[src]={start:new Date(),state:'loading',end:null,time:null};var item=preloadedImages[src];img=new Image();img.onload=function(){item.end=new Date();item.time=(item.end-item.start)/1000;item.state='ok';img.onload=null;img.onerror=null;}
img.onerror=function(){item.end=new Date();item.time=(item.end-item.start)/1000;item.state='error';img.onload=null;img.onerror=null;}
img.src=src;}}else{for(var i=0;i<len;i++){GUI.preloadImage(arguments[i]);}}},preloadCssImages:function(){var sheets=document.styleSheets,i,shLen=sheets.length,cssPile=new GUI.StringBuffer();for(i=0;i<shLen;i++){var csshref=(sheets[i].href)?sheets[i].href:window.location.href,baseURLarr=csshref.split('/');baseURLarr.pop();var baseURL=baseURLarr.join('/');if(baseURL!=""){baseURL+='/';}
cssPile.clear();if(sheets[i].cssRules){var thisSheetRules=sheets[i].cssRules;for(var j=0,rulesLen=thisSheetRules.length;j<rulesLen;j++){cssPile.append(thisSheetRules[j].cssText);}}else{cssPile.append(sheets[i].cssText);}
var imgUrls=cssPile.toString().match(/[^\(]+\.(gif|jpg|jpeg|png)/g);if(imgUrls!=null&&imgUrls.length>0&&imgUrls!=''){for(var j=0,len=imgUrls.length;j<len;j++){var src=imgUrls[j];src=(src[0]=='/'||src.match('http://'))?src:baseURL+src;GUI.preloadImage(src);};}}},setTheme:function(theme,cssPath){var prevTheme=window.JSGUI_THEME;if(theme==prevTheme){return;}
var sheets=document.styleSheets,i=sheets.length,themeLoaded=false;if(!cssPath){cssPath=window.libPath+'css/'+theme+'/';}
while(i--){sh=sheets[i];if(sh.disabled&&(sh.href.indexOf(cssPath)>-1)){themeLoaded=true;sh.disabled=false;}}
if(!themeLoaded){var cssFiles=window.debug?['x-loader.css','x-layout.css','x-region.css','x-hint.css','x-mask.css','x-dialog.css','x-messages.css','x-inlineedit.css','x-menu.css','x-tree.css','x-grid.css','x-toolbar.css','x-tabbar.css','x-paging.css','global.gridfilterslayout.css','x-actions.css','x-calendar.css','x-colorpanel.css','x-forms.css','x-quickbar.css','x-main-container.css','x-wizard.css','x-informer.css','x-autocompleter.css','x-progressbar.css','x-popupinformer.css','x-container.css']:['jsgui-all.css'];var cssBefore='<link href="'+libPath+cssPath,cssAfter='" rel="stylesheet" type="text/css" />';cssFiles=cssBefore+cssFiles.join(cssAfter+cssBefore)+cssAfter;var head=document.getElementsByTagName('head')[0];GUI.Dom.append(head,cssFiles);}
if(prevTheme!='default'){var sh,prevCssPath=window.libPath+'css/'+prevTheme+'/';i=sheets.length;while(i--){sh=sheets[i];if(!sh.disabled&&(sh.href.indexOf(prevCssPath)>-1)){sh.disabled=false;}}}
window.JSGUI_THEME=theme;},appendClearDiv:function(to){var div=document.createElement('div');div.className='clear';to=GUI.$(to);to.appendChild(div);},isSet:function(val){return(val!==undefined)&&(val!==null);},isUndefined:function(val){return typeof val=='undefined';},isNumber:function(val){return typeof val=='number';},isBoolean:function(val){return typeof val=='boolean';},isString:function(val){return typeof val=='string';},isFunction:function(val){return typeof val=='function';},isArray:function(o){return Object.prototype.toString.call(o)==='[object Array]';},isObject:function(object){return typeof object=='object';},isDate:function(object){return object&&object.constructor===Date;},isEmpty:function(val){return(val===undefined)||(val===null)||(val===false)||(val==0)||(val=='')||((val&&val.constructor===Array)&&(val.length==0));},toArray:Object.toArray,arrayIndexOf:function(arr,obj){var len=arr.length;while(len--){if(arr[len]==obj){return len;}}
return-1;},arrayRemove:function(arr,o){var index=GUI.arrayIndexOf(arr,o);if(index!=-1){arr.splice(index,1);}
return arr;},extractPropertyValues:function(arr,name){var res=[],i,len=arr.length;for(i=0;i<len;i++){res.push(arr[i][name]);}
return res;},destroyObject:function(obj){for(var i in obj){if(GUI.isFunction(obj[i])){obj[i]=null;}else{delete obj[i];}}},constrain:function(value,min,max){return Math.min(Math.max(value,min),max);},getDisabledImageUrl:function(url){if(GUI.isString(url)){return url.replace(/^(.*)\.(jpg|gif|png|jpeg)$/i,'$1-disabled.$2');}},getHoverImageUrl:function(url){if(GUI.isString(url)){return url.replace(/^(.*)\.(jpg|gif|png|jpeg)$/i,'$1-hover.$2');}},getToggledImageUrl:function(url){if(GUI.isString(url)){return url.replace(/^(.*)\.(jpg|gif|png|jpeg)$/i,'$1-toggled.$2');}},escapeRe:function(s){return s.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1");},escape:function(string){return string.replace(/('|\\)/g,"\\$1");},toQueryString:Object.toQueryString,measureWidth:function(elem,styles){var tmp=document.createElement('SPAN');var style=tmp.style;if(GUI.isSet(styles)){$(tmp).setStyle(styles);}
style.position='absolute';style.top='-10000px';document.body.appendChild(tmp);if(GUI.isString(elem)){tmp.innerHTML=elem;}else if(GUI.isString(elem.innerHTML)){tmp.innerHTML=elem.innerHTML;}
var width=tmp.offsetWidth;document.body.removeChild(tmp);return width;},formatString:function(){var args=Object.toArray(arguments);var str=args.shift();return str.replace(/\{(\d*?)\}/gm,function(match,name){return args[name];});},formatDate:function(date,format){return date.formatDate(format);},parseDate:function(str,format){if(GUI.isDate(str)){return str;}
if(!format||!str){return null;}
var day,month,year;var delimeter=format.match(/[dmy](\W+)[dmy]/i);delimeter=delimeter[1];var arStr=str.split(delimeter);var arFormat=format.split(delimeter);for(var i=0;i<arFormat.length;i++){switch(arFormat[i]){case'd':day=parseInt(arStr[i],10);break;case'm':month=parseInt(arStr[i],10);break;case'Y':year=parseInt(arStr[i],10);break;case'y':year=parseInt(arStr[i],10);break;}}
if(!isNaN(day)&&!isNaN(month)&&!isNaN(year)){return new Date(year,month-1,day);}
return false;},toColorPart:function(number){if(number>255){number=255;}
var digits=number.toString(16);if(number<16){return'0'+digits;}
return digits;},parseColor:function(string){var color='',match;if(match=_rgbRe.exec(string)){var part;for(var i=1;i<=3;i++){part=Math.max(0,Math.min(255,parseInt(match[i])));color+=GUI.toColorPart(part);}
return color;}
if(match=_hexRe.exec(string)){if(match[1].length==3){for(var i=0;i<3;i++){color+=match[1].charAt(i)+match[1].charAt(i);}
return color;}
return match[1];}
return false;},clean:function(node){var p;while(p=node.firstChild){node.removeChild(p);}},getFly:function(){if(!GUI._flyEl){var node=document.createElement('div');node.style.display='none';node.id='jsgui-flyel';document.body.appendChild(node);GUI._flyEl=node;}
return GUI._flyEl},getFlyOff:function(){if(!GUI._flyOffEl){GUI._flyOffEl=document.createElement('div');GUI._flyOffEl.id='jsgui-flyoffel';}
return GUI._flyOffEl;},destroyNode:function(node){if(!GUI.isIE){return GUI.remove(node);}
if(node.parentNode){node.parentNode.removeChild(node);}
var _node,_destroyNode=node;switch(node.nodeName){case'TD':case'TH':_destroyNode=_cont=document.createElement('table');_node=document.createElement('tbody');_cont=_cont.appendChild(_node);_node=document.createElement('tr');_cont=_cont.appendChild(_node);_cont.appendChild(node);break;case'TR':_destroyNode=_cont=document.createElement('table');_node=document.createElement('tbody');_cont=_cont.appendChild(_node);_cont.appendChild(node);break;case'THEAD':case'TBODY':case'TFOOT':_destroyNode=_cont=document.createElement('table');_cont.appendChild(node);break;default:break;}
_destroyNode.outerHTML='';_destroyNode=node=_node=_cont=null;},remove:function(element){element=GUI.$(element);var parent=element.parentNode;if(parent){parent.removeChild(element);}else{}},replace:function(old,replace){old.parentNode.replaceChild(replace,old);GUI.destroyNode(old);old=replace=null;},show:function(elem){elem=GUI.$(elem);elem.style.display='';},hide:function(elem){elem=GUI.$(elem);elem.style.display='none';},toggle:function(elem){var style=GUI.$(elem).style;style.display=(style.display==='none')?'':'none';},isHidden:function(elem){elem=GUI.$(elem);return(elem.style.display=='none');},repaint:function(node){GUI.Dom.addClass(node,'x-repaint');setTimeout(function(){GUI.Dom.removeClass(node,'x-repaint');},0);},unselectable_IE:function(node){node=GUI.$(node);node.unselectable="on";node.on("selectstart",blockSelectionHandler);node.addClass("x-unselectable");},unselectable_Other:function(node){node=GUI.$(node);var s=node.style;s.MozUserSelect='none';s.KhtmlUserSelect='none';},unselectable:function(node){GUI.unselectable=GUI.isIE?GUI.unselectable_IE:GUI.unselectable_Other;return GUI.unselectable(node);},createInput:function(name){var hidden;if(GUI.isString(name)&&name.length){if(GUI.isIE){hidden=document.createElement('<input name="'+name+'">');}else{hidden=document.createElement('input');hidden.name=name;}}else{hidden=document.createElement('input');}
return hidden;},renderIntoContainer:function(container,node){container.appendChild(node);},_contains_IE:function(container,containee){if(!containee||!container){return false;}
return container.contains(containee);},_contains_Gecko:function(container,containee){if(!containee||!container){return false;}
return!!(container.compareDocumentPosition(containee)&16);},_contains_Emulation:function(container,containee){if(!containee||!container){return false;}
var parent=containee,c=10;while(parent=parent.parentNode){if(parent==container){return true;}else if(!parent.tagName||(c--==0)){return false;}}
return false;},contains:function(container,containee){if(container.contains){GUI.contains=GUI._contains_IE;}else if(container.compareDocumentPosition){GUI.contains=GUI._contains_Gecko;}else{GUI.contains=GUI._contains_Emulation;}
return GUI.contains(container,containee);},findParentByTag:function(elem,tagName,to,className){to=to||document.body;tagName=tagName.toUpperCase();if(className){return GUI._findParentByTagAndClass(elem,tagName,to,className);}else{return GUI._findParentByTag(elem,tagName,to);}},_findParentByTag:function(elem,tagName,to){while(elem&&(elem!=to)){if(!elem.tagName){return false;}
if(elem.nodeName==tagName){return elem;}
elem=elem.parentNode;}
return false;},_findParentByTagAndClass:function(elem,tagName,to,className){while(elem&&(elem!=to)){if(!elem.tagName){return false;}
if(elem.nodeName==tagName){if(GUI.Dom.hasClass(elem,className)){return elem;}}
elem=elem.parentNode;}
return false;},getHorizontalBorders:function(element){element=GUI.$(element);var lBorder=(element.getStyle('border-left-style')!='none')?getDim(element.getStyle('border-left-width')):0;var rBorder=(element.getStyle('border-right-style')!='none')?getDim(element.getStyle('border-right-width')):0;return lBorder+rBorder;},getVerticalBorders:function(element){element=GUI.$(element);var tBorder=(element.getStyle('border-top-style')!='none')?getDim(element.getStyle('border-top-width')):0;var bBorder=(element.getStyle('border-bottom-style')!='none')?getDim(element.getStyle('border-bottom-width')):0;return tBorder+bBorder;},getHorizontalPadding:function(element){element=GUI.$(element);var lPadding=getDim(element.getStyle('padding-left'));var rPadding=getDim(element.getStyle('padding-right'));return lPadding+rPadding;},getVerticalPadding:function(element){element=GUI.$(element);var tPadding=getDim(element.getStyle('padding-top'));var bPadding=getDim(element.getStyle('padding-bottom'));return tPadding+bPadding;},_stripAlpha:function(filter){return filter.replace(_alphaRe,'');},setOpacity_IE:function(element,value){var currentStyle=element.currentStyle;if((currentStyle&&!currentStyle.hasLayout)||(!currentStyle&&element.style.zoom=='normal')){element.style.zoom=1;}
var filter=element.style.filter,style=element.style;if(value===''){if(filter=GUI._stripAlpha(filter)){style.filter=filter;}else{style.removeAttribute('filter');}
return element;}else if(value<0.00001){value=0;}
style.filter=GUI._stripAlpha(filter)+'alpha(opacity='+
(value*100)+')';return element;},setOpacity_Other:function(element,value){element.style.opacity=(value==='')?'':(value<0.00001)?0:value;return element;},setOpacity:function(element,value){GUI.setOpacity=GUI.isIE?GUI.setOpacity_IE:GUI.setOpacity_Other;return GUI.setOpacity(element,value);},getEventTarget:function(e){var targ=e.target||e.srcElement;return GUI.isSafari&&targ&&(3==targ.nodeType)?targ=targ.parentNode:targ;},getRelatedTarget:function(evt){if(evt.type=='mouseover'){return evt.relatedTarget||evt.fromElement;}else if(evt.type=='mouseout'){return evt.relatedTarget||evt.toElement;}else{throw new Error("getRelatedTarget can be called only for mover/mout");}},preventDefault:function(e){if(GUI.isIE){e.returnValue=false;}else{e.preventDefault();}},stopPropagation:function(e){if(GUI.isIE){e.cancelBubble=true;}else{e.stopPropagation();}},stopEvent:function(e){GUI.stopPropagation(e);GUI.preventDefault(e);},cloneEvent:function(evt){var e={};Object.extend(e,evt);return e;},isMouseEnter:function(node,evt){var relTarget=evt.relatedTarget||evt.fromElement;return!((node==relTarget)||GUI.contains(node,relTarget));},isMouseLeave:function(node,evt){var relTarget=evt.relatedTarget||evt.toElement;return!((node==relTarget)||GUI.contains(node,relTarget));},isButton:function(event,code){if(GUI.isIE){var buttonMap={0:1,1:4,2:2};GUI.isButton=function(event,code){return event.button==buttonMap[code];};}else if(GUI.isSafari){GUI.isButton=function(event,code){switch(code){case 0:return event.which==1&&!event.metaKey;case 1:return event.which==1&&event.metaKey;default:return false;}};}else{GUI.isButton=function(event,code){return event.which?(event.which===code+1):(event.button===code);};}
return GUI.isButton(event,code);},isLeftClick:function(event){return GUI.isButton(event,0)},isMiddleClick:function(event){return GUI.isButton(event,1)},isRightClick:function(event){return GUI.isButton(event,2)},isNavKeyPress:function(event){var k=event.keyCode;return(k>=33&&k<=40)||k==Event.KEY_RETURN||k==Event.KEY_TAB||k==Event.KEY_ESC;},pointerXY:function(event){return{x:event.pageX||(event.clientX+
(document.documentElement.scrollLeft||document.body.scrollLeft)),y:event.pageY||(event.clientY+
(document.documentElement.scrollTop||document.body.scrollTop))};},makeVisible:function(node){var hiddenNodes=[],p=node;while(p&&p.tagName){if(GUI.isHidden(p)){hiddenNodes.push(p);}
p=p.parentNode;}
var len=hiddenNodes.length,elem;if(len-->0){elem=hiddenNodes[len];style=elem.style;node._oldposition=style.position;node._olddisplay=style.display;node._oldleft=style.left;node._oldtop=style.top;node._olddisplay=style.display;style.position='absolute';style.display='block';style.top='-10000px';}
while(len-->0){GUI.show(hiddenNodes[len]);}
node._cacheId=GUI.getUniqId('tmp-');undoCache[node._cacheId]=hiddenNodes;},undoVisible:function(node){var hiddenNodes=undoCache[node._cacheId];var len=hiddenNodes.length,elem;if(len-->0){elem=hiddenNodes[len];style=elem.style;style.display=node._olddisplay;style.position=node._oldposition;style.left=node._oldleft;style.top=node._oldtop;node._olddisplay=undefined;node._oldposition=undefined;node._oldleft=undefined;node._oldtop=undefined;}
while(len-->0){GUI.hide(hiddenNodes[len]);}
delete undoCache[node._cacheId];node._cacheId=null;},getClientWidth:function(node){GUI.makeVisible(node);var w=node.clientWidth;GUI.undoVisible(node);return w;},getClientHeight:function(node){GUI.makeVisible(node);var h=GUI.getInnerHeight(node);GUI.undoVisible(node);return h;},getFullWidth:function(node){var w=GUI.getDimensions(node).width;return w;},getFullHeight:function(node){var h=GUI.getDimensions(node).height;return h;},runDomVisible:function(element,wasVisibleCb,wasHiddenCb){element=$(element);var display=$(element).getStyle('display');if(display!='none'&&display!=null){if(GUI.isFunction(wasVisibleCb)){return wasVisibleCb(element);}else{return;}}
wasHiddenCb=wasHiddenCb||wasVisibleCb;if(!GUI.isFunction(wasHiddenCb)){return;}
var els=element.style;var originalVisibility=els.visibility;var originalPosition=els.position;var originalDisplay=els.display;els.position='absolute';els.display='block';var res=wasHiddenCb(element);els.display=originalDisplay;els.position=originalPosition;return res;},_getDimensions:function(element){return{width:element.offsetWidth,height:element.offsetHeight};},getDimensions:function(node,forceVisible){if(!forceVisible){return{width:node.offsetWidth,height:node.offsetHeight};}
var f=GUI._getDimensions;if(forceVisible=='deep'){GUI.makeVisible(node);var res=f(node);GUI.undoVisible(node);return res;}
return GUI.runDomVisible(node,f,f);},getClientSize:function(elem){if(elem==document||elem==document.body){return{width:GUI.getViewportWidth(),height:GUI.getViewportHeight()};}
return{width:elem.clientWidth,height:elem.clientHeight};},setFullWidth:function(element,width){element=$(element);if(GUI.isString(width)&&width.endsWith('%')){element.style.width=width;return;}
var clientWidth=width;if(!GUI.isBorderBox){var padding=GUI.getHorizontalPadding(element);var borders=GUI.getHorizontalBorders(element);clientWidth-=padding+borders;if(clientWidth<0){clientWidth=0;}}
element.style.width=clientWidth.toString()+'px';},setClientHeight:function(e,v){if(GUI.isBorderBox){v+=GUI.getVerticalPadding(e)+GUI.getVerticalBorders(e);}
if(v<0){console.log('Can not set such height because of padding or borders');v=0;}
e.style.height=v+'px';},setClientWidth:function(e,v){if(GUI.isBorderBox){v+=GUI.getHorizontalPadding(e)+GUI.getHorizontalBorders(e);}
if(v<0){console.log('Can not set such width because of padding or borders');v=0;}
e.style.height=v+'px';},setFullHeight:function(element,height){element=$(element);if(GUI.isString(height)&&height.endsWith('%')){element.style.height=height;return;}
var height=parseInt(height,10);if(height<0){console.log('trying to set negative height!!',element,height);height=0;}
var clientHeight=height;if(!GUI.isBorderBox){var padding=GUI.getVerticalPadding(element);var borders=GUI.getVerticalBorders(element);clientHeight-=padding+borders;if(clientHeight<0){clientHeight=0;}}
element.style.height=clientHeight.toString()+'px';},getViewportWidth:function(){return GUI.isStrict?document.documentElement.clientWidth:document.body.clientWidth;},getViewportHeight:function(){if(GUI.isIE){return GUI.isStrict?document.documentElement.clientHeight:document.body.clientHeight;}else{return self.innerHeight;}},getDocumentWidth:function(){var w=GUI.isStrict?document.documentElement.scrollWidth:document.body.scrollWidth;return Math.max(w,GUI.getViewportWidth())-1;},getDocumentHeight:function(){var h=GUI.isStrict?document.documentElement.scrollHeight:document.body.scrollHeight;return Math.max(h,GUI.getViewportHeight());},getInnerHeight:function(element){element=GUI.$(element);var tPadding=getDim(element.getStyle('padding-top'));var bPadding=getDim(element.getStyle('padding-bottom'));return element.offsetHeight-tPadding-bPadding;},getInnerNodesHeight:function(elem){var h=0;var i=elem.childNodes.length;while(i--){h+=parseInt(elem.childNodes[i].offsetHeight,10)}
return h;},getScroll:function(elem){var d=elem,doc=elem.ownerDocument,docEl=doc.documentElement,body=doc.body;if((d==docEl)||(d==body)){var l,t;if(GUI.isIE&&GUI.isStrict){l=docEl.scrollLeft||(body.scrollLeft||0);t=docEl.scrollTop||(body.scrollTop||0);}else{l=window.pageXOffset||(body.scrollLeft||0);t=window.pageYOffset||(body.scrollTop||0);}
return{left:l,top:t};}else{return{left:d.scrollLeft,top:d.scrollTop};}},getScrollableContainer:function(elem){var parent=elem.parentNode;while(parent){if($(parent).getStyle('overflow')===null){return parent;}else if(!parent.tagName||parent.tagName.toUpperCase()=="HTML"){return false;}
parent=parent.parentNode;}
return false;},getTotalScroll:function(element,to){to=to||document.body;var left=0,top=0;var parent=element.parentNode;while(parent){if((parent==to)||!parent.tagName||(parent.tagName=='HTML')){break;}
if(!GUI.isOpera||((parent.nodeName!='TR')&&(GUI.Dom.getStyle(parent,'display')!='inline'))){left+=parent.scrollLeft;top+=parent.scrollTop;}
if(GUI.Dom.getStyle(parent,'position')=='absolute'){break;}
parent=parent.parentNode;}
return[left,top];},scrollIntoView:function(cont,elem,dir){dir=dir||'vh';var p1=GUI.getPosition(elem),p2=GUI.getPosition(cont);if(dir.indexOf('h')>-1){var relLeft=p1.left-p2.left+cont.scrollLeft,elemLeft=relLeft-cont.clientLeft,elemWidth=elem.offsetWidth,contWidth=cont.clientWidth;if((elemLeft<0)||(elemWidth>contWidth)){cont.scrollLeft=elemLeft;}else if(elemLeft+elemWidth>contWidth){cont.scrollLeft=elemLeft+elemWidth-contWidth;}}
if(dir.indexOf('v')>-1){var relTop=p1.top-p2.top+cont.scrollTop,elemTop=relTop-cont.clientTop,elemHeight=elem.offsetHeight,contHeight=cont.clientHeight;if(elemTop<cont.scrollTop){cont.scrollTop=elemTop;}else if(elemTop+elemHeight>cont.scrollTop+contHeight){cont.scrollTop=elemTop+elemHeight-contHeight;}}},_getPosition:function(element){var top=0,left=0;if(element.getBoundingClientRect){var d=element.ownerDocument,docEl=d.documentElement,body=d.body,b=element.getBoundingClientRect();left=Math.round(b.left);top=Math.round(b.top);left-=docEl.clientLeft||body.clientLeft||0;top-=docEl.clientTop||body.clientTop||0;if(GUI.isIE&&(element==body||element==docEl)){return[left-bl,top-bt];}else{var scroll=GUI.getScroll(docEl);left+=scroll.left;top+=scroll.top;res=[left,top];res.left=left;res.top=top;return res;}}
var d=element.ownerDocument,body=d.body,docEl=d.documentElement,parent=element;top=element.offsetTop;left=element.offsetLeft;while((parent=parent.offsetParent)&&parent!==body&&parent!==docEl){if(GUI.isOpera&&(parent.tagName==='TD')){continue;}else{top+=parent.offsetTop||0;left+=parent.offsetLeft||0;}}
var scroll=GUI.getTotalScroll(element);left-=scroll[0];top-=scroll[1];var res=[left,top];res.left=left;res.top=top;return res;},getPosition:function(node,forceVisible){if(!forceVisible){return GUI._getPosition(node);}
return GUI.runDomVisible(node,GUI._getPosition);},getLocalCoordinates:function(elem,xy){if((elem==document)||(elem==document.body)||(!elem.offsetParent)){return xy;}
var elemPos=GUI.Dom.getStyle(elem,'position');if(elemPos!='relative'&&elemPos!='absolute'){var offParent=GUI.getPosition(elem.offsetParent,true);}else{var offParent=GUI.getPosition(elem,true);}
var res=[];res[0]=xy[0]-offParent[0];res[1]=xy[1]-offParent[1];res.left=res[0];res.top=res[1];return res;},getRelativeOffset:function(elem,cont){var p1=GUI.getPosition(elem,true),p2=GUI.getPosition(cont,true);return[p1.left-p2.left,p1.top-p2.top];},registerObject:function(obj){GUI._registeredObjects[GUI._registeredObjectsIdx++]=obj;},destroyObjects:function(){GUI.Event.removeAll();for(var i=0,obj;i<GUI._registeredObjectsIdx;i++){var obj=GUI._registeredObjects[i];if(obj.purgeListeners){obj.purgeListeners();}
GUI.destroyObject(obj);}},_registeredObjects:[],_registeredObjectsIdx:0,getLocationGetParams:function(){var res={},pairs=window.location.search.substring(1).split('&'),i,len=pairs.length,pair;for(i=0;i<len;i++){pair=pairs[i].split('=',2);res[decodeURIComponent(pair[0])]=decodeURIComponent(pair[1]);}
return res;}});if(window.debugJs||window.debug){GUI.assert=function(cond,msg){if(!cond){console.log('Assertion failed: '+msg);}}}else{GUI.assert=GUI.emptyFunction;}
if(GUI.ElementExtensions){GUI.$=function(elem){if(typeof elem=='string'){elem=document.getElementById(elem);}
return elem;};}else{GUI.$=function(elem,raw){if(typeof elem=='string'){elem=document.getElementById(elem);}
return elem?(raw?elem:GUI.Dom.extend(elem)):null;};}
if(GUI.isIE){var StringBuffer=function(str){this.buf=[];this.length=0;if(GUI.isSet(str)){this.append(str);}};StringBuffer.prototype={append:function(str){this.buf[this.length++]=str;return this;},clear:function(){this.buf=[];this.length=0;return this;},toString:function(){return this.buf.join('');}};}else{var StringBuffer=function(str){this.buf=(GUI.isSet(str))?str:'';};StringBuffer.prototype={append:function(str){this.buf+=str;return this;},clear:function(){this.buf='';return this;},toString:function(){return this.buf;}};}
GUI.StringBuffer=StringBuffer;}());if(GUI.isIE6){try{document.execCommand("BackgroundImageCache",false,true);}catch(e){}}
$=GUI.$;Prototype={Browser:{IE:GUI.isIE}};GUI.profile=function(func,scope){var time=new Date()-0;if(func){func.call(scope);}else{console.log(arguments)}
time=new Date()-time;console.log(time+' ms');};GUI.GetWidth=function(){if(parseInt(navigator.appVersion)>3){if(navigator.appName=="Netscape"){return window.innerWidth;}
if(navigator.appName.indexOf("Microsoft")!=-1){return document.body.offsetWidth;}}};

(function(){function ExtendedEvent(e){if(e._jsguiExtendedEvent){return e;}
this.e=e;this.target=this.getTarget();this.ctrlKey=e.ctrlKey||e.metaKey;this.shiftKey=e.shiftKey;this.altKey=e.altKey;}
ExtendedEvent.prototype={_jsguiExtendedEvent:true,KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_SPACE:32,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_END:35,KEY_HOME:36,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_INSERT:45,KEY_DELETE:46,ctrlKey:false,shiftKey:false,altKey:false,getCharCode:function(){return this.e.charCode||this.e.keyCode;},stop:function(){this.preventDefault();this.stopPropagation();},within:function(element){return GUI.Dom.extend(this.target).within(element);},isMouseEnter:function(element){var relTarg=this.getRelatedTarget();return!relTarg||!relTarg.within(element);},isMouseLeave:function(element){var relTarg=this.getRelatedTarget();return!relTarg||!relTarg.within(element);},isButton:function(code){if(GUI.isIE){var buttonMap={0:1,1:4,2:2};ExtendedEvent.prototype.isButton=function(code){return this.e.button==buttonMap[code];};}else if(GUI.isSafari){ExtendedEvent.prototype.isButton=function(code){switch(code){case 0:return this.e.which==1&&!this.e.metaKey;case 1:return this.e.which==1&&this.e.metaKey;default:return false;}};}else{ExtendedEvent.prototype.isButton=function(code){return this.e.which?(this.e.which===code+1):(this.e.button===code);};}
return this.isButton(code);},isLeftClick:function(){return this.isButton(0);},isMiddleClick:function(){return this.isButton(1);},isRightClick:function(){return this.isButton(2);},isNavKeyPress:function(){var k=this.e.keyCode;return(k>=33&&k<=40)||k==this.KEY_RETURN||k==this.KEY_TAB||k==this.KEY_ESC;},isSpecialKey:function(){var k=this.e.keyCode;return(this.e.type=='keypress'&&this.ctrlKey)||this.isNavKeyPress()||(k>=16&&k<=20)||(k>=44&&k<=45);},getKey:function(){return this.e.keyCode;}};if(GUI.isIE){Object.extend(ExtendedEvent.prototype,{preventDefault:function(){this.e.returnValue=false;},stopPropagation:function(){this.e.cancelBubble=true;},getTarget:function(){return GUI.Dom.extend(this.e.srcElement||this.e.target);},getRelatedTarget:function(){switch(this.e.type){case'mouseover':case'mouseenter':return GUI.Dom.extend(this.e.fromElement);case'mouseout':case'mouseleave':return GUI.Dom.extend(this.e.toElement);}},getPageXY:function(){var bd=GUI.getBody(),html=document.documentElement,e=this.e;return[e.clientX+bd.scrollLeft-html.clientLeft,e.clientY+bd.scrollTop-html.clientTop];}});}else{Object.extend(ExtendedEvent.prototype,{preventDefault:function(){this.e.preventDefault();},stopPropagation:function(){this.e.stopPropagation();},getTarget:function(){return GUI.Dom.extend(this.e.target);},getRelatedTarget:function(){var targ=this.e.relatedTarget;if(targ){try{if(targ.nodeType==3){targ=targ.parentNode;}}catch(e){return null;}
return GUI.Dom.extend(targ);}
return null;},getPageXY:function(){return[this.e.pageX,this.e.pageY];}});}
GUI.ExtendedEvent=ExtendedEvent;}());

(function(){var _windowResizeEvent,_windowResizeTask,_resizeMutex=false,_lastWidth,_lastHeight;var Event={onWindowResize:function(listener,scope){if(!_windowResizeEvent){_windowResizeEvent=new GUI.Utils.Event();_windowResizeTask=new GUI.Utils.DelayedTask(Event._windowResizeHandler);Event.on(window,'resize',Event.fireWindowResize);}
_windowResizeEvent.addListener(listener,scope);},unWindowResize:function(listener,scope){_windowResizeEvent.removeListener(listener,scope);},_windowResizeHandler:function(){var curWidth=GUI.getViewportWidth(),curHeight=GUI.getViewportHeight();if(curWidth!=_lastWidth||curHeight!=_lastHeight){_windowResizeEvent.fire(_lastWidth=curWidth,_lastHeight=curHeight);}},fireWindowResize:function(){if(_resizeMutex){return;}
_resizeMutex=true;if(_windowResizeEvent){if(GUI.isIE){_windowResizeTask.delay(150);}else{Event._windowResizeHandler();}}
_resizeMutex=false;},on:function(element,eventName,handler,scope){var elementCache,wrapperId;if(!element._jsguiElementId){var elementId=++Event._elementsCounter;element._jsguiElementId=elementId;elementCache=(Event._elementsCache[elementId]={});}else{elementCache=Event._elementsCache[element._jsguiElementId];}
if(!elementCache[eventName]){wrapperId=Event._addWrapper(element,eventName);elementCache[eventName]=wrapperId;}else{wrapperId=elementCache[eventName];}
Event._addListener(wrapperId,handler,scope);},un:function(element,eventName,handler,scope){if(!element){console.log('no element in Event.un');console.trace();throw new Error("GUI.Event.un: Element is undefined");}
var elementId=element._jsguiElementId,elementCache=Event._elementsCache[elementId];if(elementCache===undefined){return false;}
if(typeof eventName=='undefined'){for(eventName in elementCache){Event.un(element,eventName);}}else{var wrapperId=elementCache[eventName];if(Event._removeListener(wrapperId,handler,scope)){Event._removeWrapper(element,eventName,wrapperId);delete Event._elementsCache[elementId][eventName];}}},removeAll:function(){},fire:function(element,eventName,data){Event.fire=(document.createEvent)?function(element,eventName,data){var event,doc=element.nodeType==9?element:element.ownerDocument;event=doc.createEvent("HTMLEvents");data=data||{};if(Event._isDomEvent(eventName)){event.initEvent(eventName,true,true);Object.extend(event,data);}else{event.initEvent('dataavailable',true,true);event.eventName=eventName;event.memo=data;}
element.dispatchEvent(event);}:function(element,eventName,data){var event,doc=element.nodeType==9?element:element.ownerDocument;event=doc.createEventObject();data=data||{};if(Event._isDomEvent(eventName)){Object.extend(event,data);event.eventType='on'+eventName;}else{event.eventType='ondataavailable';event.eventName=eventName;event.memo=data;}
element.fireEvent(event.eventType,event);}
return Event.fire(element,eventName);},_elementsCache:{},_elementsCounter:0,_listeners:{},_listenersCounter:0,_wrappers:{},_wrappersCounter:0,_isDomEvent:function(eventName){return!eventName.include(':');},_eventDispatcher:function(wrapperId,evt,sender){var c=Event._wrappers[wrapperId];evt=evt||window.event;if(c.eventName&&(evt.eventName!==c.eventName)){return false;}
var listeners=Event._listeners,ls=c.listeners,len=ls.length,i,listener;if(!c.reverse){for(i=0;i<len;i++){listener=listeners[ls[i]];if(listener){listener[0].call(listener[1],evt);}}}else{while(len--){listener=listeners[ls[len]];if(listener){listener[0].call(listener[1],evt);}}}},_addListener:function(wrapperId,listener,scope){var id=++Event._listenersCounter;Event._listeners[id]=[listener,scope];Event._wrappers[wrapperId].listeners.push(id);},_removeListener:function(wrapperId,listener,scope){var listeners=Event._wrappers[wrapperId].listeners,i=listeners.length;if(listener){while(i--){var listenerId=listeners[i],l=Event._listeners[listenerId];if((l[0]==listener)&&(l[1]==scope)){delete Event._listeners[listenerId];listeners.splice(i,1);break;}}
return(listeners.length==0);}
while(i--){delete Event._listeners[listeners[i]];}
Event._wrappers[wrapperId].listeners=[];return true;},_getOuterWrapper:function(element,ow){return{func:function(e){var rel=e.relatedTarget;if(!((element==rel)||GUI.contains(element,e.relatedTarget))){return ow.call(this,e);}},listeners:[]};},_addWrapper:function(element,eventName){var id=++Event._wrappersCounter,wrapper;if(!GUI.isIE&&(eventName=='mouseenter'||eventName=='mouseleave')){wrapper=this._getOuterWrapper(element,Event._getWrapper2(id));eventName=(eventName=='mouseenter')?'mouseover':'mouseout';}else{wrapper=Event._getWrapper(id);}
if(!Event._isDomEvent(eventName)){wrapper.eventName=eventName;eventName='dataavailable';}else{if(eventName=='unload'&&element==window){wrapper.reverse=true;}}
Event._wrappers[id]=wrapper;if(element.addEventListener){element.addEventListener(eventName,wrapper.func,false);}else{element.attachEvent('on'+eventName,wrapper.func);}
return id;},_removeWrapper:function(element,eventName,wrapperId){var wrapper=Event._wrappers[wrapperId];if(!GUI.isIE&&(eventName=='mouseenter'||eventName=='mouseleave')){eventName=(eventName=='mouseenter')?'mouseover':'mouseout';}
if(!Event._isDomEvent(eventName)){delete wrapper.eventName;eventName='dataavailable';}
if(element.removeEventListener){element.removeEventListener(eventName,wrapper.func,false);}else{element.detachEvent('on'+eventName,wrapper.func);}
delete wrapper.listeners;delete Event._wrappers[wrapperId];},extend:function(e){if(e._jsguiExtendedEvent){return e;}else{return new GUI.ExtendedEvent(e);}}};if(GUI.isIE){Object.extend(Event,{_getWrapper:function(wrapperId){return{func:new Function('evt','GUI.Event._eventDispatcher('+wrapperId+', evt, this)'),listeners:[]};},_getWrapper2:function(wrapperId){return new Function('evt','GUI.Event._eventDispatcher('+wrapperId+', evt, this)');}});}else{Object.extend(Event,{_getWrapper:function(wrapperId){return{func:function(e){Event._eventDispatcher(wrapperId,e,this);},listeners:[]};},_getWrapper2:function(wrapperId){return function(e){Event._eventDispatcher(wrapperId,e,this);};}});}
GUI.Event=Event;Object.extend(document,{fire:Event.fire.methodize(),on:Event.on.methodize(),un:Event.un.methodize(),loaded:false});}());document.on('dom:loaded',function(){var bd=GUI.getBody();if(!bd){return;}
var cls=GUI.isIE?("x-ie "+(GUI.isIE6?'x-ie6':GUI.isIE7?'x-ie7':GUI.isIE8?'x-ie7':'')):GUI.isGecko?"x-gecko":GUI.isOpera?"x-opera":GUI.isSafari?"x-safari":GUI.isChrome?"x-chrome x-safari":'';if(GUI.isBorderBox){cls+=' x-border-box';}
if(GUI.isStrict){var p=bd.parentNode;if(p){if(p.className&&p.className!=''){p.className+=' x-strict';}else{p.className='x-strict';}}}
bd.addClass(cls);});(function(){var timer;function fireContentLoadedEvent(){if(document.loaded){return;}
if(timer){window.clearInterval(timer);}else if(document.removeEventListener){document.removeEventListener("DOMContentLoaded",fireContentLoadedEvent,false);}
document.loaded=true;document.fire('dom:loaded');document.un('dom:loaded');}
if(document.addEventListener){if(GUI.isSafari){timer=window.setInterval(function(){if(/loaded|complete/.test(document.readyState)){fireContentLoadedEvent();}},0);GUI.Event.on(window,'load',fireContentLoadedEvent);}else{document.addEventListener("DOMContentLoaded",fireContentLoadedEvent,false);}}else{document.write("<script id=\"__onDOMContentLoaded\" defer=\"defer\" src=\"//:\"><\/script>");var defer=document.getElementById('__onDOMContentLoaded');defer.onreadystatechange=function(){if(this.readyState=="complete"){this.onreadystatechange=null;GUI.remove(defer);defer=null;fireContentLoadedEvent();}};}}());(function(){if(autoDestroy){function cleanUpObjects(){GUI.destroyObjects();}
GUI.Event.on(window,'unload',cleanUpObjects);}
if(GUI.isIE){function cleanUpFp(){var fp=Function.prototype;delete fp.defer;delete fp.bind;delete fp.bindAsEventListener;delete fp.methodize;GUI.Event.un(window,'unload',cleanUpFp);}
GUI.Event.on(window,'unload',cleanUpFp);}}());if(!window.Event){Event={};}
Event.observe=GUI.Event.on;Event.stopObserving=GUI.Event.un;Event.stop=function(e){GUI.stopPropagation(e);GUI.preventDefault(e);};

(function(){var Dom={_whereTable:{beforeBegin:'previousSibling',afterBegin:'firstChild',beforeEnd:'lastChild',afterEnd:'nextSibling'},insertAdjacentElement:function(node,where,fragment){if(window.HTMLElement&&window.HTMLElement.prototype.insertAdjacentElement){Dom.insertAdjacentElement=function(node,where,fragment){if(node.insertAdjacentElement){node.insertAdjacentElement(where,fragment);return node[Dom._whereTable[where]];}else{return Dom._insertAdjacentElement_emulation(node,where,fragment);}};}else{Dom.insertAdjacentElement=Dom._insertAdjacentElement_emulation;}
return Dom.insertAdjacentElement(node,where,fragment);},_insertAdjacentElement_emulation:function(node,where,fragment){switch(where){case'beforeBegin':node.parentNode.insertBefore(fragment,node);return node.previousSibling;case'afterBegin':node.insertBefore(fragment,node.firstChild);return node.firstChild;case'beforeEnd':node.appendChild(fragment);return node.lastChild;case'afterEnd':if(node.nextSibling){node.parentNode.insertBefore(fragment,node.nextSibling);}else{node.parentNode.appendChild(fragment);}
return node.nextSibling;default:throw new Error("Dom.insertAdjacentElement(): invalid where value: "+where);}},insertAdjacentHTML:function(node,where,html){if(document.createElement('div').insertAdjacentHTML){Dom.insertAdjacentHTML=Dom._insertAdjacentHTML_native;}else{Dom.insertAdjacentHTML=Dom._insertAdjacentHTML_emulation;}
return Dom.insertAdjacentHTML(node,where,html);},_insertAdjacentHTML_native:function(node,where,html){node.insertAdjacentHTML(where,html);return node[Dom._whereTable[where]];},_insertAdjacentHTML_emulation:function(node,where,html){var r=node.ownerDocument.createRange();r.setStartBefore(node);var fragment=r.createContextualFragment(html);return Dom.insertAdjacentElement(node,where,fragment);},insertAdjacentText:function(node,where,text){if(document.createElement('div').insertAdjacentHTML){Dom.insertAdjacentText=function(node,where,text){node.insertAdjacentText(where,text);}}else{Dom.insertAdjacentText=function(node,where,text){var fragment=document.createTextNode(text)
Dom.insertAdjacentElement(where,fragment)}}
return Dom.insertAdjacentText(node,where,html);},insertBefore:function(node,html){return Dom.insertAdjacentHTML(node,'beforeBegin',html);},append:function(node,html){return Dom.insertAdjacentHTML(node,'beforeEnd',html);},prepend:function(node,html){return Dom.insertAdjacentHTML(node,'afterBegin',html);},hasClass:function(node,className){node=GUI.$(node);return className&&(' '+node.className+' ').indexOf(' '+className+' ')!=-1;},hasClasses:function(node,classes){node=GUI.$(node);var i=classes.length,nodeClass=' '+node.className+' ';while(i--){if(!classes[i]||nodeClass.indexOf(' '+classes[i]+' ')==-1){return false;}}
return true;},addClass:function(node,className){node=GUI.$(node);if(className&&!Dom.hasClass(node,className)){node.className=node.className+' '+className;}
return node;},setClass:function(node,className){node=GUI.$(node);if(typeof(className)=='string'){node.className=className;}else{node.className=className.join(' ');}
return node;},_classReCache:{},removeClass:function(node,className){node=GUI.$(node);if(!className||!node.className){return node;}
if(Dom.hasClass(node,className)){var re=Dom._classReCache[className];if(!re){re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)',"g");Dom._classReCache[className]=re;}
node.className=node.className.replace(re," ");}
return node;},setStyle:function(element,styles){element=$(element);for(var i in styles){element.style[i]=styles[i];}
return element;},within:function(element,container){return element==container||GUI.contains(container,element);},getDimensions:function(node){return{width:node.offsetWidth,height:node.offsetHeight};},getWidth:function(node){return node.offsetWidth;},getHeight:function(node){return node.offsetHeight;},unitPattern:/\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,addUnits:function(v,defaultUnit){if(v===''||v=='auto'){return v;}
if(v===undefined){return'';}
if(typeof v=="number"||Dom.unitPattern.test(v)){return v+(defaultUnit||'px');}
return v;},adjustWidth:function(autoAdjust){if(typeof width=="number"){if(autoAdjust&&!GUI.isBorderBox){}
if(width<0){width=0;}}
return width;},setWidth:function(w,autoAdjustBox){if(autoAdjustBox){w=Dom.adjustWidth(w);}
w.style.width=w;},getDom:function(html){var div;if(!Dom._getDomNode){div=Dom._getDomNode=document.createElement('div');}else{div=Dom._getDomNode;}
div.innerHTML=html;return div.firstChild;},_flyNodes:{},getFlyNode:function(tag){if(!Dom._flyNodes[tag]){var node=document.createElement(tag);node.id='jsgui-dom-fly-node';Dom._flyNodes[tag]=node;}
return Dom._flyNodes[tag];},on:function(){GUI.Event.on.apply(this,arguments)},un:function(){GUI.Event.un.apply(this,arguments)},query:function(){peppy.query.apply(this,arguments);},queryParent:function(elem,selector,to){var arr=selector.split('.',2),tag,cls;if(arr[1]){tag=arr[0].length>0?arr[0].toUpperCase():null;cls=arr[1];}else{tag=arr[0].toUpperCase();cls=null;}
to=to||document.body;if(tag&&cls){while(elem&&(elem!=to)){if(!elem.tagName){return false;}
if(elem.nodeName==tag){if(GUI.Dom.hasClass(elem,cls)){return elem;}}
elem=elem.parentNode;}
return false;}else if(tag){while(elem&&(elem!=to)){if(!elem.tagName){return false;}
if(elem.nodeName==tag){return elem;}
elem=elem.parentNode;}
return false;}else if(cls){while(elem&&(elem!=to)){if(!elem.tagName){return false;}
if(GUI.Dom.hasClass(elem,cls)){return elem;}
elem=elem.parentNode;}
return false;}},findDescedent:function(parent,search){var classes=search.split('.'),tagName=classes.shift(),res=[];if(!tagName){tagName='*';}
var i,node,nodes=parent.getElementsByTagName(tagName),len=nodes.length;for(i=0;i<len;i++){node=nodes[i];if(Dom.hasClasses(node,classes)){return node;}}
return null;},findDescedents:function(parent,search){var classes=search.split('.'),tagName=classes.shift(),res=[];if(!tagName){tagName='*';}
var i,node,nodes=parent.getElementsByTagName(tagName),len=nodes.length;for(i=0;i<len;i++){node=nodes[i];if(Dom.hasClasses(node,classes)){res.push(node);}}
return res;},findChild:function(parent,search){var classes=search.split('.'),tagName=classes.shift(),i,node,nodes=parent.childNodes,len=nodes.length;if(tagName){tagName=tagName.toUpperCase();}
for(i=0;i<len;i++){node=nodes[i];if(tagName&&node.nodeName!=tagName){continue;}
if(Dom.hasClasses(node,classes)){return node;}}
return null;},findChilds:function(parent,search){var classes=search.split('.'),tagName=classes.shift(),res=[],index=0;var i,node,nodes=parent.childNodes,len=nodes.length;if(tagName){tagName=tagName.toUpperCase();}
for(i=0;i<len;i++){node=nodes[i];if(tagName&&node.nodeName!=tagName){continue;}
if(Dom.hasClasses(node,classes)){res[index++]=node;}}
return res;},findNextSibling:function(node,search){var classes=search.split('.'),tagName=classes.shift(),res=[],index=0;if(tagName){tagName=tagName.toUpperCase();}
while(node=node.nextSibling){if(tagName&&node.nodeName!=tagName){continue;}
if(Dom.hasClasses(node,classes)){res[index++]=node;}}
return res;},findPrevSibling:function(node,search){var classes=search.split('.'),tagName=classes.shift(),res=[],index=0;if(tagName){tagName=tagName.toUpperCase();}
while((node=node.previousSibling)!=null){if(tagName&&node.nodeName!=tagName){continue;}
if(Dom.hasClasses(node,classes)){res[index++]=node;}}
return res;}};if(GUI.isIE){Dom.getStyle=function(element,style,doNotExtend){if(!doNotExtend){element=GUI.$(element);}
style=(style=='float'||style=='cssFloat')?'styleFloat':style.camelize();var value=element.style[style];if(!value&&element.currentStyle){value=element.currentStyle[style];}
if(style=='opacity'){if(value=(element.getStyle('filter')||'').match(/alpha\(opacity=(.*)\)/))
if(value[1])return parseFloat(value[1])/100;return 1.0;}
return value;};Object.extend(Dom,{getOuterHTML:function(node){return node.outerHTML;}});}else{Dom.getStyle=function(element,name){element=GUI.$(element);name=(name=='float')?'cssFloat':name.camelize();var value=element.style[name];if(!value){var css=document.defaultView.getComputedStyle(element,null);value=css?css[name]:null;}
if(name=='opacity')return value?parseFloat(value):1.0;return value=='auto'?null:value;};Object.extend(Dom,{_emptyTags:{'IMG':true,'BR':true,'INPUT':true,'META':true,'LINK':true,'PARAM':true,'HR':true},getOuterHTML:function(node){var attr,attrs=node.attributes,len=attrs.length,str="<"+node.tagName;for(var i=0;i<len;i++){attr=attrs[i];str+=' '+attr.name+"=\""+attr.value+"\"";}
return Dom._emptyTags[node.tagName]?str+">":str+">"+node.innerHTML+"</"+node.tagName+">";}});}
Dom._elementExtensions={on:Dom.on.methodize(),un:Dom.un.methodize(),addClass:Dom.addClass.methodize(),setClass:Dom.setClass.methodize(),removeClass:Dom.removeClass.methodize(),hasClass:Dom.hasClass.methodize(),getStyle:Dom.getStyle.methodize(),setStyle:Dom.setStyle.methodize(),within:Dom.within.methodize(),getDimensions:Dom.getDimensions.methodize(),getWidth:Dom.getWidth.methodize(),getHeight:Dom.getHeight.methodize(),findDescedent:Dom.findDescedent.methodize(),findDescedents:Dom.findDescedents.methodize(),findChild:Dom.findChild.methodize(),findParent:GUI.findParentByTag.methodize(),queryParent:Dom.queryParent.methodize(),query:function(selectorGroups,includeRoot,recursed,flat){return peppy.query(selectorGroups,this,includeRoot,recursed,flat);}};if(!GUI.ElementExtensions&&document.createElement('div')['__proto__']){window.HTMLElement={};window.HTMLElement.prototype=document.createElement('div')['__proto__'];GUI.ElementExtensions=true;}
if(GUI.ElementExtensions){Object.extend(HTMLElement.prototype,Dom._elementExtensions);}
document.query=Dom._elementExtensions.query;GUI.Dom=Dom;GUI.addClass=Dom.addClass;GUI.hasClass=Dom.hasClass;GUI.removeClass=Dom.removeClass;}());(function(){GUI.Dom.extend=GUI.SpecificElementExtensions?function(node){return node;}:function(node){if(!node||node._jsguiExtended||node==window){return node;}
Object.extend(node,GUI.Dom._elementExtensions);node._jsguiExtended=1;return node;};}());if(!window.Element){Element={};}
Element.observe=GUI.Event.on;Element.stopObserving=GUI.Event.un;

(function(){var i18n=GUI.i18n;GUI.ButtonTypes={OK:{caption:i18n.GUI_OK,hint:i18n.GUI_OK,img:''},CANCEL:{caption:i18n.GUI_CANCEL,hint:i18n.GUI_CANCEL,img:''},CLOSE:{caption:i18n.GUI_CLOSE,hint:i18n.GUI_CLOSE,img:''},SAVE_CLOSE:{caption:i18n.GUI_SAVE_CLOSE,hint:i18n.GUI_SAVE_CLOSE,img:''},ADD:{caption:i18n.GUI_ADD,hint:i18n.GUI_ADD,img:''},EDIT:{caption:i18n.GUI_EDIT,hint:i18n.GUI_EDIT,img:''},DELETE:{caption:i18n.GUI_DELETE,hint:i18n.GUI_DELETE,img:''},PRINT:{caption:i18n.GUI_PRINT,hint:i18n.GUI_PRINT,img:''},INSERT:{caption:i18n.GUI_INSERT,hint:i18n.GUI_INSERT,img:''},CREATE:{caption:i18n.GUI_CREATE,hint:i18n.GUI_CREATE,img:''},APPLY:{caption:i18n.GUI_APPLY,hint:i18n.GUI_APPLY,img:''}};}());

GUI.Utils={};

$.on=Event.observe;GUI.Utils.Observable=Class.create();GUI.Utils.Observable.prototype={initialize:function(){if(this.listeners){this.on(this.listeners);delete this.listeners;}
GUI.registerObject(this);},fireEvent:function(){if(this.eventsSuspended!==true){var ce=this.events[arguments[0].toLowerCase()];if(typeof ce=="object"){return ce.fire.apply(ce,Array.prototype.slice.call(arguments,1));}}
return true;},filterOptRe:/^(?:scope|delay|buffer|single)$/,addListener:function(eventName,fn,scope,o){if(typeof eventName=="object"){o=eventName;for(var e in o){if(this.filterOptRe.test(e)){continue;}
if(typeof o[e]=="function"){this.addListener(e,o[e],o.scope,o);}else{this.addListener(e,o[e].fn,o[e].scope,o[e]);}}
return;}
o=(!o||typeof o=="boolean")?{}:o;eventName=eventName.toLowerCase();var ce=this.events[eventName]||true;if(typeof ce=="boolean"){ce=new GUI.Utils.Event(this,eventName);this.events[eventName]=ce;}
ce.addListener(fn,scope,o);},removeListener:function(eventName,fn,scope){if(typeof eventName=='object'){var o=eventName;for(var e in o){if(this.filterOptRe.test(e)){continue;}
if(typeof o[e]=="function"){this.removeListener(e,o[e],o.scope);}else{this.removeListener(e,o[e].fn,o[e].scope);}}
return;}
eventName=eventName.toLowerCase();var ce=this.events[eventName];if(typeof ce=="object"){ce.removeListener(fn,scope);}},purgeListeners:function(){for(var evt in this.events){if(typeof this.events[evt]=="object"){this.events[evt].clearListeners();}}},addEvents:function(o){if(!this.events){this.events={};}
var name,i,a=arguments,events=this.events;if(typeof o=='string'){for(i=0;name=a[i];i++){events[name]=true;}}else{Object.extendIf(events,o);}},hasListener:function(eventName){var e=this.events[eventName];return typeof e=="object"&&e.listeners.length>0;},suspendEvents:function(){this.eventsSuspended=true;},resumeEvents:function(){this.eventsSuspended=false;},capture:function(o,fn,scope){throw new Exception('Observable.capture is not implemented!');},releaseCapture:function(o){o.fireEvent=GUI.Utils.Observable.prototype.fireEvent;}};GUI.Utils.Observable.prototype.on=GUI.Utils.Observable.prototype.addListener;GUI.Utils.Observable.prototype.un=GUI.Utils.Observable.prototype.removeListener;(function(){var createBuffered=function(h,o,scope){var task=new GUI.Utils.DelayedTask();return function(){task.delay(o.buffer,h,scope,Array.prototype.slice.call(arguments,0));};};var createSingle=function(h,e,fn,scope){return function(){e.removeListener(fn,scope);return h.apply(scope,arguments);};};var createDelayed=function(h,o,scope){return function(){var args=Array.prototype.slice.call(arguments,0);setTimeout(function(){h.apply(scope,args);},o.delay||10);};};GUI.Utils.Event=Class.create();GUI.Utils.Event.prototype={initialize:function(obj,name){this.name=name;this.obj=obj;this.listeners=[];},addListener:function(fn,scope,options){var o=options||{};scope=scope||this.obj;if(!this.isListening(fn,scope)){var l={fn:fn,scope:scope,options:o};var h=fn;if(o.delay){h=createDelayed(h,o,scope);}
if(o.single){h=createSingle(h,this,fn,scope);}
if(o.buffer){h=createBuffered(h,o,scope);}
l.fireFn=h;if(!this.firing){this.listeners.push(l);}else{this.listeners=this.listeners.slice(0);this.listeners.push(l);}}},findListener:function(fn,scope){scope=scope||this.obj;var ls=this.listeners;for(var i=0,len=ls.length;i<len;i++){var l=ls[i];if(l.fn==fn&&l.scope==scope){return i;}}
return-1;},isListening:function(fn,scope){return this.findListener(fn,scope)!=-1;},removeListener:function(fn,scope){var index;if((index=this.findListener(fn,scope))!=-1){if(!this.firing){this.listeners.splice(index,1);}else{this.listeners=this.listeners.slice(0);this.listeners.splice(index,1);}
return true;}
return false;},clearListeners:function(){this.listeners=[];},fire:function(){var ls=this.listeners,scope,len=ls.length;if(len>0){this.firing=true;var args=Array.prototype.slice.call(arguments,0);for(var i=0;i<len;i++){var l=ls[i];if(l.fireFn.apply(l.scope||this.obj||window,arguments)===false){this.firing=false;return false;}}
this.firing=false;}
return true;}};}());

GUI.Utils.Collection=Class.create();Object.extend(Object.extend(GUI.Utils.Collection.prototype,GUI.Utils.Observable.prototype),{initialize:function(allowFunctions,keyFn){this.allowFunctions=false;this.items=[];this.map={};this.keys=[];this.length=0;this.addEvents({"clear":true,"add":true,"replace":true,"remove":true,"sort":true});this.allowFunctions=allowFunctions===true;if(keyFn){this.getKey=keyFn;}
GUI.Utils.Observable.prototype.initialize.call(this);},add:function(key,o){if(arguments.length==1){o=arguments[0];key=this.getKey(o);}
if(typeof key=="undefined"||key===null){this.length++;this.items.push(o);this.keys.push(null);}else{var old=this.map[key];if(old){return this.replace(key,o);}
this.length++;this.items.push(o);this.map[key]=o;this.keys.push(key);}
this.fireEvent("add",this.length-1,o,key);return o;},getKey:function(o){return o.id;},replace:function(key,o){if(arguments.length==1){o=arguments[0];key=this.getKey(o);}
var old=this.item(key);if(typeof key=="undefined"||key===null||typeof old=="undefined"){return this.add(key,o);}
var index=this.indexOfKey(key);this.items[index]=o;this.map[key]=o;this.fireEvent("replace",key,old,o);return o;},addAll:function(objs){if(arguments.length>1||objs instanceof Array){var args=arguments.length>1?arguments:objs;for(var i=0,len=args.length;i<len;i++){this.add(args[i]);}}else{for(var key in objs){if(this.allowFunctions||typeof objs[key]!="function"){this.add(key,objs[key]);}}}},each:function(fn,scope){var items=[].concat(this.items);for(var i=0,len=items.length;i<len;i++){if(fn.call(scope||items[i],items[i],i,len)===false){break;}}},eachKey:function(fn,scope){for(var i=0,len=this.keys.length;i<len;i++){fn.call(scope||window,this.keys[i],this.items[i],i,len);}},find:function(fn,scope){for(var i=0,len=this.items.length;i<len;i++){if(fn.call(scope||window,this.items[i],this.keys[i])){return this.items[i];}}
return null;},insert:function(index,key,o){if(arguments.length==2){o=arguments[1];key=this.getKey(o);}
if(index>=this.length){return this.add(key,o);}
this.length++;this.items.splice(index,0,o);if(typeof key!="undefined"&&key!=null){this.map[key]=o;}
this.keys.splice(index,0,key);this.fireEvent("add",index,o,key);return o;},remove:function(o){return this.removeAt(this.indexOf(o));},removeAt:function(index){if(index<this.length&&index>=0){this.length--;var o=this.items[index];this.items.splice(index,1);var key=this.keys[index];if(typeof key!="undefined"){delete this.map[key];}
this.keys.splice(index,1);this.fireEvent("remove",o,key);return o;}
return false;},removeKey:function(key){return this.removeAt(this.indexOfKey(key));},getCount:function(){return this.length;},indexOf:function(o){return this.items.indexOf(o);},indexOfKey:function(key){return this.keys.indexOf(key);},item:function(key){var item=typeof this.map[key]!="undefined"?this.map[key]:this.items[key];return typeof item!='function'||this.allowFunctions?item:null;},itemAt:function(index){return this.items[index];},keyAt:function(index){return this.keys[index];},key:function(key){return this.map[key];},contains:function(o){return this.indexOf(o)!=-1;},containsKey:function(key){return typeof this.map[key]!="undefined";},clear:function(){this.length=0;this.items=[];this.keys=[];this.map={};this.fireEvent("clear");},first:function(){return this.items[0];},last:function(){return this.items[this.length-1];},_sort:function(property,dir,fn){var dsc=String(dir).toUpperCase()=="DESC"?-1:1;fn=fn||function(a,b){return a-b;};var c=[],k=this.keys,items=this.items;for(var i=0,len=items.length;i<len;i++){c[c.length]={key:k[i],value:items[i],index:i};}
c.sort(function(a,b){var v=fn(a[property],b[property])*dsc;if(v==0){v=(a.index<b.index?-1:1);}
return v;});for(var i=0,len=c.length;i<len;i++){items[i]=c[i].value;k[i]=c[i].key;}
this.fireEvent("sort",this);},sort:function(dir,fn){this._sort("value",dir,fn);},keySort:function(dir,fn){this._sort("key",dir,fn||function(a,b){return String(a).toUpperCase()-String(b).toUpperCase();});},getRange:function(start,end){var items=this.items;if(items.length<1){return[];}
start=start||0;end=Math.min(typeof end=="undefined"?this.length-1:end,this.length-1);var r=[];if(start<=end){for(var i=start;i<=end;i++){r[r.length]=items[i];}}else{for(var i=start;i>=end;i--){r[r.length]=items[i];}}
return r;},filter:function(property,value,anyMatch,caseSensitive){if(!GUI.isSet(value)){return this.clone();}
value=this.createValueMatcher(value,anyMatch,caseSensitive);return this.filterBy(function(o){return o&&value.test(o[property]);});},filterBy:function(fn,scope){var r=new GUI.Utils.Collection();r.getKey=this.getKey;var k=this.keys,it=this.items;for(var i=0,len=it.length;i<len;i++){if(fn.call(scope||this,it[i],k[i])){r.add(k[i],it[i]);}}
return r;},findIndex:function(property,value,start,anyMatch,caseSensitive){if(!GUI.isSet(value)){return-1;}
value=this.createValueMatcher(value,anyMatch,caseSensitive);return this.findBy(function(o){return o&&value.test(o[property]);},null,start);},findIndexBy:function(fn,scope,start){var k=this.keys,it=this.items;for(var i=(start||0),len=it.length;i<len;i++){if(fn.call(scope||this,it[i],k[i])){return i;}}
if(typeof start=='number'&&start>0){for(var i=0;i<start;i++){if(fn.call(scope||this,it[i],k[i])){return i;}}}
return-1;},createValueMatcher:function(value,anyMatch,caseSensitive){if(!value.exec){value=String(value);value=new RegExp((anyMatch===true?'':'^')+GUI.escapeRe(value),caseSensitive?'':'i');}
return value;},clone:function(){var r=new GUI.Utils.Collection();var k=this.keys,it=this.items;for(var i=0,len=it.length;i<len;i++){r.add(k[i],it[i]);}
r.getKey=this.getKey;return r;}});GUI.Utils.Collection.prototype.get=GUI.Utils.Collection.prototype.item;

(function()
{var ComponentMgr=Class.create();var prototype={initialize:function()
{this._components=[];this._indexByName={};window.Cmp={};},register:function(name,object)
{if(!GUI.isString(name)){object=name;name=name.getId();}
if(!name){return;}
var regName=this.isRegistered(object);if(regName){throw new Error("Object is already registered with name: "+regName);}else{var index=this._components.length;this._components[index]=object;this._indexByName[name]=index;window.Cmp[name]=object;}},unregister:function(object)
{var regName=this.isRegistered(object);if(!regName){console.log("Object is not registered to unregister!",object);console.trace();}else{var index=this._indexByName[regName];delete this._components[index];delete this._indexByName[regName];delete window.Cmp[regName];}},isRegistered:function(object){var i=this._components.length;while(i--){if(this._components[i]===object){return this._getNameByIndex(i);}}
return false;},get:function(name){var index=this._indexByName[name];if(GUI.isNumber(index)){return this._components[index];}else{return false;}},_getNameByIndex:function(index)
{for(var name in this._indexByName){if(this._indexByName[name]==index){return name;}}
return false;}};Object.extend(ComponentMgr.prototype,prototype);GUI.ComponentMgr=new ComponentMgr();GUI.getCmp=GUI.ComponentMgr.get.bind(GUI.ComponentMgr);})();

GUI.Utils.DelayedTask=function(fn,scope,args){var id=null,d,t;var call=function(){var now=new Date().getTime();if(now-t>=d){clearInterval(id);id=null;fn.apply(scope,args||[]);}};this.delay=function(delay,newFn,newScope,newArgs){if(id&&delay!=d){this.cancel();}
d=delay;t=new Date().getTime();fn=newFn||fn;scope=newScope||scope;args=newArgs||args;if(!id){id=setInterval(call,d);}};this.cancel=function(){if(id){clearInterval(id);id=null;}};};

(function()
{var Region=function(t,r,b,l){this.top=t;this[1]=t;this.right=r;this.bottom=b;this.left=l;this[0]=l;};Region.prototype={contains:function(region){return(region.left>=this.left&&region.right<=this.right&&region.top>=this.top&&region.bottom<=this.bottom);},getArea:function(){return((this.bottom-this.top)*(this.right-this.left));},getHeight:function(){return this.bottom-this.top;},getWidth:function(){return this.right-this.left;},intersect:function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new Region(t,r,b,l);}else{return null;}},union:function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new Region(t,r,b,l);},adjust:function(t,l,b,r){this.top+=t;this.left+=l;this.right+=r;this.bottom+=b;return this;}};Region.getRegion=function(el){var p=GUI.getPosition.getXY(el,true);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new Region(t,r,b,l);};var Point=function(x,y){if(GUI.isArray(x)){y=x[1];x=x[0];}
this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};Point.prototype=new Region();GUI.Utils.Region=Region;GUI.Utils.Point=Point;}());

(function()
{var DragDropMgr=Class.create();var prototype={dragPixelThresh:3,dragTimeThresh:1000,dragTimeout:null,stopPropagation:false,preventDefault:true,useCache:true,initialize:function(config)
{this.handleIds={};this.registeredDDs={};this.dragOvers={};this.locationCache={};this.dragObj=null;document.on('dom:loaded',this.onLoad,this);},registerDD:function(ddObj,group){if(!this.registeredDDs[group]){this.registeredDDs[group]={};}
this.registeredDDs[group][ddObj.config.id]=ddObj;},unregisterDD:function(ddObj,group){if(this.dragObj==ddObj){this.stopDrag();}
delete this.registeredDDs[group][ddObj.config.id];},getDDById:function(id){for(var i in this.registeredDDs){if(this.registeredDDs[i][id]){return this.registeredDDs[i][id];}}},registerHandle:function(ddId,handleId){if(!this.handleIds[ddId]){this.handleIds[ddId]={};}
this.handleIds[ddId][handleId]=handleId;},unregisterHandle:function(ddId,handleId){delete this.handleIds[ddId][handleId];},isHandle:function(ddId,handleId){return(this.handleIds[ddId]&&this.handleIds[ddId][handleId]);},handleWasClicked:function(node,id){if(this.isHandle(id,node.id)){return true;}else{var p=node.parentNode;while(p){if(this.isHandle(id,p.id)){return true;}else{p=p.parentNode;}}}
return false;},handleMouseDown:function(e,ddObj){this.dragObj=ddObj;this.dragObjConfig=ddObj.ddConfig;var dom=ddObj.getDom();var xy=e.getPageXY();this.startX=xy[0];this.startY=xy[1];var pos=GUI.getPosition(dom);this.deltaX=this.startX-pos.left;this.deltaY=this.startY-pos.top;this.dragThreshMet=false;this.dragTimeout=setTimeout(function(){var DDM=GUI.Utils.DDM;DDM.startDrag(DDM.startX,DDM.startY);},this.dragTimeThresh);},startDrag:function(x,y){clearTimeout(this.dragTimeout);if(this.dragObj){if(!this.dragObj.ddConfig.moveOnly){this.refreshCache(this.dragObj.ddConfig.groups);}
if(this.dragObj.onBeforeDragStart(x,y)!==false){this.dragObj.onDragStart(x,y);this.dragThreshMet=true;}else{this.dragObj=null;}}},stopDrag:function(e){if(this.dragObj){if(this.dragThreshMet){this.dragObj.onDragEnd(e);}}
this.dragObj=null;this.dragOvers={};},fireDragEvents:function(e,isDrop){var pt=new GUI.Utils.Point(e.getPageXY());var dc=this.dragObj;var oldOvers=[];var outEvts=[];var overEvts=[];var dropEvts=[];var enterEvts=[];for(var i in this.dragOvers){var ddo=this.dragOvers[i];if(!this.isOverTarget(pt,ddo)){outEvts.push(ddo);}
oldOvers[i]=true;delete this.dragOvers[i];}
for(var group in dc.ddConfig.groups){for(i in this.registeredDDs[group]){var oDD=this.registeredDDs[group][i];if(oDD.ddConfig.isTarget&&oDD!=dc){if(this.isOverTarget(pt,oDD)){if(!oldOvers[oDD.config.id]){enterEvts.push(oDD);}
overEvts.push(oDD);this.dragOvers[oDD.config.id]=oDD;if(isDrop){dropEvts.push(oDD);}}}}}
var acceptsDrop=false;var len=0;for(i=0,len=outEvts.length;i<len;++i){outEvts[i].onDragLeave(e,this.dragObj);}
for(i=0,len=enterEvts.length;i<len;++i){enterEvts[i].onDragEnter(e,this.dragObj);}
for(i=0,len=overEvts.length;i<len;++i){var res=overEvts[i].onDragOver(e,this.dragObj,pt);if(res===true){acceptsDrop=true;}}
if(isDrop&&acceptsDrop){for(i=0,len=dropEvts.length;i<len;++i){dropEvts[i].onDragDrop(e,this.dragObj);}}
if(isDrop&&!(dropEvts.length&&acceptsDrop)){dc.onInvalidDrop(e);}
return acceptsDrop;},refreshCache:function(groups){for(var sGroup in groups){if("string"!=typeof sGroup){continue;}
for(var i in this.registeredDDs[sGroup]){var oDD=this.registeredDDs[sGroup][i];this.refreshCacheOne(oDD);}}},refreshCacheOne:function(oDD){var loc=this.getLocation(oDD);if(loc){this.locationCache[oDD.config.id]=loc;}else{delete this.locationCache[oDD.config.id];}},getLocation:function(oDD){var el=GUI.$(oDD.ddConfig.targetElId),pos,x1,x2,y1,y2,t,r,b,l;if(!el){return null;}
pos=GUI.getPosition(el);if(!pos){return null;}
x1=pos[0];x2=x1+el.offsetWidth;y1=pos[1];y2=y1+el.offsetHeight;t=y1;r=x2;b=y2;l=x1;var loc=new GUI.Utils.Region(t,r,b,l);if(oDD.ddConfig.clipElId){el=GUI.$(oDD.ddConfig.clipElId);pos=GUI.getPosition(el);l=pos[0];r=l+el.offsetWidth;t=pos[1];b=t+el.offsetHeight;var clip=new GUI.Utils.Region(t,r,b,l);loc=loc.intersect(clip);if(!loc){loc=new GUI.Utils.Point(0,-10000);}}
return loc;},isOverTarget:function(pt,oTarget,intersect){var loc=this.locationCache[oTarget.config.id];if(!loc||!this.useCache){loc=this.getLocation(oTarget);this.locationCache[oTarget.config.id]=loc;}
if(!loc){return false;}
oTarget.cursorIsOver=loc.contains(pt);var dc=this.dragObj;if(!dc||!dc.getTargetCoord||(!intersect&&!dc.constrainX&&!dc.constrainY)){return oTarget.cursorIsOver;}},stopEvent:function(e){if(this.stopPropagation){e.stopPropagation();}
if(this.preventDefault){e.preventDefault();}},onMouseMove:function(e){if(!this.dragObj){return true;}
e=new GUI.ExtendedEvent(e);if(!this.dragThreshMet){var xy=e.getPageXY(),diffX=Math.abs(this.startX-xy[0]),diffY=Math.abs(this.startY-xy[1]);if(diffX>this.dragPixelThresh||diffY>this.dragPixelThresh){this.startDrag(this.startX,this.startY);}}else{var acceptsDrop=false;if(!this.dragObj.ddConfig.moveOnly){acceptsDrop=this.fireDragEvents(e,false);}
if(this.dragObj.onBeforeDrag(e)!==false){this.dragObj.onDrag(e,acceptsDrop);}}
this.stopEvent(e);},onMouseUp:function(e){if(!this.dragObj){return;}
e=new GUI.ExtendedEvent(e);clearTimeout(this.dragTimeout);if(this.dragThreshMet){this.fireDragEvents(e,true);}else{}
this.stopDrag(e);this.stopEvent(e);},onLoad:function(){document.on('mouseup',this.onMouseUp,this);document.on('mousemove',this.onMouseMove,this);GUI.Event.on(window,'unload',this.onUnLoad,this);},onUnLoad:function(){document.un('mouseup',this.onMouseUp,this);document.un('mousemove',this.onMouseMove,this);GUI.Event.un(window,'unload',this.onUnLoad,this);}};Object.extend(DragDropMgr.prototype,prototype);GUI.Utils.DDM=new DragDropMgr();})();

(function()
{var Draggable=Class.create();var superproto=GUI.Utils.Observable.prototype;var prototype={initialize:function(config)
{var defCfg={dd:{linkedElId:null,dragElId:null,handleElId:null,targetElId:null,isTarget:false,moveOnly:true,disabled:false,groups:{'default':true},clipElId:null,hasOuterHandles:false}};Object.extend(defCfg,config);this.config=defCfg;superproto.initialize.call(this);this.DDM=GUI.Utils.DDM;this.ddConfig=this.config.dd;this.addEvents('dragover');},initDD:function(){for(var i in this.ddConfig.groups){this.DDM.registerDD(this,i);}
var el=GUI.$(this.ddConfig.linkedElId);if(!el){console.log('no linkedEl',this.ddConfig.linkedElId);return;}
if(!this.ddConfig.targetElId){this.ddConfig.targetElId=this.ddConfig.linkedElId;}
el.on('mousedown',this.onDdMouseDown,this);},destroyDD:function(){GUI.$(this.ddConfig.linkedElId).un('mousedown',this.onDdMouseDown,this);for(var i in this.ddConfig.groups){this.DDM.unregisterDD(this,i);}},setHandleElId:function(id){this.ddConfig.handleElId=id;this.DDM.registerHandle(this.ddConfig.linkedElId,id);},unsetHandleElId:function(id){if(this.ddConfig.handleElId==id)
this.ddConfig.handleElId=null;this.DDM.unregisterHandle(this.ddConfig.linkedElId,id);},setOuterHandleElId:function(id){GUI.$(id).on('mousedown',this.onDdMouseDown,this);this.setHandleElId(id);this.ddConfig.hasOuterHandles=true;},unsetOuterHandleElId:function(id){GUI.$(id).un('mousedown',this.onDdMouseDown,this);this.unsetHandleElId(id);this.ddConfig.hasOuterHandles=false;},setStartPosition:function(e){var dom=GUI.$(this.ddConfig.linkedElId);this.startPageXY=[dom.offsetLeft,dom.offsetTop];},dragValidator:function(e){var target=e.getTarget();return(((target.nodeName!='INPUT')||(target.type!='checkbox'))&&(this.ddConfig.linkedElId==this.ddConfig.handleElId||this.DDM.handleWasClicked(target,this.ddConfig.linkedElId)));},enableDD:function(){this.ddConfig.disabled=false;},disableDD:function(){this.ddConfig.disabled=true;},onDdMouseDown:function(e){if(this.ddConfig.disabled){return true;}
e=new GUI.ExtendedEvent(e);this.DDM.refreshCacheOne(this);var pt=new GUI.Utils.Point(e.getPageXY());if(this.ddConfig.hasOuterHandles||this.DDM.isOverTarget(pt,this)){if(this.dragValidator(e)){this.setStartPosition(e);this.DDM.handleMouseDown(e,this);this.DDM.stopEvent(e);}}},onBeforeDragStart:function(e){},onDragStart:function(e){},onBeforeDrag:function(e){},onDrag:function(e,dropAccepted){},onBeforeDragEnd:function(e){},onDragEnd:function(e){},onDragEnter:function(e,dragObj){},onDragOver:function(e,dragObj){this.fireEvent('dragOver',this,dragObj,e);},onDragLeave:function(e,dragObj){},onDragDrop:function(e,dragObj){},onInvalidDrop:function(e){}};Object.extend(Draggable.prototype,superproto);Object.extend(Draggable.prototype,prototype);GUI.Utils.Draggable=Draggable;})();

(function()
{function STemplate(tpl,bind)
{var template=tpl,tagRe=/\{(.*?)\}/gm,self={},getters={};function replacer(match,name)
{if(name.indexOf('.')){var tree=name.split('.',10),curName=tree.shift(),i=tree.length,curr;curr=(curName=='this')?bind:self[curName];while(i--){if(typeof curr=='undefined')return'undefined';curr=curr[tree.shift()];}
return curr;}else{return self[name];}}
self.fetch=function()
{return template.replace(tagRe,replacer);};self.bind=function(to)
{bind=to;}
return self;}
GUI.STemplate=STemplate;}
());(function(){var cache={},getCompiledCode;if(GUI.isIE){getCompiledCode=function(str){var funcCode="var p=[],obj=obj||{},print=function(){p.push.apply(p,arguments);};"+"with(obj){p.push('"+
str.replace(/[\r\t\n]/g," ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('").split("\r").join("\\'")
+"');}return p.join('');";return funcCode;};}else{getCompiledCode=function(str){var funcCode="var p='',obj=obj||{},print=function(){p = p.concat.apply(p,arguments);};"+"with(obj){p+='"+
str.replace(/[\r\t\n]/g," ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"'+$1+'").split("<%").join("';").split("%>").join("p+='").split("\r").join("\\'")
+"';}return p;";return funcCode;};}
var Template=function tmpl(str,data,cacheId){if(cacheId){fn=cache[cacheId]=cache[cacheId]||Template(str);}else{var funcCode=getCompiledCode(str);try{fn=new Function("obj",funcCode);}catch(e){console.log('Error compiling template, generated code: '+funcCode);return null;}}
return data?fn(data):fn;};GUI.Template=Template;})();

(function()
{var WindowMgr=Class.create({zseed:5000,alwaysOnTopzseed:10000,initialize:function(){this.registeredWindows={};this.activeWindow=null;this.accessList=[];this.maxUsedZindex=this.zseed;document.on('dom:loaded',this.onLoad,this);},register:function(win){this.registeredWindows[win.config.id]=win;this.accessList.push(win);win.on('hide',this.activateLast,this);},unregister:function(win){delete this.registeredWindows[win.config.id];GUI.arrayRemove(this.accessList,win);win.un('hide',this.activateLast,this);if(win==this.activeWindow){this.activeWindow=null;}},get:function(id){return(GUI.isObject(id))?id:this.registeredWindows[id];},bringToFront:function(win){win=this.get(win);if(win!=this.activeWindow){win._lastAccess=new Date().getTime();this.orderWindows();return true;}
return false;},sendToBack:function(win){win=this.get(win);win._lastAccess=-(new Date().getTime());this.orderWindows();},getActive:function(){return this.activeWindow;},sortWindows:function(d1,d2){return(!d1._lastAccess||d1._lastAccess<d2._lastAccess)?-1:1;},orderWindows:function(){var a=this.accessList,len=a.length,zIndex;this.maxUsedZindex=this.zseed;if(len>0){a.sort(this.sortWindows);var seed=a[0].WM.zseed;for(var i=0;i<len;i++){var win=a[i];if(win&&win.visible){zIndex=win.alwaysOnTop?this.alwaysOnTopzseed+(i*10):seed+(i*10);win.setZIndex(zIndex);}}}
this.activateLast();},getMaxUsedZIndex:function(){if(this.activeWindow){return this.activeWindow.getZIndex();}else{return this.zseed;}},setActiveWin:function(win){if(win!=this.activeWindow){if(this.activeWindow){}
this.activeWindow=win;if(win){}}},activateLast:function(){for(var i=this.accessList.length-1;i>=0;--i){if(this.accessList[i].visible){this.setActiveWin(this.accessList[i]);return;}}
this.setActiveWin(null);},onKeyDown:function(e){if(this.activeWindow){this.activeWindow.onKeyDown(e);}},onKeyUp:function(e){if(this.activeWindow){this.activeWindow.onKeyUp(e);}},onKeyPress:function(e){if(this.activeWindow){this.activeWindow.onKeyPress(e);}},onLoad:function(){document.on('keydown',this.onKeyDown,this);document.on('keyup',this.onKeyUp,this);document.on('keypress',this.onKeyPress,this);},onUnLoad:function(){document.un('keydown',this.onKeyDown,this);document.un('keyup',this.onKeyUp,this);document.un('keypress',this.onKeyPress,this);}});GUI.Utils.WM=new WindowMgr();})();

GUI.Fx={};

(function(){var Component=Class.create(GUI.Utils.Observable,{hint:null,disabled:false,hidden:false,inDom:false,hideMode:'display',disabledClass:'x-disabled',deferFocusTime:20,initialize:function(config){this.plugins=[];if(config){if(!config.listeners){config.listeners={};}
if(config.onClick){config.listeners.click=config.onClick;delete config.onClick;}
if(config.onChange){config.listeners.change=config.onChange;delete config.onChange;}
Object.extend(this,config);}
this.initialConfig=config||{};this.config=this;this.addEvents({'beforeShow':true,'show':true,'beforeHide':true,'hide':true,'beforeRender':true,'render':true,'afterRender':true,'disable':true,'enable':true,'beforedestroy':true,'destroy':true});this.getId();GUI.ComponentMgr.register(this);Component.superclass.initialize.call(this);if(this.plugins&&!GUI.isArray(this.plugins)){this.plugins=[this.plugins];}
this.initComponent();if(this.plugins){if(GUI.isArray(this.plugins)){for(var i=0,len=this.plugins.length;i<len;i++){this.plugins[i].init(this);}}else{this.plugins.init(this);}}
if(this.assignTo){this.assign(this.assignTo);delete this.assignTo;}else if(this.renderTo){this.render(this.renderTo);delete this.renderTo;}},destroy:function(quick){if(this.fireEvent('beforedestroy',this)===false){return;}
if(this.plugins){if(GUI.isArray(this.plugins)){for(var i=0,len=this.plugins.length;i<len;i++){if(this.plugins[i].destroy){this.plugins[i].destroy(this);}}}else{if(this.plugins.destroy){this.plugins.destroy(this);}}
this.plugins=null;}
this.onBeforeDestroy(quick);this.onDestroy(quick);GUI.ComponentMgr.unregister(this);this.fireEvent('destroy',this);this.purgeListeners();GUI.destroyObject(this);},render:function(to,before){if(this.rendered){return;}
if(this.fireEvent('beforerender',this)===false){return;}
if(GUI.isSet(to)){this.holder=to;}
this.holder=GUI.$(this.holder);if(!this.holder){throw new Error("Holder is null.");}
if(GUI.isSet(before)){if(GUI.isNumber(before)){before=this.holder.childNodes[before];if(before&&before.nodeType==3){before=null;}}else{before=GUI.$(before);}}
if(this.containerCls){this.holder.addClass(this.containerCls);}
var res=this.onRender();if(GUI.isSet(res)){if(before){if(GUI.isString(res)){this.dom=GUI.Dom.insertBefore(before,res);}else{this.dom=this.holder.insertBefore(res,before);}}else{if(GUI.isString(res)){this.dom=GUI.Dom.append(this.holder,res);}else{this.dom=this.holder.appendChild(res);}}}else{if(!this.dom){throw new Error('Component.render(): no this.dom');}}
GUI.Dom.extend(this.dom);this.rendered=true;this.inDom=true;this.fireEvent('render',this);this.onAfterRender(this.dom);this.onPostAfterRender();this.attachEventListeners();this.fireEvent('afterrender',this);if(this.hidden){this.hide();}
if(this.disabled){this.disable();}},onPostAfterRender:function(){},unrender:function(quick){this.removeEventListeners();if(!quick){GUI.destroyNode(this.dom);this.dom=null;}
this.rendered=this.inDom=false;},assign:function(to){},disable:function(){if(this.rendered){this.onDisable();}
this.disabled=true;this.fireEvent('disable',this);return this;},enable:function(){if(this.rendered){this.onEnable();}
this.disabled=false;this.fireEvent('enable',this);return this;},focus:function(){if(this.dom){try{this.dom.focus();}catch(e){}}
return this;},deferFocus:function(delay){delay=(delay!=null)?delay:this.deferFocusTime;this.focus.defer(delay,this);return this;},blur:function(){if(this.dom){try{this.dom.blur();}catch(e){}}
return this;},show:function(){if(this.fireEvent('beforeshow',this)===false){return this;}
this.hidden=false;if(this.rendered){this.onShow();}
this.fireEvent('show',this);return this;},hide:function(){if(this.fireEvent("beforehide",this)===false){return this;}
this.hidden=true;if(this.rendered){this.onHide();}
this.fireEvent('hide',this);return this;},setHint:function(v){this.hint=v;if(this.dom){GUI.Popup.Hint.add(this.dom,v);}
return this;},isDisabled:function(){return this.disabled;},isEnabled:function(){return!this.disabled;},getId:function(){return this.id||(this.id="jsgui-cmp-"+(++GUI.Component.AUTO_ID));},getDom:function(){return this.dom;},addPlugin:function(obj){this.plugins.push(obj);},removePlugin:function(pl){if(this.plugins.remove(pl)){pl.destroy();return true;}
return false;},getPlugin:function(className){var plugins=this.plugins,i;for(i=0,len=plugins.length;i<len;i++){var plugin=plugins[i];if(plugin instanceof className){return plugin;}}
return null;},getPlugins:function(className){var plugins=this.plugins,res=[],i;for(i=0,len=plugins.length;i<len;i++){var plugin=plugins[i];if(plugin instanceof className){res.push(plugin);}}
return res;},initComponent:function(){},onRender:function(){return'<div></div>';},onAfterRender:function(){this.inDom=true;if(GUI.isSet(this.hint)){GUI.Popup.Hint.add(this.dom,this.hint);}},onBeforeDestroy:function(){},onDestroy:function(fast){if(this.dom){if(this.dom.un){this.dom.un();}
if(!fast){GUI.destroyNode(this.dom);}}
this.holder=this.dom=null;},attachEventListeners:function(){},removeEventListeners:function(){},onDisable:function(){this.dom.addClass(this.disabledClass);},onEnable:function(){this.dom.removeClass(this.disabledClass);},onShow:function(){if(this.hideParent){this.holder.removeClass('x-hide-'+this.hideMode);}else{this.dom.removeClass('x-hide-'+this.hideMode);}},onHide:function(){if(this.hideParent){this.holder.addClass('x-hide-'+this.hideMode);}else{this.dom.addClass('x-hide-'+this.hideMode);}}});Component.AUTO_ID=0;GUI.Component=Component;}());

(function(){var BoxComponent=Class.create(GUI.Component,{autoWidthClass:'jsgui-autowidth',initialize:function(config){BoxComponent.superclass.initialize.call(this,config);},initComponent:function(){BoxComponent.superclass.initComponent.call(this);this.addEvents({resize:true,move:true});},onAfterRender:function(dom){BoxComponent.superclass.onAfterRender.call(this,dom);},onPostAfterRender:function(){this.suspendEvents();this.setSize(this.width,this.height);this.resumeEvents();},getWidth:function(){return this.dom?this.dom.offsetWidth:this.width;},getHeight:function(){return this.dom?this.dom.offsetHeight:this.height;},getConfigSize:function(){return{width:this.width,height:this.height};},getSize:function(){if(!this.dom){return this.getConfigSize();}
return{width:this.dom.offsetWidth,height:this.dom.offsetHeight};},setSize:function(w,h){if(typeof w=='object'){h=w.height;w=w.width;}
this.width=w;this.height=h;if(!this.inDom){return this;}
var adj=this.adjustSize(w,h),aw=adj.width,ah=adj.height;if(aw!==undefined||ah!==undefined){var rz=this.getResizeEl(),style=rz.style;if(!this.deferHeight&&aw!==undefined&&ah!==undefined){if(typeof aw=='number'){style.width=aw+'px';}else{style.width=aw;}
if(typeof ah=='number'){style.height=ah+'px';}else{style.height=ah;}}else if(!this.deferHeight&&ah!==undefined){if(GUI.isNumber(ah)){ah=ah.constrain(0);style.height=ah+'px';}else{style.height=ah;}}else if(aw!==undefined){if(typeof aw=='number'){aw=aw.constrain(0);style.width=aw+'px';}else{style.width=aw;}}
if(aw=='auto'){GUI.Dom.addClass(rz,this.autoWidthClass);}else{GUI.Dom.removeClass(rz,this.autoWidthClass);}
this.onResize(aw,ah,w,h);this.fireEvent('resize',this,aw,ah,w,h);}
return this;},adjustSize:function(w,h){if(this.autoWidth){w='auto';}
if(this.autoHeight){h='auto';}
if(GUI.isNumber(w)){w=w.constrain(0);}
if(GUI.isNumber(h)){h=h.constrain(0);}
return{width:w,height:h};},getResizeEl:function(w,h){return this.resizeEl||this.dom;},getPositionEl:function(){return this.positionEl||this.dom;},setWidth:function(w){return this.setSize(w);},setHeight:function(h){return this.setSize(undefined,h);},onResize:function(){},getPosition:function(relative){if(!this.inDom){return{left:this.x,top:this.y};}
var el=this.getPositionEl();return relative?{left:parseInt(GUI.Dom.getStyle(el,'left'),10),top:parseInt(GUI.Dom.getStyle(el,'top'),10)}:GUI.getPosition(el);},setPosition:function(x,y){if(x&&typeof x[1]=='number'){y=x[1];x=x[0];}
this.x=x;this.y=y;if(!this.inDom){return this;}
var adj=this.adjustPosition(x,y);var ax=adj.x,ay=adj.y;var el=this.getPositionEl();if(ax!==undefined||ay!==undefined){if(ax!==undefined&&ay!==undefined){el.style.left=ax+'px';el.style.top=ay+'px';}else if(ax!==undefined){el.style.left=ax+'px';}else if(ay!==undefined){el.style.top=ay+'px';}
this.onPosition(ax,ay);this.fireEvent('move',this,ax,ay);}
return this;},adjustPosition:function(x,y){return{x:x,y:y};},onPosition:function(){}});GUI.BoxComponent=BoxComponent;}());

(function(){var ClickRepeater=Class.create(GUI.Utils.Observable,{delay:500,interval:50,initialize:function(config){if(config){Object.extend(this,config);}
this.dom=GUI.$(this.dom);GUI.unselectable(this.dom);this.addEvents({mousedown:true,mouseup:true,click:true});this.dom.on('mousedown',this.onMouseDown,this);this.timerDelegate=this.onTimer.bind(this);ClickRepeater.superclass.initialize.call(this);},destroy:function(){this.dom.un('mousedown',this.onMouseDown,this);this.dom=null;},onMouseDown:function(e){e=GUI.Event.extend(e);e.preventDefault();clearTimeout(this.timerId);this.time=new Date()-0;if(this.pressedClass){this.dom.addClass(this.pressedClass);}
document.on('mouseup',this.onMouseUp,this);this.dom.on('mouseout',this.onMouseOut,this);this.fireEvent('mousedown',this);this.fireEvent('click',this);this.timerId=setTimeout(this.timerDelegate,this.delay);},onTimer:function(){this.fireEvent('click',this);this.timerId=setTimeout(this.timerDelegate,this.interval);},onMouseUp:function(){clearTimeout(this.timerId);document.un('mouseup',this.onMouseUp,this);if(this._mouseOverAttached){this.dom.un('mouseover',this.onMouseOver,this);this._mouseOverAttached=false;}
this.dom.un('mouseout',this.onMouseOut,this);this.dom.removeClass(this.pressedClass);this.fireEvent('mouseup',this);},onMouseOut:function(){clearTimeout(this.timerId);if(this.pressedClass){this.dom.removeClass(this.pressedClass);}
if(!this._mouseOverAttached){this.dom.on('mouseover',this.onMouseOver,this);this._mouseOverAttached=true;}else{console.log('bug');}},onMouseOver:function(){if(this._mouseOverAttached){this.dom.un('mouseover',this.onMouseOver,this);this._mouseOverAttached=false;}else{console.log('bug');}
if(this.pressedClass){this.dom.addClass(this.pressedClass);}
this.timerId=setTimeout(this.timerDelegate,this.interval);}});GUI.Utils.ClickRepeater=ClickRepeater;}());

(function(){var Container=Class.create(GUI.BoxComponent,{defaultCls:'jsgui-container',autoDestroy:true,initialize:function(config){Container.superclass.initialize.call(this,config);},initComponent:function(){Container.superclass.initComponent.call(this);this.addEvents({afterLayout:true,afterChildrenLayout:true,beforeRemove:true,remove:true});var items=this.items;if(items){delete this.items;if(GUI.isArray(items)){this.add.apply(this,items);}else{this.add(items);}}else{this.initItems();}},initItems:function(){if(!this.items){this.items=new GUI.Utils.Collection(false);this.getLayout();}},onRender:function(){var dom=document.createElement('div');dom.id=this.id;dom.className=this.defaultCls+(this.cls?' '+this.cls:'');return dom;},onBeforeDestroy:function(fast){if(this.items){this.items.each(function(item){item.ownerCt=null;item.destroy(fast);});}
if(this.layout&&this.layout.destroy){this.layout.destroy();}
Container.superclass.onBeforeDestroy.call(this,fast);},render:function(){Container.superclass.render.apply(this,arguments);if(this.layout){if(GUI.isString(this.layout)){if(GUI.Layouts[this.layout]){this.layout=new GUI.Layouts[this.layout](this.layoutConfig);}else{throw new Error('Unknown layout: "'+this.layout+'"');}}
this.setLayout(this.layout);if(GUI.isSet(this.activeItem)){var item=this.activeItem;delete this.activeItem;this.layout.setActiveItem(item);return;}}
if(!this.ownerCt){this.doLayout();}
if(this.monitorResize===true){GUI.Event.onWindowResize(this.onWindowResize,this);}},onWindowResize:function(w,h){this.doLayout(false);},getLayout:function(){if(!this.layout){var layout=new GUI.Layouts.Layout(this.layoutConfig);this.setLayout(layout);}
return this.layout;},getLayoutTarget:function(){return this.dom;},setLayout:function(layout){if(this.layout&&this.layout!=layout){this.layout.setContainer(null);}
this.initItems();this.layout=layout;layout.setContainer(this);},add:function(comp){if(!this.items){this.initItems();}
var a=arguments,len=a.length;if(len>1){for(var i=0;i<len;i++){this.add(a[i]);}
return;}
var c=this.lookupComponent(this.applyDefaults(comp));var pos=this.items.length;if(this.fireEvent('beforeadd',this,c,pos)!==false&&this.onBeforeAdd(c)!==false){this.items.add(c);c.ownerCt=this;this.fireEvent('add',this,c,pos);}
return c;},onBeforeAdd:function(item){if(item.ownerCt){item.ownerCt.remove(item,false);}},remove:function(comp,autoDestroy){var c=this.getComponent(comp);if(c&&this.fireEvent('beforeremove',this,c)!==false){this.items.remove(c);delete c.ownerCt;if(autoDestroy===true||(autoDestroy!==false&&this.autoDestroy)){c.destroy();}
if(this.layout&&this.layout.activeItem==c){delete this.layout.activeItem;}
this.fireEvent('remove',this,c);}
return c;},getComponent:function(cmp){if(typeof cmp=='object'){return cmp;}
return this.items.get(cmp);},doLayout:function(shallow){if(this.rendered&&this.layout){this.layout.layout();}
if(shallow!==false&&this.items){var cs=this.items.items;for(var i=0,len=cs.length;i<len;i++){var c=cs[i];if(c.doLayout){c.doLayout();}}
this.fireEvent('afterChildrenLayout',this);}},getComponent:function(comp){if(typeof comp=='object'){return comp;}
return this.items.get(comp);},lookupComponent:function(comp){if(!comp.events){var cls=comp.cmp||GUI.Panel
comp.cmp=null;return new cls(comp);}
return comp;},applyDefaults:function(c){if(this.defaults){if(GUI.isString(c)){c=GUI.getCmp(c);Object.extend(c,this.defaults);}else if(!c.events){Object.extendIf(c,this.defaults);}else{Object.extend(c,this.defaults);}}
return c;}});Container.Layouts={};GUI.Utils.Container=Container;}());

(function(){var ApplicationContainer=Class.create(GUI.Utils.Container,{layout:'Application',initComponent:function(){ApplicationContainer.superclass.initComponent.call(this);document.getElementsByTagName('html')[0].className+=' jsgui-container-application';this.dom=document.body;this.dom.scroll='no';this.autoWidth=true;this.height='100%';GUI.Event.onWindowResize(this.fireResize,this);this.holder=this.dom;},onRender:GUI.emptyFunction,fireResize:function(w,h){this.fireEvent('resize',this,w,h,w,h);}});GUI.ApplicationContainer=ApplicationContainer;}());

(function(){var Panel=Class.create(GUI.Utils.Container,{baseClass:'jsgui-panel',headerClass:'jsgui-panel-header',bodyWrapClass:'jsgui-panel-bodywrap',topBarClass:'jsgui-panel-topbar',_bodyClass:'jsgui-panel-body',bottomBarClass:'jsgui-panel-bottombar',toolButtonClass:'jsgui-toolbutton',collapsedClass:'jsgui-panel-collapsed',parts:'body',caption:'',collapsable:false,collapseHides:false,doubleClickToggles:true,scrollable:false,collapsed:false,initComponent:function(){this.toolbox=[];Panel.superclass.initComponent.call(this);if(this.header){this.parts+=',header';delete this.header;}else if(this.caption&&this.header!==false){this.parts+=',header';}
if(this.toolbox){var item,tb=this.toolbox,i=tb.length;this.toolButtons={};while(i--){item=tb[i];this.toolButtons[item.name]=item;}}
if(this.collapsable&&!this.toolButtons.toggle){var btn={scope:this,handler:this.toggle,name:'toggle'};this.toolButtons.toggle=btn;this.toolbox.push(btn);}},toggle:function(){return this[this.collapsed?'expand':'collapse']();},collapse:function(){if(this.collapsed||(this.fireEvent('beforecollapse',this)===false)){return;}
this.onCollapse();},onCollapse:function(animate){if(animate){}else{this.onAfterCollapse();}},onAfterCollapse:function(){this.collapsed=true;GUI.hide(this[this.collapseEl]);this.dom.addClass(this.collapsedClass);this.fireEvent('collapse',this);},expand:function(){if(!this.collapsed||(this.fireEvent('beforeexpand',this)===false)){return;}
this.onExpand();},onExpand:function(animate){if(animate){}else{this.dom.removeClass(this.collapsedClass);GUI.show(this[this.collapseEl]);this.onAfterExpand();}},onAfterExpand:function(){this.collapsed=false;this.fireEvent('expand',this);},getToolboxMarkup:function(){var i,item,html=new GUI.StringBuffer(),tb=this.toolbox,len=tb.length;for(i=0;i<len;i++){item=tb[i];html.append('<a href="#" class="'+this.toolButtonClass+' jsgui-toolbutton-'+item.name+'">&#160;</a>');}
return html+'';},getToolButtonEl:function(name){return this.headerEl?GUI.Dom.findChild(this.headerEl,'a.jsgui-toolbutton-'+name):null;},addToolButtonClass:function(name,cls){var btn=this.getToolButtonEl(name);if(btn){GUI.Dom.addClass(btn,cls);}},showToolButton:function(name){var btn=this.getToolButtonEl(name);if(btn){GUI.show(btn);}},hideToolButton:function(name){var btn=this.getToolButtonEl(name);if(btn){GUI.hide(btn);}},onRender:function(){var html=new GUI.StringBuffer();html.append('<div id="'+this.id+'" class="'+this.baseClass+'">');if(this.parts.indexOf('header')!=-1){html.append('<div class="'+this.headerClass+'">');if(this.toolbox){html.append(this.getToolboxMarkup());}
html.append('<span class="jsgui-panel-header-title">'+this.caption+'</span>');html.append('</div>');}
html.append('<div class="'+this.bodyWrapClass+'">');if(this.topBar){html.append('<div class="'+this.topBarClass+'"></div>');}
var style=this.style||'';html.append('<div style="'+style+'" class="'+this._bodyClass+(this.bodyClass?' '+this.bodyClass:'')+'">')
if(this.content){html.append(this.content);}
html.append('</div>');if(this.bottomBar){html.append('<div class="'+this.bottomBarClass+'"></div>');}
html.append('</div></div>');return html+'';},onAfterRender:function(el){var bodyWrap,cur;if(this.parts.indexOf('header')!=-1){this.headerEl=GUI.Dom.extend(el.firstChild);bodyWrap=this.headerEl.nextSibling;GUI.unselectable(this.headerEl);this.headerEl.on('click',this.onHeaderClick,this);if(this.collapsable&&this.doubleClickToggles){this.headerEl.on('dblclick',this.toggle,this);}}else{bodyWrap=el.firstChild;}
this.bodyWrapEl=bodyWrap;this.setCollapseHides(this.collapseHides);if(this.topBar){this.topBarEl=bodyWrap.firstChild;this.bodyEl=this.topBarEl.nextSibling;if(GUI.isString(this.topBar)){this.topBarEl.innerHTML=this.topBar;}else if(GUI.isArray(this.topBar)){this.topBar=new GUI.ToolBar({align:'none',elements:this.topBar});this.topBar.render(this.topBarEl);}else if(this.topBar.render){this.topBar.render(this.topBarEl);}
this.toolbar=this.topBar;}else{this.bodyEl=bodyWrap.firstChild;}
if(this.bottomBar){this.bottomBarEl=this.bodyEl.nextSibling;this.bottomBar.render(this.bottomBarEl);}
if(this.scrollable){this.bodyEl.style.overflow='auto';}},onDestroy:function(fast){this.headerEl=this.topBarEl=this.bodyEl=this.bottomBarEl=null;Panel.superclass.onDestroy.call(this,fast);},setScrollable:function(scrollable){if(typeof scrollable=='undefined'){scrollable=true;}
this.scrollable=scrollable;if(this.bodyEl){this.bodyEl.style.overflow=(scrollable)?'auto':'';}},setCollapseHides:function(v){this.collapseEl=(this.collapseHides=v)?'dom':'bodyWrapEl';},onHeaderClick:function(e){e=GUI.Event.extend(e);e.preventDefault();var target=e.target;if(target.nodeName=='A'){var match=target.className.match(this.toolButtonClass+'-(\\w+)'),name=match&&match[1],button=name&&this.toolButtons[name],handler=button&&button.handler;if(handler){handler.call(button.scope,name);}}},getContentHeight:function(){if(this.dom){return this.bodyEl.offsetHeight-1;}},getContentWidth:function(){if(this.dom){return this.bodyEl.offsetWidth-2;}},getContentSize:function(){return{width:this.getContentWidth(),height:this.getContentHeight()}},onResize:function(w,h){if(w!==undefined||h!==undefined){if(true){if(typeof w=='number'){var width=this.adjustBodyWidth(w-this.getFrameWidth());GUI.setFullWidth(this.bodyEl,width);}else if(w=='auto'){this.bodyEl.style.width=w;}
if(typeof h=='number'){GUI.setFullHeight(this.bodyEl,this.adjustBodyHeight(h-this.getFrameHeight()));}else if(h=='auto'){this.bodyEl.style.height=h;}}else{}
this.fireEvent('bodyresize',this,w,h);}},adjustBodyHeight:function(h){return h;},adjustBodyWidth:function(w){return w;},getFrameWidth:function(){return 0;},getFrameHeight:function(){var h=0;if(this.headerEl){h+=this.headerEl.offsetHeight;}
if(this.topBar){h+=this.topBarEl.offsetHeight;}
if(this.bottomBar){h+=this.bottomBarEl.offsetHeight;}
return h;},getLayoutTarget:function(){return this.bodyEl;}});GUI.Panel=Panel;}());

(function(){var Layout=Class.create({elementType:'Layouts.Layout',initialize:function(config){Object.extend(this,config);},monitorResize:false,activeItem:null,layout:function(){var target=this.container.getLayoutTarget();GUI.Dom.extend(target);this.onLayout(this.container,target);this.container.fireEvent('afterlayout',this.container,this);},onLayout:function(ct,to){this.renderAll(ct,to);},isValidParent:function(c,target){var el=c.getPositionEl?c.getPositionEl():c.getDom();return el.parentNode==target.dom;},renderAll:function(ct,to){var items=ct.items.items;for(var i=0,len=items.length;i<len;i++){var c=items[i];if(c&&(!c.rendered||!this.isValidParent(c,to))){this.renderItem(c,i,to);}}},renderItem:function(c,position,to){if(c&&!c.rendered){c.render(to,position);if(this.extraCls){var t=c.getPositionEl?c.getPositionEl():c;t.addClass(this.extraCls);}
if(this.renderHidden&&c!=this.activeItem){c.hide();}}},onResize:function(){if(this.container.collapsed){return;}
var b=this.container.bufferResize;if(b){if(!this.resizeTask){this.resizeTask=new GUI.Utils.DelayedTask(this.layout,this);this.resizeBuffer=typeof b=='number'?b:100;}
this.resizeTask.delay(this.resizeBuffer);}else{this.layout();}},setContainer:function(ct){if(this.monitorResize&&ct!=this.container){if(this.container){this.container.un('resize',this.onResize,this);}
if(ct){ct.on('resize',this.onResize,this);}}
this.container=ct;},parseMargins:function(v){var ms=v.split(' '),len=ms.length;if(len==1){ms[1]=ms[0];ms[2]=ms[0];ms[3]=ms[0];}else if(len==2){ms[2]=ms[0];ms[3]=ms[1];}else if(len==3){m[3]=ms[1];}
return{top:parseInt(ms[0],10)||0,right:parseInt(ms[1],10)||0,bottom:parseInt(ms[2],10)||0,left:parseInt(ms[3],10)||0};},destroy:GUI.emptyFunction});if(!GUI.Layouts){GUI.Layouts={};}
GUI.Layouts.Layout=Layout;}());

(function(){var FormLayout=Class.create(GUI.Layouts.Layout,{labelSeparator:':',setContainer:function(ct){FormLayout.superclass.setContainer.call(this,ct);if(ct.labelAlign){ct.addClass('x-form-label-'+ct.labelAlign);}
if(ct.hideLabels){this.labelStyle="display:none";this.elementStyle="padding-left:0;";this.labelAdjust=0;}else{this.labelSeparator=ct.labelSeparator||this.labelSeparator;ct.labelWidth=ct.labelWidth||100;if(typeof ct.labelWidth=='number'){var pad=(typeof ct.labelPad=='number'?ct.labelPad:5);this.labelAdjust=ct.labelWidth+pad;this.labelStyle="width:"+ct.labelWidth+"px;";this.elementStyle="padding-left:"+(ct.labelWidth+pad)+'px';}
if(ct.labelAlign=='top'){this.labelStyle="width:auto;";this.labelAdjust=0;this.elementStyle="padding-left:0;";}}
if(!this.fieldTpl){var t='<div class="x-formlayout-item {5}" tabIndex="-1">'+'<label for="{0}" style="{2}" class="x-formlayout-item-label formlayout-item">{1}{4}</label>'+'<div class="x-formlayout-field" id="x-form-el-{0}" style="{3}">'+'</div><div class="{6}"></div>'+'</div>';FormLayout.prototype.fieldTpl=t;}},renderItem:function(c,position,to){if(c&&!c.rendered&&c.isFormField&&c.type!='hidden'){var args=[c.id,c.label,c.labelStyle||this.labelStyle||'',this.elementStyle||'',typeof c.labelSeparator=='undefined'?this.labelSeparator:c.labelSeparator,(c.itemCls||this.container.itemCls||'')+(c.hideLabel?' x-hide-label':''),c.clearCls||'x-form-clear-left'];if(typeof position=='number'){position=to.childNodes[position]||null;}
var html=this.fieldTpl.format.apply(this.fieldTpl,args);if(position){GUI.Dom.insertBefore(position,html);}else{GUI.Dom.append(to,html);}
c.render('x-form-el-'+c.id);}else{FormLayout.superclass.renderItem.apply(this,arguments);}},isValidParent:function(c,target){return true;}});GUI.Layouts.Form=FormLayout;}());

(function(){var TableLayout=Class.create(GUI.Layouts.Layout,{monitorResize:false,setContainer:function(ct){TableLayout.superclass.setContainer.call(this,ct);this.currentRow=0;this.currentColumn=0;this.cells=[];},onLayout:function(ct,target){var cs=ct.items.items,len=cs.length,c,i;if(!this.table){target.addClass('x-table-layout-ct');this.table=GUI.Dom.append('<table class="x-tablelayout" cellSpacing="0"><tbody></tbody></table>',target)
this.renderAll(ct,target);}},getRow:function(index){var row=this.table.tBodies[0].childNodes[index];if(!row){row=document.createElement('tr');this.table.tBodies[0].appendChild(row);}
return row;},getNextCell:function(c){var cell=this.getNextNonSpan(this.currentColumn,this.currentRow);var curCol=this.currentColumn=cell[0],curRow=this.currentRow=cell[1];for(var rowIndex=curRow;rowIndex<curRow+(c.rowspan||1);rowIndex++){if(!this.cells[rowIndex]){this.cells[rowIndex]=[];}
for(var colIndex=curCol;colIndex<curCol+(c.colspan||1);colIndex++){this.cells[rowIndex][colIndex]=true;}}
var td=document.createElement('td');if(c.cellId){td.id=c.cellId;}
var cls='x-table-layout-cell';if(c.cellCls){cls+=' '+c.cellCls;}
td.className=cls;if(c.colspan){td.colSpan=c.colspan;}
if(c.rowspan){td.rowSpan=c.rowspan;}
this.getRow(curRow).appendChild(td);return td;},getNextNonSpan:function(colIndex,rowIndex){var cols=this.columns;while((cols&&colIndex>=cols)||(this.cells[rowIndex]&&this.cells[rowIndex][colIndex])){if(cols&&colIndex>=cols){rowIndex++;colIndex=0;}else{colIndex++;}}
return[colIndex,rowIndex];},renderItem:function(c,position,target){if(c&&!c.rendered){c.render(this.getNextCell(c));}},isValidParent:function(c,target){return true;}});GUI.Layouts.Table=TableLayout;}());

(function(){var ApplicationLayout=Class.create(GUI.Layouts.Layout,{elementType:'Layouts.Application',cls:'jsgui-layout-application-container',itemCls:'jsgui-layout-application-item',monitorResize:true,animateOpacity:false,render:function(ct,target){target.style.position='relative';target.addClass(this.cls);var i,items=ct.items.items,len=items.length,regions={};for(i=0;i<len;i++){var item=items[i],pos=item.pos;if(!item.rendered){item.render(target,i);item.dom.addClass(this.itemCls);}
regions[pos]=new ApplicationLayout.Region(this,item.initialConfig,pos,item.split);regions[pos].render(target,item);}
this.regions=regions;if(!regions.center){throw new Error('ApplicationLayout.render(): Main region is not defined!');}
this.rendered=true;},destroy:function(){var names=['left','right','top','bottom'];for(var i=0;i<names.length;i++){var region=this.regions[names[i]];if(region){if(region.destroy){region.destroy();}}}
ApplicationLayout.superclass.destroy.call(this);},onLayout:function(ct,target){if(!this.rendered){this.render(ct,target);}
var s,m,r,ss,size=GUI.getClientSize(target),w=size.width,h=size.height,cWidth=w,cHeight=h,cX=0,cY=0,splitterWidth,regions=this.regions;if(w<20||h<20){return;}
if((r=regions.top)&&r.isVisible()){s=r.getSize();m=r.getMargins();s.width=w-(m.left+m.right);s.x=m.left;s.y=m.top;cY=s.y+s.height+m.bottom;cHeight-=cY;if(r.split&&!r.collapsed){ss=r.splitter.dom.style,splitterHeight=5;cY+=splitterHeight;cHeight-=splitterHeight;ss.left=s.x+'px';ss.top=s.y+s.height+'px';ss.width=s.width.constrain(0)+'px';}
r.applyLayout(s);}
if((r=regions.bottom)&&r.isVisible()){s=r.getSize();m=r.getMargins();s.width=w-(m.left+m.right);s.x=m.left;var totalHeight=s.height+m.top+m.bottom;s.y=h-totalHeight+m.top;if(r.split&&!r.collapsed){ss=r.splitter.dom.style,splitterHeight=5;cHeight-=splitterHeight;ss.left=s.x+'px';ss.top=s.y-splitterHeight+'px';ss.width=s.width.constrain(0)+'px';}
cHeight-=totalHeight;r.applyLayout(s);}
if((r=regions.left)&&r.isVisible()){s=r.getSize();m=r.getMargins();s.height=cHeight-(m.top+m.bottom);s.x=m.left;s.y=cY+m.top;var totalWidth=(s.width+m.left+m.right);if(r.split&&!r.collapsed){ss=r.splitter.dom.style,splitterWidth=5;totalWidth+=splitterWidth;ss.left=(s.x+s.width)+'px';ss.top=s.y+'px';ss.height=s.height.constrain(0)+'px';}
cX+=totalWidth;cWidth-=totalWidth;r.applyLayout(s);}
if((r=regions.right)&&r.isVisible()){s=r.getSize();m=r.getMargins();s.height=cHeight-(m.top+m.bottom);var totalWidth=(s.width+m.left+m.right);s.x=w-totalWidth+m.left;s.y=cY+m.top;if(r.split&&!r.collapsed){ss=r.splitter.dom.style,splitterWidth=5;totalWidth+=splitterWidth;ss.left=(s.x-splitterWidth)+'px';ss.top=s.y+'px';ss.height=s.height.constrain(0)+'px';}
cWidth-=totalWidth;r.applyLayout(s);}
r=regions.center;var m=r.getMargins(),centerBox={x:cX+m.left,y:cY+m.top,width:cWidth-(m.left+m.right),height:cHeight-(m.top+m.bottom)};r.applyLayout(centerBox);ss=null;},isValidParent:function(c,target){return true;}});GUI.Layouts.Application=ApplicationLayout;}());(function(){var Region=function(layout,config,pos,split){if(config){Object.extend(this,config);}
this.layout=layout;this.position=pos;this.split=split;};Region.prototype={collapsedTemplate:'<div class="jsgui-layout-application-item-collapsed"><a href="#" class="jsgui-toolbutton jsgui-toolbutton-expand-{0}"></a></div>',defaultMargins:{left:0,top:0,right:0,bottom:0},animateSliding:window.GUI_FX_ANIMATION==true,animateToggle:window.GUI_FX_ANIMATION==true,render:function(containerEl,containerItem){this.targetEl=containerEl;this.item=containerItem;this.dom=containerItem.getDom();if(GUI.isString(this.margins)){this.margins=this.layout.parseMargins(this.margins);}
this.margins=Object.extendIf(this.margins||{},this.defaultMargins);if(this.position!='center'){containerItem.on({scope:this,beforeCollapse:this.onBeforeCollapse,collapse:this.onCollapse,beforeExpand:this.onBeforeExpand,expand:this.onExpand,hide:this.onHide,show:this.onShow});if(this.collapsable){containerItem.setCollapseHides(true);}
var btn=containerItem.toolButtons&&containerItem.toolButtons.toggle;if(btn){containerItem.addToolButtonClass('toggle','jsgui-toolbutton-collapse-'+this.position);}
if(this.split){this.splitter=new GUI.Splitter({linkedEl:this.item,position:this.position,vertical:this.position=='top'||this.position=='bottom'});this.splitter.render(containerEl);}}},destroy:function(){if(this.position!='center'&&this.item.un){this.item.un({scope:this,beforeCollapse:this.onBeforeCollapse,collapse:this.onCollapse,beforeExpand:this.onBeforeExpand,expand:this.onExpand,hide:this.onHide,show:this.onShow});}
this.item=this.targetEl=this.dom=null;if(this.toggleFx){this.toggleFx.destroy();this.toggleFx=null;}
if(this.slideFx){this.slideFx.destroy();this.slideFx=null;}
if(this.collapsedEl){GUI.destroyNode(this.collapsedEl);this.collapsedEl=null;}
if(this.splitter){this.splitter.destroy();this.splitter=null;}},applyLayout:function(box){this.lastBox=box;if(this.collapsed){this.applyLayoutCollapsed(box);}else{this.item.setSize(box.width,box.height);this.item.setPosition(box.x,box.y);}},applyLayoutCollapsed:function(box){var el=this.getCollapsedEl(),s=el.style;s.left=box.x+'px';s.top=box.y+'px';GUI.setFullWidth(el,box.width);GUI.setFullHeight(el,box.height);},isVisible:function(){return!this.item.hidden;},getMargins:function(){return this.collapsed&&this.cmargins?this.cmargins:this.margins;},getSize:function(){if(this.collapsed){var el=this.getCollapsedEl();return GUI.getDimensions(el);}
return this.item.getSize();},prepareToggleAnimator:function(){if(!this.toggleFx){this.toggleFx=new Animator({duration:500,scope:this,onComplete:this.onToggleFxComplete});}
if(!this.toggleFx.isRunning()){this._oldScrollable=this.item.scrollable;if(this._oldScrollable){this.item.setScrollable(false);}
this.toggleFx.clearSubjects();var pos=this.item.getPosition(true),size=this.item.getSize();this._restorePos=pos;switch(this.position){case'left':this.toggleFx.addSubject(new NumericalStyleSubject(this.dom,'left',pos.left-size.width,pos.left));break;case'right':this.toggleFx.addSubject(new NumericalStyleSubject(this.dom,'left',pos.left+size.width,pos.left));break;case'top':this.toggleFx.addSubject(new NumericalStyleSubject(this.dom,'top',pos.top-size.height,pos.top));break;case'bottom':this.toggleFx.addSubject(new NumericalStyleSubject(this.dom,'top',pos.top+size.height,pos.top));break;}
this.toggleFx.state=this.collapsed?1:0;this.toggleFx.propagate();}},onToggleFxComplete:function(fx){if(fx.state==0){this.afterCollapse();}else if(fx.state==1){this.afterExpand();}
if(this._oldScrollable){this.item.setScrollable(this._oldScrollable);}},onBeforeCollapse:function(p,animate){if(this.splitter){this.splitter.hide();}
this.getCollapsedEl().style.visibility='';this.collapsed=true;this.getCollapsedEl().style.visibility='visible';this.getCollapsedEl().style.zIndex=102;this.dom.style.zIndex=100;this.layout.layout();this.onCollapse(this.item);this.item.collapsed=true;return false;},onCollapse:function(item,animate){animate=animate===false?false:this.animateToggle;if(animate){this.dom.addClass('jsgui-fx-noscroll');this.prepareToggleAnimator();this.toggleFx.seekTo(0);this.toggleFx.propagate();}else{this.afterCollapse();}},afterCollapse:function(){this.dom.style.visibility='hidden';this.dom.style.zIndex='';this.getCollapsedEl().style.zIndex='';this.dom.removeClass('jsgui-fx-noscroll');if(this._restorePos!=null){var s=this.dom.style;s.left=this._restorePos.left+'px';s.top=this._restorePos.top+'px';}},onBeforeExpand:function(item,animate){if(this.slid){return false;}},onExpand:function(item,animate){var c=this.getCollapsedEl();if(this.position=='left'||this.position=='right'){this.item.setSize(undefined,GUI.getFullHeight(c));this.item.setPosition(this.item.x,c.offsetTop);}else{this.item.setSize(GUI.getFullWidth(c),undefined);this.item.setPosition(c.offsetLeft);}
c.style.visibility='hidden';this.dom.style.zIndex=100;animate=animate===false?false:this.animateToggle;this.collapsed=false;if(animate){this.dom.addClass('jsgui-fx-noscroll');this.prepareToggleAnimator();this.toggleFx.seekTo(1);this.toggleFx.propagate();}else{this.afterExpand();}
this.dom.style.visibility='';},afterExpand:function(){if(this.splitter){this.splitter.show();}
this.layout.layout();this.dom.style.zIndex='';this.dom.removeClass('jsgui-fx-noscroll');},getCollapsedEl:function(){if(!this.collapsedEl){var html=this.collapsedTemplate.format(this.position),el=GUI.Dom.append(this.targetEl,html);this.collapsedEl=GUI.Dom.extend(el);el.on('click',this.onCollapsedClick,this);}
return this.collapsedEl;},onCollapsedClick:function(e){e=GUI.Event.extend(e);e.preventDefault();var target=e.target;if(target.nodeName=='A'){if(this.slid){this.afterSlideIn();}
this.item.expand();}else{this.toggleSlid();}},toggleSlid:function(){return this[this.slid?'slideIn':'slideOut']();},prepareSlideAnimator:function(){if(!this.slideFx){this.slideFx=new Animator({duration:500,scope:this,onComplete:this.onSlideFxComplete});}
if(!this.slideFx.isRunning()){this.slideFx.clearSubjects();var property,start,left;switch(this.position){case'left':property='left';end=this.collapsedEl.offsetLeft+GUI.getFullWidth(this.collapsedEl);start=end-parseInt(this.dom.style.width,10);break;case'right':property='left';start=this.collapsedEl.offsetLeft;end=start-parseInt(this.dom.style.width,10);break;case'top':property='top';end=this.collapsedEl.offsetTop+GUI.getFullHeight(this.collapsedEl);start=end-parseInt(this.dom.style.height,10);break;case'bottom':property='top';start=this.collapsedEl.offsetTop;end=start-parseInt(this.dom.style.height,10);break;}
if(property){this.slideFx.addSubject(new NumericalStyleSubject(this.dom,property,start,end));}
if(this.animateOpacity&&!GUI.isIE){this.slideFx.addSubject(new NumericalStyleSubject(this.dom,'opacity',0,1));}
this.slideFx.state=this.slid?1:0;this.slideFx.propagate();if(this.position=='left'||this.position=='right'){this.item.setPosition(undefined,this.collapsedEl.offsetTop);}else{this.item.setPosition(this.collapsedEl.offsetLeft,undefined);}}},onSlideFxComplete:function(fx){if(fx.state==0){this.afterSlideIn();}else if(fx.state==1){this.afterSlideOut();}
if(!GUI.isIE){GUI.setOpacity(this.dom,'');}},slideOut:function(){var btn=this.item.getToolButtonEl('toggle');if(btn){GUI.hide(btn);}
this.collapsedEl.style.zIndex=102;this.dom.style.zIndex=100;if(this.position=='left'||this.position=='right'){this.item.setHeight(this.collapsedEl.offsetHeight);}else{this.item.setWidth(this.collapsedEl.offsetWidth);}
this._restorePos=this.item.getPosition(true);if(this.animateSliding){this.dom.addClass('jsgui-fx-noscroll');this.prepareSlideAnimator();this.slideFx.seekTo(1);this.slideFx.propagate();}else{switch(this.position){case'left':this.item.setPosition(this.collapsedEl.offsetLeft+GUI.getFullWidth(this.collapsedEl),undefined);break;case'right':this.item.setPosition(this.collapsedEl.offsetLeft-parseInt(this.dom.style.width,10),undefined);break;case'bottom':this.item.setPosition(undefined,this.collapsedEl.offsetTop-parseInt(this.dom.style.height,10));break;case'top':this.item.setPosition(undefined,this.collapsedEl.offsetTop+GUI.getFullHeight(this.collapsedEl));break;}}
this.dom.style.visibility='';this.slid=true;document.on('click',this.onDocumentMouseDown,this);},afterSlideOut:function(){this.dom.removeClass('jsgui-fx-noscroll');},onDocumentMouseDown:function(e){e=GUI.Event.extend(e);if(!e.within(this.dom)&&!e.within(this.getCollapsedEl())){this.slideIn();}},slideIn:function(){this.collapsedEl.style.zIndex=102;if(this.animateSliding){this.dom.addClass('jsgui-fx-noscroll');this.prepareSlideAnimator();this.slideFx.seekTo(0);this.slideFx.propagate();}else{this.afterSlideIn();}},afterSlideIn:function(){this.collapsedEl.style.zIndex='';this.dom.style.zIndex='';this.dom.style.visibility='hidden';this.dom.removeClass('jsgui-fx-noscroll');if(this._restorePos){this.item.setPosition(this._restorePos.left,this._restorePos.top);}
var btn=this.item.getToolButtonEl('toggle');if(btn){GUI.show(btn);}
this.slid=false;document.un('click',this.onDocumentMouseDown,this);},onHide:function(){if(this.collapsed){this.getCollapsedEl().hide();}else if(this.splitter){this.splitter.hide();}},onShow:function(){if(this.collapsed){this.getCollapsedEl().show();}else if(this.splitter){this.splitter.show();}}};GUI.Layouts.Application.Region=Region;}());

(function(){var FitLayout=Class.create(GUI.Layouts.Layout,{elementType:'Layouts.Fit',monitorResize:true,onLayout:function(ct,to){FitLayout.superclass.onLayout.call(this,ct,to);if(!this.container.collapsed){var size=GUI.getDimensions(to);this.setItemSize(this.activeItem||ct.items.itemAt(0),size);}},setItemSize:function(item,size){if(item&&size.height>0){item.setSize(size);}}});GUI.Layouts.Fit=FitLayout;}());

(function(){var CardLayout=Class.create(GUI.Layouts.Fit,{elementType:'Layouts.Card',deferredRender:false,renderHidden:true,setActiveItem:function(item){item=this.container.getComponent(item);if(this.activeItem!=item){if(this.activeItem){this.activeItem.hide();}
this.activeItem=item;item.show();this.layout();}},renderAll:function(ct,to){if(this.deferredRender){this.renderItem(this.activeItem,undefined,to);}else{CardLayout.superclass.renderAll.call(this,ct,to);}}});GUI.Layouts.Card=CardLayout;}());

(function(){var CarouselLayout=Class.create(GUI.Layouts.Layout,{monitorResize:true,deferredRender:false,renderHidden:false,wrapped:false,extraCls:'jsgui-layout-carousel-item',animate:true,initialize:function(config){CarouselLayout.superclass.initialize.call(this,config);if(this.animate){this.fx=new Animator({duration:500});}},setActiveItem:function(item){var ct=this.container;item=ct.getComponent(item);if(this.activeItem!=item){if(this.wrapEl){var itemIndex=ct.items.indexOf(item);if(this.animate){this.fx.seekTo(itemIndex/(ct.items.length-1));}else{var offset=itemIndex*this.wrapEl.parentNode.offsetWidth;this.wrapEl.style.left=(-offset)+'px';}}
this.activeItem=item;}},renderAll:function(ct,to){if(!this.wrapped){var div=document.createElement('div');div.className='jsgui-layout-carousel-wrap';to.appendChild(div);to=div;this.wrapEl=div;this.wrapped=true;}else{to=this.wrapEl;}
if(this.deferredRender){this.renderItem(this.activeItem,undefined,to);}else{CarouselLayout.superclass.renderAll.call(this,ct,to);}},onLayout:function(ct,to){CarouselLayout.superclass.onLayout.call(this,ct,to);if(!this.container.collapsed){var item,size=GUI.getDimensions(to),items=ct.items.items,i=items.length,wrapWidth=this.wrapEl.parentNode.offsetWidth;if(!this.fx.isRunning()){this.fx.clearSubjects();this.fx.addSubject(new NumericalStyleSubject(this.wrapEl,'left',0,(1-i)*wrapWidth));}
var itemIndex=this.container.items.indexOf(this.activeItem);offset=itemIndex*wrapWidth;this.wrapEl.style.left=(-offset)+'px';while(i--){item=items[i];this.setItemPosition(item,size,i);this.setItemSize(item,size);}}},setItemPosition:function(item,size,index){if(item){var offset=index*size.width;item.setPosition(offset,0);}},setItemSize:function(item,size){if(item&&size.height>0){item.setSize(size);}}});GUI.Layouts.Carousel=CarouselLayout;}());

(function()
{var Element=Class.create();var superproto=GUI.Utils.Draggable.prototype;var prototype={initialize:function(config){superproto.initialize.call(this,config);var cfg=this.config;Object.extend(cfg,{id:undefined,html:undefined,holder:undefined,className:undefined,disabled:false,visible:true});Object.extend(cfg,config);this.elementType='GUI.Element';this.disabled=cfg.disabled?1:0;this.visible=cfg.visible;this.addEvents({beforeRender:true,afterRender:true,show:true,hide:true});if(typeof cfg.onBeforeRender=='function'){this.on('beforeRender',cfg.onBeforeRender,this);}
if(typeof cfg.onAfterRender=='function'){this.on('afterRender',cfg.onAfterRender,this);}
if(typeof cfg.onShow=='function'){this.on('show',cfg.onShow,this);}
if(typeof cfg.onHide=='function'){this.on('hide',cfg.onHide,this);}},destroy:function(fast){if(this.dom){this.unrender(fast);}
this.purgeListeners();GUI.destroyObject(this);},render:function(to){if(!this.fireEvent('beforeRender',this)){return;}
if(this.dom){this.unrender();}
var cfg=this.config;if(to){cfg.holder=to;}else{to=cfg.holder;}
to=GUI.$(to);if(!to){throw new Error(this.elementType+' error in method render(): No holder '+to+' found');}
this._render(to);this.attachEventListeners();this.fireEvent('afterRender',this);},unrender:function(fast){if(!this.dom){return false;}
this.removeEventListeners();if(!fast){GUI.destroyNode(this.dom);}
this.dom=null;},show:function(){if(!this.visible){this.visible=true;if(this.dom){GUI.show(this.dom);}
this.fireEvent('show',this);}},hide:function(){if(this.visible){this.visible=false;if(this.dom){GUI.hide(this.dom);}
this.fireEvent('hide',this);}},disable:function(flag){if((flag!==undefined)&&(!flag)){this.enable();}else{this.disabled++;if(this.disabled==1){this._disable();}}},_disable:function(){},enable:function(){if(this.disabled>0){this.disabled--;if(this.disabled==0){this._enable();}}},_enable:function(){},isEnabled:function(){return!this.disabled;},isDisabled:function(){return!!this.disabled;},getId:function(){return this.config.id;},getHolder:function(){return this.config.holder;},getHtml:function(){return this.config.html;},getVisibility:function(){var id=this.config.id;if($(id)){if(($(id).style.display==='none')||($(id).style.visibility==='hidden')){return false;}else{return true;}}
throw new Error(this.elementType+' error in method getVisibility(). Invalid id: '+id);},getDom:function(){return this.dom;},setHtml:function(html){this.config.html=html;},_render:function(to){if(!to){throw new Error('Can not render to:'+to);}
var div=document.createElement('SPAN');var cfg=this.config;to.appendChild(div);if(GUI.isString(cfg.id))
div.id=cfg.id;if(GUI.isString(cfg.html))
div.innerHTML=cfg.html;if(GUI.isString(cfg.className))
div.className=cfg.className;this.dom=div;if(!this.visible){GUI.hide(this.dom);}},attachEventListeners:function(){},removeEventListeners:function(){}};Object.extend(Element.prototype,superproto);Object.extend(Element.prototype,prototype);GUI.Element=Element;}());

(function(){var ActiveElement=Class.create(GUI.BoxComponent,{icon:'',iconClass:'',text:'',iconRight:'',iconRightClass:'',xtype:'',hint:'',mode:'auto',className:'x-activeelement x-tab',extraClass:'',focusClass:'x-tab-focused',pressedClass:'x-tab-pressed',hoverClass:'x-tab-hover',disabledClass:'x-tab-disabled',lCellClass:'x-tab-l',iconCellClass:'x-tab-icon',textCellClass:'x-tab-link',iconRightCellClass:'x-tab-list',rCellClass:'x-tab-r',linkClass:'jsgui-link',useImageSwitchingForDisabledState:true,clickEvent:'click',canToggle:false,toggled:false,initialize:function(config){if(config){if(!GUI.isSet(config.text)&&GUI.isSet(config.caption)){config.text=config.caption;delete config.caption;}
if(!GUI.isSet(config.icon)&&GUI.isSet(config.img)){config.icon=config.img;delete config.img;}}
ActiveElement.superclass.initialize.call(this,config);},initComponent:function(){ActiveElement.superclass.initComponent.call(this);this.addEvents({'click':true});if(this.xtype&&this.xtype.length>0){var btn;if(GUI.ButtonTypes&&(btn=GUI.ButtonTypes[this.xtype])){this.icon=btn.img||'';this.iconClass=btn.iconClass||'';this.text=btn.caption||'';this.iconRight=btn.iconRight||'';this.hint=btn.hint||'';}}},_getTemplate:function(hasIcon,hasText,hasRightIcon){return'<table id="{this.id}" class="{this.className} {this.extraClass}">'+'<tbody><tr><td unselectable="on" class="{this.lCellClass}"><div></div></td>'+
(hasIcon?('<td unselectable="on" class="{this.iconCellClass}">'+'<img {icon} src="'+GUI.emptyImageUrl+'"/></td>'):'')+
(hasText?'<td unselectable="on" class="{this.textCellClass}">'+'<a href="javascript:" class="caption {this.linkClass}">{this.text}</a></td>':'')+
(hasRightIcon?('<td unselectable="on" class="{this.iconRightCellClass}">'+'<img {iconRight} src="'+GUI.emptyImageUrl+'"/></td>'):'')+'<td unselectable="on" class="{this.rCellClass}"><div></div></td></tr></tbody></table>';},getSelf:function(){return ActiveElement;},_getCachedTemplate:function(hasIcon,hasText,hasRightIcon){var tplId=this.iconRight?4:0+
this.text?2:0+
(this.icon||this.iconClass)?1:0,c;if(!(c=this.getSelf()._tplCache[tplId])){return(this.getSelf()._tplCache[tplId]=this._getTemplate(hasIcon,hasText,hasRightIcon));}else{return c;}},onRender:function(){var tpl=this._getTemplate(this.icon||this.iconClass,this.text,this.iconRight||this.iconRightClass);tpl=new GUI.STemplate(tpl,this);tpl.icon=(this.iconClass&&this.iconClass.length)?('class="'+this.iconClass+'"'):('style="background-image: url(\''+this.icon+'\');"');tpl.iconRight=(this.iconRightClass&&this.iconRightClass.length)?('class="'+this.iconRightClass+'"'):('style="background-image: url(\''+this.iconRight+'\');"');tpl=tpl.fetch();return tpl;},onAfterRender:function(btn){ActiveElement.superclass.onAfterRender.call(this,btn);this.initButtonEl(btn);},onDestroy:function(fast){this.clsDom=this.captionEl=null;ActiveElement.superclass.onDestroy.call(this,fast);},initButtonEl:function(btn){this.dom=btn;this.clsDom=GUI.Dom.extend(btn.getElementsByTagName('tbody')[0]);if(!this.text.isEmpty()){this.captionEl=GUI.Dom.extend(this.clsDom.getElementsByTagName('a')[0]);this.captionEl.on('focus',this.onFocus,this);this.captionEl.on('blur',this.onBlur,this);}
if(this.hint){this.setHint(this.hint);}
if(this.canToggle&&this.toggled){this.clsDom.addClass(this.pressedClass);}
btn.on('mouseenter',this.onMouseEnter,this);btn.on('mouseleave',this.onMouseLeave,this);btn.on('mousedown',this.onMouseDown,this);btn.on(this.clickEvent,this.onClick,this);btn.on('click',this.preventDefaultEvent,this);GUI.unselectable(btn);},preventDefaultEvent:function(e){e=GUI.Event.extend(e);e.preventDefault();},removeEventListeners:function(){this.dom.un();if(this.captionEl){this.captionEl.un();}},setIcon:function(value){this.icon=value;if(this.dom){this.dom.findDescedents('td.'+this.iconCellClass)[0].firstChild.style.backgroundImage='url('+value+')';}},setIconClass:function(value){this.iconClass=value;if(this.dom){this.dom.findDescedents('td.'+this.iconCellClass)[0].firstChild.className=value;}},setText:function(value){this.text=value;if(this.captionEl){this.captionEl.innerHTML=value;}},setIconRight:function(value){this.iconRight=value;if(this.dom){this.dom.findDescedents('td.'+this.iconRightCellClass)[0].firstChild.style.backgroundImage='url('+value+')';}},setHint:function(value){this.hint=value;if(this.dom){this.dom.setAttribute('hint',value);}},toggle:function(state){if(!this.canToggle){return;}
if(!GUI.isSet(state)){state=!this.toggled;}
this.toggled=state;if(state){this.clsDom.addClass(this.pressedClass);}else{this.clsDom.removeClass(this.pressedClass);}
this.fireEvent('toggle',this,state);},getName:function(){return this.name;},onDisable:function(){this.clsDom.addClass(this.disabledClass);this.clsDom.removeClass(this.hoverClass);if(this.useImageSwitchingForDisabledState&&!this.icon.isEmpty()){var iconCell=this.dom.findDescedents('td.'+this.iconCellClass)[0];if(iconCell&&iconCell.firstChild){iconCell.firstChild.style.backgroundImage='url('+
GUI.getDisabledImageUrl(this.icon)+')';}else{console.log('No icon cell while having icon?',this);}}},onEnable:function(){this.clsDom.removeClass(this.disabledClass);if(this.useImageSwitchingForDisabledState&&!this.icon.isEmpty()){var iconCell=this.dom.findDescedents('td.'+this.iconCellClass)[0];if(iconCell&&iconCell.firstChild){iconCell.firstChild.style.backgroundImage='url('+this.icon+')';}else{console.log('No icon cell while having icon?',this);}}},onMouseDown:function(e){e=GUI.Event.extend(e);e.preventDefault();if(!this.disabled){if(!this.pressed){this.clsDom.addClass(this.pressedClass);document.on('mouseup',this.onMouseUp,this);this.pressed=true;}}},onMouseUp:function(e){if(!this.disabled){if(!this.toggled){this.pressed=false;this.clsDom.removeClass(this.pressedClass);}
document.un('mouseup',this.onMouseUp,this);}},onClick:function(e){e=GUI.Event.extend(e);if(!this.disabled){if(this.canToggle){this.toggle();}
this.fireEvent('click',this);}},onMouseEnter:function(e){if(!this.disabled){this.clsDom.addClass(this.hoverClass);}},onMouseLeave:function(e){this.clsDom.removeClass(this.hoverClass);},onFocus:function(e){if(!this.disabled){this.clsDom.addClass(this.focusClass);}},onBlur:function(e){this.clsDom.removeClass(this.focusClass);},caption:function(value){if(GUI.isSet(value)){this.setText(value);}else{return this.text;}},img:function(value){if(GUI.isSet(value)){this.setIcon(value);}else{return this.icon;}},isToggled:function(){return this.toggled;}});ActiveElement._tplCache=new Array(8);GUI.ActiveElement=ActiveElement;}());

GUI.Popup={};

GUI.Popup.Region=Class.create();GUI.Popup.Region.startzIndex=10000;GUI.Popup.Region.zIndexCounter=GUI.Popup.Region.startzIndex;GUI.Popup.Region.getzIndex=function(){var val=GUI.Popup.Region.zIndexCounter;GUI.Popup.Region.zIndexCounter+=5;return val;}
Object.extend(Object.extend(GUI.Popup.Region.prototype,GUI.Utils.Draggable.prototype),{paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,borderLeft:0,borderRight:0,borderTop:0,borderBottom:0,initialize:function(config){GUI.Utils.Draggable.prototype.initialize.apply(this,arguments);var cfg=this.config;Object.extend(cfg,{parentNode:null,content:'',id:GUI.getUniqId('x-region-'),className:'x-region',dimensions:{top:0,left:0},padding:'',border:'',useShim:false});Object.extend(cfg,config);this.visible=false;this.alignArgs=[];this.setPadding(cfg.padding);this.setBorder(cfg.border);this.addEvents({show:true,beforeHide:true,hide:true});},destroy:function(){if(this.visible){this.hide();}
this.config.parentNode=null;},setPadding:function(str){var t,r,b,l,arr=str.split(' ',4);t=r=b=l=0;t=arr[0]||0;r=(arr[1]==null)?t:arr[1];b=(arr[2]==null)?t:arr[0];l=(arr[3]==null)?(arr[1]==null?t:r):arr[0];this.paddingLeft=l-0;this.paddingRight=r-0;this.paddingTop=t-0;this.paddingBottom=b-0;},setBorder:function(str){var t,r,b,l,arr=str.split(' ',4);t=r=b=l=0;t=(arr[0]==null||arr[0]=='')?0:arr[0];r=(arr[1]==null)?t:arr[1];b=(arr[2]==null)?t:arr[0];l=(arr[3]==null)?(arr[1]==null?t:r):arr[0];this.borderLeft=l-0;this.borderRight=r-0;this.borderTop=t-0;this.borderBottom=b-0;},alignTo:function(id,pos,offset){if(this.dom){this._alignTo(id,pos,offset);}else{this.alignArgs=GUI.toArray(arguments);}},show:function(){var cfg=this.config;var style;if(!this.visible){var node=document.createElement('div');node.id=cfg.id;node.style.position='absolute';node.className=cfg.className;GUI.hide(node);if(!cfg.parentNode){cfg.parentNode=document.body;}
cfg.parentNode.appendChild(node);node.innerHTML=cfg.content;this.dom=GUI.Dom.extend(node);this.visible=true;node=null;}
var dim=cfg.dimensions;var style=this.dom.style;this.setDimensions(dim);style.zIndex=cfg.zIndex||GUI.Popup.Region.getzIndex();this.dom.style.visibility='hidden';GUI.show(this.dom);if((GUI.isSet(this.alignArgs))&&(this.alignArgs.length>0)){this._alignTo.apply(this,this.alignArgs);this.alignArgs=[];}
this.dom.style.visibility='';this.fireEvent('show',this);if(cfg.useShim){if(!this.shim){this.createShim();}else{GUI.show(this.shim);}
setTimeout(function(){this.syncShim();}.bind(this),10);}},hide:function(){if(this.visible){if(this.fireEvent('beforeHide',this)===false){return;}
if(this.shim){GUI.hide(this.shim);}
this.visible=false;this.fireEvent('hide',this);}
if(this.dom){GUI.destroyNode(this.dom);this.dom=null;}},hideByOffset:function(){var cfg=this.config;this._oldPosition=[cfg.dimensions.left,cfg.dimensions.top];this.setDimensions({top:-10000});},showByOffset:function(){if(this._oldPosition){this.setDimensions({left:this._oldPosition[0],top:this._oldPosition[1]});delete this._oldPosition;}},takeRegion:function(id){var cfg=this.config;var dim=cfg.dimensions;var elem=$(id);var pos=GUI.getPosition(elem);var elemDim=elem.getDimensions();dim.left=pos[0];dim.top=pos[1];dim.height=elemDim.height;dim.width=elemDim.width;this.setDimensions(dim);if(this.visible){}},takeDocument:function(extend){var cfg=this.config;var dim=cfg.dimensions;dim.left=0;dim.top=0;if(this.dom){this.dom.setStyle({left:'0px',top:'0px',width:'100%',height:'100%'});}
dim.height=GUI.getDocumentHeight();dim.width=GUI.getDocumentWidth();if(this.dom){this.dom.setStyle({left:'0px',top:'0px',width:dim.width+'px',height:dim.height+'px'});}},setContent:function(content){this.config.content=content;if(this.visible){this.dom.innerHTML=content;}},adjustWidth:function(w){if(!GUI.isBorderBox){w-=this.paddingLeft+this.paddingRight+this.borderLeft+this.borderRight;}
return w;},adjustHeight:function(h){if(!GUI.isBorderBox){h-=this.paddingTop+this.paddingBottom+this.borderTop+this.borderBottom;}
return h;},setDimensions:function(dimensions){Object.extend(this.config.dimensions,Object.clone(dimensions));if(this.dom){var style=this.dom.style;if(GUI.isNumber(dimensions.left)){style.left=dimensions.left+'px';}else if(GUI.isString(dimensions.left)){style.left=dimensions.left;}
if(GUI.isNumber(dimensions.top)){style.top=dimensions.top+'px';}else if(GUI.isString(dimensions.top)){style.top=dimensions.top;}
if(GUI.isNumber(dimensions.width)){style.width=this.adjustWidth(dimensions.width)+'px';}else if(GUI.isString(dimensions.width)){style.width=dimensions.width;}
if(GUI.isNumber(dimensions.height)){style.height=this.adjustHeight(dimensions.height)+'px';}else if(GUI.isString(dimensions.height)){style.height=dimensions.height;}}},setPosition:function(x,y){var dims=this.config.dimensions,style=this.dom&&this.dom.style;if(x!==undefined){dims.left=x;if(style){style.left=GUI.isNumber(x)?x+'px':x;}}
if(y!==undefined){dims.top=y;if(style){style.top=GUI.isNumber(y)?y+'px':y;}}},getWidth:function(){return this.dom?this.dom.offsetWidth:this.config.dimensions.width;},getDimensions:function(){var xy=GUI.getPosition(this.dom);var dim=GUI.getDimensions(this.dom);var cfgDim=this.config.dimensions;cfgDim.left=xy[0];cfgDim.top=xy[1];cfgDim.width=dim.width;cfgDim.height=dim.height;return{left:cfgDim.left,top:cfgDim.top,width:cfgDim.width,height:cfgDim.height};},getElement:function(){return this.dom;},getDom:function(){return this.dom;},setZIndex:function(zIndex){this.config.zIndex=zIndex;if(this.visible){this.dom.style.zIndex=zIndex;}},getVisibility:function(){return this.visible;},_alignTo:function(id,pos,offset){var c=false;var p1="",p2="";offset=offset||[0,0];if(!pos){pos="tl-bl";}else if(pos=="?"){pos="tl-bl?";}else if(pos.indexOf("-")==-1){pos="tl-"+pos;}
pos=pos.toLowerCase();var m=pos.match(/^([a-z]+)-([a-z]+)(\?)?$/);if(!m){throw new Error("Element.alignTo with an invalid alignment "+pos);}
p1=m[1];p2=m[2];c=!!m[3];var elem=$(id);var dim=this.config.dimensions;var a1=this.getAnchorXY(this.dom,p1,true);var a2=this.getAnchorXY(elem,p2,false);var x=a2[0]-a1[0]+offset[0];var y=a2[1]-a1[1]+offset[1];var swapX=false,swapY=false;if(c){var w=GUI.getFullWidth(this.dom);var h=GUI.getFullHeight(this.dom);var r=this.getRegion(elem);var dw=GUI.getViewportWidth(elem),dh=GUI.getViewportHeight(elem);var p1y=p1.charAt(0),p1x=p1.charAt(p1.length-1);var p2y=p2.charAt(0),p2x=p2.charAt(p2.length-1);var swapY=((p1y=="t"&&p2y=="b")||(p1y=="b"&&p2y=="t"));var swapX=((p1x=="r"&&p2x=="l")||(p1x=="l"&&p2x=="r"));var doc=document;var scrollX=(doc.documentElement.scrollLeft||doc.body.scrollLeft||0);var scrollY=(doc.documentElement.scrollTop||doc.body.scrollTop||0);if((x+w)>dw){x=swapX?(r.left-w):(dw+scrollX-w);x-=offset[0];}
if((x+w)>dw+scrollX){x=swapX?(r.left-w):(dw+scrollX-w);x-=offset[0];}
if(x<scrollX){x=swapX?r.right:scrollX;x+=offset[0];}
if((y+h)>dh+scrollY){y=swapY?(r.top-h):(dh+scrollY-h);y-=offset[1];}
if(y<scrollY){y=swapY?r.bottom:scrollY;y+=offset[1];}}
var xy=GUI.getLocalCoordinates(this.config.parentNode,[x,y]);x=xy[0];y=xy[1];dim.left=x;dim.top=y;this.dom.setStyle({left:x+'px',top:y+'px'});},getRegion:function(elem){var pos=GUI.getPosition(elem);var dim=GUI.getDimensions(elem);return{left:pos[0],top:pos[1],right:pos[0]+dim.width,bottom:pos[1]+dim.height};},getAnchorXY:function(elem,anchor,local,size){var dim=this.config.dimensions;var w,h,vp=false;if(!size){if(elem==document.body||elem==document){vp=true;w=GUI.getViewportWidth(elem);h=GUI.getViewportHeight(elem);}else{var _dim=GUI.getDimensions(elem);w=_dim.width;h=_dim.height;}}else{w=size.width;h=size.height;}
var x=0,y=0,r=Math.round;switch((anchor||"tl").toLowerCase()){case"c":x=r(w*0.5);y=r(h*0.5);break;case"t":x=r(w*0.5);y=0;break;case"l":x=0;y=r(h*0.5);break;case"r":x=w;y=r(h*0.5);break;case"b":x=r(w*0.5);y=h;break;case"tl":x=0;y=0;break;case"bl":x=0;y=h;break;case"br":x=w;y=h;break;case"tr":x=w;y=0;break;}
if(local===true){return[x,y];}
if(vp){var sc=GUI.getScroll(elem);return[x+sc.left,y+sc.top];}
var o=GUI.getPosition(elem);;return[x+o[0],y+o[1]];},createShim:function(){var iframe=document.createElement('iframe');iframe.className='x-shim';iframe.frameBorder='no';this.dom.parentNode.insertBefore(iframe,this.dom);this.shim=iframe;},syncShim:function(){if(this.dom){this.shim.style.left=this.dom.offsetLeft+'px';this.shim.style.top=this.dom.offsetTop+'px';this.shim.style.width=this.dom.offsetWidth+'px';this.shim.style.height=this.dom.offsetHeight+'px';}}});

(function(){var Dialog=Class.create();var superproto=GUI.Popup.Region.prototype;var prototype={imgPath:window.JSGUI_IMAGES_PATH+'x-dialog/',dialogTemplate:'<table class="x-dialog-holder"><tbody><tr class="dialog-title">'+'<td class="dialog-topl"><div class="dialog-topl"></div></td>'+'<td class="dialog-header"><div class="container">'+'<div id="{this.titleId}" class="title">'+'<span class="dialog-header shadow">{title}</span>'+'<span class="dialog-header txt">{title}</span>'+'</div><div class="ico">'+'<div class="ico-container" id="{this.iconsBarId}">'+'</div></div><div class="clear"></div></td>'+'<td class="dialog-topr"><div class="dialog-topr"></div></td></tr>'+'{toolbar}'+'<tr class="dialog-content"><td class="dialog-mdll"><div></div></td>'+'<td class="dialog-mdlc"><div class="dialog-content-holder" id="{this.contentId}" >'+'{content}'+'</div></td><td class="dialog-mdlr"><div></div></td></tr>'+'<tr class="dialog-bottom">'+'<td class="dialog-btml"><div class="dialog-bottom dialog-btml"></div></td>'+'<td class="dialog-btmc"><div class="dialog-bottom dialog-btmc"></div></td>'+'<td class="dialog-btmr"><div class="dialog-bottom dialog-btmr"></div></td>'+'</tr></tbody></table>',toolbarTemplate:'<tr class="dialog-tools"><td colspan="3" class="dialog-tools">'+'<div class="dialog-tools-l"><div class="dialog-tools-r"><div class="dialog-tools-c">'+'<div id="{this.toolbarId}" class="dialog-tools-container"></div></div></div></div></td></tr>',initialize:function(config){this.types={error:'x-dialog-type-error',information:'x-dialog-type-info'};var defCfg={id:GUI.getUniqId('x-dialog-'),cls:'x-dialog',modal:false,title:'',toolbuttons:[{name:'close',img:this.imgPath+'x-dialog-ico-close.gif'}],dimensions:{left:0,top:0},constrainViewport:true,zIndex:5000,visible:false,animate:window.GUI_FX_ANIMATION==true,toolbar:null,toolbarHeight:25,dd:{linkedElId:null,dragElId:null,handleElId:null,isTarget:true,moveOnly:true,groups:{'dialog':true},enableDrag:false,dropReciever:false,dragType:''},alwaysOnTop:false,minimizeClass:'x-dialog-minimized',maximizeClass:'x-dialog-maximized',autoDestroy:false,allowScrollbars:true,closeOnEsc:true,autoCenter:true};Object.extend(defCfg,config);defCfg.dd.linkedElId=defCfg.id;var titleId=GUI.getUniqId('x-dialog-title-');defCfg.dd.handleElId=titleId;superproto.initialize.call(this,defCfg);Object.extend(this.config,defCfg);var cfg=this.config;if(GUI.isIE){cfg.animate=false;}
this.WM=GUI.Utils.WM;this.elementType='GUI.Popup.Dialog';this.alignArgs=null;this.visible=cfg.visible;this.scrollable=false;this.state='normal';this.toolbarId=GUI.getUniqId('x-dialog-toolbar-');this.iconsBarId=GUI.getUniqId('x-dialog-iconsbar-');this.topId=GUI.getUniqId('x-dialog-top-');this.centerId=GUI.getUniqId('x-dialog-center-');this.bottomId=GUI.getUniqId('x-dialog-bottom-');this.contentId=GUI.getUniqId('x-dialog-content-');this.titleId=titleId;this.glass=null;this.rendered=false;this.restoreDimensions=null;this.closeOnHide=false;this.alwaysOnTop=cfg.alwaysOnTop;this.beforeLimitDim={};this.originalDim={};this.defHandlers={close:this.close,minimize:this.minimize,maximize:this.maximize,restore:this.restore};var tb=this.config.toolbuttons;if((typeof this.config.maximizable==='undefined')&&GUI.isArray(tb)){var i=tb.length;while(i--){var tbItem=tb[i];if(tbItem.name=='maximize'){this.config.maximizable=true;break;}}}
this.addEvents({close:true,dialogAction:true,resize:true,beforeClose:true,restore:true,maximize:true});if(!GUI.isSet(this.config.dimensions.width)){this.config.dimensions.width='';}
if(!GUI.isSet(this.config.dimensions.height)){this.config.dimensions.height='';}
if(cfg.type){var t=this.types[cfg.type];if(t){cfg.typeClass=t;}}},create:function(){var cfg=this.config;if(!cfg.parentNode){cfg.parentNode=document.body;}
if(GUI.isArray(cfg.toolbar)){if(!GUI.isSet(cfg.toolbarHeight)){throw new Error('Dialog: You have to specify toolbarHeight when using toolbar!');}
this.toolbar=new GUI.ToolBar({align:'none',elements:cfg.toolbar});}else{cfg.toolbarHeight=0;}
if(this.config.modal){var maskZIndex=(GUI.isNumber(cfg.zIndex))?cfg.zIndex-1:GUI.Popup.Region.getzIndex();this.glass=new GUI.Popup.Region({parentNode:cfg.parentNode,zIndex:maskZIndex,content:'<div class="glass">&nbsp</div>'});this.glass.takeDocument(true);}
var tpl=new GUI.STemplate(this.dialogTemplate,this);tpl.title=cfg.title;if(this.toolbar){var toolbarTpl=new GUI.STemplate(this.toolbarTemplate,this);tpl.toolbar=toolbarTpl.fetch();}else{tpl.toolbar='';}
if(typeof cfg.content=='string'){tpl.content=cfg.content;}else if(cfg.content.innerHTML!==undefined){tpl.content=cfg.content.innerHTML;}else{throw new Error(this.elementType+' create() error: cfg.content is not string or domnode!');}
var node=document.createElement('div');node.id=cfg.id;node.style.position='absolute';node.style.zIndex=cfg.zIndex||GUI.Popup.Region.getzIndex();node.className=cfg.cls;GUI.hide(node);if(GUI.isIE){cfg.parentNode.appendChild(node);node.innerHTML=tpl.fetch();}else{node.innerHTML=tpl.fetch();cfg.parentNode.appendChild(node);}
if(cfg.typeClass){GUI.Dom.extend(node.firstChild).addClass(cfg.typeClass);}
this.dom=GUI.Dom.extend(node);var a=document.createElement('a');a.className='jsgui-dialog-focuslink';a.href='#';a.tabIndex=-1;node.appendChild(a);a.innerHTML='&#160;';this.focusEl=a;if(this.scrollable){GUI.$(this.contentId).style.overflow='auto';}
this.toolBox=new GUI.ToolBox({items:this.config.toolbuttons,scope:this,onClick:this.onToolBoxClick});this.toolBox.render($(this.iconsBarId));if(this.toolbar){this.toolbar.render($(this.toolbarId));}
this.attachEvents();GUI.unselectable(this.dom.getElementsByTagName('tr')[0]);this.initDD();this.setHandleElId(this.titleId);this.WM.register(this);this.rendered=true;this.fireEvent('create',this);this.setDimensions(cfg.dimensions);if(this.config.animate){this.initFx();}
if(this.visible){this.show();}},initFx:function(){this.fadeEf=new Animator({duration:500,scope:this,onComplete:this.onFadeEfComplete});this.fadeEf.addSubject(new NumericalStyleSubject(this.dom,'opacity',0.1,1));this.fadeClose=new Animator({duration:500,scope:this,onComplete:this.onFadeCloseComplete});this.fadeEf.addSubject(new NumericalStyleSubject(this.dom,'opacity',0.1,1));},onFadeEfComplete:function(fx){if(fx.state){this._show();}else{this._hide();}},onFadeCloseComplete:function(fx){this._close();},unrender:function(){if(this.rendered){this.WM.unregister(this);this.destroyDD();this.removeEvents();if(this.fadeEf){this.fadeEf.destroy();}
if(this.toolBox){this.toolBox.unrender();}
if(this.toolbar){this.toolbar.unrender();}
if(this.glass&&this.glass.dom){this.glass.hide();}
GUI.destroyNode(this.dom);this.dom=this.focusEl=null;this.rendered=false;}},destroy:function(){if(this.fadeEf){this.fadeEf.destroy();}
if(this.glass){this.glass.destroy();}
if(this.dragProxy){this.dragProxy.destroy();this.dragProxy=null;}
if(this.toolBox){this.toolBox.destroy(true);this.toolBox=null;}
if(this.toolbar){this.toolbar.destroy(true);this.toolbar=null;}
if(this.rendered){this.WM.unregister(this);this.destroyDD();this.removeEvents();GUI.destroyNode(this.dom);this.dom=this.focusEl=null;this.rendered=false;}
this.purgeListeners();},setContent:function(content){if(GUI.isString(content)){this.config.content=content;if(this.dom){GUI.$(this.contentId).innerHTML=content;}}else if(GUI.isString(content.innerHTML)){GUI.$(this.contentId).innerHTML=content.innerHTML;}},appendContent:function(content){if(GUI.isString(content)){GUI.$(this.contentId).innerHTML+=content;}else if(GUI.isObject(content)){GUI.$(this.contentId).appendChild(content);}},setTitle:function(title){this.config.title=title;if(this.dom){var div=GUI.$(this.titleId);div.childNodes[0].innerHTML=title;div.childNodes[1].innerHTML=title;}},close:function(retVal){this.returnValue=retVal;if(this.fireEvent('beforeClose',this)===false){return;}
if(this.config.animate){var self=this;this.closeOnHide=true;this.hide();}else{this._close();}},_close:function(){GUI.hide(this.dom);this.removeSizeLimits();this.toBack();if(this.glass){this.glass.hide();}
this.fireEvent('hide',this);this.fireEvent('close',this,this.returnValue);if(this.unrender){this.unrender();}
if(this.config&&this.config.autoDestroy){this.destroy();}},saveDimensions:function(){this.restoreDimensions=this.getDimensions();if(!GUI.isSet(this.config.dimensions.height)){this.restoreDimensions.height='';}
if(!GUI.isSet(this.config.dimensions.width)){this.restoreDimensions.width='';}},maximize:function(){if(this.state=='maximized'){return;}
if(this.state=='minimized'){this.toolBox.showItem('minimize');this.dom.removeClass(this.config.minimizeClass);}else{this.removeSizeLimits();this.saveDimensions();}
var vw=GUI.getViewportWidth(),vh=GUI.getViewportHeight(),dim={left:0,top:0,width:vw,height:vh};this.dom.addClass(this.config.maximizeClass);this.state='maximized';this.setDimensions(dim);this.disableDD();this.toolBox.hideItem('maximize');this.toolBox.showItem('restore');this.onWindowResize(vw,vh);this.fireEvent('maximize',this);},getContentId:function(){return this.contentId;},minimize:function(){if(this.state=='minimized'){return;}
if(this.state=='normal'){this.saveDimensions();}else{this.toolBox.showItem('maximize');this.dom.removeClass(this.config.maximizeClass);this.enableDD();}
this.state='minimized';this.setDimensions({width:'auto',height:'auto'});this.dom.addClass(this.config.minimizeClass);this.center();this.toolBox.hideItem('minimize');this.toolBox.showItem('restore');},restore:function(){if(this.state=='normal'){return;}
this.toolBox.hideItem('restore');if(this.state=='minimized'){this.dom.removeClass(this.config.minimizeClass);this.config.dimensions=this.getDimensions();this.toolBox.showItem('minimize');}else if(this.state=='maximized'){this.dom.removeClass(this.config.maximizeClass);this.toolBox.showItem('maximize');$(this.contentId).style.height='';this.enableDD();}
this.state='normal';this.setDimensions(this.restoreDimensions);this.onWindowResize(GUI.getViewportWidth(),GUI.getViewportHeight());this.fireEvent('restore',this);},toFront:function(){if(this.WM.bringToFront(this)){}},toBack:function(){this.WM.sendToBack(this);},setActive:function(active){},deferShow:function(){this.show.defer(10,this);},show:function(animateFrom){this.dom.style.visibility='hidden';GUI.show(this.dom);this.visible=true;if(this.config.autoCenter){this.alignTo(document.body,'c-c');}
if(this.config.modal){this.glass.show();GUI.unselectable(this.glass.dom);}
this.toFront();if(this.config.animate){GUI.setOpacity(this.dom,0);this.dom.style.visibility='';this.deferFocus();this.fadeEf.seekTo(1);}else{this.dom.style.visibility='';this.deferFocus();this._show();}
this.onWindowResize(GUI.getViewportWidth(),GUI.getViewportHeight());},_show:function(){this.fireEvent('show',this);},hide:function(){this.visible=false;if(this.config.animate){this.fadeEf.seekTo(0);}else{this._hide();}},_hide:function(){if(this.closeOnHide){this.closeOnHide=false;return this._close();}
if(this.config.modal){this.glass.hide();}
GUI.hide(this.dom);this.removeSizeLimits();this.toBack();this.fireEvent('hide',this);},setDim:function(node,dim,val){var style=node.style;if(GUI.isNumber(val)){if(dim=='width'){node.style.width=this.adjustWidth(val)+'px';}else if(dim=='height'){node.style.height=this.adjustHeight(val)+'px';}else{style[dim]=val+'px';}}else if(GUI.isString(val)){style[dim]=val;}},getContentHeightFromFull:function(h){if(this.state=='maximized'){h=h-28-8-this.config.toolbarHeight;}else{h=h-28-14-this.config.toolbarHeight;}
return(h>0)?h:0;},getContentWidthFromFull:function(w){w-=(this.state=='maximized')?16:20;return w.constrain(0);},adjustContentWidth:function(cw){return cw;},adjustContentHeight:function(cw){return cw;},setDimensions:function(dim){Object.extend(this.config.dimensions,Object.clone(dim));if(this.dom){for(var name in dim){this.setDim(this.dom,name,dim[name]);}
var node=$(this.contentId);if(GUI.isNumber(dim.width)){var w=this.getContentWidthFromFull(dim.width);w=this.adjustContentWidth(w);this.setDim(node,'width',(w<0)?0:w);}else if(GUI.isString(dim.width)){this.setDim(node,'width',dim.width);}
if(GUI.isNumber(dim.height)){var h=this.getContentHeightFromFull(dim.height);h=this.adjustContentHeight(h);this.setDim(node,'height',h);}else if(GUI.isString(dim.height)){this.setDim(node,'height',dim.height);}
this.fireEvent('resize',this);}else{this.fireEvent('resize',this);}},getZIndex:function(){return this.config.zIndex;},setZIndex:function(value){this.config.zIndex=value;if(this.dom){if(this.config.modal){this.glass.setZIndex(value-1);}
this.dom.style.zIndex=value;}},focus:function(){try{this.focusEl.focus();}catch(e){}},deferFocus:function(){this.focus.defer(20,this);},attachEvents:function(){GUI.Event.onWindowResize(this.onWindowResize,this);this.dom.on('mousedown',this.onMouseDown,this);if(this.config.maximizable){GUI.$(this.titleId).on('dblclick',this.onTitleDblClick,this);}},removeEvents:function(){GUI.Event.unWindowResize(this.onWindowResize,this);this.dom.un('mousedown',this.onMouseDown,this);if(this.config.maximizable){GUI.$(this.titleId).un('dblclick',this.onTitleDblClick,this);}},onTitleDblClick:function(){switch(this.state){case'minimized':case'maximized':this.restore();break;case'normal':this.maximize();break;}},onMouseDown:function(e){this.toFront();},onToolBoxClick:function(tb,item){if(!this.fireEvent('dialogAction',this,item.name)){return;}
if(typeof this.defHandlers[item.name]=='function'){this.defHandlers[item.name].call(this);}},onWindowResize:function(vw,vh){var newDim={};if(this.state=='maximized'){newDim.width=vw-1;newDim.height=vh;if(GUI.isIE){}}else{var w=this.dom.offsetWidth,h=this.dom.offsetHeight;if(w>vw){newDim.width=vw;if(this.beforeLimitDim.width==null){this.beforeLimitDim.width=w;this.originalDim.width=this.config.dimensions.width||'';}}else if(w<vw){if(this.beforeLimitDim.width!=null){if(vw<this.beforeLimitDim.width){newDim.width=vw;}else{newDim.width=this.originalDim.width;delete this.beforeLimitDim.width;delete this.originalDim.width;}}}
if(h>vh){newDim.height=vh;if(this.beforeLimitDim.height==null){this.beforeLimitDim.height=h;this.originalDim.height=this.config.dimensions.height||'';}}else if(h<vh){if(this.beforeLimitDim.height!=null){if(vh<this.beforeLimitDim.height){newDim.height=vh;}else{newDim.height=this.originalDim.height;delete this.beforeLimitDim.height;delete this.originalDim.height;}}}}
this.setDimensions(newDim);var node=GUI.$(this.contentId),cw=node.offsetWidth,ch=node.offsetHeight,csw=node.scrollWidth,csh=node.scrollHeight;if(this.config.allowScrollbars){if(csw>cw||csh>ch){if(!this.scrollable){node.style.overflow="auto";this.scrollable=true;}}else{if(this.scrollable){node.style.overflow='';this.scrollable=false;}}}
if((this.state!='maximized')&&this.config.autoCenter){this.center();}
if(this.config.modal){this.glass.takeDocument(true);}},removeSizeLimits:function(){var originalSize={};if(this.beforeLimitDim.width){originalSize.width=this.originalDim.width;delete this.beforeLimitDim.width;delete this.originalDim.width;}
if(this.beforeLimitDim.height){originalSize.height=this.originalDim.height;delete this.beforeLimitDim.height;delete this.originalDim.height;}
this.setDimensions(originalSize);},onKeyDown:function(e){},onKeyUp:function(e){if(this.config.closeOnEsc){e=GUI.Event.extend(e);if(e.getKey()==e.KEY_ESC){this.close();}}},onKeyPress:function(e){},center:function(){this._alignTo(document.body,'c-c');},onDragStart:function(){var cfg=this.config;if(!this.dragProxy){this.dragProxy=new GUI.Popup.Region({className:'x-window-proxy',zIndex:this.config.zIndex+5});}
this.dragProxy.takeRegion(this.dom.firstChild);this.hideByOffset();this.dragProxy.show();if(cfg.constrainViewport){var dims=this.getDimensions();this.maxX=GUI.getViewportWidth()-dims.width;this.maxY=GUI.getViewportHeight()-dims.height;}},onDrag:function(e){var xy=e.getPageXY(),x=xy[0],y=xy[1],style=this.dragProxy.dom.style;x-=this.DDM.deltaX;y-=this.DDM.deltaY;if(this.config.constrainViewport){x=x.constrain(0,this.maxX);y=y.constrain(0,this.maxY);}
style.left=x+'px';style.top=y+'px';},onDragEnd:function(e){if(e){var xy=e.getPageXY(),x=xy[0],y=xy[1];x-=this.DDM.deltaX;y-=this.DDM.deltaY;if(this.config.constrainViewport){x=x.constrain(0,this.maxX);y=y.constrain(0,this.maxY);}
this.setDimensions({left:x,top:y});}
this.dragProxy.hide();}};Object.extend(Dialog.prototype,superproto);Object.extend(Dialog.prototype,prototype);GUI.Popup.Dialog=Dialog;}());

(function()
{var MessageBox=Class.create();var superproto=GUI.Popup.Dialog.prototype;var prototype={imgPath:window.JSGUI_IMAGES_PATH+'x-messagebox/',initialize:function(config){var defCfg={id:GUI.getUniqId('x-messagebox-'),modal:true,type:'error',title:'',text:'',toolbuttons:[{name:'close',title:"Close\nCloses window",img:this.imgPath+'../x-dialog/x-dialog-ico-close.gif'}],buttons:[],buttonsAlign:'center',contentcls:'jsgui-messagebox-text',dimensions:{top:-10000},visible:false,animate:window.GUI_FX_ANIMATION==true};Object.extend(defCfg,config);superproto.initialize.call(this,defCfg);Object.extend(this.config,defCfg);var cfg=this.config;this.types={error:'x-dialog-type-error',information:'x-dialog-type-info',confirmation:'x-dialog-type-info x-dialog-type-confirmation'};this.elementType='GUI.Popup.MessageBox';this.buttonsHolderId=GUI.getUniqId('buttons-holder-');this.textId=GUI.getUniqId('text-holder-');this.defHandlers={close:this.close}
var typeCls=this.types[cfg.type];var html='';if(typeCls){cfg.typeClass=typeCls;html+='<div class="jsgui-messagebox-icon"></div><div id="'
+this.textId+'" class="'+cfg.contentcls+'">'+cfg.text+'</div>';}else{html='<div class="'+cfg.contentcls+'" id="'+this.textId+'">'+cfg.text+'</div>';}
html+='<div class="jsgui-clear"></div>';if(GUI.isArray(cfg.buttons)&&cfg.buttons.length){html+='<div class="buttons-holder" id="'+this.buttonsHolderId+'"></div>';}
cfg.content=html;},destroy:function(){if(this.rendered){this.unrender();}
if(this.btnToolbar){this.btnToolbar.destroy(true);}
superproto.destroy.call(this);},unrender:function(){if(this.btnToolbar){this.btnToolbar.unrender(true);}
superproto.unrender.call(this);},create:function(){superproto.create.call(this);var cfg=this.config;if(GUI.isArray(cfg.buttons)&&cfg.buttons.length){this.btnToolbar=new GUI.ToolBar({position:'horizontal',align:cfg.buttonsAlign,className:'x-toolbar form-buttons'});for(var b,i=0;i<cfg.buttons.length;i++){b=cfg.buttons[i];this.btnToolbar.add(b.name,new GUI.ToolBar.Button(b));}
this.btnToolbar.render(this.buttonsHolderId);}},close:function(btn){if(!GUI.isSet(btn)){btn='close';}
if(this.config.animate){var self=this;this.fadeEf.options.onComplete=function(){self._close(btn);}
this.fadeEf.seekTo(0);}else{this._close(btn);}},setText:function(text){this.config.text=text;if(this.dom){$(this.textId).innerHTML=text;}},_close:function(btn){this.toBack();if(this.glass){this.glass.hide();}
this.fireEvent('hide',this);this.fireEvent('close',this,btn);if(this.unrender){this.unrender();}
if(this.config&&this.config.autoDestroy){this.destroy();}},adjustContentWidth:function(cw){return GUI.isBorderBox?cw:cw-20;},adjustContentHeight:function(cw){return GUI.isBorderBox?cw:cw-25;}};Object.extend(MessageBox.prototype,superproto);Object.extend(MessageBox.prototype,prototype);GUI.Popup.MessageBox=MessageBox;}());

(function()
{var Hint=Class.create({className:'x-region x-hint',delay:50,followMouse:false,visible:false,template:'<table><tbody><tr><td><div class="x-hint">'+'<div class="hint-top"><div class="hint-r">'+'<div class="hint-c"></div></div></div>'+'<div class="hint-mdl"><div class="hint-r">'+'<div class="hint-c"><div class="hint-data"{0}>'+'<span>{1}</span>{2}</div></div></div></div><div class="hint-btm">'+'<div class="hint-r"><div class="hint-c"></div></div></div>'+'</div></td></tr></tbody></table>',initialize:function(){},init:function(){var dom=document.createElement('div');dom.className=this.className+' x-hide-offsets';document.body.appendChild(dom);this.dom=GUI.Dom.extend(dom);this.attachEventListeners();},destroy:function(){if(this.dom){this.removeEventListeners();GUI.destroyNode(this.dom);this.dom=null;}},renderHint:function(hint){if(!GUI.isString(hint.caption)){hint.caption='';}
return this.template.formatArr([GUI.isNumber(hint.contentHeight)?(' style="height: '+hint.contentHeight+'px"'):'',hint.caption,(hint.text&&hint.text.length)?('<p>'+hint.text.replace(/(\r?\n)/g,'<br />')+'</p>'):'']);},add:function(node,caption,text){var hint=caption;if(text&&text.length){hint+='\n'+text;}
if(hint&&hint.length){node.setAttribute('hint',hint);}else if(node.getAttribute('hint')){if(GUI.isIE){node.hint=null;}else{node.removeAttribute('hint');}}},has:function(node){var hint;if(GUI.isIE){hint=node.hint;}else{hint=node.getAttribute('hint');}
return GUI.isString(hint)&&hint.length;},get:function(node){var hint=(GUI.isIE)?node.hint:node.getAttribute('hint');var firstCr=hint.indexOf('\n');var caption=hint.substring(0,firstCr);var text=hint.substring(firstCr+1);if(hint&&hint.length){return{caption:caption,text:text};}
return false;},show:function(t){this._hintTarget=t;var hint=this.get(t);this.dom.innerHTML=this.renderHint(hint);var s=this.dom.style;this.dom.visibility='hidden';this.setPosition(0,0);this.type=t.getAttribute('hinttype')||'hint';this.followMouse=t.getAttribute('followmouse')||false;var div=this.dom.findDescedent('div.hint-data');div.style.width='';var maxWidth=t.getAttribute('hintmaxwidth');if(maxWidth){maxWidth=parseInt(maxWidth,10);}
if(!maxWidth){maxWidth=(this.type=='help')?250:1000;}
if(div.offsetWidth>maxWidth){maxWidth-=23;maxWidth=maxWidth.constrain(0);div.style.width=maxWidth+'px';}
this._updatePosition();this.dom.visibility='';this.visible=true;},_updatePosition:function(){var vw=GUI.getViewportWidth(),vh=GUI.getViewportHeight(),scroll=GUI.getScroll(GUI.getBody()),x,y,t=this._hintTarget,type=t.getAttribute('hinttype')||'hint';;var w=this.dom.offsetWidth;if(type=='hint'){var h=this.dom.offsetHeight;x=(this.pointerX+w>vw)?vw-w:this.pointerX;y=(this.pointerY+21+h>vh)?this.pointerY-h:this.pointerY+21;}else if(type=='help'){var pos=GUI.getPosition(t),targetWidth=t.offsetWidth,offsetX=3;y=pos[1]-2;if(pos[0]+targetWidth+offsetX+w<=vw){x=pos[0]+targetWidth+offsetX;}else if(pos[0]-w-offsetX>=0){x=pos[0]-w-offsetX;}else{x=vw-w;}}
x+=scroll.left;y+=scroll.top;this.setPosition(x,y);},hide:function(){this.setPosition(0,-10000);this.visible=false;},onScroll:function(){if(this.visible){this.hide();}},attachEventListeners:function(){var elem=GUI.getBody();GUI.Dom.extend(elem);elem.on('mousedown',this.onMouseDown,this);elem.on('mousemove',this.onMouseMove,this);elem.on('mouseover',this.onMouseOver,this);elem.on('mouseout',this.onMouseOut,this);elem.on('unload',this.destroy,this);GUI.Event.on(window,'scroll',this.onScroll,this);window.setInterval(this.hintPoller.bind(this),this.delay);},removeEventListeners:function(){var elem=GUI.getBody();GUI.Dom.extend(elem);elem.un('mousedown',this.onMouseDown,this);elem.un('mousemove',this.onMouseMove,this)
elem.un('mouseover',this.onMouseOver,this);elem.un('mouseout',this.onMouseOut,this);elem.un('unload',this.destroy,this);GUI.Event.un(window,'scroll',this.onScroll,this);},setPosition:function(x,y){if(this.dom){var s=this.dom.style;s.left=x+'px';s.top=y+'px';}},onMouseDown:function(e){e=GUI.Event.extend(e);if(this.visible){if(this.type=='help'&&e.within(this._hintTarget)){return;}
this.hide();}},onMouseOver:function(e){this.lastTarget=e.srcElement||e.target;},onMouseOut:function(e){if(this.visible){e=GUI.Event.extend(e);if(e.isMouseLeave(this._hintTarget)){this.hide();}}
this.lastTarget=null;},onMouseMove:function(e){if(this.visible){if(this.followMouse){this.pointerX=e.clientX;this.pointerY=e.clientY;this._updatePosition();}else{}}else{this.lastMoveTs=new Date();this.pointerX=e.clientX;this.pointerY=e.clientY;}},hintPoller:function(){if(this.lastMoveTs&&(new Date()-this.delay>=this.lastMoveTs)){if(this.lastTarget){var t=this.lastTarget,lim=9;while(t&&t.tagName&&lim){if(this.has(t)){this.show(t);break;}
t=t.parentNode;lim--;}
this.lastTarget=null;}
this.lastMoveTs=null;}}});GUI.Popup.Hint=new Hint();document.on('dom:loaded',function(){GUI.Popup.Hint.init();})})();

GUI.Inline=Class.create();Object.extend(Object.extend(GUI.Inline.prototype,GUI.Utils.Observable.prototype),{elementType:'GUI.Inline',template:'<div class="inlineedit" id="inlineEditDiv">'+'<div class="inlineedit-top">'+'<div class="inlineedit-l"><div class="inlineedit-r"><div class="inlineedit-c">'+'</div></div></div></div>'+'<div class="inlineedit-mdl"><div class="inlineedit-l">'+'<div class="inlineedit-r"><div class="inlineedit-c">'+'<div class="inlineedit-content">'+'<table><tr><td class="input">'+'<div id="td_inline"><input id="inline_value" type="text" /><div id="tmpDivEntityDecode" style="display: none;"></div>'+'</div></td>'+'<td class="ico"><div>'+'<img width="13" height="13" id="inline_apply" src="'+
window.JSGUI_IMAGES_PATH+'inlineedit/apply.gif" alt="" hint="'+GUI.i18n.GUI_APPLY+'" />'+'<img width="13" height="13" id="inline_delete" src="'+
window.JSGUI_IMAGES_PATH+'inlineedit/delete.gif" alt="" hint="'+GUI.i18n.GUI_CANCEL+'" />'+'</div></td></tr></table></div></div></div></div></div>'+'<div class="inlineedit-btm"><div class="inlineedit-l">'+'<div class="inlineedit-r"><div class="inlineedit-c"></div></div></div></div></div>',initialize:function(config){GUI.Utils.Observable.prototype.initialize.apply(this,arguments);this.config={};Object.extend(this.config,{width:100,autoApply:false});Object.extend(this.config,config);this.ClickListener=this.ClickCancel.bindAsEventListener(this);this.ClickApplyListener=this.ClickApply.bindAsEventListener(this);this.KeyPressListener=this.KeyPress.bindAsEventListener(this);this.addEvents({apply:true,cancel:true});this.fRegion=new GUI.Popup.Region({});this.sRegion=new GUI.Popup.Region({dimensions:{width:this.config.width},content:this.template});this.anime=new Animator({duration:300,scope:this,onComplete:function(fx){if(fx.state==0){this.fRegion.hide();this.sRegion.hide();fx.clearSubjects();}
else{document.getElementById('inline_value').select();}}});this.visible=false;},show:function(node){if(this.visible){this.ClickApply();}
var elem=node.textId,value=node.config.text;this.node=node;this.config.holder=elem;this.config.value=value;this.fRegion.takeDocument();this.fRegion.show();this.fRegion.dom.style.background="white";GUI.setOpacity(this.fRegion.dom,0.4);GUI.$(this.fRegion.dom).on('click',this.ClickApply,this);var tree=node.getOwnerTree(),width=tree.getClientWidth()-GUI.$(elem).offsetLeft+tree.getScrollLeft()+9;this.sRegion.setDimensions({width:width});this.sRegion.alignTo(elem,'l-l',GUI.isIE?[-5,1]:[-9,1]);this.sRegion.show();var region=$('inlineEditDiv');$('inlineEditDiv').setStyle({opacity:0.1});this.anime.clearSubjects();this.anime.addSubject(new NumericalStyleSubject(region,'opacity',0.1,1));this.anime.seekTo(1);try{$('tmpDivEntityDecode').innerHTML='<textarea id="tmpTxtEntityDecode">'+this.config.value+'</textarea>';$('inline_value').value=$('tmpTxtEntityDecode').value;}catch(e){$('inline_value').value=this.config.value;}
$('td_inline').style.width=(width-49)+'px';document.getElementById('inline_value').focus();document.getElementById('inline_value').select();GUI.$('inline_apply').on('click',this.ClickApply,this);GUI.$('inline_delete').on('click',this.ClickListener);GUI.$('inline_value').on('keyup',this.KeyPressListener);this.visible=true;},ClickCancel:function(){this.fRegion.dom.un('click',this.ClickApply,this);GUI.$('inline_apply').un('click',this.ClickApply,this);GUI.$('inline_delete').un('click',this.ClickCancel,this);GUI.$('inline_value').un('keyup',this.KeyPress,this);this.anime.seekTo(0);this.fireEvent('cancel',this,this.node);this.node=null;this.visible=false;},ClickApply:function(){var value=$('inline_value').value;if(value==''){value=this.config.value;}
if(this.config.autoApply){$(this.config.holder).innerHTML=value;}
this.fireEvent('apply',this,this.node,value);this.fRegion.dom.un('click',this.ClickApply,this);GUI.$('inline_apply').un('click',this.ClickApply,this);GUI.$('inline_delete').un('click',this.ClickCancel,this);GUI.$('inline_value').un('keyup',this.KeyPress,this);this.node=null;this.anime.seekTo(0);this.visible=false;},KeyPress:function(event){if(event.keyCode==13){this.ClickApply();}
else if(event.keyCode==27){this.ClickCancel();}
GUI.stopEvent(event);},destroy:function(){this.anime.destroy();this.fRegion.destroy();this.sRegion.destroy();}});

(function(){var Mask=Class.create(GUI.Utils.Observable,{animate:window.GUI_FX_ANIMATION==true,className:'x-mask',text:GUI.i18n.GUI_LOADING,elementType:'GUI.Popup.Mask',template:'<div id="{0}" class="glass"></div>'+'<div class="x-loader-case1"><div class="x-loader-case2">'+'<table class="x-loader"><col><tr><td>'+'<div class="x-loader">'+'<div class="top"><div><div></div></div></div>'+'<div class="mdl"><div><div><span>{1}</span></div></div></div>'+'<div class="btm"><div><div></div></div></div>'+'</div>'+'</td></tr></table>'+'</div></div>',initialize:function(config){if(GUI.isIE){this.animate=false;}
if(config){Object.extend(this,config);}
this.addEvents({show:true,hide:true});Mask.superclass.initialize.call(this,config);this.maskGlassId=GUI.getUniqId('x-mask-layout-');},onAnimatorComplete:function(anim){if(anim.state==0){this._hide();}else{this._show();}},setElement:function(element){this.element=element;},initRegion:function(){this.region=new GUI.Popup.Region({className:this.className,zIndex:10,content:this.template.formatArr([this.maskGlassId,this.text])});if(this.animate){this.fadeEf=new Animator({duration:500,interval:20,scope:this,onComplete:this.onAnimatorComplete});}},show:function(){if(!this.region){this.initRegion();}
var elem;if(this.element){elem=GUI.$(this.element);if(elem){this.region.config.parentNode=elem;if(GUI.isIE){}}}
if(!elem){console.log('Mask: No element... ',this.element);return false;}
this.region.show();GUI.unselectable(this.region.dom);if(this.animate){this.fadeEf.clearSubjects();this.fadeEf.addSubject(new NumericalStyleSubject(this.region.getElement(),'opacity',0.1,1));this.fadeEf.seekTo(1);}else{GUI.setOpacity(this.region.getElement(),1);this._show();}},_show:function(){this.fireEvent('show',this);},hide:function(){if(this.animate){this.fadeEf.seekTo(0);}else{this._hide();}},_hide:function(){this.region.hide();this.fireEvent('hide',this);},destroy:function(){this.purgeListeners();if(this.fadeEf){this.fadeEf.destroy();this.fadeEf=null;}
if(this.region){this.region.destroy();this.region=null;}
this.element=null;}});GUI.Popup.Mask=Mask;}());

(function()
{var Menu=Class.create();var superproto=GUI.Popup.Region.prototype;var prototype={initialize:function(config)
{superproto.initialize.call(this);var cfg=this.config;Object.extend(cfg,{id:GUI.getUniqId('x-menu-'),className:'',name:null,items:[],animate:window.GUI_FX_ANIMATION==true,effect:['slide'],lazyRender:true,destroyOnHide:true,onClick:null,hideOnDocumentClick:false,preloadImages:true,light:false,showDescription:true,enableScrollers:true,scrollerHeight:8,scrollStep:24,hideOnChildHide:true,messageItemCaption:GUI.i18n.GUI_POPUP_MENU_NO_ITEMS});if(!GUI.isIE){cfg.effect.push('fade');}
Object.extend(cfg,config);this.setItems(cfg.items);this.addEvents('click','mouseOver','mouseleave');if(GUI.isFunction(cfg.onClick)){this.on('click',cfg.onClick);}
if(cfg.animate){this.addEvents({fxComplete:true});this.fx=new Animator({duration:250,scope:this,onComplete:function(fx){this.fireEvent('fxComplete',fx);}});if(GUI.isString(cfg.effect)){cfg.effect=[cfg.effect];}
this.on('fxComplete',this.onFxComplete,this);}
if(cfg.name){GUI.ComponentMgr.register(cfg.name,this);}
if(!cfg.lazyRender){if(cfg.destroyOnHide){throw new Error("destroyOnHide option can only be used with lazyRender");}
this.render();}},setItems:function(items){this._indexById={};this._indexByName={};if(items.length==0){items.push({'disabled':false,'message':true,'caption':this.config.messageItemCaption});}
var i=items.length;while(i--){var item=items[i];if(item.img){item.imgDisabled=GUI.getDisabledImageUrl(item.img);if(this.config.preloadImages){GUI.preloadImage(item.img,item.imgDisabled);}}
if(item.sub){item.sub=new Menu(item.sub);}
var id=GUI.getUniqId('x-menu-item-');item.id=id;this._indexById[id]=i;if(GUI.isString(item.name)&&(item.name.length>0)){if(!GUI.isSet(this._indexByName[item.name])){this._indexByName[item.name]=item;}else{console.log('Duplicate menu item name:',item.name);}}}
this.config.items=items;},getItemByName:function(name){return this._indexByName[name];},hideItem:function(name){var item=this.getItemByName(name);if(item){item.hidden=true;}},showItem:function(name){var item=this.getItemByName(name);if(item){item.hidden=false;}},setItemCaption:function(name,caption){var item=this.getItemByName(name);if(item){item.caption=caption;}},initFx:function(){var cfg=this.config;this.fx.clearSubjects();var menu=this.dom;if(cfg.effect.include('fade')){GUI.setOpacity(menu,0.1);this.fx.addSubject(new NumericalStyleSubject(menu,'opacity',0.1,1.0));};if(cfg.effect.include('slide')){var d=GUI.getDimensions(menu),tableEl=menu.firstChild;tableEl.style.width=d.width+'px';tableEl.style.height=d.height+'px';menu.style.overflow='hidden';menu.style.width=1;menu.style.height=1;this.fx.addSubject(new NumericalStyleSubject(menu,'width',1,d.width));this.fx.addSubject(new NumericalStyleSubject(menu,'height',1,d.height));}},onFxComplete:function(fx){if(!this.dom){return;}
var effects=this.config.effect,menuStyle=this.dom.style,tableStyle=this.dom.firstChild.style;if(effects.include('fade')){if(fx.state==0){GUI.setOpacity(this.dom,'');}}
if(effects.include('slide')){tableStyle.width=tableStyle.height='';menuStyle.width=menuStyle.height='';}
if(fx.state==0){menuStyle.visibility='hidden';this._hide();fx.clearSubjects();}},show:function(parent,parentItemId){if(this.dom&&this.visible){return;}
this.parent=parent;var cfg=this.config;if(!this.dom&&cfg.lazyRender){this.render();}
var style=this.dom.style;style.visibility='hidden';style.display='';this.attachEventListeners();if(cfg.enableScrollers){this.applyScrollers(this.dom.offsetTop);}
if(this.fx){this.initFx();this.fx.seekTo(1);}
style.visibility='';this.visible=true;},setShowDescription:function(val){var menu=this.getRootMenu();menu.config.showDescription=val;},_getItemHtml:function(item){var o=new GUI.StringBuffer();o.append('<tr id="'+item.id+'"');if(item.hidden){o.append(' style="display: none;"');}
o.append('class="x-menu-item');if(item.disabled){o.append((item.sub)?' sub-item-disabled':' x-menu-disabled');}else if(item.message){o.append(' x-menu-no-hover');}else{if(item.sub){o.append(' sub-item');}}
o.append('"><td><div class="item-wrapper"><table cellspacing="0"><tbody><tr><td class="x-menu-item-ico">');if(item.img||item.iconClass){o.append('<img width="'+(item.imgWidth||16)+'" height="'+
(item.imgHeight||16)+'" title="" alt="" src="');if(item.iconClass){o.append(GUI.emptyImageUrl+'" class="'+item.iconClass);}else{o.append((item.disabled)?item.imgDisabled:item.img);}
o.append('"/>');}
o.append('</td><td class="x-menu-item-txt">');if(item.caption){o.append(item.caption);}
var showDescription=this.getRootMenu().config.showDescription;if(showDescription&&item.descr){o.append('<br/><span>'+item.descr+'</span>');}
o.append('</td><td class="x-menu-item-bullet">')
if(true){o.append('<img title="" alt="" src="'+GUI.emptyImageUrl+'" />');}
o.append('</td></tr></tbody></table></div></td></tr>');return o.toString();},render:function(){if(this.dom){this.removeEventListeners();GUI.destroyNode(this.dom);this.dom=null;}
this.visible=false;var cfg=this.config;var menu=document.createElement('div');menu.className='x-region'+(cfg.className?' '+cfg.className:'');menu.style.overflow='visible';menu.style.zIndex=GUI.Popup.Region.zIndexCounter+1;var o=new GUI.StringBuffer();o.append('<table cellspacing="0" class="x-menu-case"><col /><tbody><tr><td>').append('<div class="x-menu');if(cfg.light){o.append(' x-menu-light');}
var width='';if(GUI.isNumber(cfg.width)){width=' style="width:'+cfg.width+'px;"';}else if(GUI.isString(cfg.width)){width=' style="width:'+cfg.width+';"';}
o.append('"><div class="x-menu-shdw">'+'<div class="x-menu-shdw-l1"></div>'+'<div class="x-menu-shdw-l2"></div>'+'<div class="x-menu-shdw-l3"></div></div>'+'<div'+width+' class="x-menu-data-case">'+'<div class="x-menu-items-wrapper">'+'<table cellspacing="0" class="x-menu-items"><col /><col /><tbody>'+'</div>');for(var i=0,len=cfg.items.length;i<len;i++){o.append(this._getItemHtml(cfg.items[i]));}
o.append('</tbody></table></div></div></td></tr></tbody></table>');this.dom=$(menu);var dim=cfg.dimensions;this.setPosition([dim.left,dim.top]);menu.style.visibility='hidden';if(!cfg.parentNode){cfg.parentNode=document.body;}
cfg.parentNode.appendChild(menu);menu.innerHTML=o.toString();this.wrapperEl=this.dom.findDescedent('.x-menu-items-wrapper');GUI.unselectable(this.dom);if(GUI.isArray(this.alignArgs)&&this.alignArgs.length){this._alignTo.apply(this,this.alignArgs);this.alignArgs=null;}
GUI.hide(menu);},applyScrollers:function(y){this.wrapperEl.style.height='auto';var maxHeight,fullHeight=this.wrapperEl.offsetHeight;if(this.config.maxHeight){maxHeight=this.config.maxHeight;}else{maxHeight=GUI.getViewportHeight()-y-3*this.config.scrollerHeight;}
if(fullHeight>maxHeight&&maxHeight>0){this._currentMax=maxHeight;this.wrapperEl.style.height=maxHeight+'px';this.createScrollers();}else{this.wrapperEl.style.height=fullHeight;if(this.scroller){this.scroller.top&&GUI.hide(this.scroller.top);this.scroller.bottom&&GUI.hide(this.scroller.bottom);}}},_getScroller:function(top){var div=document.createElement('div');div.className='x-menu-scroller x-menu-scroller-'+(top?'top':'bottom');div.innerHTML='<div>&nbsp;</div>';return div;},createScrollers:function(){if(!this.scroller){var topScroller=this._getScroller(true);this.wrapperEl.parentNode.insertBefore(topScroller,this.wrapperEl);var bottomScroller=this._getScroller(false);this.wrapperEl.parentNode.appendChild(bottomScroller);this.scroller={position:0,top:topScroller,bottom:bottomScroller};var ClickRepeater=GUI.Utils.ClickRepeater;this._topRepeater=new ClickRepeater({dom:topScroller,pressedClass:'x-menu-scroller-pressed',listeners:{scope:this,click:this.onTopScrollerClick}});this._bottomRepeater=new ClickRepeater({dom:bottomScroller,pressedClass:'x-menu-scroller-pressed',listeners:{scope:this,click:this.onBottomScrollerClick}});}},setPosition:function(pos){var dim=this.config.dimensions;dim.left=pos[0];dim.top=pos[1];if(this.dom){var style=this.dom.style;style.left=pos[0]+'px';style.top=pos[1]+'px';}},hide:function(fast){if(!this.dom){return;}
if(this.subMenu){this.hideSubMenu();}
this.removeEventListeners();if(this.fx&&!fast){this.fx.seekTo(0);}else{this._hide();}
if(this.parent&&GUI.isFunction(this.parent.onChildHide)){this.parent.onChildHide(this);}},_hide:function(){GUI.hide(this.dom);this.visible=false;if(this.config.destroyOnHide){GUI.destroyNode(this.dom);this.scroller=null;this.dom=null;}},onChildHide:function(menu){},showSubMenu:function(itemId){var item=this.getItemById(itemId),sub=item.sub;if(this.submenu!=sub){this.hideSubMenu();var offset=GUI.isIE?[-3,-1]:[-3,-2];sub.alignTo(GUI.$(itemId),'tl-tr?',offset);sub.show(this,itemId);this.subMenu=sub;this.parentItemId=itemId;GUI.$(itemId).addClass('x-menu-item-openedsubmenu');}},hideSubMenu:function(){if(this.subMenu){GUI.$(this.parentItemId).removeClass('x-menu-item-openedsubmenu');this.subMenu.hide();this.subMenu=null;}},hideParent:function(){if(this.config.hideOnChildHide===false){return;}
this.hide();if(this.parent&&this.parent.hideParent){this.parent.hideParent();}},getRootMenu:function(){if(this.parent&&this.parent.getRootMenu){return this.parent.getRootMenu();}else{return this;}},getItemById:function(id){var index=this._indexById[id];if(GUI.isNumber(index)){return this.config.items[this._indexById[id]];}
return false;},isVisible:function(){return this.dom&&this.visible;},attachEventListeners:function(){if(this.config.hideOnDocumentClick){GUI.Dom.on((GUI.isIE)?document.body:document,'mousedown',this.bodyClickHandler,this);}
GUI.Dom.extend(this.dom);this.dom.on('click',this.menuClickHandler,this);this.dom.on('mouseover',this.mouseOverHandler,this);this.dom.on('mouseout',this.mouseOutHandler,this);},removeEventListeners:function(){if(this.config.hideOnDocumentClick){GUI.Dom.un((GUI.isIE)?document.body:document,'mousedown',this.bodyClickHandler,this);}
this.dom.un();},bodyClickHandler:function(e){e=GUI.Event.extend(e);if(this.dom){var close=this.mouseOverMenu(e,this);if(!close){this.hide();}}},mouseOverMenu:function(e,menu){var ret=e.within(menu.getDom());for(var i=0;i<menu.config.items.length;i++){if(menu.config.items[i].sub){ret=ret||this.mouseOverMenu(e,menu.config.items[i].sub);}}
return ret;},menuClickHandler:function(e){e=GUI.Event.extend(e);e.preventDefault();var itemDiv=e.target.findParent('tr',this.dom,'x-menu-item');if(!itemDiv){return;}
var item=this.getItemById(itemDiv.id);if(item.disabled){return;}
if(item.message){this.hide();return;}
if(item.sub){this.showSubMenu(itemDiv.id);}else{if(GUI.isFunction(item.handler)){item.handler(item);}
if(this.parent&&this.parent.getRootMenu){this.parent.getRootMenu().fireEvent('click',this,item);}else{this.fireEvent('click',this,item);}
this.hideParent();}},mouseOverHandler:function(e){e=GUI.Event.extend(e);var itemDiv=e.target.findParent('tr',this.dom,'x-menu-item');if(itemDiv){if(e.isMouseEnter(itemDiv)){this.onItemMouseEnter(itemDiv);}}else if(itemDiv=e.target.findParent('div',this.dom,'x-menu-scroller')){if(e.isMouseEnter(itemDiv)){this.onScrollerMouseEnter(e,itemDiv);}}
this.fireEvent('mouseOver',this,e);},onItemMouseEnter:function(itemDiv){var item=this.getItemById(itemDiv.id);if(item.disabled||item.message){return;}
if(GUI.isIE){GUI.Dom.addClass(itemDiv,'x-menu-item-hover');}
if(this.subMenu&&(this.subMenu!=item.sub)){this.hideSubMenu();}
if(item.sub){if(!item.sub.isVisible()){this.showSubMenu(itemDiv.id);}}},mouseOutHandler:function(e){e=GUI.Event.extend(e);var itemDiv=e.target.findParent('tr',this.dom,'x-menu-item');var relatedTarget=e.getRelatedTarget();if(itemDiv){if(!e.isMouseLeave(itemDiv)){return;}
this.onItemMouseLeave(itemDiv);}else if(itemDiv=e.target.findParent('div',this.dom,'x-menu-scroller')){if(e.isMouseLeave(itemDiv)){this.onScrollerMouseLeave(e,itemDiv);}}
if(this.subMenu){if(!GUI.contains(this.subMenu.dom,relatedTarget)){this.hideSubMenu();}}
if(e.isMouseLeave(this.dom)){if(this.parent){if(this.subMenu&&GUI.contains(this.subMenu.dom,relatedTarget)){return;}
if(GUI.contains(this.parent.dom,relatedTarget)){return}
this.hideParent();}
this.fireEvent('mouseleave',this,e);}},onItemMouseLeave:function(itemDiv){var item=this.getItemById(itemDiv.id);if(item.disabled||item.message){return;}
if(GUI.isIE){GUI.Dom.removeClass(itemDiv,'x-menu-item-hover');}},onTopScrollerClick:function(e,scroller){this.wrapperEl.scrollTop-=this.config.scrollStep;},onBottomScrollerClick:function(e,scroller){this.wrapperEl.scrollTop+=this.config.scrollStep;},onScrollerMouseEnter:function(e,scroller){GUI.Dom.addClass(scroller,'x-menu-scroller-hover');},onScrollerMouseLeave:function(e,scroller){GUI.Dom.removeClass(scroller,'x-menu-scroller-hover');}};Object.extend(Menu.prototype,superproto);Object.extend(Menu.prototype,prototype);GUI.Popup.Menu=Menu;})();

(function()
{var ToolBox=Class.create();var superproto=GUI.Utils.Observable.prototype;var prototype={initialize:function(config)
{superproto.initialize.call(this);this.config={id:GUI.getUniqId('x-toolbox-'),className:'x-toolbox',itemClass:'toolbox',items:[],onClick:null,holder:null};var cfg=this.config;Object.extend(cfg,config);this._indexById={};this._indexByName={};var i=cfg.items.length;while(i--){var item=cfg.items[i];var id=GUI.getUniqId('x-toolbox-button-');item.id=id;this._indexById[id]=this._indexByName[item.name]=i;}
this.addEvents({click:true});if(GUI.isFunction(cfg.onClick)){this.on('click',cfg.onClick,cfg.scope);}
if(cfg.name){GUI.ComponentMgr.register(cfg.name,this);}},destroy:function(quick){this.purgeListeners();if(this.dom){this.removeEventListeners();if(!quick){GUI.destroyNode(this.dom);}
this.dom=null;}
this.config.holder=null;},unrender:function(){if(this.dom){this.removeEventListeners();GUI.destroyNode(this.dom);this.dom=null;}},render:function(to){if(this.dom){this.unrender();}
this.visible=false;var cfg=this.config;if(to){cfg.holder=to;}else{to=cfg.holder;}
to=GUI.$(to);var div=document.createElement('div');div.id=cfg.id;div.className=cfg.className;var o=new GUI.StringBuffer();for(var i=0,len=cfg.items.length;i<len;i++){var item=cfg.items[i];o.append('<a class="'+cfg.itemClass+'" id="'+item.id+'"');if(item.hidden){o.append(' style="display: none;"');}
if(item.title){o.append(' hint="'+item.title+'"');}
o.append('><img align="absmiddle" src="');if(item.iconClass){o.append(GUI.emptyImageUrl+'" class="'+item.iconClass);}else{o.append(item.img);}
o.append('" alt="" /></a>');}
if(GUI.isIE){to.appendChild(div);div.innerHTML=o.toString();}else{div.innerHTML=o.toString();to.appendChild(div);}
this.dom=GUI.Dom.extend(div);this.attachEventListeners();},hideItem:function(name){var item=this.getItemByName(name);if(item&&!item.hidden){item.hidden=true;if(this.dom){GUI.hide(item.id);}}},showItem:function(name){var item=this.getItemByName(name);if(item&&item.hidden){item.hidden=false;if(this.dom){GUI.show(item.id);}}},getItemById:function(id){var index=this._indexById[id];if(GUI.isNumber(index)){return this.config.items[index];}
return false;},getItemByName:function(name){var index=this._indexByName[name];if(GUI.isNumber(index)){return this.config.items[index];}
return false;},attachEventListeners:function(){this.dom.on('click',this.clickHandler,this);},removeEventListeners:function(){this.dom.un();},clickHandler:function(e){e=GUI.Event.extend(e);e.stop();var itemNode=e.target.findParent('A',this.dom);if(!itemNode){return;}
var item=this.getItemById(itemNode.id);if(GUI.isFunction(item.onClick)){item.onClick.call(item.scope,item);}
this.fireEvent('click',this,item);}};Object.extend(ToolBox.prototype,superproto);Object.extend(ToolBox.prototype,prototype);GUI.ToolBox=ToolBox;})();

(function()
{var WizardDialog=Class.create();var superproto=GUI.Popup.Dialog.prototype;var i18n=GUI.i18n;var prototype={initialize:function(config){var defCfg={id:GUI.getUniqId('x-wizard-dialog-'),modal:true,title:'',text:'',toolbuttons:[{name:'close',title:"Close\nCloses window",img:window.JSGUI_IMAGES_PATH+'x-dialog/x-dialog-ico-close.gif'}],buttons:[{name:'prev',caption:i18n.GUI_PREV},{name:'next',caption:i18n.GUI_NEXT}],buttonsAlign:'right',wizard:{},visible:false,animate:window.GUI_FX_ANIMATION==true};Object.extend(defCfg,config);superproto.initialize.call(this,defCfg);Object.extend(this.config,defCfg);var self=this;var cfg=this.config;if(GUI.isIE){cfg.animate=false;}
this.elementType='GUI.Popup.WizardDialog';this.buttonsHolderId=GUI.getUniqId('buttons-holder-');this.textId=GUI.getUniqId('text-holder-');this.wizardId=GUI.getUniqId('wizard-');this.defHandlers={close:this.close}
cfg.content='<div id="'+this.wizardId+'"></div>';if(GUI.isArray(cfg.buttons)&&cfg.buttons.length){cfg.content+='<div class="buttons-holder" id="'+this.buttonsHolderId+'"></div>';}
this.addEvents({close:true});},create:function(){superproto.create.call(this);var cfg=this.config;if(GUI.isArray(cfg.buttons)&&cfg.buttons.length){this.btnToolbar=new GUI.ToolBar({className:'x-toolbar form-buttons',position:'horizontal',align:cfg.buttonsAlign});var self=this;var btnCfg;for(var i=0;i<cfg.buttons.length;i++){var b=cfg.buttons[i];btnCfg={};Object.extend(btnCfg,b);if(b.name=='prev'&&!GUI.isFunction(btnCfg.onClick)){btnCfg.onClick=this.onPrevClick.bind(this);}else if(b.name=='next'&&!GUI.isFunction(btnCfg.onClick)){btnCfg.onClick=this.onNextClick.bind(this);}else if(b.name=='close'&&!GUI.isFunction(btnCfg.onClick)){btnCfg.onClick=this.close.bind(this);}
this.btnToolbar.add(b.name,new GUI.ToolBar.Button(btnCfg));}
this.btnToolbar.render(this.buttonsHolderId);GUI.addClass(this.buttonsHolderId,'wizard');GUI.appendClearDiv(this.buttonsHolderId);}
this.wizard=new GUI.Wizard(cfg.wizard);this.wizard.render(this.wizardId);},getButton:function(name){return this.btnToolbar.getElement(name);},destroy:function(){if(this.dom){if(this.wizard){this.wizard.destroy();}
if(this.btnToolbar){this.btnToolbar.destroy();}}
superproto.destroy.call(this);},onPrevClick:function(){this.wizard.prevStep();},onNextClick:function(){this.wizard.nextStep();}};Object.extend(WizardDialog.prototype,superproto);Object.extend(WizardDialog.prototype,prototype);GUI.Popup.WizardDialog=WizardDialog;}());

GUI.Forms={};

(function(){var Field=Class.create(GUI.BoxComponent,{name:null,value:undefined,type:null,defaultText:'',readOnly:false,tabIndex:-1,className:'',fieldClass:'x-form-field',focusClass:'x-form-field-focus',hoverClass:'x-form-field-hover',invalidClass:'x-form-field-invalid',disabledClass:'x-form-field-disabled',defaultTextClass:'jsgui-field-defaulttext',focused:false,isFormField:true,allowEmpty:false,validateOnBlur:true,editable:true,errorNodeHolder:'body',disableValidationPopups:false,validationDelay:200,livevalidation:false,autohide:true,hidedelay:3000,animate:false,cssFloat:'none',errorTemplate:'<table><tr><td><div class="validationMsg"><div class="top">'+'<div class="l"><div class="r"><div class="c"></div></div></div></div>'+'<div class="mdl"><div class="l"><div class="r"><div class="c">'+'<div class="validationText"><p>{0}</p></div>'+'</div></div></div></div>'+'<div class="btm"><div class="l"><div class="r"><div class="c"></div></div></div>'+'</div></div></td></tr></table>',initialize:function(config){if(config){if(GUI.isSet(config.editable)&&!GUI.isSet(config.readOnly)){config.readOnly=config.editable;delete config.editable;}}
Field.superclass.initialize.call(this,config);},assign:function(to){to=GUI.$(to);if(!to){throw new Error("Element to assign to is null.");}
if(to._jsguiComponent||this.onBeforeAssign(to)===false){return false;}
this.onAssign(to);this.fireEvent('assign',this,to);this.render(to.parentNode,to);GUI.destroyNode(to);to=null;return true;},validate:function(){if(this.disabled){return true;}
var valid=true,msg;if(this.allowEmpty&&this.getValue()==''){return true;}
for(var name in this.validators){var validator=this.validators[name];if(!validator.validate()){valid=false;msg=validator.getErrorMessage();break;}}
if(valid){this.setValid();}else{this.setInvalid(msg);}
return valid;},getStylingEl:function(){return this.fieldEl;},setInvalid:function(msg){this.getStylingEl().addClass(this.invalidClass);if(!this.disableValidationPopups){var html=this.errorTemplate.format(msg),errNode;if(!this.errorHolder){switch(this.errorNodeHolder){case'body':errNode=document.body;break;case'parent':errNode=this.dom.parentNode;break;default:errNode=GUI.$(this.errorNodeHolder);break;}
this.errorHolder=new GUI.Popup.Region({parentNode:errNode});}
var region=this.errorHolder;region.setContent(html);if(!region.getVisibility()){region.alignTo(this.dom,'tl-tr',[0,-7]);region.show();GUI.Event.on(region.dom,'click',this.setValid,this);if(this.animate){this.showEf.config.element=region.getElement();this.showEf.execute();}}
if(this.autohide){this.hideTask.delay(this.hidedelay);}}
this.fireEvent('invalid',this,msg);},setValid:function(onlyHide){this.getStylingEl().removeClass(this.invalidClass);if(!this.errorHolder){return;}
var region=this.errorHolder;if(region.getVisibility()){GUI.Event.un(region.dom,'click',this.setValid,this);if(this.animate){if(this.showEf.context){this.showEf.stop();}
this.hideEf.config.element=region.getElement();this.hideEf.execute();}else{this._setValid();}}
this.fireEvent('valid',this);},_setValid:function(){this.errorHolder.hide();},getName:function(){return this.name;},getValue:function(){if(!this.fieldEl){return this.value;}
var v=this.fieldEl.value;if(v==this.defaultText){return'';}else{return v;}},getRawValue:function(){return(this.fieldEl)?this.fieldEl.value:this.value;},setValue:function(v,silent){var oldValue=this.getValue();this.value=v;if(this.fieldEl){this.fieldEl.value=(v===null||v===undefined?'':v);this.validate();}
if(v!=oldValue&&!silent){this.fireEvent('change',this,v,oldValue);}},clear:function(){if(this.getValue()!=''){this.setRawValue('');}
this.applyDefaultText();this.blur();},setRawValue:function(v){this.value=v;if(this.fieldEl){this.fieldEl.value=(v===null||v===undefined?'':v);}},reset:function(){this.setValue(this.defaultValue);this.setValid();},initComponent:function(){Field.superclass.initComponent.call(this);this.addEvents({'focus':true,'blur':true,'change':true,'valid':true,'invalid':true,'assign':true});this.validators={};if(this.autohide){this.hideTask=new GUI.Utils.DelayedTask(this.setValid,this);}
if(this.animate){this.showEf=new GUI.Fx.Animator({time:300,sleep:50,modificators:[{type:'alpha',from:0,to:1.0}]});this.hideEf=new GUI.Fx.Animator({time:300,sleep:50,modificators:[{type:'alpha',from:1.0,to:0}]});this.hideEf.on('stop',this._setValid,this);}},onBeforeAssign:function(to){return to.nodeName=='INPUT'&&to.type==this.type;},onAssign:function(elem){var value;if(GUI.isSet(elem.id)){GUI.ComponentMgr.unregister(this);this.id=elem.id;GUI.ComponentMgr.register(this);}else{elem.id=this.id;}
this.addClass=elem.className?elem.className:null;this.name=elem.getAttribute('name');this.disabled=elem.disabled;var autohide=elem.getAttribute('autohide');if(autohide==='true'){this.autohide=true;}else if(autohide==='false'){this.autohide=false;}
var hidedelay=elem.getAttribute('hidedelay');if(hidedelay!==null){this.hideDelay=hidedelay;}
var livevalidation=elem.getAttribute('livevalidation');if(GUI.isSet(livevalidation)){this.livevalidation=(livevalidation=='true');}
var disableValidationPopups=elem.getAttribute('disableValidationPopups');if(GUI.isSet(disableValidationPopups)){this.disableValidationPopups=(disableValidationPopups=='true');}
var validation=elem.getAttribute('validation');if(GUI.isSet(validation)){this.validation=this.parseAttributeParams(validation);}
var value=elem.value;if(value.length>0&&value!=this.defaultText){this.value=value;}
var value=elem.style.width;if(GUI.isSet(value)){if(value.endsWith('%')){this.width=value;}else if(value.endsWith('px')){this.width=parseInt(value,10);}else if(value!=''){this.width=value;}}
var v=elem.style.height;if(GUI.isSet(v)){if(v.endsWith('%')){this.height=v;}else if(v.endsWith('px')){this.height=parseInt(v,10);}}
v=elem.getAttribute('deftext');if(GUI.isSet(v)){this.defaultText=v;}
this.readOnly=!!elem.readOnly;var cssFloat=elem.style[GUI.isIE?'styleFloat':'cssFloat'];if(cssFloat){this.cssFloat=cssFloat;}
var attr=elem.getAttribute('validateonblur');if(attr!=null){this.validateOnBlur=(attr=='false')?false:true;}},parseAttributeParams:function(str){str=str.replace(/\s+/g,'');var arr=str.split(',',10);var params={};for(var i=0,len=arr.length;i<len;i++){var item=arr[i];var param=item.split(':',2);if(GUI.isSet(param[0])){params[param[0].toLowerCase()]=(GUI.isSet(param[1]))?param[1]:true;}}
return params;},removeValidator:function(name){if(!this.validators[name]){throw new Error('Trying to remove validator, that was not attached');}
delete this.validators[name];},getValidator:function(name){if(GUI.isSet(this.validators[name])){return this.validators[name];}
return false;},onRender:function(){var fieldEl=this.getFieldElement();GUI.Dom.extend(fieldEl);fieldEl._jsguiComponent=true;this.initField(fieldEl);this.initValidators();return fieldEl;},getFieldElement:function(){var dom=GUI.createInput(this.name);dom.type=this.type;return dom;},initField:function(dom){dom.id=this.getId();dom.addClass(this.fieldClass);dom.addClass(this.className);if(this.addClass!=null){dom.addClass(this.addClass);}
if(this.readOnly)dom.readOnly=true;if(this.tabIndex>-1)dom.setAttribute('tabIndex',this.tabIndex);this.defaultValue=this.value;},initValidators:function(){if(this.livevalidation){this.validationTask=new GUI.Utils.DelayedTask(this.validate,this);}
if(this.validation){for(var name in this.validation){this.addValidator(name,this.validation[name]);}}},addValidator:function(name,params){name=name.capitalize();if(!GUI.Forms.Validation[name]){throw new Error('Trying to add unknown validator: '+name);}
var validator=new GUI.Forms.Validation[name]({field:this,params:params});if(!this.validators[name]){this.validators[name]=validator;}else{throw new Error('Trying to add another validator with the same name');}},adjustSize:function(w,h){var s=Field.superclass.adjustSize.call(this,w,h);s.width=this.adjustWidth(this.dom.nodeName,s.width);return s;},adjustWidth:function(tag,w){if(typeof w=='number'){if(GUI.isStrict){w-=6;}}
return w;},onAfterRender:function(dom){Field.superclass.onAfterRender.call(this,dom);this.fieldEl=dom;if(this.value!==undefined){this.setValue(this.value,true);}else if(!this.doNotReadValueFromDom){if(dom.value.length>0&&dom.value!=this.defaultText){this.setValue(dom.value,true);}}
this.originalValue=this.getValue();if(this.cssFloat!='none'){dom.style[GUI.isIE?'styleFloat':'cssFloat']=this.cssFloat;}},attachEventListeners:function(){this.fieldEl.on('focus',this.onFocus,this);this.fieldEl.on('blur',this.onBlur,this);this.fieldEl.on('mouseenter',this.onMouseEnter,this);this.fieldEl.on('mouseleave',this.onMouseLeave,this);if(this.livevalidation){this.fieldEl.on('keyup',this.onKeyUp,this);}},removeEventListeners:function(){this.fieldEl.un();},onDestroy:function(fast){if(this.validationTask){this.validationTask.cancel();}
if(this.hideTask){this.hideTask.cancel();}
if(this.errorHolder){this.errorHolder.destroy();this.errorHolder=null;}
for(var name in this.validators){delete this.validators[name];}
Field.superclass.onDestroy.call(this,fast);},applyDefaultText:function(){if(this.dom&&this.defaultText&&(this.getRawValue().length==0||this.getRawValue()==this.defaultText)){this.setRawValue(this.defaultText);this.dom.addClass(this.defaultTextClass);}},onDisable:function(){Field.superclass.onDisable.call(this);this.fieldEl.disabled=true;},onEnable:function(){Field.superclass.onEnable.call(this);this.fieldEl.disabled=false;},onFocus:function(){if(!this.focused){this.fieldEl.addClass(this.focusClass);if(this.selectOnFocus){this.fieldEl.select();}
this.focused=true;this.startValue=this.getValue();this.fireEvent('focus',this);}},onBeforeBlur:function(){},onBlur:function(){this.onBeforeBlur();this.fieldEl.removeClass(this.focusClass);this.focused=false;if(this.validateOnBlur){this.validate();}
var v=this.getValue();if(v!==this.startValue){this.fireEvent('change',this,v,this.startValue);}
this.fireEvent('blur',this);},onMouseEnter:function(event){if(!this.disabled){this.fieldEl.addClass(this.hoverClass);}},onMouseLeave:function(event){if(!this.disabled){this.fieldEl.removeClass(this.hoverClass);}},onKeyUp:function(e){if(!GUI.isNavKeyPress(e)){this.validationTask.delay(this.validationDelay);}},getElement:function(){return this.dom;},getFocusElId:function(){return this.id;}});GUI.Forms.Field=Field;}());

(function(){var CheckBox=Class.create(GUI.Forms.Field,{type:'checkbox',className:'x-form-checkbox',focusClass:'x-form-checkbox-focus',hoverClass:'x-form-checkbox-hover',invalidClass:'x-form-checkbox-invalid',disabledClass:'x-form-checkbox-disabled',checked:false,initialize:function(config){CheckBox.superclass.initialize.call(this,config);},isChecked:function(){return(this.dom)?this.dom.checked:this.checked;},setChecked:function(checked){if(checked===true||checked==='true'||checked==='on'){this.checked=true;}else if(checked===false||checked==='false'||checked==='off'){this.checked=false;}else{this.checked=(checked===undefined)?true:!!checked;}
if(this.dom){this.dom.checked=this.checked;}
this.fireEvent('change',this,checked);},attachEventListeners:function(){CheckBox.superclass.attachEventListeners.call(this);},onAssign:function(dom){CheckBox.superclass.onAssign.call(this,dom);this.checked=dom.checked;},initField:function(fieldEl){CheckBox.superclass.initField.call(this,fieldEl);},onAfterRender:function(fieldEl){CheckBox.superclass.onAfterRender.call(this,fieldEl);fieldEl.on('click',this.onClick,this);fieldEl.checked=this.checked;},onClick:function(e){this.checked=this.dom.checked;this.fireEvent('change',this,this.checked);}});GUI.Forms.CheckBox=CheckBox;}());

(function(){var Hidden=Class.create(GUI.Forms.Field,{type:'hidden',initialize:function(config){Hidden.superclass.initialize.call(this,config);},setSize:GUI.emptyFunction,setWidth:GUI.emptyFunction,setHeight:GUI.emptyFunction,setInvalid:GUI.emptyFunction,setValid:GUI.emptyFunction});GUI.Forms.Hidden=Hidden;}());

(function(){var Radio=Class.create(GUI.Forms.CheckBox,{type:'radio',className:'x-form-radio',focusClass:'x-form-radio-focus',hoverClass:'x-form-radio-hover',invalidClass:'x-form-radio-invalid',disabledClass:'x-form-radio-disabled',initialize:function(config){Radio.superclass.initialize.call(this,config);}});GUI.Forms.Radio=Radio;}());

(function(){var TextField=Class.create(GUI.Forms.Field,{type:'text',className:'x-form-textfield',initialize:function(config){TextField.superclass.initialize.call(this,config);},initComponent:function(){TextField.superclass.initComponent.call(this);},attachEventListeners:function(){TextField.superclass.attachEventListeners.call(this);if(this.defaultText){this.on('blur',this.postBlur,this);this.on('focus',this.preFocus,this);this.applyDefaultText();}},onAssign:function(elem){TextField.superclass.onAssign.call(this,elem);var attrsMap={size:'size',maxlength:'maxLength'};var value=elem.getAttribute('size');if(GUI.isSet(value)&&value>0){this.size=value;}
value=elem.getAttribute('maxlength');if(GUI.isSet(value)&&value>0){this.maxLength=value;}},initField:function(fieldEl){TextField.superclass.initField.call(this,fieldEl);if(GUI.isSet(this.size))fieldEl.size=this.size;if(GUI.isSet(this.maxLength))fieldEl.maxlength=this.maxLength;if(GUI.isGecko||GUI.isChrome){fieldEl.setAttribute('autocomplete','off');}},postBlur:function(){this.applyDefaultText();},preFocus:function(){if(this.defaultText){if(this.dom.value==this.defaultText){this.setRawValue('');this.dom.removeClass(this.defaultTextClass);}}},selectText:function(start,end){var v=this.getRawValue();var doFocus=false;try{if(v.length>0){start=start===undefined?0:start;end=end===undefined?v.length:end;var d=this.fieldEl;if(d.setSelectionRange){d.setSelectionRange(start,end);}else if(d.createTextRange){var range=d.createTextRange();range.moveStart("character",start);range.moveEnd("character",end-v.length);range.select();}
doFocus=GUI.isGecko||GUI.isOpera;}else{doFocus=true;}}catch(e){}
if(doFocus){this.focus();}}});GUI.Forms.TextField=TextField;}());

(function(){var TextArea=Class.create(GUI.Forms.TextField,{cols:20,rows:4,className:'x-form-textarea',initialize:function(config){TextArea.superclass.initialize.call(this,config);},initComponent:function(){TextArea.superclass.initComponent.call(this);},attachEventListeners:function(){TextArea.superclass.attachEventListeners.call(this);},onAssign:function(elem){TextArea.superclass.onAssign.call(this,elem);var attrsMap={cols:'cols',rows:'rows'};for(var i in attrsMap){var value=elem.getAttribute(i);if(GUI.isSet(value)){this[attrsMap[i]]=value;}}},onBeforeAssign:function(to){return to.nodeName=='TEXTAREA';},getFieldElement:function(){var dom=document.createElement('textarea');if(this.name!=null){dom.name=this.name;}
return dom;},initField:function(dom){TextArea.superclass.initField.call(this,dom);if(GUI.isSet(this.cols))dom.cols=this.cols;if(GUI.isSet(this.rows))dom.rows=this.rows;}});GUI.Forms.TextArea=TextArea;}());

(function(){var Autocompleter=Class.create(GUI.Forms.TextField,{autoApply:true,searchDelay:0,cls:'x-autocompleter',maxContentHeight:null,listOpened:false,selectedIndex:-1,minSearchCharacters:3,loader:true,searchFor:false,hideEmptyList:false,autoApplyPosition:true,initialize:function(c){if(c){if(c.apply){c.applyConfig=c.apply;delete c.apply;}
if(c.search){c.searchConfig=c.search;delete c.search;}}
Autocompleter.superclass.initialize.call(this,c);},initComponent:function(){Autocompleter.superclass.initComponent.call(this);this.jsonviewId=this.id+'-jsonview';this.loaderId=this.id+'-loader';this.searchTask=new GUI.Utils.DelayedTask(this.doSearch,this);this.list=new GUI.Popup.Region({className:this.cls});this.rowPrefix=this.id+'-row-';this.contentId=this.id+'-content';var preTpl=this.templates.pre+'<div id="'+this.contentId+'">';var wrappedRow='<div class="row" id="'+this.rowPrefix+'{this.index}">'
+this.templates.row+'</div>';var postTpl='</div>'
+this.templates.post;this.jsonview=new GUI.JsonView({holder:this.jsonviewId,preTpl:preTpl,rowTpl:wrappedRow,postTpl:postTpl,noDataTpl:this.templates.nodata,visible:false});this.listTpl=new GUI.STemplate(this.templates.list,this);this.data=null;this.addEvents({beforeApply:true,applySuccess:true,applyFailure:true,searchSuccess:true,select:true});},apply:function(){var params={},value=this.getValue(),row=false;if(this.data&&this.selectedIndex>-1){row=this.data.rows[this.selectedIndex];}
if(this.fireEvent('beforeApply',this,value,row)===false){return;}
params[this.applyConfig.paramName]=value;if(this.applyConfig.baseParams){Object.extend(params,this.applyConfig.baseParams)}
if(this.applyConfig.url){new Ajax.Request(this.applyConfig.url,{parameters:GUI.toQueryString(params),method:this.applyConfig.method||'post',scope:this,onSuccess:this.onApplySuccess,onFailure:this.onApplyFailure});}},onApplySuccess:function(response,request){try{var data=request.responseJson;this.fireEvent('applySuccess',this,data);}catch(e){console.log('Exception in onApplySuccess: ',e);}},onApplyFailure:function(){this.fireEvent('applyFailure',this);},doSearch:function(){if(this.getValue().length<this.minSearchCharacters){this.hideList();return false;}
if(!this.hideEmptyList)this.hideSearchResults();this.showLoader();var params={};params[this.searchConfig.paramName]=this.getValue();if(this.searchConfig.baseParams){Object.extend(params,this.searchConfig.baseParams)}
if(this._request&&!this._request.complete){this._request.abort();}
this._request=new Ajax.Request(this.searchConfig.url,{parameters:GUI.toQueryString(params),method:this.searchConfig.method,scope:this,onSuccess:this.onSearchSuccess,onFailure:this.onSearchFailure});},onSearchSuccess:function(transport,request){try{var data=request.responseJson;this.data=data;this.hideLoader();if(this.hideEmptyList){if(data.total>0){this.showList();this.showSearchResults(data);}
else{this.hideList();}}
else this.showSearchResults(data);this.fireEvent('searchSuccess',this);}catch(e){}},onSearchFailure:function(){},showList:function(){if(this.listOpened||this.getValue()==''){return;}
this.list.setDimensions({width:GUI.getFullWidth(this.dom)});this.list.setContent(this.listTpl.fetch());if(this.autoApplyPosition)this.list.alignTo(this.dom,'tr-br?');this.list.show();this.listOpened=true;this.hideLoader();this.hideSearchResults();this.jsonview.render();this.attachListEventListeners();},hideList:function(){if(!this.listOpened){return;}
this.removeListEventListeners();this.jsonview.unrender();this.list.hide();this.listOpened=false;},showLoader:function(){if(!this.listOpened){this.showList();}
if(this.loader)GUI.show(this.loaderId);},hideLoader:function(){if(this.listOpened){if(this.loader)GUI.hide(this.loaderId);}},showSearchResults:function(data){if(!this.listOpened){this.showList();}
this.selectedIndex=-1;this.jsonview.update(data);if(this.searchFor&&GUI.$(this.searchForId))GUI.$(this.searchForId).innerHTML=this.getValue();if(GUI.isNumber(this.maxContentHeight)){var div=GUI.$(this.contentId);var h=GUI.getClientHeight(this.jsonview.dom);if(h>this.maxContentHeight){div.style.overflow='auto';div.style.height=this.maxContentHeight.toString()+'px';}}
this.jsonview.show();},hideSearchResults:function(){this.jsonview.hide();},attachEventListeners:function(){Autocompleter.superclass.attachEventListeners.call(this);this.dom.on('keydown',this.onKeyDown,this);this.dom.on('keyup',this.onKeyUp2,this);},removeEventListeners:function(){Autocompleter.superclass.removeEventListeners.call(this);},attachListEventListeners:function(){document.on('mousedown',this.onDocumentMouseDown,this);var jv=GUI.Dom.extend(this.jsonview.dom);jv.on('mouseover',this.onJVMouseOver,this);jv.on('mouseout',this.onJVMouseOut,this);jv.on('click',this.onJVClick,this);},removeListEventListeners:function(){document.un('mousedown',this.onDocumentMouseDown,this);var jv=this.jsonview.dom;jv.un('mouseover',this.onJVMouseOver,this);jv.un('mouseout',this.onJVMouseOut,this);jv.un('click',this.onJVClick,this);},select:function(){if(this.selectedIndex>-1){var data=this.jsonview.getData();var text=data.rows[this.selectedIndex].text.replace(/<[^>]*>/g,'');if(data.rows[this.selectedIndex].id!='searchFor')this.setValue(text);this.fireEvent('select',this,data.rows[this.selectedIndex],text);}
this.hideList();if(this.autoApply){this.apply();}
if(this.selectedIndex==-1&&this.searchApply)this.searchApply(this,this.getValue());},selectRow:function(index){if(this.selectedIndex>-1){var id=this.rowPrefix+this.selectedIndex.toString();var row=GUI.$(id);if(row){GUI.removeClass(row,'hover');}}
if(index>-1){var id=this.rowPrefix+index.toString();var row=GUI.$(id);if(row){GUI.addClass(row,'hover');this.selectedIndex=index;GUI.scrollIntoView(GUI.$(this.contentId),row);}}else{this.selectedIndex=-1;}},moveSelectionNext:function(){var data=this.jsonview.getData();var len=data.rows.length;if(len==0){this.selectedIndex=-1;}else if(this.selectedIndex+1<len){this.selectRow(this.selectedIndex+1);}
else{this.selectRow(0);}},moveSelectionPrev:function(){var data=this.jsonview.getData();var len=data.rows.length;if(len==0){this.selectedIndex=-1;}else if(this.selectedIndex-1>-1){this.selectRow(this.selectedIndex-1);}
else{this.selectRow(len-1);}},onKeyUp2:function(e){e=GUI.Event.extend(e);if(this.searchFor&&GUI.$(this.searchForId))GUI.$(this.searchForId).innerHTML=this.getValue();if(!e.isNavKeyPress()){this.searchTask.delay(this.searchDelay);}},onKeyDown:function(e){e=GUI.Event.extend(e);switch(e.e.keyCode){case e.KEY_DOWN:if(!this.listOpened){this.searchTask.delay(0);}else{this.moveSelectionNext();}
break;case e.KEY_UP:if(this.listOpened){this.moveSelectionPrev();}
break;case e.KEY_RETURN:if(this.listOpened){this.select();}else{if(this.autoApply)this.apply();if(this.searchApply)this.searchApply(this,this.getValue());}
break;case e.KEY_ESC:if(this.listOpened){this.hideList();}
break;}},onDocumentMouseDown:function(e){e=GUI.Event.extend(e);if((this.listOpened&&e.target.within(this.list.dom))||e.target.within(this.dom)){return;}
this.hideList();},getEventRow:function(e){return e.target.findParent('div',this.jsonview.dom,'row');},getRowIndex:function(row){var tmp=row.id.split(this.rowPrefix,2);return tmp[1];},onJVMouseOver:function(e){e=GUI.Event.extend(e);var row=this.getEventRow(e);if(row){if(e.isMouseEnter(row)){var index=this.getRowIndex(row);this.selectRow(index);}}},onJVMouseOut:function(e){e=GUI.Event.extend(e);var row=this.getEventRow(e);if(row){if(e.isMouseLeave(row)){this.selectRow(-1);}}},onJVClick:function(e){e=GUI.Event.extend(e);e.preventDefault();var row=this.getEventRow(e);if(row){this.select();}}});GUI.Forms.Autocompleter=Autocompleter;}());

(function(){var PasswordField=Class.create(GUI.Forms.TextField,{type:'password',className:'x-form-textfield',initialize:function(config){PasswordField.superclass.initialize.call(this,config);}});GUI.Forms.PasswordField=PasswordField;}());

(function(){var TriggerField=Class.create(GUI.Forms.TextField,{wrapperClass:'',longClass:'',triggerEvent:'mousedown',triggerImg:GUI.emptyImageUrl,triggerClass:'x-form-trigger',triggerHoverClass:'x-form-trigger-hover',triggerDisabledClass:'x-form-trigger-disabled',triggerPressedClass:'x-form-trigger-pressed',inTable:false,domTemplate:'<table id="{0}-wrapper" class="x-form-triggerfield {1}" cellspacing="0">'+'<tbody><tr><td class="combo-input"></td>'+'<td class="combo-trigger"><img src="{2}"/></td></tr></tbody></table>',width:150,hiddenInput:false,triggerOnFieldClick:true,initialize:function(config){TriggerField.superclass.initialize.call(this,config);},initComponent:function(){TriggerField.superclass.initComponent.call(this);this.addEvents({trigger:true});},onAssign:function(to){TriggerField.superclass.onAssign.call(this,to);},onRender:function(){this.fieldEl=TriggerField.superclass.onRender.call(this);var tmp=GUI.getFly(),html=this.domTemplate.format(this.id,this.wrapperClass,this.triggerImg);tmp.innerHTML=html;var dom=tmp.removeChild(tmp.firstChild);var wrapper=GUI.Dom.findDescedents(dom,'td.combo-input')[0];wrapper.appendChild(this.fieldEl);if(this.hiddenInput&&this.name){this.fieldEl.name='';this.hiddenField=GUI.createInput(this.name);this.hiddenField.type='hidden';wrapper.appendChild(this.hiddenField);}
return dom;},onAfterRender:function(dom){TriggerField.superclass.onAfterRender.call(this,this.fieldEl);this.triggerEl=GUI.Dom.findDescedents(dom,'td.combo-trigger')[0].firstChild;GUI.Dom.extend(this.triggerEl);this.triggerEl.addClass(this.triggerClass);if(this.inTable){this.dom.addClass('intable');}
if(GUI.isString(this.width)&&this.width.endsWith('%')){this.dom.addClass(this.longClass);}
if(this.cssFloat!='none'){dom.style[GUI.isIE?'styleFloat':'cssFloat']=this.cssFloat;}},onDestroy:function(quick){if(this.triggerEl){this.triggerEl.un();this.triggerEl=null;}
TriggerField.superclass.onDestroy.call(this,quick);},adjustSize:function(w,h){return{width:w,height:h};},attachEventListeners:function(){TriggerField.superclass.attachEventListeners.call(this);this.attachTriggerEvents();},attachTriggerEvents:function(){this.triggerEl.on('mouseover',this.onTriggerMouseOver,this);this.triggerEl.on('mouseout',this.onTriggerMouseOut,this);this.triggerEl.on('mousedown',this.onTriggerMouseDown,this);this.triggerEl.on(this.triggerEvent,this.onTriggerClick,this);this.triggerEl.on('click',this.preventDefaultEvent);if(this.triggerOnFieldClick){this.fieldEl.on(this.triggerEvent,this.onTriggerClick,this);}},preventDefaultEvent:function(e){e=GUI.Event.extend(e);e.preventDefault();},removeEventListeners:function(){this.triggerEl.un();TriggerField.superclass.removeEventListeners.call(this);},focus:function(){if(this.fieldEl){try{this.fieldEl.focus();}catch(e){}}},onDisable:function(){TriggerField.superclass.onDisable.call(this);if(this.fieldEl){this.fieldEl.addClass(this.disabledClass);}},onEnable:function(){TriggerField.superclass.onEnable.call(this);if(this.fieldEl){this.fieldEl.removeClass(this.disabledClass);}},onMouseEnter:function(e){if(!this.disabled){TriggerField.superclass.onMouseEnter.call(this,e);this.triggerEl.addClass(this.triggerHoverClass);}},onMouseLeave:function(e){if(!this.disabled){TriggerField.superclass.onMouseLeave.call(this,e);this.triggerEl.removeClass(this.triggerHoverClass);}},onTriggerMouseOver:function(e){this.onMouseEnter(e);},onTriggerMouseOut:function(e){this.onMouseLeave(e);},onTriggerMouseDown:function(e){if(!this.disabled&&GUI.isLeftClick(e)){this.triggerEl.addClass(this.triggerPressedClass);document.on('mouseup',this.onTriggerMouseUp,this);}},onTriggerMouseUp:function(e){if(!this.disabled&&GUI.isLeftClick(e)){this.triggerEl.removeClass(this.triggerPressedClass);document.un('mouseup',this.onTriggerMouseUp,this);}},onTriggerClick:function(e){},getStylingEl:function(){return this.dom;}});GUI.Forms.TriggerField=TriggerField;}());

(function(){var SpinEdit=Class.create(GUI.Forms.TriggerField,{value:0,size:1,step:1,digits:2,leadingZero:false,wrapperClass:'x-form-spinedit',longClass:'longspinedit',triggerClass:'x-form-spinedit-trigger',triggerUpClass:'x-form-trigger-up',triggerUpHoverClass:'x-form-trigger-up-hover',triggerUpPressedClass:'x-form-trigger-up-pressed',triggerUpDisabledClass:'x-form-trigger-up-disabled',triggerDownClass:'x-form-trigger-down',triggerDownHoverClass:'x-form-trigger-down-hover',triggerDownPressedClass:'x-form-trigger-down-pressed',triggerDownDisabledClass:'x-form-trigger-down-disabled',triggerUpDisabled:false,triggerDownDisabled:false,triggerOnFieldClick:false,domTemplate:'<table id="{0}-wrapper" class="x-form-triggerfield {1}" cellspacing="0">'+'<tbody><tr><td class="combo-input"></td>'+'<td class="combo-trigger"><span><img class="" src="{2}"/>'+'<img class="" src="{2}"/></span></td></tr></tbody></table>',initialize:function(config){SpinEdit.superclass.initialize.call(this,config);},getValue:function(){return parseInt(SpinEdit.superclass.getValue.call(this),10);},setValue:function(value,silent){if(!silent){if(this.fireEvent('beforechange',this,value)===false){return false;}}
if(!GUI.isNumber(value)){value=parseInt(value,10);if(isNaN(value)){value=0;}}
value=value.constrain(this.min,this.max);var oldValue=this.getValue();this.value=value;if(this.fieldEl){var formattedValue;if(value===null||value===undefined){formattedValue='';}else{formattedValue=this.leadingZero?value.toPaddedString(this.digits):value.toString();}
this.fieldEl.value=formattedValue;this.validate();}
if(value!=oldValue&&!silent){this.fireEvent('change',this,value,oldValue);}
if(this.dom){if(value==this.min){if(!this.triggerDownDisabled){this.triggerDownDisabled=true;if(this.triggerDownEl){this.triggerDownEl.addClass(this.triggerDownDisabledClass);}}}else if(this.triggerDownDisabled){this.triggerDownDisabled=false;if(this.triggerDownEl){this.triggerDownEl.removeClass(this.triggerDownDisabledClass);}}
if(value==this.max){if(!this.triggerUpDisabled){this.triggerUpDisabled=true;if(this.triggerUpEl){this.triggerUpEl.addClass(this.triggerUpDisabledClass);}}}else if(this.triggerUpDisabled){this.triggerUpDisabled=false;if(this.triggerUpEl){this.triggerUpEl.removeClass(this.triggerUpDisabledClass);}}}},initComponent:function(){SpinEdit.superclass.initComponent.call(this);this.addEvents({triggerUp:true,triggerDown:true,beforechange:true});if(!GUI.isNumber(this.value)){var value=parseInt(this.value,10);this.value=(isNaN(value))?0:value;}},attachEventListeners:function(){SpinEdit.superclass.attachEventListeners.call(this);},attachTriggerEvents:function(){this.triggerEl.on('mouseover',this.onTriggerMouseOver,this);this.triggerEl.on('mouseout',this.onTriggerMouseOut,this);this.dom.on('keydown',this.onKeyDown,this);},onKeyDown:function(e){e=GUI.Event.extend(e);switch(e.getKey()){case e.KEY_UP:this.setValue(this.value+this.step);break;case e.KEY_DOWN:this.setValue(this.value-this.step);break;}},onAssign:function(to){SpinEdit.superclass.onAssign.call(this,to);var v;if(GUI.isSet(v=to.getAttribute('max'))){this.max=parseInt(v,10);}
if(GUI.isSet(v=to.getAttribute('min'))){this.min=parseInt(v,10);}
if(GUI.isSet(v=to.getAttribute('step'))){this.step=parseInt(v,10);}
if(GUI.isSet(v=to.getAttribute('leadingzero'))){this.leadingZero=true;}else{this.leadingZero=false;}
if(GUI.isSet(v=to.getAttribute('digits'))){this.digits=parseInt(v,10);}},onAfterRender:function(dom){SpinEdit.superclass.onAfterRender.call(this,dom);this.triggerUpEl=GUI.Dom.extend(this.triggerEl.firstChild);this.triggerDownEl=GUI.Dom.extend(this.triggerEl.lastChild);this.triggerUpEl.addClass(this.triggerUpClass);if(this.triggerUpDisabled){this.triggerUpEl.addClass(this.triggerUpDisabledClass);}
this.triggerDownEl.addClass(this.triggerDownClass);if(this.triggerDownDisabled){this.triggerDownEl.addClass(this.triggerDownDisabledClass);}
var ClickRepeater=GUI.Utils.ClickRepeater;this.upRepeater=new ClickRepeater({dom:this.triggerUpEl,pressedClass:this.triggerUpPressedClass,listeners:{scope:this,click:this.onTriggerUpClick}});this.downRepeater=new ClickRepeater({dom:this.triggerDownEl,pressedClass:this.triggerDownPressedClass,listeners:{scope:this,click:this.onTriggerDownClick,pressedClass:this.triggerDownPressedClass}});},onDestroy:function(quick){this.triggerUpEl=null;this.triggerDownEl=null;if(this.downRepeater){this.downRepeater.destroy();this.downRepeater=null;}
if(this.upRepeater){this.upRepeater.destroy();this.upRepeater=null;}
SpinEdit.superclass.onDestroy.call(this,quick);},onBeforeBlur:function(){var v=parseInt(this.getRawValue(),10);if(isNaN(v)||v!=v.constrain(this.min,this.max)){v=this.startValue;}
this.setRawValue(v);},onTriggerUpClick:function(){if(!this.disabled&&!this.triggerUpDisabled){this.setValue(this.value+this.step);}},onTriggerDownClick:function(){if(!this.disabled&&!this.triggerDownDisabled){this.setValue(this.value-this.step);}},onTriggerMouseOver:function(e){e=new GUI.ExtendedEvent(e);if(!this.disabled){if(e.target==this.triggerUpEl){this.triggerUpEl.addClass(this.triggerUpHoverClass);}else if(e.target==this.triggerDownEl){this.triggerDownEl.addClass(this.triggerDownHoverClass);}
this.onMouseEnter(e);}},onTriggerMouseOut:function(e){e=new GUI.ExtendedEvent(e);if(!this.disabled){if(e.target==this.triggerUpEl){this.triggerUpEl.removeClass(this.triggerUpHoverClass);}else if(e.target==this.triggerDownEl){this.triggerDownEl.removeClass(this.triggerDownHoverClass);}
if(!((e.relatedTarget==this.fieldEl)||GUI.contains(this.fieldEl,e.relatedTarget))){this.onMouseLeave(e);}}}});GUI.Forms.SpinEdit=SpinEdit;}());

(function(){var i18n=GUI.i18n;var Combo=Class.create(GUI.Forms.TriggerField,{listHeight:'auto',listWidth:'auto',listMessageClass:'x-form-combo-list-message',minWidth:0,wrapperClass:'x-form-combo',listClass:'x-form-combo-list',itemClass:'x-form-combo-list-item',itemSelectedClass:'x-form-combo-list-item-selected',itemHoverClass:'x-form-combo-list-item-hover',minWidthClass:'x-form-combo-list-minwidth',hintClass:'x-combo-hint',hoverClass:'x-form-combo-hover',invalidClass:'x-form-combo-invalid',hintOffsetX:-7,hintOffsetY:2,valueField:'value',listField:'text',textField:'text',descriptionField:'description',readOnly:false,selectedIndex:-1,hiddenInput:true,autoWidth:false,autoReapplyAutoWidth:true,minWidth:35,width:150,allowDeselect:false,triggerEvent:'mousedown',value:'',domTemplate:'<table id="{0}-wrapper" class="x-form-triggerfield {1}" cellspacing="0">'+'<tbody><tr><td class="combo-input"><div></div><span class="combo-input-wrapper"></span></td>'+'<td class="combo-trigger"><a href="#"></a></td></tr></tbody></table>',autocomplete:false,selectOnFocus:true,showListOnClick:true,minSearchCharacters:1,searchDelay:0,searchParam:'query',resultsField:'results',typeAhead:true,searchFields:[],substituteValue:true,initialize:function(config){Combo.superclass.initialize.call(this,config);},initComponent:function(){Combo.superclass.initComponent.call(this);this.addEvents({listShow:true,listHide:true,beforeSelect:true,select:true});this.itemSelector='div.'+this.itemClass;this.initSelectionModel();if(GUI.isArray(this.options)){var options=this.options;this.options=new GUI.Utils.Collection();this.suspendEvents();this.setOptions(options);this.resumeEvents();}else{this.options=new GUI.Utils.Collection();}
this._listItems=this.options.items;this.searchTask=new GUI.Utils.DelayedTask(this.doSearch,this);},getDefaultSmConfig:function(){return{singleSelect:true};},initSelectionModel:function(){if(!this.sm){this.sm=new GUI.Forms.Combo.SelectionModel(this.getDefaultSmConfig());}
this.sm.init(this);},onBeforeAssign:function(dom){return dom.nodeName=='SELECT'&&!dom.multiple;},onAssign:function(elem){Combo.superclass.onAssign.call(this,elem);this.autoWidth=!!elem.getAttribute('autoWidth');var listWidth=elem.getAttribute('listWidth');if(GUI.isString(listWidth)&&listWidth.length){this.listWidth=parseInt(listWidth,10);}
var listHeight=elem.getAttribute('listHeight');if(GUI.isString(listHeight)&&listHeight.length){this.listHeight=parseInt(listHeight,10);}
var v=elem.getAttribute('minWidth');if(GUI.isSet(v)){this.minWidth=parseInt(v,10);}
var v=elem.getAttribute('maxWidth');if(GUI.isSet(v)){this.maxWidth=parseInt(v,10);}
var options=elem.options,o;this.suspendEvents();this.clear();for(var i=0,len=options.length;i<len;i++){o=options[i];this.add({text:o.text,value:o.value,selected:o.defaultSelected||o.selected});}
this.resumeEvents();},onAfterRender:function(dom){this.divEl=GUI.Dom.extend(dom.getElementsByTagName('div')[0]);var focusEl=GUI.Dom.extend(dom.getElementsByTagName('a')[0]);focusEl.on('focus',this.onFocus,this);focusEl.on('blur',this.onBlur,this);this.focusEl=focusEl;Combo.superclass.onAfterRender.call(this,dom);var span=GUI.Dom.findDescedent(dom,'span.combo-input-wrapper');span.appendChild(this.divEl);span.appendChild(this.fieldEl);this.fieldEl.on('focus',this.onFocus,this);if(this.autoWidth){this.doAutoWidth();}
if(this.unselectable){if(GUI.isIE){this.dom.unselectable='on';this.divEl.unselectable='on';}}},onBlur:function(){if(!this.listOpened){Combo.superclass.onBlur.call(this);if(this.autocomplete&&this.textFieldVisible){this.hideTextField();this.searchTask.cancel();if(this._searchRequest&&!this._searchRequest.complete){this._searchRequest.abort();this.clearListMessage();}}}},onDestroy:function(fast){this.clearItemsDom();this.listFocusEl=this.listHolder=null;if(this.listOpened){this.hideList();}
if(this.list){this.list.destroy();this.list=null;}
this.divEl=this.focusEl=this.triggerEl=null;Combo.superclass.onDestroy.call(this,fast);},attachEventListeners:function(){this.divEl.on('mouseenter',this.onMouseEnter,this);this.divEl.on('mouseleave',this.onMouseLeave,this);this.divEl.on('click',this.onMouseDown,this);this.divEl.on('click',this.onClick,this);this.triggerEl.on('mouseover',this.onTriggerMouseOver,this);this.triggerEl.on('mouseout',this.onTriggerMouseOut,this);this.triggerEl.on('mousedown',this.onTriggerMouseDown,this);this.triggerEl.on('keydown',this.onTriggerKeyDown,this);this.triggerEl.on('keyup',this.onTriggerKeyUp,this);this.triggerEl.on(this.triggerEvent,this.onTriggerClick,this);this.triggerEl.on('click',this.preventDefaultEvent);if(this.triggerOnFieldClick){this.fieldEl.on(this.triggerEvent,this.onTriggerClick,this);}
if(this.defaultText){this.on('blur',this.postBlur,this);this.on('focus',this.preFocus,this);this.applyDefaultText();}},getValue:function(){if(this.valueField){return typeof this.value!='undefined'?this.value:'';}else{return Combo.superclass.getValue.call(this);}},_resetSelectedPropertyItem:function(item){item.selected=false;},resetSelectedProperty:function(){this.options.each(this._resetSelectedPropertyItem);},setValue:function(v,quiet){if(this.dom){this.dom.removeClass(this.defaultTextClass);}
var text=v;this.resetSelectedProperty();if(this.valueField){var r=this.findRecord(this.valueField,v);if(r){text=r[this.textField];this.selectedIndex=this.options.indexOf(r);this.sm.selectItem(r,false,true);}else{if(this.valueNotFoundText!==undefined){text=this.valueNotFoundText;}
this.selectedIndex=-1;}}
this.lastSelectionText=text;var oldValue=this.getValue();if(this.hiddenField){this.hiddenField.value=v;}
this.value=this.startValue=v;if(this.divEl){var span=(text===null||text===undefined?'':text);this.divEl.innerHTML='<span'+(this.unselectable&&GUI.isIE?' unselectable="on"':'')+'>'+span+'</span>';}
if(this.fieldEl){this.fieldEl.value=(text===null||text===undefined)?'':text;}
if(!quiet&&(v!=oldValue)){this.fireEvent('change',this,v,oldValue);}
this.applyDefaultText();},setRawValue:function(v){if(this.divEl){this.divEl.innerHTML='<span'+(this.unselectable&&GUI.isIE?' unselectable="on"':'')+'>'+
(v===null||v===undefined?'':v)+'</span>';}
if(this.fieldEl){this.fieldEl.value=v;}},getRawValue:function(){if(this.fieldEl&&this.textFieldVisible){return this.fieldEl.value;}
return(this.divEl&&this.divEl.firstChild)?this.divEl.firstChild.innerHTML:'';},clear:function(){this.options.clear();this.setValue('',true);},add:function(option){option=Object.clone(option);if(!option.id){option.id=GUI.getUniqId('');}
option.domId=this.id+'-item-'+option.id;this.options.add(option);this.onItemAdd(option);if(option.selected){this.sm.selectItem(option,true);}
this._listItems=this.options.items;},setOptions:function(options){this.options.clear();this.sm.clearSelections();for(var i=0,len=options.length;i<len;i++){this.add(options[i]);}
if(this.autoWidth&&this.autoReapplyAutoWidth&&this.dom){this.doAutoWidth();}
if(this.listOpened){this.updateList();}},getValueField:function(){return this.valueField||this.textField;},getOptionValue:function(option){return option[this.getValueField()];},findRecord:function(field,value){return this.options.find(function(item){return item[field]==value;});},getItemByDomId:function(id){return this.findRecord('domId',id);},getItemByValue:function(value){return this.findRecord(this.getValueField(),value);},getIndexByValue:function(v){var r=this.findRecord((this.valueField)?this.valueField:this.textField,v);return this.options.indexOf(r);},selectItem:function(i){this.select(parseInt(i,10));},select:function(v){if(GUI.isNumber(v)){var r=this.options.itemAt(v);this.setValue(r?this.getOptionValue(r):'');}else{this.setValue(v);}},hideHint:function(){if(this.hintList&&this.hintList.getVisibility()){this.hintList.dom.un();this.hintList.hide();this.hintAssignedNode=null;}},getHintAlignNode:function(node){return node;},showHint:function(node,text,descr){if(!this.hintList){this.hintList=new GUI.Popup.Region();}
if(this.hintList.getVisibility()){this.hideHint();}
this.hintList.setContent(GUI.Popup.Hint.renderHint({caption:text,text:descr}));this.hintList.alignTo(this.getHintAlignNode(node),'l-l',[this.hintOffsetX,this.hintOffsetY]);this.hintList.show();this.hintAssignedNode=node;var dom=this.hintList.dom;GUI.Dom.extend(dom);dom.on('click',this.onHintClick,this);},onHintClick:function(e){GUI.Event.fire(this.hintAssignedNode,e.type,{});},getListDom:function(){return this.list&&this.list.dom;},focus:function(){if(this.dom&&this.dom.hasClass(this.defaultTextClass)){this.dom.removeClass(this.defaultTextClass);}
if(this.textFieldVisible){try{this.fieldEl.focus();}catch(e){}}else if(this.focusEl){try{this.focusEl.focus();}catch(e){}}},deferFocus:function(){this.focus.defer(20,this);},focusItem:function(node){if(this.selectedId){if(this.selectedId!=node.id){GUI.$(this.selectedId).removeClass(this.itemHoverClass);this.hideHint();}}
this.selectedId=node.id;this.onFocusItem(node);},onFocusItem:function(node){node.addClass(this.itemHoverClass);GUI.scrollIntoView(this.getListDom(),node,'v');var item=this.getItemByDomId(node.id);if(item){if(node.scrollWidth>node.offsetWidth){this.showHint(node,item[this.listField],item[this.descriptionField]);}}},focusFirst:function(){var node=this.getListDom().findChild(this.itemSelector);if(node){this.focusItem(node);}},focusNext:function(){if(!this.selectedId){this.focusFirst();}else{var nextNode=GUI.Dom.findNextSibling(GUI.$(this.selectedId),this.itemSelector)[0];if(nextNode){this.focusItem(nextNode);}}},focusPrev:function(){if(!this.selectedId){this.focusLast();}else{var prevNode=GUI.Dom.findPrevSibling(GUI.$(this.selectedId),this.itemSelector)[0];if(prevNode){this.focusItem(prevNode);}}},focusLast:function(){var items=this.getListDom().findChild('.'+this.itemClass);if(items&&items.length>0){this.focusItem(items[items.length-1]);}},getItemIndex:function(node){var item=this.getItemByDomId(node.id);if(item){return this.options.indexOf(item);}
return-1;},doAutoWidth:function(){var needReopen=false;if(this.listOpened){this.hideList();needReopen=true;}
this.initList();this.list.config.dimensions.width=null;this.list.setPosition(0,-10000);this.list.show();var width=this.list.getWidth();this.list.hide();width=this.adjustAutoWidth(width);width=width.constrain(this.minWidth,this.maxWidth);this.setWidth(width);if(needReopen){this.showList();}},adjustAutoWidth:function(width){return width+18-1;},getListItemHtml:function(item){var itemClass=this.itemClass;if(item.selected){itemClass+=' '+this.itemSelectedClass;}
var itemHtml='<div unselectable="on" class="x-form-combo-list-item-text">'+item[this.listField]+'</div>',descrHtml;if(GUI.isSet(item[this.descriptionField])){descrHtml='<div unselectable="on" class="x-form-combo-list-item-description">'+item[this.descriptionField]+'</div>';}else{descrHtml='';}
return'<div unselectable="on" id="'+item.domId+'" class="'+itemClass+'">'+itemHtml+descrHtml+'</div>';},getListHtml:function(items){var html=new GUI.StringBuffer();if(this.minWidth){html.append('<div class="'+this.minWidthClass+'" style="width: '+this.minWidth+'px;"></div>');}
var hasMessage=GUI.isSet(this.listMessage)&&this.listMessage!='';html.append('<div class="'+this.listMessageClass+'" style="display: '+
(hasMessage?'block':'')+';">'+(hasMessage?this.listMessage:'')+'</div>');items=items||this._listItems;for(var i=0,len=items.length;i<len;i++){html.append(this.getListItemHtml(items[i]));}
return html.toString();},initList:function(items){if(!this.list){this.list=new GUI.Popup.Region({className:this.listClass,parentNode:this.listHolder?this.listHolder:document.body,border:'1'});}
if(GUI.isNumber(this.listWidth)){this.list.config.dimensions.width=this.listWidth;}
this.updateList(items);if(this.listOpened){this.list.alignTo(this.dom,'tl-bl?');}},updateList:function(items){if(this.list){this.list.setContent(this.getListHtml(items));}
var lastFocusedNode=GUI.$(this.selectedId);if(lastFocusedNode){this.onFocusItem(lastFocusedNode);}else{this.selectedId=null;}},showList:function(items){this.initList(items);if(!this.listOpened){if(this.listWidth=='auto'){this.list.config.dimensions.width=this.dom.offsetWidth;}
this.list.show();var dom=this.list.dom;GUI.Dom.extend(dom);if(this.listWidth=='content'&&GUI.isIE){dom.style.visibility='hidden';setTimeout(function(){GUI.setFullWidth(dom,dom.offsetWidth);dom.style.visibility='';},1);}
var a=document.createElement('a');a.className='jsgui-combo-list-focuslink';a.href='#';a.tabIndex=-1;dom.appendChild(a);a.innerHTML='&#160;';this.listFocusEl=GUI.Dom.extend(a);dom.on('mouseover',this.onListMouseOver,this);dom.on('mouseout',this.onListMouseOut,this);dom.on('mousedown',this.onListMouseDown,this);dom.on('click',this.onListClick,this);document.on('mousedown',this.onDocumentMouseDown,this);dom.on('keydown',this.onListKeyDown,this);dom.on('keyup',this.onListKeyUp,this);if(GUI.isNumber(this.listHeight)&&this.options.length>this.listHeight){if(!GUI.isSet(this.itemHeight)){var item=dom.findDescedents('div.'+this.itemClass)[0];this.itemHeight=item.offsetHeight;}
GUI.setClientHeight(dom,this.itemHeight*this.listHeight);}
this.listOpened=true;this.fireEvent('listShow',this);}
if(this.autocomplete){}
this.list.alignTo(this.dom,'tl-bl?');(function(){if(!this.listOpened){return;}
var v=this.getValue(),selItem=this.findRecord(this.valueField,v);if(selItem){var
itemDom=this.getItemDom(selItem);if(itemDom){this.selectedId=itemDom.id;GUI.scrollIntoView(this.list.dom,itemDom,'v');}}}).defer(20,this);},deferFocusList:function(){this.focusList.defer(20,this);},focusList:function(){if(this.listFocusEl){try{this.listFocusEl.focus();}catch(e){}}},hideList:function(){if(this.listOpened){this.hideHint();document.un('mousedown',this.onDocumentMouseDown,this);this.list.dom.un();this.list.hide();this.clearItemsDom();this.listOpened=false;this.fireEvent('listHide',this);this.selectedId=null;this.focus();}},onTriggerKeyDown:function(e){e=GUI.Event.extend(e);switch(e.getKey()){case e.KEY_DOWN:e.stop();break;}},onTriggerKeyUp:function(e){e=GUI.Event.extend(e);if(this.listOpened){return;}
switch(e.getKey()){case e.KEY_DOWN:this.showList();break;}},onTriggerClick:function(e){e=GUI.Event.extend(e);if(!this.disabled){this._listItems=this.options.items;if(this.listOpened){this.hideList();}else{if(this.autocomplete&&this.dataUrl){this._listItems=[];this.sm.clearSelections();this.options.clear();this.updateList();this.setListMessage(GUI.formatString(i18n.GUI_ENTER_CHARATER,this.minSearchCharacters));}
else{if((this.getValue()=='')&&(this.options.length==0)){this.setListMessage(GUI.formatString(i18n.GUI_ENTER_CHARATER,this.minSearchCharacters));}else{this.clearListMessage();}}
this.showList();this.deferFocusList();}}},onDocumentMouseDown:function(e){e=GUI.Event.extend(e);var t=e.target;if(!(t.within(this.list.dom)||(this.hintList&&t.within(this.hintList.dom))||t.within(this.dom))){this.hideList();if(this.textFieldVisible){this.hideTextField();}
if(this.defaultText&&this.dom&&!this.dom.hasClass(this.defaultTextClass)){this.dom.addClass(this.defaultTextClass);}}},_preSelectOption:function(){var item;if(this.selectedId){item=this.getItemByDomId(this.selectedId);}
if(item){if(this._lastSearchedText!=null&&this.substituteValue){this.fieldEl.value=item[this.textField];this.selectText(this._lastSearchedText.length);}}},onListKeyDown:function(e){e=GUI.Event.extend(e);switch(e.getKey()){case e.KEY_DOWN:e.stop();if(this.selectedId){this.focusNext();}else{this.focusFirst();}
this._preSelectOption();break;case e.KEY_UP:e.stop();if(this.selectedId){this.focusPrev();}else{this.focusLast();}
this._preSelectOption();break;case e.KEY_RETURN:e.preventDefault();break;}},onListKeyUp:function(e){e=GUI.Event.extend(e);switch(e.getKey()){case e.KEY_ESC:e.stop();this.hideList();break;case e.KEY_RETURN:if(this.selectedId){this.onListItemClick(this.selectedId);}
break;default:if(this.autocomplete&&!e.isSpecialKey()){this.searchTask.delay(this.searchDelay);}}},onListMouseDown:function(e){e=GUI.Event.extend(e);if(e.target.nodeName!='INPUT'){e.stop();}else{e.stopPropagation();}},onListClick:function(e){var node,item;e=GUI.Event.extend(e);if((node=e.target.queryParent(this.itemSelector))){this.onListItemClick(node.id);}},onListItemClick:function(nodeId){var item=this.getItemByDomId(nodeId);if(item){this.fireEvent('itemClick',this,item);if(this.textFieldVisible){this._lastSearchedText=null;this.selectText(this.fieldEl.value.length);}}
this.hideList();},onListMouseOver:function(e){e=GUI.Event.extend(e);var node;if((node=e.target.queryParent(this.itemSelector))){if(e.isMouseEnter(node)){this.onItemMouseEnter(node);}}},onListMouseOut:function(e){e=GUI.Event.extend(e);var node;if((node=e.target.queryParent(this.itemSelector))){if(e.isMouseLeave(node)){this.onItemMouseLeave(node);}}},onClick:function(){if(this.disabled){return;}
if(this.listOpened){this.hideList();}else if(this.showListOnClick){this.showList();}},onMouseEnter:function(event){if(!this.disabled){this.triggerEl.addClass(this.triggerHoverClass);this.dom.addClass(this.hoverClass);}},onMouseLeave:function(event){if(!this.disabled){this.triggerEl.removeClass(this.triggerHoverClass);this.dom.removeClass(this.hoverClass);}},onItemAdd:function(){},onItemRemove:function(item){if(item.dom){GUI.remove(item.dom);item.dom=null;}},getItemDom:function(item){return(item.dom=GUI.$(item.domId));},clearItemsDom:function(){this.options.each(function(item){item.dom=null;});},onItemMouseOver:function(item){this.focusItem(this.options.indexOf(item));},onItemMouseEnter:function(node){var item=this.getItemByDomId(node.id);if(item){this.focusItem(node);this.fireEvent('itemMouseOver',this,item);}else{GUI.Dom.addClass(node,this.itemHoverClass);}},onItemMouseLeave:function(node){node.removeClass(this.itemHoverClass);this.selectedId=null;},onItemSelect:function(item){this.setValue(this.getOptionValue(item));},onItemDeselect:function(item){var dom=this.getItemDom(item);if(dom){dom.removeClass(this.itemSelectedClass);}},showTextField:function(){var selItem=this.sm.getSelected();this.fieldEl.value=selItem?selItem[this.textField]:'';this._lastSearchedText=null;this.fieldEl.style.display='block';this.textFieldVisible=true;this.fieldEl.un();this.fieldEl.on('keydown',this.onInputKeyDown,this);this.fieldEl.on('keyup',this.onInputKeyUp,this);this.fieldEl.on('blur',this.onBlur,this);this.fieldEl.select();this.deferFocus();},hideTextField:function(){this.fieldEl.style.display='';this.fieldEl.un('keydown',this.onInputKeyDown,this);this.fieldEl.un('keyup',this.onInputKeyUp,this);this.fieldEl.un('blur',this.onBlur,this);this.textFieldVisible=false;},onMouseDown:function(e){if(this.autocomplete&&!this.disabled){this.showTextField();}},doSearch:function(){var val=this.fieldEl.value;if(this._lastSearchedText===val){return;}
this._lastSearchedText=val;if(val.length<this.minSearchCharacters){if(val==''&&!this.dataUrl){this._listItems=this.options.items;this.clearListMessage();this.updateList();return;}
this.setListMessage(GUI.formatString(i18n.GUI_ENTER_CHARATER,this.minSearchCharacters));return;}
var data={};if(this.baseParams){Object.extend(data,this.baseParams);}
data[this.searchParam]=val;if(this.dataUrl){if(this._searchRequest&&!this._searchRequest.complete){this._searchRequest.abort();}
this._listItems=[];this.setListMessage(i18n.GUI_SEARCHING);this.updateList();this._searchRequest=new GUI.Ajax.Request(this.dataUrl,{method:'post',data:data,scope:this,onSuccess:this.onSearchSuccess,onFailure:this.onSearchFailure});}else{var options=this.options.items,len=options.length,i,filteredOptions=[],lcVal=val.toLowerCase();for(i=0;i<len;i++){option=options[i];if(this.searchFields&&this.searchFields.length>0){var search_flag=false;for(var j=0;j<this.searchFields.length;j++){if(option[this.searchFields[j]]){if(option[this.searchFields[j]].toLowerCase().indexOf(lcVal)===0){search_flag=true;}}}
if(search_flag){option=Object.clone(option);option.selected=false;filteredOptions.push(option);}}
else{if(option[this.textField].toLowerCase().indexOf(lcVal)===0){option=Object.clone(option);option.selected=false;filteredOptions.push(option);}}}
this.showFilteredList(filteredOptions);}},showFilteredList:function(options){if(options.length){this.clearListMessage();}else{this.setListMessage(i18n.GUI_NO_RECORDS_FOUND);this.selectedId=null;}
if(this.dataUrl){this.setOptions(options);}else{this._listItems=options;}
if(!this.listOpened){this.showList();}else{this.updateList();}
if(this.typeAhead){var item=options[0];if(item){var selStart=this.getRawValue().length,newValue=item[this.textField];if(this._lastInputKey!=8&&this._lastInputKey!=46&&this.substituteValue){this.fieldEl.value=newValue;this.selectText(selStart);}
if(!this.selectedId){this.focusFirst();}}}},onSearchSuccess:function(response,req){var json=req.responseJson;if(json&&json[this.resultsField]){var options=json[this.resultsField];this.showFilteredList(options);}},onSearchFailure:function(){this._listItems=[];this.setListMessage(i18n.GUI_SEARCH_FAILURE);},onInputKeyDown:function(e){e=GUI.Event.extend(e);var key=e.getKey();if(((key==e.KEY_DOWN)||(key==e.KEY_UP))&&!this.listOpened){this._listItems=this.options.items;this.clearListMessage();this.showList();return;}
switch(key){case e.KEY_DOWN:e.stop();if(this.selectedId){this.focusNext();}else{this.focusFirst();}
this._preSelectOption();break;case e.KEY_UP:e.stop();if(this.selectedId){this.focusPrev();}else{this.focusLast();}
this._preSelectOption();break;case e.KEY_RETURN:e.preventDefault();break;}},onInputKeyUp:function(e){e=GUI.Event.extend(e);this._lastInputKey=e.getKey();switch(this._lastInputKey){case e.KEY_ESC:e.stop();this.hideList();break;case e.KEY_RETURN:if(this.selectedId){this.onListItemClick(this.selectedId);}
break;case e.KEY_BACKSPACE:case e.KEY_DELETE:if(this.fieldEl.value==''){this.selectItem(-1);this.sm.clearSelections();break;}
default:if(this.autocomplete&&!e.isSpecialKey()){this.searchTask.delay(this.searchDelay);}}},setListMessage:function(msg){this.listMessage=msg;if(this.listOpened){var div=this.getListDom().findDescedent('div.'+this.listMessageClass);if(div){div.innerHTML=msg;}
div.style.display=(msg==='')?'':'block';}else{this.updateList();if(msg!=''){this.showList();}}},clearListMessage:function(){this.setListMessage('');}});GUI.Forms.Combo=Combo;}());

(function(){var ComboTree=Class.create(GUI.Forms.Combo,{type:'hidden',hiddenInput:false,className:'x-form-combotree',listHeight:10,itemHeight:18,width:200,rootText:'Root',lazyInitList:false,multiple:false,autoLoad:true,rtl:false,initialize:function(config){ComboTree.superclass.initialize.call(this,config);},initComponent:function(){ComboTree.superclass.initComponent.call(this);if(!this.tree||!this.tree.render){this.initTree();}
if(!this.lazyInitList){this.initList();}},initTree:function(){var rootConfig={id:'null',text:this.rootText,async:false,expanded:this.autoLoad};if(this.tree&&this.tree.dataUrl){rootConfig.async=true;}
if(this.options){rootConfig.child=this.options;}
var treeConfig={checkBox:true,freeCheckbox:true,alwaysExpanded:false,rootVisible:this.multiple?true:false,root:new GUI.Tree.Node(rootConfig),height:'auto'};if(!this.multiple){treeConfig.checkBox=false;}
if(this.tree){Object.extend(treeConfig,this.tree);delete this.tree;}
this.tree=new GUI.Tree(treeConfig);this.tree.on('select',this.onNodeSelect,this);this.tree.on('nodecollapse',this.checkListHeight,this);this.tree.on('nodeexpand',this.checkListHeight,this);},onAfterRender:function(dom){ComboTree.superclass.onAfterRender.call(this,dom);},onNodeSelect:function(tree,node){if(!this.multiple){this.selectedNode=node;this.setValue(node.id);this.hideList();}else{var checked=node.checked;tree.clearChecked(true);node.setChecked(true);}},initList:function(){if(!this.list){this.list=new GUI.Popup.Region({className:this.listClass,parentNode:this.listHolder?this.listHolder:document.body,dimensions:{top:-10000},border:'1'});this.list.show();var a=document.createElement('a');a.className='jsgui-combo-list-focuslink';a.href='#';a.tabIndex=-1;this.list.dom.appendChild(a);a.innerHTML='&#160;';this.listFocusEl=GUI.Dom.extend(a);}
if(GUI.isNumber(this.listWidth)){this.list.setDimensions({width:this.listWidth});}
if(!this.tree.rendered){this.tree.render(this.list.dom);}
if(this.listOpened){this.list.alignTo(this.fieldEl,'tl-bl?');}},showList:function(){this.initList();if(!this.listOpened){if(this.listWidth=='auto'){var w=this.dom.offsetWidth;this.tree.setWidth(w-2);this.list.setDimensions({width:w});}
if(GUI.isSet(this.listHeight)){this.checkListHeight();}
var dom=this.list.dom;document.on('mousedown',this.onDocumentMouseDown,this);this.listOpened=true;}
this.list.alignTo(this.dom,'tl-bl?');this.focusList();this.deferFocusList();this.fireEvent('listShow',this);},hideList:function(){if(this.listOpened){document.un('mousedown',this.onDocumentMouseDown,this);this.list.setDimensions({top:-10000});this.listOpened=false;this.fireEvent('listHide',this);this.updateValue();}},updateValue:function(){var rawValue='';if(this.multiple){var arr=this.tree.getCheckedNodes(),count=arr.length,allCount=this.tree.getNodesCount();if(!this.tree.isRootVisible()){allCount--;}
switch(count){case 0:rawValue='';break;case 1:rawValue=arr[0].config.text;break;case allCount:rawValue=GUI.i18n.GUI_ALL
break;default:rawValue=GUI.i18n.GUI_MULTIPLE_SELECTION;break;}}else{var node=this.tree.getSelectedNode();rawValue=node?node.config.text:'';}
this.setRawValue(rawValue);if(this.dom&&rawValue.length>0){this.dom.removeClass(this.defaultTextClass);}
this.applyDefaultText();},attachEventListeners:function(){ComboTree.superclass.attachEventListeners.call(this);if(this.triggerOnFieldClick){this.fieldEl.on(this.triggerEvent,this.onTriggerClick,this);}},onTriggerClick:function(){this.showList();},onBeforeAssign:function(dom){return dom.nodeName=='SELECT';},onAssign:function(elem){ComboTree.superclass.onAssign.call(this,elem);var options=elem.options;this.clear();for(var i=0,len=options.length;i<len;i++){var o=options[i];this.add({id:o.value,text:o.text,checked:o.selected});}},getStylingEl:function(){return this.dom;},onDestroy:function(fast){if(this.tree){this.tree.destroy(fast);this.tree=null;}
ComboTree.superclass.onDestroy.call(this,fast);},getSelections:function(){if(this.multiple){return this.tree.getCheckedNodes();}else{var node=this.tree.getSelectedNode();return(node)?[node]:[];}},getTree:function(){return this.tree;},getValue:function(){var ids=[];if(this.tree){var nodes=this.tree.getCheckedNodes();for(var i=0,len=nodes.length;i<len;i++){ids[i]=nodes[i].id;}}
return ids;},setValue:function(ids){var node;this.tree.root.setChecked(false,true,true);if(GUI.isArray(ids)){for(var i=0,len=ids.length;i<len;i++){node=this.tree.getNodeById(ids[i]);if(node){if(this.multiple){node.setChecked(true);}else{this.tree.selectNode(node,true);break;}}}}else{node=this.tree.getNodeById(ids);if(node){if(this.multiple){node.setChecked(true);}else{this.tree.selectNode(node,true);}}}
this.updateValue();},clear:function(){this.tree.root.removeChildren();},add:function(option){return this.tree.root.appendChild(new GUI.Tree.Node(option));},setOptions:function(options){if(!this.tree||!this.tree.render){this.initTree();}
this.tree.root.loadChildren(options);},reloadData:function(){this.tree.root.reload();},checkListHeight:function(){var tree=this.tree,h=tree.getScrollHeight(),maxHeight=this.itemHeight*this.listHeight;if(this._listHeightLimited){if(h<maxHeight){tree.setHeight('auto');this._listHeightLimited=false;}}else{if(h>maxHeight){tree.setHeight(maxHeight);this._listHeightLimited=true;}}}});GUI.Forms.ComboTree=ComboTree;}());

(function(){var SelectionModel=Class.create(GUI.Utils.Observable,{elementType:'GUI.Forms.Combo.SelectionModel',singleSelect:false,initialize:function(config){SelectionModel.superclass.initialize.call(this);if(config){Object.extend(this,config);}
this.selections=new GUI.Utils.Collection();this.last=false;this.lastActive=false;this.addEvents({selectionchange:true,beforeitemselect:true,itemselect:true,itemdeselect:true});},init:function(combo){this.combo=combo;this.initEvents();},initEvents:function(){this.combo.on('itemClick',this.onItemClick,this);},onItemClick:function(combo,item,e){if(item.selected){if(this.combo.allowDeselect){this.deselectItem(item);}}else if(!item.selected){this.selectItem(item,true);}},clearSelections:function(fast){if(fast!==true){var s=this.selections;s.each(function(item){this.deselectItem(item);},this);s.clear();}else{this.selections.clear();this.fireEvent("selectionchange",this);}
this.last=false;},getSelections:function(){return[].concat(this.selections.items);},getSelected:function(){return this.selections.itemAt(0);},getCount:function(){return this.selections.length;},selectItem:function(item,keepExisting,preventNotify){if(item.noSelect){return false;}
if(this.fireEvent("beforeitemselect",this,item,keepExisting)!==false){if(!keepExisting||this.singleSelect){this.clearSelections();}
this.selections.add(item);item.selected=true;this.last=this.lastActive=item;if(!preventNotify){this.combo.onItemSelect(item);}
this.fireEvent("itemselect",this,item);this.fireEvent("selectionchange",this);return true;}else{return false;}},selectAll:function(){this.selections.clear();var self=this;this.combo.options.each(function(item){self.selectItem(item,true);});},isAllSelected:function(){return this.combo.options.length==this.selections.length;},selectRange:function(item1,item2,keepExisting){if(!keepExisting){this.clearSelections();}
var startItem=this.combo.options.indexOf(item1);var endItem=this.combo.options.indexOf(item2);if(startItem<=endItem){for(var i=startItem;i<=endItem;i++){this.selectItem(this.combo.options.itemAt(i),true);}}else{for(var i=startItem;i>=endItem;i--){this.selectItem(this.combo.options.itemAt(i),true);}}},deselectItem:function(item,preventNotify){if(item.noSelect){return false;}
if(this.last==item){this.last=false;}
if(this.lastActive==item){this.lastActive=false;}
if(item){this.selections.remove(item);item.selected=false;if(!preventNotify){this.combo.onItemDeselect(item);}
this.fireEvent("itemdeselect",this,item);this.fireEvent("selectionchange",this);return true;}else{return false;}}});GUI.Forms.Combo.SelectionModel=SelectionModel;}());

(function(){var List=Class.create(GUI.Forms.Combo,{type:'hidden',hiddenInput:false,className:'x-form-list',contentClass:'x-form-list-content',invalidClass:'x-form-list-invalid',itemClass:'x-form-list-item',itemHoverClass:'x-form-list-item-hover',itemSelectedClass:'x-form-list-item-selected',minWidthClass:'x-form-list-minwidth',autoWidthClass:'x-form-list-autowidth',hintClass:'x-form-list-hint',width:200,multiple:false,allowDeselect:true,domTemplate:'<div class="<%=className%>"><table cellspacing="0" cellpadding="0"><tbody><tr><td valign="top" class="<%=contentClass%>">'+'</td></tr></tbody></table></div>',initialize:function(config){List.superclass.initialize.call(this,config);},initComponent:function(){List.superclass.initComponent.call(this);if(!this.multiple){this.allowDeselect=false;}},getDefaultSmConfig:function(){return{singleSelect:!this.multiple};},onAssign:function(dom){if(dom.size>0){this.listHeight=dom.size;}
this.multiple=dom.multiple;if(this.multiple){this.allowDeselect=true;}
if(this.sm){this.sm.singleSelect=!this.multiple;}
List.superclass.onAssign.call(this,dom);},onRender:function(){var html=GUI.Template(this.domTemplate,{className:this.className,contentClass:this.contentClass});this.initValidators();return html;},onAfterRender:function(dom){this.dom.id=this.getId();this.contentEl=GUI.Dom.findDescedents(dom,'.'+this.contentClass)[0];GUI.Dom.extend(this.contentEl);this.updateItems();if(GUI.isNumber(this.listHeight)){if(!GUI.isSet(this.itemHeight)){this.itemHeight=this.multiple?25:22;}
this.height=this.listHeight*this.itemHeight;}
this.contentEl.on('click',this.onListClick,this);this.contentEl.on('mouseover',this.onListMouseOver,this);this.contentEl.on('mouseout',this.onListMouseOut,this);},getListItemHtml:function(item){var itemClass=this.itemClass,itemHtml,descrHtml;if(item.selected){itemClass+=' '+this.itemSelectedClass;}
if(this.multiple){itemHtml='<div class="x-form-list-item-text"><input type="checkbox"'+
(item.selected?' checked="checked"':'')
+' /><span>'+item[this.listField]+'</span></div>';}else{itemHtml='<div class="x-form-list-item-text">'+item[this.listField]+'</div>';}
if(GUI.isSet(item[this.descriptionField])){descrHtml='<div class="x-form-list-item-description">'+item[this.descriptionField]+'</div>';}else{descrHtml='';}
return'<div id="'+item.domId+'" class="'+itemClass+'">'+itemHtml+descrHtml+'</div>';},onDestroy:function(){this.contentEl.un();List.superclass.onDestroy.call(this);},attachEventListeners:function(){},updateItems:function(){if(this.contentEl){this.contentEl.innerHTML=this.getListHtml();}},initList:GUI.emptyFunction,showList:GUI.emptyFunction,hideList:GUI.emptyFunction,updateValue:GUI.emptyFunction,onBeforeAssign:function(dom){return(dom.nodeName=='SELECT')&&(dom.getAttribute('xtype')=='list');},getValue:function(){var ids=[],selections=this.sm.getSelections(),valueField=this.getValueField();for(var i=0,len=selections.length;i<len;i++){ids[i]=selections[i][valueField];}
return ids;},setValue:function(values){var item;this.sm.clearSelections();this.selectedIndex=-1;if(values==null){return;}
if(GUI.isArray(values)){for(var i=0,len=values.length;i<len;i++){item=this.getItemByValue(values[i]);this.sm.selectItem(item,true);this.selectedIndex=this.options.indexOf(item);}}else{item=this.getItemByValue(values);this.sm.selectItem(item);this.selectedIndex=this.options.indexOf(item);}},clear:function(){this.options.clear();if(this.contentEl){this.contentEl.innerHTML='';}},beginUpdate:function(){this.deferUpdate=true;},endUpdate:function(){this.deferUpdate=false;this.updateItems();},getListDom:function(){return this.dom;},onItemSelect:function(item){this.selectedIndex=this.options.indexOf(item);var dom=this.getItemDom(item);if(dom){dom.addClass(this.itemSelectedClass);if(this.multiple){dom.findDescedent('input').checked=true;}
if(this.validateOnBlur||this.livevalidation){this.validate();}}},onItemDeselect:function(item){List.superclass.onItemDeselect.call(this,item);if(this.selectedIndex==this.options.indexOf(item)){this.selectedIndex=-1;}
var dom=this.getItemDom(item);if(dom){dom.removeClass(this.itemSelectedClass);if(this.multiple){dom.findDescedent('input').checked=false;}}},setOptions:function(options){List.superclass.setOptions.call(this,options);this.updateItems();}});GUI.Forms.List=List;}());

(function(){var MultipleCombo=Class.create(GUI.Forms.Combo,{doNotReadValueFromDom:true,type:'hidden',listClass:'x-form-multiplecombo-list',itemClass:'x-form-multiplecombo-list-item',itemHoverClass:'x-form-multiplecombo-list-item-hover',itemSelectedClass:'x-form-multiplecombo-list-item-selected',minWidthClass:'x-form-multiplecombo-list-minwidth',hintClass:'x-form-multiplecombo-item-hint',width:200,checkbox:true,showSelectAll:true,allowDeselect:true,initialize:function(config){MultipleCombo.superclass.initialize.call(this,config);},initComponent:function(){MultipleCombo.superclass.initComponent.call(this);},getDefaultSmConfig:function(){return{singleSelect:false};},onBeforeAssign:function(dom){return dom.nodeName=='SELECT'&&dom.multiple;},adjustAutoWidth:function(width){return width-1;},getValue:function(){var ids=[],selections=this.sm.getSelections(),valueField=this.getValueField();for(var i=0,len=selections.length;i<len;i++){ids[i]=selections[i][valueField];}
return ids;},setValue:function(values){var item;this.sm.clearSelections();if(GUI.isArray(values)){for(var i=0,len=values.length;i<len;i++){item=this.getItemByValue(values[i]);if(item){this.sm.selectItem(item,true);}}}else{item=this.getItemByValue(values);if(item){this.sm.selectItem(item);}}
if(this.divEl){this.updateValue();}},setOptions:function(options){MultipleCombo.superclass.setOptions.call(this,options);this.updateValue();},updateValue:function(){if(this.divEl){var text,count=this.sm.getCount(),allCount=this.options.length;switch(count){case 0:text='';break;case 1:text=this.sm.getSelected()[this.textField];break;case allCount:text=GUI.i18n.GUI_ALL
break;default:text=GUI.i18n.GUI_MULTIPLE_SELECTION;break;}
this.divEl.innerHTML='<span>'+text+'</span>';}
this.value=this.getValue();if(this.hiddenField){var i,hiddenVal=[],selection=this.sm.getSelections(),len=selection.length;for(i=0;i<len;i++){hiddenVal[i]=selection[i][this.valueField||this.textField];}
this.hiddenField.value=hiddenVal.join(',');}},getListItemHtml:function(item){var itemClass=this.itemClass,itemHtml,descrHtml;if(item.selected){itemClass+=' '+this.itemSelectedClass;}
if(this.checkbox){itemHtml='<div class="x-form-multiplecombo-list-item-text"><input type="checkbox"'+
(item.selected?' checked="checked"':'')
+' /><span>'+item[this.listField]+'</span></div>';}else{itemHtml='<div class="x-form-multiplecombo-list-item-text">'+item[this.listField]+'</div>';}
if(GUI.isSet(item[this.descriptionField])){descrHtml='<div class="x-form-multiplecombo-list-item-description">'+item[this.descriptionField]+'</div>';}else{descrHtml='';}
return'<div id="'+item.domId+'" class="'+itemClass+'">'+itemHtml+descrHtml+'</div>';},getListHtml:function(){var html=MultipleCombo.superclass.getListHtml.call(this);if(!this.showSelectAll){return html;}
var item={domId:this.id+'-select-all',selected:this.sm.isAllSelected()};item[this.listField]=GUI.i18n.GUI_SELECT_ALL;var preHtml=this.getListItemHtml(item);return preHtml+html;},onListItemClick:function(nodeId){var item=this.getItemByDomId(nodeId);if(item){this.fireEvent('itemClick',this,item);}else if(nodeId==this.id+'-select-all'){if(this.sm.isAllSelected()){this.sm.clearSelections();}else{this.sm.selectAll();}}},onSelectionChange:function(){if(!this.showSelectAll){return;}
var dom=GUI.$(this.id+'-select-all'),cb=dom.findDescedents('input')[0];if(this.sm.isAllSelected()){dom.addClass(this.itemSelectedClass);cb.checked=true;}else{dom.removeClass(this.itemSelectedClass);cb.checked=false;}},onItemSelect:function(item){var dom=this.getItemDom(item);if(dom){dom.addClass(this.itemSelectedClass);if(this.checkbox){dom.findDescedents('input')[0].checked=true;}
this.onSelectionChange();}
this.updateValue();},onItemDeselect:function(item){MultipleCombo.superclass.onItemDeselect.call(this,item);var dom=this.getItemDom(item);if(dom){dom.removeClass(this.itemSelectedClass);if(this.checkbox){dom.findDescedents('input')[0].checked=false;}
this.onSelectionChange();}
this.updateValue();},getHintAlignNode:function(node){return node.getElementsByTagName('span')[0];},onListKeyDown:function(e){e=GUI.Event.extend(e);switch(e.getKey()){case e.KEY_SPACE:e.stop();break;default:MultipleCombo.superclass.onListKeyDown.call(this,e);break;}},onListKeyUp:function(e){e=GUI.Event.extend(e);switch(e.getKey()){case e.KEY_SPACE:e.stop();if(this.selected){this.onListItemClick(this.selected);}
break;case e.KEY_RETURN:if(this.selected){this.onListItemClick(this.selected);}
break;default:MultipleCombo.superclass.onListKeyUp.call(this,e);break;}}});GUI.Forms.MultipleCombo=MultipleCombo;}());

(function(){var DatePicker=Class.create(GUI.Forms.TriggerField,{readOnly:true,size:20,format:'d/m/Y',wrapperClass:'x-form-datepicker',initialize:function(config){DatePicker.superclass.initialize.call(this,config);},setValue:function(value){DatePicker.superclass.setValue.call(this,GUI.parseDate(value,this.format).formatDate(this.format));if(this.hiddenField){this.hiddenField.value=GUI.parseDate(this.value,this.format).getTime();}},setToday:function(){this.setValue(new Date());},setDate:function(date){this.setValue(date.formatDate(this.format));},getDate:function(){return GUI.parseDate(this.value,this.format);},initComponent:function(){DatePicker.superclass.initComponent.call(this);this.addEvents({});},attachEventListeners:function(){DatePicker.superclass.attachEventListeners.call(this);},onAssign:function(elem){DatePicker.superclass.onAssign.call(this,elem);var format=elem.getAttribute('format');if(format){this.format=String(format);}},onRender:function(){return DatePicker.superclass.onRender.call(this);},onAfterRender:function(dom){DatePicker.superclass.onAfterRender.call(this,dom);},showCalendar:function(){if(!this.calendar){this.calendar=new GUI.Calendar();this.calendar.on('dayClick',this.onCalendarSelect,this);}
var date=this.getDate();if(date){this.calendar.setDate(date);}
if(!this.list){this.list=new GUI.Popup.Region({});}
this.list.show();this.calendar.render(this.list.getElement());this.list.alignTo(this.dom,'tl-bl?');GUI.Event.on(document,'mousedown',this.onDocumentMouseDown,this);GUI.Event.on(this.fieldEl,'mousedown',this.onMouseDown,this);this.calendarOpened=true;},hideCalendar:function(){GUI.Event.un(document,'mousedown',this.onDocumentMouseDown,this);GUI.Event.un(this.fieldEl,'mousedown',this.onMouseDown,this);this.calendar.unrender();this.list.hide();this.calendarOpened=false;},onTriggerClick:function(e){e=GUI.Event.extend(e);if(!this.disabled&&e.isLeftClick()){if(this.calendarOpened){this.hideCalendar();}else{this.showCalendar();}}},onCalendarSelect:function(cal,value){this.setValue(value);this.hideCalendar();},onDocumentMouseDown:function(e){e=new GUI.ExtendedEvent(e);if(!(GUI.contains(this.list.dom,e.target)||GUI.contains(this.dom,e.target))){this.hideCalendar();}},onMouseDown:function(e){if(this.calendarOpened){this.hideCalendar();}}});GUI.Forms.DatePicker=DatePicker;}());

(function(){var ColorPicker=Class.create(GUI.Forms.TriggerField,{readOnly:true,wrapperClass:'x-form-colorpicker',initialize:function(config){ColorPicker.superclass.initialize.call(this,config);},setValue:function(value){ColorPicker.superclass.setValue.call(this,value);if(this.fieldEl){var style=this.fieldEl.style;if(value&&value.length>0){value='#'+value;}else{value='';}
style.backgroundColor=style.color=value;}},initComponent:function(){ColorPicker.superclass.initComponent.call(this);this.addEvents({'select':true});},onAfterRender:function(dom){ColorPicker.superclass.onAfterRender.call(this,dom);},showColorPanel:function(){if(!this.colorPanel){this.colorPanel=new GUI.ColorPanel({clickEvent:'mousedown'});this.colorPanel.on('select',this.onColorPanelSelect,this);}
if(!this.list){this.list=new GUI.Popup.Region({});}
this.list.show();this.colorPanel.render(this.list.getElement());this.list.alignTo(this.dom,'tl-bl?');document.on('mousedown',this.onDocumentMouseDown,this);GUI.Event.on(this.fieldEl,'mousedown',this.onMouseDown,this);this.colorPanelOpened=true;},hideColorPanel:function(){document.un('mousedown',this.onDocumentMouseDown,this);GUI.Event.un(this.fieldEl,'mousedown',this.onMouseDown,this);this.colorPanel.unrender();this.list.hide();this.colorPanelOpened=false;},onTriggerClick:function(e){e=new GUI.ExtendedEvent(e);e.preventDefault();if(!this.disabled){if(this.colorPanelOpened){this.hideColorPanel();}else{this.showColorPanel();}}},onColorPanelSelect:function(cp,value){this.fireEvent('select',this,value);this.setValue(value);this.hideColorPanel();},onDocumentMouseDown:function(e){e=new GUI.ExtendedEvent(e);if(!(GUI.contains(this.list.dom,e.target)||GUI.contains(this.dom,e.target))){this.hideColorPanel();}},onMouseDown:function(e){if(this.colorPanelOpened){this.hideColorPanel();}}});GUI.Forms.ColorPicker=ColorPicker;}());

(function(){var ColorPicker=Class.create(GUI.Forms.TriggerField,{readOnly:true,wrapperClass:'x-form-colorpicker2',hoverClass:'x-form-colorpicker2-hover',triggerOnFieldClick:false,value:'000000',width:'auto',iconClass:'',domTemplate:'<table id="{0}-wrapper" class="x-form-triggerfield {1}" cellspacing="0">'+'<tbody><tr><td class="combo-input"><div></div></td>'+'<td class="combo-trigger"><a href="#"></a></td></tr></tbody></table>',initialize:function(config){ColorPicker.superclass.initialize.call(this,config);},attachEventListeners:function(){this.dom.on('mouseenter',this.onMouseEnter,this);this.dom.on('mouseleave',this.onMouseLeave,this);this.attachTriggerEvents();this.divEl.on('mousedown',this.onMouseDown,this);},setValue:function(value){ColorPicker.superclass.setValue.call(this,value);if(this.divEl){var style=this.divEl.style;value='#'+value;style.backgroundColor=value;}},initComponent:function(){ColorPicker.superclass.initComponent.call(this);this.addEvents({'select':true});},onAfterRender:function(dom){this.divEl=GUI.Dom.extend(dom.getElementsByTagName('div')[0]);this.divEl.addClass(this.iconClass);ColorPicker.superclass.onAfterRender.call(this,dom);if(this.unselectable){if(GUI.isIE){this.dom.unselectable='on';this.divEl.unselectable='on';}}},showColorPanel:function(){if(!this.colorPanel){this.colorPanel=new GUI.ColorPanel({clickEvent:'mousedown'});this.colorPanel.on('select',this.onColorPanelSelect,this);}
if(!this.list){this.list=new GUI.Popup.Region({});}
this.list.show();this.colorPanel.render(this.list.getElement());this.list.alignTo(this.dom,'tl-bl?');document.on('mousedown',this.onDocumentMouseDown,this);GUI.Event.on(this.fieldEl,'mousedown',this.onMouseDown,this);this.colorPanelOpened=true;},hideColorPanel:function(){document.un('mousedown',this.onDocumentMouseDown,this);GUI.Event.un(this.fieldEl,'mousedown',this.onMouseDown,this);this.colorPanel.unrender();this.list.hide();this.colorPanelOpened=false;},onTriggerClick:function(e){e=new GUI.ExtendedEvent(e);e.preventDefault();if(!this.disabled){if(this.colorPanelOpened){this.hideColorPanel();}else{this.showColorPanel();}}},onColorPanelSelect:function(cp,value){this.fireEvent('select',this,value);this.setValue(value);this.hideColorPanel();},onDocumentMouseDown:function(e){e=GUI.Event.extend(e);if(!(GUI.contains(this.list.dom,e.target)||GUI.contains(this.dom,e.target))){this.hideColorPanel();}},onMouseDown:function(e){this.fireEvent('select',this,this.getValue());},onMouseEnter:function(event){if(!this.disabled){this.dom.addClass(this.hoverClass);}},onMouseLeave:function(event){if(!this.disabled){this.dom.removeClass(this.hoverClass);}},onTriggerMouseOver:function(e){},onTriggerMouseOut:function(e){}});GUI.Forms.ColorPicker2=ColorPicker;}());

GUI.Forms.Validation={};

(function(){var Validator=Class.create(GUI.Utils.Observable,{elementType:'GUI.Forms.Validation.Validator',initialize:function(config){if(config){Object.extend(this,config);}
this.addEvents({beforeValidation:true});Validator.superclass.initialize.call(this);},destroy:function(){this.purgeListeners();},validate:function(){try{var value=this.field.getValue();}catch(e){console.log(e);throw e;}
return this.validateCustom(value);},validateCustom:function(value){if(this.fireEvent('beforeValidation',this,value)===false){return false;}
var isValid=this.validateFunc(value);return isValid;},validateFunc:function(value){throw'You need to override validateFunc() method in your validator!';},getErrorMessage:function(){return this.errorMessage;}});GUI.Forms.Validation.Validator=Validator;}());

(function(){var Custom=Class.create(GUI.Forms.Validation.Validator,{errorMessage:GUI.i18n.GUI_VALIDATION_CUSTOM,elementType:'GUI.Forms.Validation.Custom',initialize:function(config){Custom.superclass.initialize.call(this,config);if(GUI.isSet(this.params)){this.pattern=new RegExp(this.params);}},validateFunc:function(value){return this.pattern.test(value);}});GUI.Forms.Validation.Custom=Custom;}());

(function(){var Email=Class.create(GUI.Forms.Validation.Custom,{errorMessage:GUI.i18n.GUI_VALIDATION_EMAIL,elementType:'GUI.Forms.Validation.Email',initialize:function(config){Email.superclass.initialize.call(this,config);this.pattern=/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i;}});GUI.Forms.Validation.Email=Email;}());

(function(){var Login=Class.create(GUI.Forms.Validation.Custom,{errorMessage:GUI.i18n.GUI_VALIDATION_LOGIN,elementType:'GUI.Forms.Validation.Login',initialize:function(config){Login.superclass.initialize.call(this,config);this.pattern=/(^[A-Za-z]+[A-Za-z0-9._\-]*$)|(^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$)/;}});GUI.Forms.Validation.Login=Login;}());

(function(){var Maxlength=Class.create(GUI.Forms.Validation.Validator,{errorMessage:GUI.i18n.GUI_VALIDATION_MAXLENGTH,elementType:'GUI.Forms.Validation.Maxlength',initialize:function(config){Maxlength.superclass.initialize.call(this,config);if(GUI.isSet(this.params)){this.maxLength=parseInt(this.params,10);}else{throw new Error(this.elementType+' error: required parameter not passed in config');}},validateFunc:function(value){return(value.length<=this.maxLength);},getErrorMessage:function(){return GUI.formatString(this.errorMessage,this.maxLength);}});GUI.Forms.Validation.Maxlength=Maxlength;}());

(function(){var Minlength=Class.create(GUI.Forms.Validation.Validator,{errorMessage:GUI.i18n.GUI_VALIDATION_MINLENGTH,elementType:'GUI.Forms.Validation.Minlength',initialize:function(config){Minlength.superclass.initialize.call(this,config);if(GUI.isSet(this.params)){this.minLength=parseInt(this.params,10);}else{throw new Error(this.elementType+' error: required parameter not passed in config');}},validateFunc:function(value){return(value.length>=this.minLength);},getErrorMessage:function(){return GUI.formatString(this.errorMessage,this.minLength);}});GUI.Forms.Validation.Minlength=Minlength;}());

(function(){var Phone=Class.create(GUI.Forms.Validation.Custom,{errorMessage:GUI.i18n.GUI_VALIDATION_PHONE,elementType:'GUI.Forms.Validation.Phone',initialize:function(config){Phone.superclass.initialize.call(this,config);this.pattern=/^\+?[-()\s0-9]*$/i;}});GUI.Forms.Validation.Phone=Phone;}());

(function(){var Siteurl=Class.create(GUI.Forms.Validation.Custom,{errorMessage:GUI.i18n.GUI_VALIDATION_SITEURL,elementType:'GUI.Forms.Validation.Siteurl',initialize:function(config){Siteurl.superclass.initialize.call(this,config);this.pattern=/(((https?)|(ftp)):\/\/[\-\w]+(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;}});GUI.Forms.Validation.Siteurl=Siteurl;}());

(function(){var Selected=Class.create(GUI.Forms.Validation.Custom,{errorMessage:GUI.i18n.GUI_VALIDATION_SELECTED,elementType:'GUI.Forms.Validation.Selected',initialize:function(config){Selected.superclass.initialize.call(this,config);},validateFunc:function(value){var f=this.field;if(f.getSelections){var sel=f.getSelections();return sel&&(sel.length>0);}else{return f.selectedIndex>-1;}}});GUI.Forms.Validation.Selected=Selected;}());

(function(){var NotEmpty=Class.create(GUI.Forms.Validation.Validator,{errorMessage:GUI.i18n.GUI_VALIDATION_NOTEMPTY,elementType:'GUI.Forms.Validation.NotEmpty',validateFunc:function(value){return(value.trim().length>0);}});GUI.Forms.Validation.NotEmpty=NotEmpty;}());

(function(){var Number=Class.create(GUI.Forms.Validation.Custom,{errorMessage:GUI.i18n.GUI_VALIDATION_NUMBER,elementType:'GUI.Forms.Validation.Number',initialize:function(config){Number.superclass.initialize.call(this,config);this.pattern=/\d+([.,]\d+)*/;}});GUI.Forms.Validation.Number=Number;}());

(function(){var Form=Class.create(GUI.Utils.Container,{method:'get',fileUpload:false,jsonExpected:true,assignMap:{'textarea':{'textarea':'TextArea','editor':'Editor'},'select':{'select-one':'Combo','select-multiple':'MultipleCombo','list':'List'},'input':{'text':'TextField','hidden':'Hidden','spin':'SpinEdit','date':'DatePicker','color':'ColorPicker','password':'PasswordField','radio':'Radio','checkbox':'CheckBox','file':'File'}},initialize:function(config){if(config){if(config.url){config.action=config.url;delete config.url;}}
Form.superclass.initialize.call(this,config);},assign:function(to){to=GUI.$(to);if(!to||to.nodeName!='FORM'){return false;}
this.dom=GUI.Dom.extend(to);this.dom.on('submit',this.onSubmit,this);this.dom.on('reset',this.onReset,this);if(GUI.isSet(to.id)){GUI.ComponentMgr.unregister(this);this.id=to.id;GUI.ComponentMgr.register(this);}else{to.id=this.id;}
var attrNode;attrNode=to.attributes['action'];this.action=attrNode?attrNode.nodeValue:'';attrNode=to.attributes['method'];this.method=attrNode?attrNode.nodeValue:'post';var v=to.getAttribute('disableValidationPopups');if(v=='true'){this.disableValidationPopups=true;}else if(v=='false'){this.disableValidationPopups=false;}
v=to.getAttribute('livevalidation');if(v=='true'){this.livevalidation=true;}else if(v=='false'){this.livevalidation=false;}
v=to.getAttribute('errorHolder');if(v){this.errorHolder=v;}
this.initItems();var fields=GUI.toArray(to.elements),defCfg={disableValidationPopups:this.disableValidationPopups,livevalidation:this.livevalidation};if(GUI.isSet(this.errorHolder)){defCfg.errorNodeHolder=this.errorHolder;}
for(var i=0,len=fields.length;i<len;i++){var field=fields[i];if(field._jsguiComponent)continue;if(field.type=='file'){this.fileUpload=true;continue;}
var tag=field.nodeName.toLowerCase(),xtype=field.getAttribute('xtype')||field.type||'text',tmp,cls=(tmp=this.assignMap[tag])?tmp[xtype]:undefined;if(cls){cls=GUI.Forms[cls];}
if(cls){var cfg=Object.extend({assignTo:field},defCfg);var f=new cls(cfg);this.add(f);this.addField(f);}}
if(this.fileUpload){if(GUI.isIE){to.encoding='multipart/form-data';}else{to.enctype='multipart/form-data';}
this.method=to.method='post';}},onReset:function(e){e=GUI.Event.extend(e);e.preventDefault();this.reset();},reset:function(){var fields=this.fields,i=fields.length;while(i--){fields[i].reset();}},getField:function(name){var res=[];this.fields.each(function(i){if(i.name==name){res.push(i);}});if(res.length==1){return res[0];}else if(res.length>1){return res;}else{return null;}},load:function(config){config=config||{};Object.extendIf(config,{url:this.action,params:this.params});this.fireEvent('beforeLoad',this);this._loadRequest=new Ajax.Request(config.url,{method:this.method,parameters:GUI.toQueryString(config.params),scope:this,onSuccess:this.onLoadSuccess,onFailure:this.onLoadFailure,onTimeout:this.onLoadTimeout,timeout:this.loadTimeout});},submit:function(config,e){config=config||{};Object.extendIf(config,{url:this.action,params:Object.clone(this.params||{})});var serialized=this.serialize();if(this.fireEvent('beforeSubmit',this,config.params,serialized,e)===false){if(e)e.preventDefault();return;}
if(e){e=GUI.Event.extend(e);}
if(this.fileUpload){return this._iframeSubmit(config,e);}else{if(e){e.stop();}
return this._ajaxSubmit(config);}},validate:function(){var valid=true;this.fields.each(function(f){if(!f.validate()){valid=false;}});if(valid){this.fireEvent('valid',this);}else{this.fireEvent('invalid',this);}
return valid;},setAction:function(action){this.action=action;},getValues:function(){var i,field,name,fields=this.fields,len=fields.length,res={};for(i=0;i<len;i++){field=fields[i];name=field.name;if(name){if(field.type=='checkbox'){res[name]=field.isChecked();}else if(field.type=='radio'){if(field.isChecked()){res[name]=res[name]=field.getValue();}}else{res[name]=field.getValue();}}}
return res;},setFieldsValues:function(data){data=this.convertJsonToNames(data);for(var name in data){var value=data[name],field,id;if(typeof value!='function'&&(field=this.getField(name))){if(GUI.isArray(field)){var len=field.length;while(len--){this.setFieldValue(field[len],value);}}else{this.setFieldValue(field,value);}}}},setFieldValue:function(field,value){if((field instanceof GUI.Forms.Combo)&&(value instanceof Array)){field.setOptions(value);}else if(field instanceof GUI.Forms.Radio){if(field.getValue()==value){field.setChecked();}}else if(field instanceof GUI.Forms.CheckBox){field.setChecked(value);}else{field.setValue(value);}},convertJsonToNames:function(object){var uri={};function _toQueryString(object,prepend){if(GUI.isNumber(object)||GUI.isString(object)||GUI.isBoolean(object)){if(!(GUI.isString(prepend)&&prepend!='')){throw new Error("At first object must be passed!");}
uri[prepend]=object;}else if(GUI.isArray(object)){if(!(GUI.isString(prepend)&&prepend!='')){throw new Error("2At first object must be passed!");}
for(var i=0,len=object.length;i<len;i++){_toQueryString(object[i],prepend+'['+i+']');}}else if(GUI.isObject(object)){for(var key in object){var value=object[key];if(GUI.isFunction(value))continue;_toQueryString(value,(GUI.isString(prepend)&&prepend!='')?prepend+'['+key+']':key);}}}
_toQueryString(object,'');return uri;},serialize:function(){var elements=GUI.toArray(this.dom.elements),o=[];for(var i=0,len=elements.length;i<len;i++){var f=elements[i];if(!f.name){continue;}
var name=encodeURIComponent(f.name);switch(f.nodeName){case'INPUT':switch(f.type){case'text':case'password':case'hidden':o.push(name+'='+encodeURIComponent(f.value));break;case'checkbox':case'radio':if(f.checked){o.push(name+'='+encodeURIComponent(f.value));}
break;}
break;case'TEXTAREA':o.push(name+'='+encodeURIComponent(f.value));break;case'SELECT':break;}}
return o.join('&');},_ajaxSubmit:function(cfg){var p=this.serialize();if(p){if(typeof p=='string'&&cfg.params){p+='&'+GUI.toQueryString(cfg.params);}}else if(cfg.params){p=GUI.toQueryString(cfg.params);}
var myAjax=new Ajax.Request(cfg.url,{method:this.method,parameters:p,scope:this,onSuccess:this.onAjaxSubmitSuccess,onFailure:this.onAjaxSubmitFailure,onTimeout:this.onAjaxSubmitTimeout,timeout:this.submitTimeout});return true;},onAjaxSubmitSuccess:function(response,request){if(this.fireEvent){this.fireEvent('afterSubmit',this,response,request);}},onAjaxSubmitFailure:function(response,request){if(this.fireEvent){this.fireEvent('invalidSubmit',this,response,request);}},onAjaxSubmitTimeout:function(response,request){if(this.fireEvent){this.fireEvent('submitTimeout',this,response,request);}},_iframeSubmit:function(cfg,e){var id=GUI.getUniqId('x-file-upload-iframe-'),d=document.createElement('div');d.innerHTML='<iframe style="visibility: hidden; width: 0px; height: 0px;" id="'
+id+'" name="'+id+'" ></iframe>';document.body.appendChild(d);if(GUI.isIE){document.frames[id].name=id;}
this.iframe=GUI.$(id);if(cfg.params){var p=GUI.toQueryString(cfg.params),bpDiv=document.createElement('div');p=p.split('&');for(var i=0,len=p.length;i<len;i++){var param=p[i].split('=',2),input=GUI.createInput(param[0]);input.type='hidden';if(GUI.isSet(param[1])){input.value=param[1];}
bpDiv.appendChild(input);}
this.dom.appendChild(bpDiv);}
if(GUI.isIE){this.iframe.src='javascript:false';}
this.iframe.on('load',this.onIframeLoad,this);this.iframe.on('error',this.onIframeError,this);var dom=this.dom;dom.target=id;if(this.submitTimeout){var i=this.iframe;(function(){GUI.destroyNode(i.parentNode);}).defer(this.submitTimeout);}
if(cfg.url){if(dom.action&&dom.action.nodeName){}else{dom.action=cfg.url;}}
if(!e){this.dom.submit();}
if(cfg.params){(function(){if(bpDiv){GUI.destroyNode(bpDiv);}}).defer(20);}
return false;},onIframeLoad:function(){var d,i=this.iframe;if(i.contentDocument){d=i.contentDocument;}else if(i.contentWindow){d=i.contentWindow.document;}else{d=i.document;}
if(d.location.href=='javascript:false'){return this.onIframeError();}
i.un();var responseText=d.body.innerHTML,response={responseText:responseText};if(this.jsonExpected){var responseJson=null;try{responseJson=responseText.evalJSON();}catch(e){}
if(responseJson==null){GUI.Ajax.Request._observable.fireEvent('invalidjson',response,this);}}
d=null;this.fireEvent('afterSubmit',this,response);(function(){GUI.destroyNode(i.parentNode);}).defer(100);return true;},onIframeError:function(){var d,i=this.iframe;i.un();if(i.contentDocument){d=i.contentDocument;}else if(i==i.contentWindow){d=i.contentWindow.document;}else{d=i.document;}
var response={responseText:d.body.innerHTML};this.fireEvent('invalidSubmit',this,response);(function(){GUI.destroyNode(i.parentNode);}).defer(100);return true;},initComponent:function(){Form.superclass.initComponent.call(this);this.addEvents('filterLoadData','afterLoad','afterSubmit','beforeLoad','beforeSubmit','invalid','invalidLoad','invalidSubmit','loadTimeout','submitTimeout','valid');this.fields=[];},addField:function(f){this.fields.push(f);},initFields:function(){var form=this;var fn=function(c){if(c.isFormField){form.addField(c);}else if(c.doLayout&&c!=form){if(c.items){c.items.each(fn);}}}
this.items.each(fn);},onRender:function(){this.initFields();var dom=document.createElement('form');return dom;},onAfterRender:function(){var f=this.dom;f.id=this.getId();if(this.action)f.action=this.action;f.method=this.method;this.dom.on('submit',this.onSubmit,this);this.dom.on('reset',this.onReset,this);},onDestroy:function(fast){if(this._loadRequest&&!this._loadRequest.complete){this._loadRequest.abort();this._loadRequest=null;}
Form.superclass.onDestroy(this,fast);},onLoadSuccess:function(response,request){if(!this.fireEvent){return;}
try{this.data=request.responseJson;this.fireEvent('filterLoadData',this,this.data);this.setFieldsValues(this.data);this.fireEvent('afterLoad',this,this.data);delete this.data;}catch(e){alert('Exception!'+e.message);}},onLoadFailure:function(response,request){if(this.fireEvent){this.fireEvent('invalidLoad',this,response,request);}},onLoadTimeout:function(reponse,request){if(this.fireEvent){this.fireEvent('loadTimeout',this,response,request);}},onSubmit:function(e){e=GUI.Event.extend(e);if(this.validate()){this.submit(null,e);}else{e.stop();}
return true;}});GUI.Forms.Form=Form;}());

(function(){var i18n=GUI.i18n;var EditorImageManager=Class.create({mode:'image',imageRe:/\.(gif|jpg|jpeg|png|bmp)$/,disableMoveInRoot:true,dialogContent:'<table class="x-editor-imagedialog" cellspacing="0"><tbody>'+'<tr><td width="25%" style="padding: 2px 0;">'+'<div id="x-editor-imagedialog-tree" style="background-color: #ffffff; /*margin-top: 2px;*/"></div>'+'{0}'+'</td>'+'<td width="75%" style="padding: 2px 0 0 5px;">'+'<div class="jsgui-listview-thumbnails" style="width: 450px; height: 400px; border: 1px solid #A4ACB1;" id="x-editor-imagedialog-thumbnails">'+'<div id="x-editor-imagedialog-preview" hint="Click to hide preview" class="jsgui-listview-preview" style="visibility: hidden;">'+'<a href="javascript:" class="jsgui-listview-closepreview">'+i18n.GUI_EDITOR_IM_CLOSE_PREVIEW+'</a>'+'<table height="100%" width="100%"><tbody>'+'<tr><td id="x-editor-imagedialog-preview-imageholder"><img src="http://jira/images/icons/task.gif" /></td></tr></tbody></table>'+'</div>'+'<div id="x-editor-imagedialog-list" class="jsgui-listview-list" style="overflow: auto; width: 450px; height: 400px;">'+'<div class="jsgui-listview-list-inner"></div>'+'</div>'+'</div>'+'<form id="x-editor-imagedialog-extimage">'+'<fieldset>'+'<legend>'+i18n.GUI_EDITOR_IM_EXTERNAL_IMAGE+'</legend>'+'<table width="100%" cellspacing="2"><tbody><tr>'+'<td><label for="x-editor-imagedialog-extsrc">URL:</label></td>'+'<td class="jsgui-textfield-fitwidth-wrap" width="100%">'+'<div style="position:relative;">'+'<input id="x-editor-imagedialog-extsrc" name="extsrc" type="text" style="width: 100%;" />'+'</div>'+'</td>'+'<td id="x-editor-imagedialog-loadimage" class="form-buttons"></td>'+'</tr></tbody></table>'+'</fieldset></form>'+'</td></tr>'+'<tr><td id="x-editor-imagedialog-toolbar" colspan="2">'+'</td></tr>'+'</tbody></table>',initialize:function(cfg){this.modes={image:{dialogTitle:i18n.GUI_EDITOR_IMAGE,extLegend:i18n.GUI_EDITOR_IM_EXTERNAL_IMAGE,loadExtCaption:i18n.GUI_EDITOR_IM_LOAD_IMAGE,name:i18n.GUI_EDITOR_IM_IMAGES,extensions:['.gif','.jpg','.jpeg','.png','.bmp'],hint:i18n.GUI_EDITOR_IMAGE,iconClass:'x-editor-button-image',attributesForm:'<form style="display: none;" id="x-editor-imagedialog-imageattributes" action="#">'+'<fieldset>'+'<legend>'+i18n.GUI_EDITOR_IM_ATTRIBUTES+'</legend>'+'<table style="table-layout: fixed; width: 100%;">'+'<col /><col width="70"/><col/><col width="70"/>'+'<tbody>'+'<tr>'+'<td><label for="x-editor-imagedialog-alt">'+i18n.GUI_EDITOR_IM_ALT+':</label></td>'+'<td colspan="3" class="jsgui-textfield-fitwidth-wrap">'+'<input id="x-editor-imagedialog-alt" name="alt" type="text" style="width: 100%;" /></td>'+'</tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-title">'+i18n.GUI_EDITOR_IM_TITLE+':</label></td>'+'<td colspan="3" class="jsgui-textfield-fitwidth-wrap">'+'<input id="x-editor-imagedialog-title" name="title" type="text" style="width: 100%;" /></td>'+'</tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-src">'+i18n.GUI_EDITOR_URL+':</label></td>'+'<td colspan="3" class="jsgui-textfield-fitwidth-wrap">'+'<input id="x-editor-imagedialog-src" name="src" type="text" style="width: 100%;" />'+'</td>'+'</tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-align">'+i18n.GUI_EDITOR_IM_ALIGN+':</label></td>'+'<td><select id="x-editor-imagedialog-align" name="align" style="width: 70px;">'+'<option value="" selected="selected">&nbsp;</option>'+'<option value="left">'+i18n.GUI_EDITOR_LEFT+'</option>'+'<option value="right">'+i18n.GUI_EDITOR_RIGHT+'</option>'+'<option value="top">'+i18n.GUI_EDITOR_TOP+'</option>'+'<option value="texttop">'+i18n.GUI_EDITOR_IM_TEXTTOP+'</option>'+'<option value="middle">'+i18n.GUI_EDITOR_MIDDLE+'</option>'+'<option value="absmiddle">'+i18n.GUI_EDITOR_IM_ABSMIDDLE+'</option>'+'<option value="baseline">'+i18n.GUI_EDITOR_IM_BASELINE+'</option>'+'<option value="bottom">'+i18n.GUI_EDITOR_BOTTOM+'</option>'+'<option value="absbottom">'+i18n.GUI_EDITOR_IM_ABSBOTTOM+'</option>'+'</select></td>'+'<td><label for="x-editor-imagedialog-border">'+i18n.GUI_EDITOR_BORDER+':</label></td>'+'<td><input id="x-editor-imagedialog-border" name="border" type="text" xtype="spin" style="width: 70px;" value="0" /></td>'+'</tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-width">'+i18n.GUI_EDITOR_WIDTH+':</label></td>'+'<td><input id="x-editor-imagedialog-width" name="width" type="text" xtype="spin" style="width: 70px;" /></td>'+'<td><label for="x-editor-imagedialog-height">'+i18n.GUI_EDITOR_HEIGHT+':</td>'+'<td><input id="x-editor-imagedialog-height" name="height" type="text" xtype="spin" style="width: 70px;" /></td>'+'</tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-hspace">'+i18n.GUI_EDITOR_IM_HSPACE+':</label></td>'+'<td><input id="x-editor-imagedialog-hspace" name="hspace" type="text" xtype="spin" style="width: 70px;" /></td>'+'<td><label for="x-editor-imagedialog-vspace">'+i18n.GUI_EDITOR_IM_VSPACE+':</label></td>'+'<td><input id="x-editor-imagedialog-vspace" name="vspace" type="text" xtype="spin" style="width: 70px;" /></td>'+'</tr>'+'</tbody></table>'+'</fieldset>'+'</form>'},flash:{dialogTitle:i18n.GUI_EDITOR_FLASH,extLegend:i18n.GUI_EDITOR_IM_EXTERNAL_FLASH,loadExtCaption:i18n.GUI_EDITOR_IM_LOAD_FLASH,name:i18n.GUI_EDITOR_IM_FLASH,hint:i18n.GUI_EDITOR_FLASH,iconClass:'x-editor-button-flash',extensions:['.swf'],attributesForm:'<form style="display: none;" id="x-editor-imagedialog-flashattributes" action="#">'+'<fieldset>'+'<legend>'+i18n.GUI_EDITOR_IM_ATTRIBUTES+'</legend>'+'<table style="table-layout: fixed; width: 100%;">'+'<col /><col width="70"/><col/><col width="70"/>'+'<tbody>'+'<tr>'+'<td><label for="x-editor-imagedialog-flash-width">'+i18n.GUI_EDITOR_WIDTH+':</label></td>'+'<td><input id="x-editor-imagedialog-flash-width" name="width" value="100" type="text" xtype="spin" style="width: 70px;" /></td>'+'<td><label for="x-editor-imagedialog-flash-height">'+i18n.GUI_EDITOR_HEIGHT+':</td>'+'<td><input id="x-editor-imagedialog-flash-height" name="height" value="100" type="text" xtype="spin" style="width: 70px;" /></td>'+'</tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-flash-hspace">'+i18n.GUI_EDITOR_IM_HSPACE+':</label></td>'+'<td><input  id="x-editor-imagedialog-flash-hspace" name="hspace" type="text" xtype="spin" style="width: 70px;" /></td>'+'<td><label for="x-editor-imagedialog-flash-vspace">'+i18n.GUI_EDITOR_IM_VSPACE+':</label></td>'+'<td><input  id="x-editor-imagedialog-flash-vspace" name="vspace" type="text" xtype="spin" style="width: 70px;" /></td>'+'</tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-flash-align">'+i18n.GUI_EDITOR_IM_ALIGN+':</label></td>'+'<td><select id="x-editor-imagedialog-flash-align" name="align" style="width: 70px;">'+'<option value="" selected="selected">&nbsp;</option>'+'<option value="left">'+i18n.GUI_EDITOR_LEFT+'</option>'+'<option value="right">'+i18n.GUI_EDITOR_RIGHT+'</option>'+'<option value="top">'+i18n.GUI_EDITOR_TOP+'</option>'+'<option value="texttop">'+i18n.GUI_EDITOR_IM_TEXTTOP+'</option>'+'<option value="middle">'+i18n.GUI_EDITOR_MIDDLE+'</option>'+'<option value="absmiddle">'+i18n.GUI_EDITOR_IM_ABSMIDDLE+'</option>'+'<option value="baseline">'+i18n.GUI_EDITOR_IM_BASELINE+'</option>'+'<option value="bottom">'+i18n.GUI_EDITOR_BOTTOM+'</option>'+'<option value="absbottom">'+i18n.GUI_EDITOR_IM_ABSBOTTOM+'</option>'+'</select></td>'+'<td><label for="x-editor-imagedialog-flash-loop">'+i18n.GUI_EDITOR_IM_LOOP+':</label></td>'+'<td>'+'<select id="x-editor-imagedialog-flash-loop" name="loop" style="width: 70px;" >'+'<option value="true">'+i18n.GUI_EDITOR_IM_TRUE+'</option>'+'<option value="false">'+i18n.GUI_EDITOR_IM_FALSE+'</option>'+'</select>'+'</td>'+'</tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-flash-quality">'+i18n.GUI_EDITOR_IM_QUALITY+':</label></td>'+'<td><select id="x-editor-imagedialog-flash-quality" name="quality" style="width: 70px;">'+'<option value="high" selected="selected">'+i18n.GUI_EDITOR_IM_HIGH+'</option>'+'<option value="medium">'+i18n.GUI_EDITOR_IM_MEDIUM+'</option>'+'<option value="low">'+i18n.GUI_EDITOR_IM_LOW+'</option>'+'</select></td>'+'<td><label for="x-editor-imagedialog-flash-scale">'+i18n.GUI_EDITOR_IM_SCALE+':</label></td>'+'<td>'+'<select id="x-editor-imagedialog-flash-scale" name="scale" style="width: 70px;" >'+'<option value="showall" selected="selected">'+i18n.GUI_EDITOR_IM_SHOW_ALL+'</option>'+'<option value="noborder">'+i18n.GUI_EDITOR_IM_NO_BORDER+'</option>'+'<option value="exactfit">'+i18n.GUI_EDITOR_IM_EXACT_FIT+'</option>'+'</select>'+'</td>'+'</tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-flash-wmode">'+i18n.GUI_EDITOR_IM_WMODE+':</label></td>'+'<td><select id="x-editor-imagedialog-flash-wmode" name="wmode" style="width: 70px;">'+'<option value="window" >'+i18n.GUI_EDITOR_IM_WINDOW+'</option>'+'<option value="opaque" selected="selected">'+i18n.GUI_EDITOR_IM_OPAQUE+'</option>'+'<option value="transparent">'+i18n.GUI_EDITOR_IM_TRANSPARENT+'</option>'+'</select></td>'+'<td colspan="2"></td>'+'</tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-flash-src">'+i18n.GUI_EDITOR_URL+':</label></td>'+'<td colspan="3" class="jsgui-textfield-fitwidth-wrap">'+'<input id="x-editor-imagedialog-flash-src" name="src" type="text" style="width: 100%;" />'+'</td>'+'</tr>'+'</tbody></table>'+'</fieldset>'+'</form>'},media:{dialogTitle:i18n.GUI_EDITOR_MEDIA,extLegend:i18n.GUI_EDITOR_IM_EXTERNAL_MEDIA,loadExtCaption:i18n.GUI_EDITOR_IM_LOAD_MEDIA,name:i18n.GUI_EDITOR_IM_MEDIA,hint:GUI.i18n.GUI_EDITOR_MEDIA,iconClass:'x-editor-button-media',extensions:['.avi','.wmv','.mpg','.mpeg','.mp3','.wav'],attributesForm:'<form style="display: none;" id="x-editor-imagedialog-mediaattributes" action="#">'+'<fieldset>'+'<legend>'+i18n.GUI_EDITOR_IM_ATTRIBUTES+'</legend>'+'<table style="table-layout: fixed; width: 100%;">'+'<col /><col width="70"/><col/><col width="70"/>'+'<tbody>'+'<tr>'+'<td><label for="x-editor-imagedialog-media-width">'+i18n.GUI_EDITOR_WIDTH+':</label></td>'+'<td><input  id="x-editor-imagedialog-media-width" name="width" value="100" type="text" xtype="spin" style="width: 70px;" /></td>'+'<td><label for="x-editor-imagedialog-media-height">'+i18n.GUI_EDITOR_HEIGHT+':</td>'+'<td><input  id="x-editor-imagedialog-media-height" name="height" value="100" type="text" xtype="spin" style="width: 70px;" /></td>'+'</tr>'+'<tr>'+'<td colspan="4"><input id="x-editor-imagedialog-media-autostart" name="autostart" type="checkbox" value="true" />'+'<label  for="x-editor-imagedialog-media-autostart">'+i18n.GUI_EDITOR_IM_AUTOSTART+'</label>'+'</td></tr>'+'<tr>'+'<td colspan="4"><input id="x-editor-imagedialog-media-showcontrols" name="showcontrols" type="checkbox" value="true" />'+'<label for="x-editor-imagedialog-media-showcontrols">'+i18n.GUI_EDITOR_IM_SHOW_CONTROLS+'</label>'+'</td></tr>'+'<tr>'+'<td colspan="4"><input id="x-editor-imagedialog-media-showstatus" name="showstatusbar" type="checkbox" value="true" />'+'<label for="x-editor-imagedialog-media-showstatus">'+i18n.GUI_EDITOR_IM_SHOW_STATUS_BAR+'</label>'+'</td></tr>'+'<tr>'+'<td><label for="x-editor-imagedialog-media-src">'+i18n.GUI_EDITOR_URL+':</label></td>'+'<td colspan="3" class="jsgui-textfield-fitwidth-wrap">'+'<input id="x-editor-imagedialog-media-src" name="src" type="text" style="width: 100%;" />'+'</td>'+'</tr>'+'</tbody></table>'+'</fieldset>'+'</form>'}}
if(cfg){Object.extend(this,cfg);}
if(!this.baseParams){this.baseParams={};}
Object.extend(this.baseParams,{type:this.mode});},init:function(editor){this.editor=editor;if(!this.imageHandlerUrl){this.imageHandlerUrl=editor.imageHandlerUrl;}
editor.on('createToolbar',this.onCreateToolbar,this);editor.on('assign',this.onAssign,this)
editor.registerEdit2SourceFilter('img2embed',this.img2embed,this);editor.registerSource2EditFilter('embed2img',this.embed2img,this);},onAssign:function(field,node){var attr=node.getAttribute('imageHandlerUrl');if(attr){this.imageHandlerUrl=attr;}},destroy:function(){if(this.mediaTypeMenu&&this.mediaTypeMenu.visible){this.hideModeMenu();this.mediaTypeMenu.destroy();}
if(this.dialog){this.dialog.destroy();this.dialog=null;}
this.editor.un('createToolbar',this.onCreateToolbar,this);this.editor.un('assign',this.onAssign,this)
this.editor=null;},onCreateToolbar:function(){var tb=this.editor.toolbars.imgflashmedia,btn,buttons=[],cfg,createMode=false;if(!tb){tb=this.editor.toolbars.imgflashmedia=new GUI.ToolBar({align:'none'});createMode=true;}
for(var i in this.modes){cfg=this.modes[i];btn=new GUI.ToolBar.Button({name:i,clickEvent:'mousedown',hint:cfg.hint,iconClass:cfg.iconClass,listeners:{scope:this,click:this.onClick},useImageSwitchingForDisabledState:false});if(createMode){tb.add(i,btn);}else{tb.insert(-1,i,btn);}}
if(createMode){tb.add(null,new GUI.ToolBar.Separator());this.editor.renderToolbars.splice(8,0,'imgflashmedia');}},onClick:function(btn){this.mode=btn.getName();var range,collapsed,selection=this.editor.getSelection();this.editMode=false;if(this.editor.iWin.getSelection){range=selection.getRangeAt(0);collapsed=range.collapsed;if(!collapsed){var node=range.startContainer.childNodes[range.startOffset];if(node&&node.nodeName&&node.nodeName=='IMG'){this.editMode=true;this.editedImage=node;}}}else if(this.editor.iDoc.selection){range=selection.createRange();if(selection.type=='Control'){collapsed=range.length==0;if(!collapsed){var node=range.item(0);if(node&&node.nodeName=='IMG'){this.editMode=true;this.editedImage=node;}}}}else{this.showError(i18n.GUI_EDITOR_IM_UNSUPPORTED_BROWSER);return;}
this.range=range;this.collapsed=collapsed;if(this.editMode){var img=this.editedImage;if(img.className=='jsgui-wysiwyg-flash'){this.mode='flash';}else if(img.className=='jsgui-wysiwyg-media'){this.mode='media';}else{this.mode='image';}}
this.dialog=this.createDialog();if(this.editMode){switch(this.mode){case'image':this.loadImageAttributes();break;case'flash':this.loadFlashAttributes();break;case'media':this.loadMediaAttributes();break;}}else{}
GUI.show(this.dialog.attributeForms[this.mode].dom);var m=this.mode;delete this.mode;this.setMode(m);this.dialog.show.defer(20,this.dialog);},createDialog:function(){var mode,attrForms=[];for(mode in this.modes){if(this.modes[mode]){attrForms.push(this.modes[mode].attributesForm);}}
attrForms=attrForms.join('');var dialogContent=this.dialogContent.format(attrForms);var dlg=new GUI.Popup.Dialog({id:'jsgui-editor-imagedialog',title:this.modes[this.mode].dialogTitle,content:dialogContent,modal:true,alwaysOnTop:true,dimensions:{width:780,height:570},toolbuttons:[{name:'restore',img:JSGUI_IMAGES_PATH+'x-dialog/x-dialog-ico-restore.gif',hidden:true},{name:'maximize',img:JSGUI_IMAGES_PATH+'x-dialog/x-dialog-ico-maximize.gif'},{name:'close',img:JSGUI_IMAGES_PATH+'x-dialog/x-dialog-ico-close.gif'}],toolbar:this.createActionToolbar()});dlg.on({scope:this,resize:this.onDialogResize,close:this.onDialogClose});dlg.create();dlg.tree=this.createDialogTree();var listInner=GUI.$('x-editor-imagedialog-list').firstChild;GUI.Dom.extend(listInner);this.listInner=listInner;listInner.on('click',this.onListInnerClick,this);GUI.$('x-editor-imagedialog-preview').on('click',this.onPreviewClick,this);this.loadExtFileButton=new GUI.ToolBar.Button({caption:'Load Image',listeners:{scope:this,click:this.onLoadExternalFileClick},renderTo:'x-editor-imagedialog-loadimage'});var tb=new GUI.ToolBar({className:'x-toolbar form-buttons',align:'right',elements:[{obj:new GUI.ToolBar.Button({xtype:'OK',listeners:{scope:this,click:function(btn){if(this.editMode){switch(this.mode){case'image':this.updateImage();break;case'flash':this.updateFlash();break;case'media':this.updateMedia();break;}
this.dialog.close();}else{var res=false;switch(this.mode){case'image':res=this.insertImage();break;case'flash':res=this.insertFlash();break;case'media':res=this.insertMedia();break;}
if(res===true){btn.disable();this.dialog.close();}}}}})},{obj:new GUI.ToolBar.Button({caption:'Cancel',listeners:{click:function(){dlg.close();}}})}]});tb.render('x-editor-imagedialog-toolbar');GUI.appendClearDiv('x-editor-imagedialog-toolbar');dlg.toolbar=tb;var imageAttributesForm=new GUI.Forms.Form({assignTo:'x-editor-imagedialog-imageattributes'}),flashAttributesForm=new GUI.Forms.Form({assignTo:'x-editor-imagedialog-flashattributes'}),mediaAttributesForm=new GUI.Forms.Form({assignTo:'x-editor-imagedialog-mediaattributes'});dlg.attributeForms={image:imageAttributesForm,flash:flashAttributesForm,media:mediaAttributesForm}
var extImageForm=new GUI.Forms.Form({assignTo:'x-editor-imagedialog-extimage',listeners:{beforesubmit:function(){return false;}}});dlg.extImageForm=extImageForm;return dlg;},createDialogTree:function(){var data={action:'getDirectoryContent',type:this.mode};Object.extendIf(data,this.baseParams);var tree=new GUI.Tree({rootVisible:false,width:'100%',height:295,dataUrl:this.imageHandlerUrl,inlineEdit:true,enableDd:true,checkBox:true,scrollable:true,postBody:Object.toQueryString(data),dd:{isTarget:true,moveOnly:false,groups:{'editor_imagemanager':true}},root:new GUI.Tree.Node({id:'',text:i18n.GUI_EDITOR_IM_IMAGES,async:true,expanded:true,editable:false})});tree.on({scope:this,beforeNodeLoad:this.onBeforeNodeLoad,nodeLoad:this.onNodeLoad,nodeLoadFailed:this.onNodeLoadFailed,beforeChangeText:this.onNodeBeforeChangeText,changeText:this.onNodeChangeText,select:this.onNodeSelect,beforemove:this.onNodeBeforeMove,move:this.onNodeMove});tree.render('x-editor-imagedialog-tree');this.tree=tree;return tree;},createActionToolbar:function(){this.modeButton=new GUI.ToolBar.Button({iconClass:this.modes[this.mode].iconClass,caption:this.modes[this.mode].name,canToggle:true,iconRight:JSGUI_IMAGES_PATH+'x-editor/arrow-down.gif',listeners:{scope:this,click:this.onChangeMediaTypeClick}});var tb=[{obj:new GUI.Element({html:'<label style="font-size: 11px;">Mode:</label>'})},{obj:this.modeButton},{obj:new GUI.ToolBar.Button({caption:i18n.GUI_EDITOR_IM_UPLOAD,iconClass:'x-insertimg-button-upload',listeners:{scope:this,click:this.onOpenUploadDialogClick}})},{obj:new GUI.ToolBar.Button({caption:i18n.GUI_EDITOR_IM_NEW_FOLDER,iconClass:'x-insertimg-button-newfolder',listeners:{scope:this,click:this.createDirectory}})},{obj:new GUI.ToolBar.Button({caption:i18n.GUI_EDITOR_IM_RENAME,iconClass:'x-insertimg-button-rename',listeners:{scope:this,click:function(){var node=this.tree.getSelectedNode();if(node){this.tree.showEditor(node);}}}})},{obj:new GUI.ToolBar.Button({caption:i18n.GUI_EDITOR_IM_DELETE,iconClass:'x-insertimg-button-delete',listeners:{scope:this,click:function(){this.showConfirmationMessage('','','remove');}.bind(this)}})},{obj:new GUI.ToolBar.Button({caption:i18n.GUI_EDITOR_IM_REFRESH,iconClass:'x-insertimg-button-refresh',listeners:{scope:this,click:this.refresh}})}];return tb;},onLoadExternalFileClick:function(){var src=this.dialog.extImageForm.getField('extsrc').getValue();if(this.isValidFile(src)){this.dialog.attributeForms[this.mode].getField('src').setValue(src);this.showPreview(src);}else{this.showError(i18n.GUI_EDITOR_IM_INVALID_URL);}},onChangeMediaTypeClick:function(btn){if(!this.mediaTypeMenu){this.mediaTypeMenu=new GUI.Popup.Menu({width:'auto',light:true,items:[{caption:i18n.GUI_EDITOR_IM_IMAGES,iconClass:'x-editor-button-image',value:'image'},{caption:i18n.GUI_EDITOR_IM_FLASH,iconClass:'x-editor-button-flash',value:'flash'},{caption:i18n.GUI_EDITOR_IM_MEDIA,iconClass:'x-editor-button-media',value:'media'}]});this.mediaTypeMenu.on({scope:this,click:this.onMenuItemClick,mouseleave:this.onMenuMouseLeave});}
if(this.mediaTypeMenu.visible){this.hideModeMenu();}else{this.showModeMenu();}},showModeMenu:function(){this.mediaTypeMenu.show();this.mediaTypeMenu.alignTo(this.modeButton.getDom(),'tl-bl',[-2,-3]);document.on('mousedown',this.onDocMouseDown,this);},hideModeMenu:function(){document.un('mousedown',this.onDocMouseDown,this);this.mediaTypeMenu.hide();this.modeButton.toggle(false);},onDocMouseDown:function(e){e=GUI.Event.extend(e);if(e.within(this.modeButton.getDom())||e.within(this.mediaTypeMenu.getDom())){}else{this.hideModeMenu();}},setMode:function(mode){var modeConfig=this.modes[mode];if(mode!=this.mode&&modeConfig){this.mode=mode;this.dialog.setTitle(modeConfig.dialogTitle);GUI.$('x-editor-imagedialog-extimage').findDescedent('legend').innerHTML=modeConfig.extLegend;this.loadExtFileButton.setText(modeConfig.loadExtCaption);this.modeButton.setText(modeConfig.name);this.modeButton.setIconClass(modeConfig.iconClass);this.tree.root.setText(modeConfig.name,true);for(var i in this.modes){GUI.hide(this.dialog.attributeForms[i].dom);}
GUI.show(this.dialog.attributeForms[mode].dom);this.setBaseParams(this.baseParams);this.refresh();this.onDialogResize(this.dialog);}},onMenuItemClick:function(menu,item){this.setMode(item.value);this.modeButton.toggle(false);},onMenuMouseLeave:function(menu,e){this.hideModeMenu();this.modeButton.toggle(false);},onOpenUploadDialogClick:function(){var uploadNode=this.tree.getSelectedNode()||this.tree.root.firstChild;if(uploadNode.leaf){uploadNode=uploadNode.parentNode;}
uploadPath=uploadNode.getPathString();var uploadDlg=new GUI.Popup.Dialog({title:i18n.GUI_EDITOR_IM_UPLOAD_FILES,alwaysOnTop:true,modal:true,content:'<form id="x-editor-imageupload" action="'+this.imageHandlerUrl+'" method="post">'+'<fieldset>'+'<legend>'+i18n.GUI_EDITOR_IM_UPLOAD_FILES_TO+' "'+uploadPath+'":</legend>'+'<input type="hidden" name="action" value="upload" />'+'<input type="hidden" name="path" value="'+uploadPath+'" />'+'<input type="hidden" name="type" value="'+this.mode+'" />'+'<input type="file" name="files[]" />'+'<input type="submit" value="'+i18n.GUI_EDITOR_IM_GO+'!" /><br/>'+'<a id="x-editor-imageupload-more" href="javascript:">'+i18n.GUI_EDITOR_IM_UPLOAD_MORE_IMAGES+'</a>'+'</fieldset>'+'</form>'});this.uploadDlg=uploadDlg;uploadDlg.create();uploadDlg.uploadNode=uploadNode;var uploadForm=new GUI.Forms.Form({assignTo:'x-editor-imageupload',params:this.baseParams});uploadForm.on('afterSubmit',this.onUploadFormAfterSubmit,this);uploadDlg.uploadForm=uploadForm;GUI.$('x-editor-imageupload-more').on('click',this.onUploadMoreClick,this);uploadDlg.show();},onUploadMoreClick:function(e){e=GUI.Event.extend(e);e.preventDefault();GUI.Dom.insertBefore(GUI.$('x-editor-imageupload-more'),'<input type="file" name="files[]" /><br/><input type="file" name="files[]" /><br/>');return false;},onUploadFormAfterSubmit:function(f,response){var res=response.responseText.evalJSON();if(res&&res.done){var errors=res.errors,urls=res.urls,i;if(errors.length){var errorMessages=[];for(i=0;i<errors.length;i++){if(errors[i].name)errorMessages.push("'"+errors[i].name+"' : "+errors[i].message);else errorMessages.push(errors[i]);}
this.showError(errorMessages.join("<br/>\n"),i18n.GUI_EDITOR_IM_UPLOAD_ERROR)}
if(urls.length){var urlMessages=[];for(i=0;i<urls.length;i++){urlMessages.push("'"+urls[i].name+"' : "+urls[i].url);}
this.showInformer(urlMessages.join("<br/>\n"),i18n.GUI_EDITOR_IM_UPLOAD_OK);this.uploadDlg.uploadNode.reload();this.updateDirectory();if(!errors.length){this.uploadDlg.close();}}}else{this.showError(i18n.GUI_EDITOR_IM_UPLOAD_SERVER_ERROR);this.uploadDlg.close();}},showInformer:function(msg,title){if(!this._informer){this._informer=new GUI.Popup.PopupInformer({type:'info'});}
this._informer.setCaption(title||'');this._informer.setText(msg);this._informer.show();},showError:function(msg,title,callback,param){var msgBox=this._errMessageBox=new GUI.Popup.MessageBox({type:'error',alwaysOnTop:true,dimensions:{width:400},buttons:[{xtype:'OK',listeners:{click:function(){msgBox.close();if(callback){callback(param);}}}}]});msgBox.create();msgBox.setTitle(title||i18n.GUI_EDITOR_ERROR);msgBox.setText(msg);msgBox.show();},showConfirmationMessage:function(msg,title,action){var msgBox=new GUI.Popup.MessageBox({type:'error',alwaysOnTop:true,dimensions:{width:400},buttons:[{xtype:'OK',listeners:{click:function(){switch(action){case'remove':this.remove();break;}
msgBox.close();}.bind(this)}},{xtype:'CANCEL',listeners:{click:function(){msgBox.close();}}}]});msgBox.create();msgBox.setTitle(title||i18n.GUI_DELETE_MESSAGE_TITLE);msgBox.setText(msg||i18n.GUI_DELETE_MESSAGE);msgBox.show();},onDialogResize:function(dlg){var dims=GUI.getClientSize(GUI.$(dlg.contentId));if(dims.width<20||dims.height<20){return;}
var leftColWidth=dims.width*0.25;leftColWidth=leftColWidth.constrain(300);this.tree.setDimensions(leftColWidth);var attrDims=GUI.getDimensions(this.dialog.attributeForms[this.mode].dom);var treeHeight=dims.height-29-2-attrDims.height;this.tree.setDimensions(undefined,treeHeight);var rightColWidth=dims.width-leftColWidth-10;this.setListViewDimensions(rightColWidth);var extImgDims=GUI.getDimensions(this.dialog.extImageForm.dom);var listViewHeight=dims.height-29-extImgDims.height
this.setListViewDimensions(undefined,listViewHeight);},onDialogClose:function(){this.editor.updateTextarea();this.editor.updateIframe();},createDirectory:function(){var parent=this.tree.getSelectedNode()||this.tree.root.firstChild;if(parent.leaf){parent=parent.parentNode;}
var data={action:'mkdir',name:i18n.GUI_EDITOR_IM_NEW_DIRECTORY,path:parent.getPathString()};Object.extendIf(data,this.baseParams);new GUI.Ajax.Request({url:this.imageHandlerUrl,baseParams:this.baseParams,data:data,scope:this,onSuccess:function(response,request){var res=request.responseJson;if(res&&res.done){var node=new GUI.Tree.Node({text:res.text,isDir:true,child:[]});parent.appendChild(node);parent.expand(false,true);this.tree.showEditor(node);this.showInformer(i18n.GUI_EDITOR_IM_CREATE_OK);}else{if(res&&res.errors&&res.errors.length>0){this.showError(res.errors.join("<br />"));}else{this.showError(i18n.GUI_EDITOR_IM_CREATE_ERROR);}}},onFailure:function(){this.showError(i18n.GUI_EDITOR_IM_CREATE_ERROR);}});},refresh:function(){this.reload=true;this.tree.root.reload();},remove:function(){var nodes=this.tree.getCheckedNodes();if(nodes.length==0){var node=this.tree.getSelectedNode();if(node){nodes=[node];}}
var i=nodes.length,urls=[];if(i==0){return;}
while(i--){urls[i]=nodes[i].getPathString();}
i=nodes.length;while(i--){try{nodes[i].remove();}catch(e){}}
var data={action:'remove',urls:urls};Object.extendIf(data,this.baseParams);new GUI.Ajax.Request({url:this.imageHandlerUrl,data:data,scope:this,onSuccess:function(response,request){var res=request.responseJson;if(res&&res.done){this.updateDirectory();this.showInformer(i18n.GUI_EDITOR_IM_REMOVE_OK);}else{this.showError(i18n.GUI_EDITOR_IM_REMOVE_ERROR);this.refresh();}},onFailure:function(){this.showError(i18n.GUI_EDITOR_IM_REMOVE_ERROR);}});},onBeforeNodeLoad:function(tree,node,data){data.parentID=node.getPathString();},onNodeLoad:function(node,response,tree){if(this.reload){this.reload=false;if(GUI.isSet(this.currentDirectoryId)){var node=tree.getNodeById(this.currentDirectoryId);tree.selectNode(node?node:tree.root.firstChild);}}
if(tree.getSelectedNode()==null&&node==tree.root){if(this.editMode){tree.suspendEvents();tree.selectNode(node.firstChild);tree.resumeEvents();}else{tree.selectNode(node.firstChild);}}
if(this.editMode){return;}
if(tree.getSelectedNode()==node){GUI.$('x-editor-imagedialog-thumbnails').removeClass('jsgui-listview-loading');this.showDirectory(node);}},onNodeLoadFailed:function(node,response,tree){this.showError(i18n.GUI_EDITOR_IM_TREE_LOAD_FAILED);if(this.tree.getSelectedNode()==node){GUI.$('x-editor-imagedialog-thumbnails').removeClass('jsgui-listview-loading');GUI.$('x-editor-imagedialog-list').firstChild.innerHTML='<label>Load failed</label>';}},onNodeBeforeChangeText:function(t,node,text,oldText){if(text==oldText){return false;}
var p=node.parentNode;if(p){if(p.getChildByText(text)){this.showError(i18n.GUI_EDITOR_IM_FOLDER_EXISTS);return false;}}},onNodeChangeText:function(t,node,text,oldText){if(text==oldText){return;}
if(text.indexOf('/')!=-1||text.indexOf('\\')!=-1||!text.match(/^[\.-a-z ]*$/i)){node.setText(oldText);this.showError(i18n.GUI_EDITOR_IM_INVALID_FILE_NAME,'',this.onRenameNodeError,{tree:this.tree,node:node});return;}
var dir=node.parentNode.getPathString()+'/',data={action:'move',path:dir+oldText,newPath:dir+text};Object.extendIf(data,this.baseParams);new GUI.Ajax.Request({url:this.imageHandlerUrl,type:this.mode,data:data,scope:this,onSuccess:function(response,request){var res=request.responseJson;if(res&&res.done){if(GUI.isSet(res.text)&&(node.getText()!=res.text)){node.setText(res.text);};this.updateDirectory();this.showInformer(i18n.GUI_EDITOR_IM_RENAME_OK);}else{node.setText(oldText);if(res&&res.errors&&res.errors.length>0){this.showError(res.errors.join("<br />"),'',this.onRenameNodeError,{tree:this.tree,node:node});}else{this.showError(i18n.GUI_EDITOR_IM_RENAME_ERROR,'',this.onRenameNodeError,{tree:this.tree,node:node});}}},onFailure:function(){this.showError(i18n.GUI_EDITOR_IM_RENAME_ERROR,'',this.onRenameNodeError,{tree:this.tree,node:node});}});},onRenameNodeError:function(obj){if(obj&&obj.tree&&obj.node){obj.tree.showEditor(obj.node);}},onNodeSelect:function(tree,node){if(!node.leaf){this.showDirectory(node);}else{this.showDirectory(node.parentNode);if(this.isValidFile(node.getText())){this.showPreview(node);}else{}}},onNodeBeforeMove:function(tree,node,oldParent,oldIndex,newParent,newIndex){if(this.disableMoveInRoot&&newParent.isRoot){return false;}
if(oldParent==newParent){return false;}
if(newParent.getChildByText(node.getText())){this.showError(i18n.GUI_EDITOR_IM_FOLDER_EXISTS);return false;}
return true;},onNodeMove:function(tree,node,oldParent,oldIndex,newParent,newIndex){var data={action:'move',path:oldParent.getPathString()+'/'+node.getText(),newPath:newParent.getPathString()+'/'+node.getText()};Object.extendIf(data,this.baseParams);new GUI.Ajax.Request({url:this.imageHandlerUrl,data:data,type:this.mode,scope:this,onSuccess:function(response,request){var res=request.responseJson;if(res&&res.done){if(node.leaf){node=node.parentNode;}
this.showDirectory(node);this.tree.selectNode(node);this.showInformer(i18n.GUI_EDITOR_IM_MOVE_OK);}else{if(res&&res.errors&&res.errors.length>0){this.showError(res.errors.join("<br />"));}else{this.showError(i18n.GUI_EDITOR_IM_MOVE_ERROR);}
this.refresh();}},onFailure:function(){this.showError(i18n.GUI_EDITOR_IM_MOVE_ERROR);this.refresh();}});},updateDirectory:function(){if(GUI.isSet(this.currentDirectoryId)){var node=this.tree.getNodeById(this.currentDirectoryId);if(node){this.showDirectory(node);}else{this.tree.selectNode(this.tree.root.firstChild);}}},showDirectory:function(node){if(!node){return false;}
this.currentDirectoryId=node.id;this.dialog.attributeForms['image'].reset();if(!node.loaded){GUI.$('x-editor-imagedialog-thumbnails').addClass('jsgui-listview-loading');node.load();return;}
var i,ch,childNodes=node.childNodes,len=childNodes.length,html=new GUI.StringBuffer(),noCacheId=new Date()-0;this._lastNoCacheId=noCacheId;for(i=0;i<len;i++){ch=childNodes[i];var imgSrc=ch.leaf?this.getNodeHref(ch):window.JSGUI_IMAGES_PATH+'x-editor/folder.gif',hint;hint=ch.getText()+"\n";if(ch.leaf){var canPreview=this.isValidFile(imgSrc);if(!canPreview||(this.mode!='image')){imgSrc=window.JSGUI_IMAGES_PATH+'x-editor/file.gif';}else{imgSrc=this._getNoCacheSrc(imgSrc,noCacheId);}
if(!canPreview){hint+=i18n.GUI_EDITOR_IM_NOT_IMAGE;}else{hint+=i18n.GUI_EDITOR_IM_SHOW_PREVIEW;}}else{hint+=i18n.GUI_EDITOR_IM_BROWSE_DIRECTORY;}
html.append('<div class="jsgui-listview-item" isdir="'+!ch.leaf+'" hint="'+hint+'" >'+'<div class="jsgui-listview-item-image-wrap"><table cellspacing="0"><tbody><tr><td><img src="'+imgSrc+'"/></td></tr></tbody></table></div>'+'<p class="jsgui-listview-item-name">'+ch.getText()+'</p>'+'</div>');}
GUI.$('x-editor-imagedialog-preview').style.visibility='hidden';GUI.$('x-editor-imagedialog-list').firstChild.innerHTML=len>0?html.toString():('<label>'+i18n.GUI_EDITOR_IM_FOLDER_EMPTY+'</label>');GUI.show('x-editor-imagedialog-list');},showPreview:function(src,doNotLoad){if(!GUI.isString(src)){src=this.getNodeHref(src);}
var holder=GUI.$('x-editor-imagedialog-preview-imageholder');this.dialog.attributeForms[this.mode].setFieldsValues({src:src});src=this._getNoCacheSrc(src,this._lastNoCacheId);switch(this.mode){case'image':this._showPreviewImage(holder,src,doNotLoad);break;case'flash':this._showPreviewFlash(holder,src);break;case'media':this._showPreviewMedia(holder,src);break;}
GUI.hide('x-editor-imagedialog-list');GUI.$('x-editor-imagedialog-preview').style.visibility='visible';},_getNoCacheSrc:function(src,noCacheId){if(typeof noCacheId=='undefined'){noCacheId=new Date()-0;}
if(src.indexOf('?')!==-1){src+='&';}else{src+='?';}
src+='__jsguiNoCache='+noCacheId;return src;},_showPreviewImage:function(imgHolder,src,doNotLoad){var img=document.createElement('img');if(!doNotLoad){img.onload=function(){this._loadImage(img);}.bind(this);}
img.src=src;imgHolder.innerHTML='';imgHolder.appendChild(img);},_showPreviewFlash:function(holder,src){var str='<embed loop="true" quality="high" scale="showall"'+' wmode="opaque" type="application/x-shockwave-flash" width="100%" height="100%" src="'+
src+'" />';holder.innerHTML=str;},_showPreviewMedia:function(holder,src){var str='<embed autostart="true" showstatusbar="false" showcontrols="true"'+' type="application/x-mplayer2" width="100%" height="100%"'+' pluginspage="http://www.microsoft.com/Windows/MediaPlayer" src="'+
src+'" />';holder.innerHTML=str;},setListViewDimensions:function(w,h){var outerNode=GUI.$('x-editor-imagedialog-thumbnails'),innerNode=GUI.$('x-editor-imagedialog-list');if(w!=null){GUI.setFullWidth(outerNode,w);GUI.setFullWidth(innerNode,w-2);}
if(h!=null){GUI.setFullHeight(outerNode,h);GUI.setFullHeight(innerNode,h-2);}},onListInnerClick:function(e){e=GUI.Event.extend(e);var itemNode=e.target.findParent('div',this.listInner,'jsgui-listview-item');if(itemNode){var name=itemNode.getElementsByTagName('p')[0].innerHTML,curNode=this.tree.getSelectedNode()||this.tree.root;if(curNode.leaf){curNode=curNode.parentNode;}
var node=curNode.getChildByText(name);if(itemNode.getAttribute('isdir')=='false'){if(this.isValidFile(name)){this.showPreview(node);}}else{if(node){this.tree.selectNode(node);}}}},onPreviewClick:function(){GUI.$('x-editor-imagedialog-preview').style.visibility='hidden';GUI.show('x-editor-imagedialog-list');if(!this.tree.getSelectedNode()){this.tree.selectNode(this.tree.root.firstChild);}},isValidImage:function(src){return this.imageRe.test(src);},isValidFile:function(src){return true;},applyImageAttributes:function(img,attrs){img.src=attrs.src;img.alt=attrs.alt;img.title=attrs.title;img.width=attrs.width;img.height=attrs.height;img.border=attrs.border;img.hspace=attrs.hspace;img.vspace=attrs.vspace;img.align=attrs.align;var s=img.style;s.marginLeft=s.marginRight=attrs.hspace+'px';s.marginTop=s.marginBottom=attrs.vspace+'px';s.borderWidth=img.border+'px';},_loadImage:function(img){var f=this.dialog.attributeForms['image'];f.setFieldsValues({width:img.width,height:img.height});img.onload=null;},loadImageAttributes:function(){var img=this.editedImage;var attrs={src:img.src,alt:img.alt,title:img.title,align:img.align,border:img.border,hspace:img.hspace.constrain(0),vspace:img.vspace.constrain(0),width:img.width,height:img.height};this.dialog.attributeForms['image'].setFieldsValues(attrs);var external=false;if(external){GUI.$('x-editor-imagedialog-extimage').value=img.src;}else{}
this.showPreview(img.src,true);},insertImage:function(){var attrs=this.dialog.attributeForms['image'].getValues();if(!attrs.src){this.showError(i18n.GUI_EDITOR_IM_SELECT_IMAGE);return false;}
var img=this.editor.iDoc.createElement('img');this.applyImageAttributes(img,attrs);if(this.editor.iWin.getSelection){if(!this.collapsed){this.range.deleteContents();}
this.range.insertNode(img);}else if(this.editor.iDoc.selection){this.editor.iWin.focus();if(this.range){this.range.pasteHTML(img.outerHTML);}else{this.showError(i18n.GUI_EDITOR_IM_NO_SELECTION);}}
this.editor.updateTextarea();return true;},updateImage:function(){var attrs=this.dialog.attributeForms['image'].getValues();this.applyImageAttributes(this.editedImage,attrs);},loadFlashAttributes:function(){var img=this.editedImage;var _attrs=img.getAttribute('name2');var attrs={src:'',align:'',hspace:0,vspace:0,width:100,height:100,loop:'true',quality:'high',scale:'showall',wmode:'opaque'};if(_attrs){_attrs=decodeURIComponent(_attrs);_attrs=_attrs.match(/<embed([\s\S]+?)\/?>/i);_attrs=_attrs&&_attrs[1];if(_attrs){var re=/(\S+)="?(\S*?)"?\s+/gi,match,res={};while((match=re.exec(_attrs))!=null){res[match[1]]=match[2];}
Object.extend(attrs,res);}}
this.dialog.attributeForms['flash'].setFieldsValues(attrs);var external=false;if(external){GUI.$('x-editor-imagedialog-extimage').value=attrs.src;}else{}
if(attrs&&attrs.src){this.showPreview(attrs.src,true);}},insertFlash:function(){var attrs=this.dialog.attributeForms['flash'].getValues();if(!attrs.src){this.showError(i18n.GUI_EDITOR_IM_SELECT_FLASH);return false;}
attrs.type='application/x-shockwave-flash';var img=this.editor.iDoc.createElement('img');this.applyFlashAttributes(img,attrs);if(this.editor.iWin.getSelection){if(!this.collapsed){this.range.deleteContents();}
this.range.insertNode(img);}else if(this.editor.iDoc.selection){this.editor.iWin.focus();if(this.range){this.range.pasteHTML(img.outerHTML);}else{this.showError(i18n.GUI_EDITOR_IM_NO_SELECTION);}}
this.editor.updateTextarea();return true;},updateFlash:function(){var attrs=this.dialog.attributeForms['flash'].getValues();if(!attrs.src){this.showError(i18n.GUI_EDITOR_IM_SELECT_FLASH);return false;}
this.applyFlashAttributes(this.editedImage,attrs);},applyFlashAttributes:function(img,attrs){attrs.type='application/x-shockwave-flash';var attrString='';for(var i in attrs){attrString+=' '+i+'="'+attrs[i]+'"';}
attrString='<embed'+attrString+'/>';img.className='jsgui-wysiwyg-flash';img.title='Flash';img.alt=attrs.src;img.width=attrs.width;img.height=attrs.height;img.hspace=attrs.hspace;img.vspace=attrs.vspace;img.align=attrs.align;img.src=GUI.emptyImageUrl;img.setAttribute('name2',encodeURIComponent(attrString));},loadMediaAttributes:function(){var img=this.editedImage;var _attrs=img.getAttribute('name2');var attrs={src:'',width:100,height:100,autostart:'false',showcontrols:'false',showstatusbar:'false'};if(_attrs){_attrs=decodeURIComponent(_attrs);_attrs=_attrs.match(/<embed([\s\S]+?)\/?>/i);_attrs=_attrs&&_attrs[1];if(_attrs){var re=/(\S+)="?(\S*?)"?\s+/gi,match,res={};while((match=re.exec(_attrs))!=null){res[match[1]]=match[2];}
Object.extend(attrs,res);}}
this.dialog.attributeForms['media'].setFieldsValues(attrs);var external=false;if(external){GUI.$('x-editor-imagedialog-extimage').value=attrs.src;}else{}
if(attrs&&attrs.src){this.showPreview(attrs.src,true);}},insertMedia:function(){var attrs=this.dialog.attributeForms['media'].getValues();if(!attrs.src){this.showError(i18n.GUI_EDITOR_IM_SELECT_MEDIA);return false;}
var img=this.editor.iDoc.createElement('img');this.applyMediaAttributes(img,attrs);if(this.editor.iWin.getSelection){if(!this.collapsed){this.range.deleteContents();}
this.range.insertNode(img);}else if(this.editor.iDoc.selection){this.editor.iWin.focus();if(this.range){this.range.pasteHTML(img.outerHTML);}else{this.showError(i18n.GUI_EDITOR_IM_NO_SELECTION);}}
this.editor.updateTextarea();return true;},updateMedia:function(){var attrs=this.dialog.attributeForms['media'].getValues();if(!attrs.src){this.showError(i18n.GUI_EDITOR_IM_SELECT_MEDIA);return false;}
this.applyMediaAttributes(this.editedImage,attrs);},applyMediaAttributes:function(img,attrs){var attrString='';attrs.pluginspage='http://www.microsoft.com/Windows/MediaPlayer';attrs.type='application/x-mplayer2';for(var i in attrs){attrString+=' '+i+'="'+attrs[i]+'"';}
attrString='<embed'+attrString+'/>';img.className='jsgui-wysiwyg-media';img.title='Media';img.alt=attrs.src;img.width=attrs.width;img.height=attrs.height;img.setAttribute('name2',encodeURIComponent(attrString));},setBaseParams:function(baseParams){if(!baseParams){baseParams={};}
baseParams.type=this.mode;this.baseParams=baseParams;if(this.tree){var data={action:'getDirectoryContent'};Object.extendIf(data,this.baseParams);this.tree.config.postBody=GUI.toQueryString(data);}},embed2img:function(html){var c1=/(<embed [\s\S]*?>)/gi;html=html.replace(c1,function(s1,s2){var r1=s2.match(/width=\s*(\S+)[\s\S]*?/gi),r2=s2.match(/height=\s*(\S+)[\s\S]*?/gi),r3=s2.match(/src=\s*(\S+)\s?/gi),w=r1&&r1[0].replace(/[>|;|]/gi,"")||'',h=r2&&r2[0].replace(/[>|;|]/gi,"")||'',alt=r3&&r3[0].replace(/[>|;|"]/gi,"")||'';if(alt){alt=alt.replace(/src/gi,"alt");}
return'<img '+w+' '+h+' '+alt+' name2="'+
encodeURIComponent(s2)+'" class="'+
(s2.indexOf("x-mplayer")>=0?'jsgui-wysiwyg-media':'jsgui-wysiwyg-flash')+'" src='+GUI.emptyImageUrl+' />';});return html;},img2embed:function(html){var c1=/(<img[^>]*?name2="([\s\S]*?)"[^>]*?>)/gi;html=html.replace(c1,function(s1,s2,s3){var r1=s2.match(/width\s*[:|=]\s*(\S+)[%|px]?/gi),r2=s2.match(/height\s*[:|=]\s*(\S+)[%|px]?/gi);s3=decodeURIComponent(s3);var h=r2[0].replace(/:/gi,"="),w=r1[0].replace(/:/gi,"=");w=w.replace(/[>|;|\/" | ]/gi,"");h=h.replace(/[>|;|\/|" ]/gi,"");h=h.replace(/=/gi,'="')+'"';w=w.replace(/=/gi,'="')+'"';s3=s3.replace(/(height\s*=\s*[\d\"\']+)/gi,h);s3=s3.replace(/(width\s*=\s*[\d\"\']+)/gi,w);return s3;});return html;},getNodeHref:function(node){var href=[];while(node){if(node.config.href){href.unshift(node.config.href);break;}else{href.unshift('/'+node.getText());}
node=node.parentNode;};return href.join('');}});if(!GUI.Forms.Plugins)GUI.Forms.Plugins={};GUI.Forms.Plugins.EditorImageManager=EditorImageManager;}());

(function(){var EditorToc=Class.create({dialogContent:'<form id="x-editor-tocdialog-form" class="x-editor-tocdialog-form" style="padding: 5px 5px 0; margin: 0; line-height: 1.5;">'+'<table class="x-editor-toc" cellspacing="8"><tbody>'+'<tr valign="top">'+'<td>'+'<label>'+GUI.i18n.GUI_EDITOR_SHOW_LEVELS+':</label>'+'</td>'+'<td>'+'<input id="x-editor-toc-1level" type="text" xtype="spin" name="levels" value="3" min="1" max="6" style="width:40px;" />'+'</td>'+'</tr>'+'<tr valign="top">'+'<td>'+'<label>'+GUI.i18n.GUI_EDITOR_TYPE+':</label>'+'</td>'+'<td>'+'<label><input type="radio" name="type" value="numbered" checked="checked" />&nbsp;'+GUI.i18n.GUI_EDITOR_NUMBERED+'</label><br/>'+'<label><input type="radio" name="type" value="markered" />&nbsp;'+GUI.i18n.GUI_EDITOR_MARKERED+'</label>'+'</td>'+'</tr>'+'<tr>'+'<td colspan="2">'+'<label><input type="checkbox" name="makeLinks" checked="checked" />&nbsp;'+GUI.i18n.GUI_EDITOR_GENERATE_LINKS+'</label><br/>'+'</td>'+'</tr>'+'<tr>'+'<td colspan="2" id="x-editor-tocdialog-toolbar" style="padding-top: 8px;" ></td>'+'</tr>'+'</tbody></table>'+'</form>',initialize:function(cfg){},init:function(editor){this.editor=editor;editor.on('createToolbar',this.onCreateToolbar,this);},destroy:function(){if(this.dialog){this.dialog.destroy();this.dialog=null;}
this.editor.un('createToolbar',this.onCreateToolbar,this);this.editor=null;},onCreateToolbar:function(){var tb=this.editor.toolbars.toc,btn1,btn2,cfg,createMode=false;if(!tb){tb=this.editor.toolbars.toc=new GUI.ToolBar({align:'none'});createMode=true;}
btn1=new GUI.ToolBar.Button({name:'inserttoc',clickEvent:'mousedown',caption:GUI.i18n.GUI_EDITOR_INSERT_TOC,hint:GUI.i18n.GUI_EDITOR_INSERT_TOC,iconClass:'x-editor-button-toc',listeners:{scope:this,click:this.onInsertTocClick},useImageSwitchingForDisabledState:false});btn2=new GUI.ToolBar.Button({name:'edittoc',clickEvent:'mousedown',caption:GUI.i18n.GUI_EDITOR_EDIT_TOC,hint:GUI.i18n.GUI_EDITOR_EDIT_TOC,iconClass:'x-editor-button-toc',listeners:{scope:this,click:this.onEditTocClick},useImageSwitchingForDisabledState:false});if(createMode){tb.add(0,btn1);tb.add(1,btn2);}else{tb.insert(-1,0,btn2);tb.insert(-1,0,btn1);}
if(createMode){tb.add(null,new GUI.ToolBar.Separator());this.editor.renderToolbars.splice(8,0,'toc');}},onInsertTocClick:function(btn){this.editor.saveRange();this.editMode=false;this.dialog=this.createDialog();this.dialog.deferShow();},onEditTocClick:function(btn){this.editor.saveRange();var toc=this.getSelectedToc();if(toc){this.editMode=true;this.editedNode=toc;this.dialog=this.createDialog();this.dialog.deferShow();}},createDialog:function(){var dialogContent=this.dialogContent;var dlg=new GUI.Popup.Dialog({id:'jsgui-editor-tocdialog',title:this.editMode?GUI.i18n.GUI_EDITOR_EDIT_TOC:GUI.i18n.GUI_EDITOR_INSERT_TOC,content:dialogContent,modal:true,alwaysOnTop:true,toolbuttons:[{name:'close',img:JSGUI_IMAGES_PATH+'x-dialog/x-dialog-ico-close.gif'}]});dlg.create();var tb=new GUI.ToolBar({className:'x-toolbar form-buttons',align:'center',elements:[{obj:new GUI.ToolBar.Button({xtype:'OK',width:60,listeners:{scope:this,click:function(){if(this.editMode){this.updateToc();this.dialog.close();}else{res=this.insertToc();this.dialog.close();}}}})},{obj:new GUI.ToolBar.Button({xtype:'CANCEL',width:60,listeners:{click:function(){dlg.close();}}})}]});tb.render('x-editor-tocdialog-toolbar');dlg.toolbar=tb;var form=new GUI.Forms.Form({assignTo:'x-editor-tocdialog-form',listeners:{beforesubmit:function(){return false;}}});dlg.form=form;if(this.editMode){var o={};if(this.editedNode.nodeName=='UL'){o.type='markered';}else if(this.editedNode.nodeName=='OL'){o.type='numbered';}
if(this.editedNode.getElementsByTagName('a').length>0){o.makeLinks=true;}else{o.makeLinks=false;}
form.setFieldsValues(o);}
return dlg;},getSelectedToc:function(){var sel=this.editor.getSelectionBounds();if(sel&&sel.root){var node=sel.root;while(node){if((node.nodeName=='UL'||node.nodeName=='OL')&&GUI.Dom.hasClass(node,'jsgui-wysiwyg-toc',true)){return node;}
node=node.parentNode;}}
return null;},updateToc:function(){var toc=this._createToc();this.editedNode.parentNode.replaceChild(toc,this.editedNode);this.editor.selectNode(toc);this.editor.updateTextarea();},insertToc:function(){var toc=this._createToc();this.editor.pasteNode(toc);if(!GUI.isIE){this.editor.selectNode(toc);}},_createToc:function(){var options=this.dialog.form.getValues(),i,j,toc,d=this.editor.iDoc,tocTag='ol',levels=parseInt(options.levels,10),makeLinks=!!options.makeLinks,type=options.type;if(type=='numbered'){tocTag='ol';}else if(type=='markered'){tocTag='ul';}
toc=d.createElement(tocTag);toc.className='jsgui-wysiwyg-toc';var allTags=d.body.getElementsByTagName('*'),len=allTags.length,i,h,tag,code,level,li;var idPrefix='';if(makeLinks){idPrefix='jsgui-autotocid-'+(new Date()-0)+'-';}
console.log(len);for(i=0;i<len;i++){h=allTags[i];tag=h.nodeName;if(tag.charAt(0)==='H'){code=tag.charCodeAt(1);if((code>=48)&&(code<=57)){level=parseInt(tag.charAt(1),10);if(level<=levels){li=d.createElement('li');if(makeLinks){if(!h.id){h.id=idPrefix+i;}
li.innerHTML='<a href="#'+h.id+'">'+h.innerHTML+'</a>';}else{li.innerHTML=h.innerHTML;}
toc.appendChild(li);}}}}
return toc;}});if(!GUI.Forms.Plugins)GUI.Forms.Plugins={};GUI.Forms.Plugins.EditorToc=EditorToc;}());

GUI.Bar=Class.create();Object.extend(Object.extend(GUI.Bar.prototype,GUI.Utils.Draggable.prototype),{initialize:function(config){GUI.Utils.Draggable.prototype.initialize.apply(this,arguments);var cfg=this.config;Object.extend(cfg,{id:GUI.getUniqId('x-bar-'),holder:undefined,className:'x-bar',elements:undefined,position:undefined,align:undefined,disabled:false,hideMode:'display',visible:true});Object.extend(cfg,config);this.elementType='GUI.Bar';this.elements=new GUI.Utils.Collection();this.rendered=false;this.disabled=cfg.disabled;this.visible=cfg.visible;if(cfg.name){GUI.ComponentMgr.register(cfg.name,this);}},destroy:function(fast){this.config.holder=null;if(this.config.name){GUI.ComponentMgr.unregister(this);}
this.elements.each(function(item){if(item.destroy){item.destroy(fast);}},this);this.elements.clear();this.purgeListeners();},add:function(name,elem){this.elements.add(name,elem);},remove:function(key){if(typeof key=='string'){return this.elements.removeKey(key);}else if(typeof key=='number'){return this.elements.removeAt(key);}},insert:function(index,name,elem){this.elements.insert(index,name,elem);},enable:function(){if(this.disabled){this.elements.each(function(elem){elem.enable();});this.disabled=false;}},disable:function(flag){if((flag!==undefined)&&(!flag)){this.enable();return;}
if(!this.disabled){this.elements.each(function(elem){elem.disable();});this.disabled=true;}},isDisabled:function(){return this.disabled;},isEnabled:function(){return!this.disabled;},setPosition:function(){throw new Error('setPosition() is an abstract method!');},setAlign:function(){throw new Error('setAlign() is an abstract method!');},getPosition:function(){return this.config.position;},getAlign:function(){return this.config.align;},getElement:function(key){return this.elements.get(key);},getElementName:function(obj){var idx=this.elements.indexOf(obj);return(GUI.isSet(idx))?this.elements.keyAt(idx):null;},indexOf:function(obj){return this.elements.indexOf(obj);},render:function(elem){if(!this.fireEvent('beforeRender',this)){return;}
if(this.dom){this.unrender();}
var cfg=this.config;if(GUI.isSet(elem)){cfg.holder=elem;}
var containerNode=GUI.$(cfg.holder);if(containerNode){this._render(containerNode);this.rendered=true;}else{throw new Error(this.elementType+' error in method render(): Element with id='+this.config.holder+' not found');}
if(!this.visible){this.hide();}
this.fireEvent('afterRender',this);},unrender:function(){if(!this.dom)return false;this.elements.each(function(item){item.unrender();},this);GUI.remove(this.dom);this.dom=null;},_render:function(){throw new Error(this.elementType+' error: _render() is an abstract method!');},getDom:function(){return this.dom;},hide:function(){this.visible=false;if(this.dom){switch(this.config.hideMode){case'visibility':this.dom.style.visibility='hidden';break;case'display':default:this.dom.style.display='none';}}},show:function(){this.visible=true;if(this.dom){switch(this.config.hideMode){case'visibility':this.dom.style.visibility='';break;case'display':default:this.dom.style.display='';}}}});

GUI.TabBar=Class.create();Object.extend(Object.extend(GUI.TabBar.prototype,GUI.Bar.prototype),{positions:['top','right','bottom','left'],aligns:{horizontal:['left','right','center','none'],vertical:['top','middle','buttom']},initialize:function(config){GUI.Bar.prototype.initialize.apply(this,arguments);var cfg=this.config;Object.extend(cfg,{id:GUI.getUniqId('x-tabbar-'),className:'x-tabbar',position:'top',multiline:false});Object.extend(cfg,config);if(!GUI.isSet(cfg.align)){cfg.align=((cfg.position=='top')||(cfg.position=='bottom'))?'left':'top';}
this.elementType='GUI.TabBar';this.activeTab=undefined;this.rendered=false;this.lastContentHidden=true;this.addEvents({tabSwitch:true});if(typeof cfg.onTabSwitch=='function'){this.on('tabSwitch',cfg.onTabSwitch,this);}
var elems,len;if(cfg.multiline){for(var i=0,rows=cfg.elements.length;i<rows;i++){var row=cfg.elements[i];for(var j=0,len=row.length;j<len;j++){var elem=row[j];this.add(elem.name,elem.obj,i);}}}else{if((typeof(elems=cfg.elements)=='object')&&((len=cfg.elements.length)>0)){for(var i=0;i<len;i++){var elem=elems[i];this.add(elem.name,elem.obj);}}}},add:function(name,elem,rowIndex){GUI.Bar.prototype.add.apply(this,arguments);if((elem instanceof GUI.TabBar.Tab)||(elem instanceof GUI.TabBar.FilterTab)){elem.setBar(this);if(elem.isActive()){if(GUI.isSet(this.activeTab)){this.activeTab.deactivate();}
elem.activate();this.activeTab=elem;}}
if(!this.rendered)return;var tbody=this.dom.firstChild;if(['top','bottom'].include(this.config.position)){var td=document.createElement('td');elem.render(td);tbody.firstChild.appendChild(td);}else{var tr=document.createElement('tr');var td=tr.appendChild(document.createElement('td'));elem.render(td);tbody.appendChild(tr);}},remove:function(key){var elem=this.getElement(key);if(elem instanceof GUI.TabBar.Tab){elem.deactivate();}
if(this.rendered){if(elem===-1){throw new Error('trying to remove non-existent tab');}
elem=elem.getDom();if(['top','bottom'].include(this.config.position)){var td=elem.parentNode;td.parentNode.removeChild(td);delete td;}else{var tr=elem.parentNode.parentNode;tr.parentNode.removeChild(tr);delete tr;}}
return GUI.Bar.prototype.remove.apply(this,arguments);},switchTo:function(id){if(GUI.isString(id)){var newTab=this.elements.get(id);}else if((id instanceof GUI.TabBar.Tab)||((id instanceof GUI.TabBar.FilterTab))){var newTab=id;}else{throw new Error(this.elementType+' error: switchTo() unknown argument');}
if(!GUI.isSet(newTab)){return;}
var oldTab=this.activeTab;if(newTab===oldTab){return;}
if(GUI.isSet(oldTab)){oldTab.deactivate(newTab.hiddenContent);}
newTab.activate();this.activeTab=newTab;this.fireEvent('tabswitch',this,this.activeTab);},closeTab:function(tab){if(tab===this.activeTab){this.nextTab();}
this.remove(this.elements.indexOf(tab));},nextTab:function(){var count=this.elements.getCount();var index=this.elements.indexOf(this.activeTab);var i=index+1;for(var c=1;c<count;c++,i++){if(i===count){i=0;}
var item=this.elements.itemAt(i);if((item instanceof GUI.TabBar.Tab)&&(item.isEnabled())){this.switchTo(item);return item;}}
return false;},setPosition:function(pos){if(!this.positions.include(pos)){throw new Error('setPosition(): unknow position type specified: '+pos);}
this.config.position=pos;if(this.rendered){this.dom.firstChild.className=pos;}},setAlign:function(align){var cfg=this.config;if((cfg.position=='top')||(cfg.position=='bottom')){if(!this.aligns.horizontal.include(align)){throw new Error('setAlign(): incorrect align for horizontal position specified: '+align);}
if(this.dom&&(align!='none')){this.dom.align=align;}}else if((cfg.position=='left')||(cfg.position=='right')){if(!this.aligns.vertical.include(align)){throw new Error('setAlign(): incorrect align for vertical position specified: '+align);}
if(this.dom){}}
cfg.align=align;},_render:function(containerNode){if(this.config.multiline){this.dom=document.createElement('div');this.dom.className='x-multiline-tabbar';containerNode.appendChild(this.dom);var rows=this.config.elements;for(var i=0,len=rows.length;i<len;i++){this._renderBar(this.dom,rows[i]);}
return;}
var table=document.createElement('table');table.className=this.config.className;this.dom=table;var tbody=table.appendChild(document.createElement('tbody'));tbody.className=this.config.position;containerNode.appendChild(table);if(['top','bottom'].include(this.config.position)){var tr=tbody.appendChild(document.createElement('tr'));this.elements.each(function(elem){var td=document.createElement('td');tr.appendChild(td);elem.render(td);});}else{this.elements.each(function(elem){var tr=tbody.appendChild(document.createElement('tr'));var td=document.createElement('td');tr.appendChild(td);elem.render(td);});}
this.setAlign(this.config.align);return this.dom;},_renderBar:function(to,items){var table=document.createElement('table'),tbody=document.createElement('tbody');table.className=this.config.className;tbody.className=this.config.position;to.appendChild(table);table.appendChild(tbody);if(['top','bottom'].include(this.config.position)){var tr=tbody.appendChild(document.createElement('tr'));for(var i=0,len=items.length;i<len;i++){var td=document.createElement('td');tr.appendChild(td);items[i].obj.render(td);};}else{for(var i=0,len=items.length;i<len;i++){var tr=tbody.appendChild(document.createElement('tr'));var td=document.createElement('td');tr.appendChild(td);items[i].render(td);};}},destroy:function(quick){GUI.Bar.prototype.destroy.call(this,quick);if(this.dom){if(!quick){GUI.destroyNode(this.dom);}
this.dom=null;}}});

(function(){var Tab=Class.create(GUI.ActiveElement,{className:'x-activeelement x-tab',innerClass:'',pressedClass:'x-tab-pressed',hoverClass:'x-tab-hover',disabledClass:'x-tab-disabled',activeClass:'x-tab-active',lCellClass:'x-tab-l',iconCellClass:'x-tab-icon',textCellClass:'x-tab-link',iconRightCellClass:'x-tab-list',rCellClass:'x-tab-r',clickEvent:'mousedown',closeOnDblClick:false,initialize:function(config){if(config){if(!config.listeners){config.listeners={};}
if(config.onBeforeActivate){config.listeners.beforeactivate=config.onBeforeActivate;delete config.onBeforeActivate;}
if(config.onAfterActivate){config.listeners.afteractivate=config.onAfterActivate;delete config.onAfterActivate;}
if(config.onBeforeDeactivate){config.listeners.beforedeactivate=config.onBeforeDeactivate;delete config.onBeforeDeactivate;}
if(config.onAfterDeactivate){config.listeners.afterdeactivate=config.onAfterDeactivate;delete config.onAfterDeactivate;}}
Tab.superclass.initialize.call(this,config);},getSelf:function(){return Tab;},activate:function(){if(this.disabled||(this.fireEvent('beforeActivate',this)===false)){return false;}
this.active=true;if(this.dom){this.onActivate();}
this.fireEvent('afterActivate',this);},onActivate:function(){this.clsDom.addClass(this.activeClass);if(this.assigned){GUI.show(this.assigned);}},deactivate:function(){if(this.disabled||(this.fireEvent('beforeDeactivate',this)===false)){return false;}
this.active=false;if(this.dom){this.onDeactivate();}
this.fireEvent('afterDeactivate',this);},onDeactivate:function(){this.clsDom.removeClass(this.activeClass);if(this.assigned){GUI.hide(this.assigned);}},close:function(){if(this.bar&&(GUI.isFunction(this.bar.remove))){this.bar.closeTab(this);}else{this.deactivate();}},setBar:function(bar){if(bar instanceof GUI.TabBar){this.bar=bar;}else{throw new Error(' error: setBar() - bar is not instance of TabBr');}},isActive:function(){return this.active;},initComponent:function(){Tab.superclass.initComponent.call(this);this.addEvents({'afterActivate':true,'afterDeactivate':true,'beforeActivate':true,'beforeDeactivate':true});},onAfterRender:function(btn){Tab.superclass.onAfterRender.call(this,btn);if(this.closeOnDblClick){btn.on('dblclick',this.onDblClick,this);}
if(this.active){this.activate();}},onDestroy:function(fast){this.assigned=this.bar=null;Tab.superclass.onDestroy.call(this,fast);},onClick:function(e){e=GUI.Event.extend(e);e.preventDefault();if(!this.disabled){if(this.bar&&(GUI.isFunction(this.bar.switchTo))){this.bar.switchTo(this);}
this.fireEvent('click',this);}},onDblClick:function(e){if(this.disabled||!this.active||!this.closeOnDblClick){return;}
this.close();}});Tab._tplCache=new Array(8);GUI.TabBar.Tab=Tab;}());

(function(){var FilterTab=Class.create(GUI.TabBar.Tab,{className:'x-activeelement x-filtertab',innerClass:'',pressedClass:'x-filtertab-pressed',hoverClass:'x-filtertab-hover',disabledClass:'x-filtertab-disabled',activeClass:'x-filtertab-active',lCellClass:'x-filtertab-l',iconCellClass:'x-filtertab-icon',textCellClass:'x-filtertab-link',iconRightCellClass:'x-filtertab-list',rCellClass:'x-filtertab-r',hiddenContentClass:'x-filtertab-hidden-content',hideContentBtnClass:'x-filtertab-hide-content-btn',iconRight:window.JSGUI_IMAGES_PATH+'activeelement/x-filtertab-iconright.gif',hiddenContent:false,animate:true,globalHide:false,unhideOnActivate:true,initialize:function(config){FilterTab.superclass.initialize.call(this,config);},getSelf:function(){return FilterTab;},onActivate:function(){this.clsDom.addClass(this.activeClass);if(this.globalHide){this.hiddenContent=this.bar.lastContentHidden;}
this.clsDom.addClass(this.hideContentBtnClass);if(this.hiddenContent){GUI.$(this.clsDom.firstChild).addClass(this.hiddenContentClass);}else{GUI.$(this.clsDom.firstChild).removeClass(this.hiddenContentClass);}
if(this.assigned&&!this.hiddenContent){if(this.bar&&this.bar.lastContentHidden){this.showContent();}else{this.showContent(true);}}},onDeactivate:function(){this.clsDom.removeClass(this.activeClass);if(this.globalHide){this.hiddenContent=this.bar.lastContentHidden;}
this.clsDom.removeClass(this.hideContentBtnClass);if(this.assigned){var tmp=this.hiddenContent;this.hideContent(!(this.animate&&!this.hiddenContent&&!this.unhideOnActivate&&!this.globalHide));this.hiddenContent=tmp;}
if(this.bar){this.bar.lastContentHidden=this.hiddenContent;}},updateContentHeight:function(){var node=GUI.$(this.assigned);GUI.makeVisible(node);node.style.top=node.style.left=0;this.contentHeight=node.clientHeight;GUI.undoVisible(node);},prepareFx:function(){if(!this.fx){this.addEvents({'fxComplete':true});var self=this,fxConfig={duration:500,onComplete:function(){self.fireEvent('fxComplete',this);}};this.fx=new Animator(fxConfig);this.on('fxComplete',function(fx){if(fx.state){this._showContent();}else{this._hideContent();}
var fxNode=GUI.$(this.assigned).parentNode;fxNode.style.top='';fxNode.parentNode.style.height='';});}
var fxNode=GUI.$(this.assigned).parentNode;if(!(this.fx.isRunning())){if(this.contentHeight==null){this.updateContentHeight();this.fx.clearSubjects();this.fx.addSubject(new NumericalStyleSubject(fxNode,'top',-this.contentHeight,0));if(!GUI.isIE){this.fx.addSubject(new NumericalStyleSubject(fxNode,'opacity',0,1));}}
if(!this.hiddenContent){this.fx.state=0.0;}else{this.fx.state=1.0;}
this.fx.propagate();}
if(!this.fx.isRunning()){fxNode.parentNode.style.height=(this.contentHeight+1)+'px';}},hideContent:function(fast){if(this.hiddenContent){return;}
this.hiddenContent=true;if(this.dom){GUI.$(this.clsDom.firstChild).addClass(this.hiddenContentClass);if(this.assigned){if(this.animate&&!fast){this.prepareFx();this.fx.seekTo(0);}else{this._hideContent();}}}},_hideContent:function(){var node=GUI.$(this.assigned),s=node.style;GUI.hide(node);},showContent:function(fast){this.hiddenContent=false;var assigned=GUI.$(this.assigned);if(this.dom){GUI.$(this.clsDom.firstChild).removeClass(this.hiddenContentClass);this.bar.lastContentHidden=false;if(this.assigned){if(this.animate&&!fast){this.prepareFx();if(!this.fx.isRunning()){}
GUI.show(assigned);this.fx.seekTo(1);}else{GUI.show(assigned);}}}},_showContent:function(){},setBar:function(bar){FilterTab.superclass.setBar.call(this,bar);if(this.globalHide){this.bar.lastContentHidden=this.hiddenContent;}},isHiddenContent:function(){return this.hiddenContent;},initComponent:function(){FilterTab.superclass.initComponent.call(this);this.addEvents({'hideContent':true});},onAfterRender:function(btn){FilterTab.superclass.onAfterRender.call(this,btn);},onClick:function(e){e=GUI.Event.extend(e);e.preventDefault();if(!this.disabled){if(this.active){if(this.hiddenContent){this.showContent();}else{this.hideContent();}
this.fireEvent('hideContent',this);}else if(this.bar&&GUI.isFunction(this.bar.switchTo)){if(this.unhideOnActivate){this.hiddenContent=false;}
this.bar.switchTo(this);}
this.fireEvent('click',this);}}});FilterTab._tplCache=new Array(8);GUI.TabBar.FilterTab=FilterTab;}());

GUI.ToolBar=Class.create();Object.extend(Object.extend(GUI.ToolBar.prototype,GUI.Bar.prototype),{itemClass:'jsgui-toolbar-item',positions:['horizontal','vertical'],aligns:{horizontal:['left','right','center'],vertical:['top','middle','bottom']},initialize:function(config){GUI.Bar.prototype.initialize.apply(this,arguments);var cfg=this.config;Object.extend(cfg,{id:GUI.getUniqId('x-toolbar-'),className:'x-toolbar',position:'horizontal'});Object.extend(this.config,config);if(!GUI.isSet(cfg.align)){cfg.align=(cfg.position=='horizontal')?'left':'top';}
this.elementType='GUI.ToolBar';this.addEvents({});var elems,len;if((typeof(elems=cfg.elements)=='object')&&((len=cfg.elements.length)>0)){for(var i=0;i<len;i++){var elem=elems[i];this.add(elem.name,elem.obj);}}},add:function(name,elem){GUI.Bar.prototype.add.apply(this,arguments);if(!this.rendered)return;var tbody=this.dom.firstChild;if(this.config.position==='horizontal'){var td=document.createElement('td');tbody.firstChild.appendChild(td);elem.render(td);}else{var tr=document.createElement('tr');var td=tr.appendChild(document.createElement('td'));tbody.appendChild(tr);elem.render(td);}},remove:function(key){if(this.rendered){var elem=this.getElement(key);if(elem===-1){throw new Error('trying to remove non-existent tab');}
elem=elem.getDom();if(this.config.position==='horizontal'){var td=elem.parentNode;td.parentNode.removeChild(td);delete td;}else{var tr=elem.parentNode.parentNode;tr.parentNode.removeChild(tr);delete tr;}}
GUI.Bar.prototype.remove.apply(this,arguments);},insert:function(){if(this.rendered){throw new Exception("GUI.Toolbar.insert() is unsupported currently when toolbar has been rendered");}
GUI.Bar.prototype.insert.apply(this,arguments);},setPosition:function(pos){if(this.positions.include(pos)){this.config.position=pos;return;}
throw new Error('setPosition(): unknow position type specified: '+pos);},setAlign:function(align){var cfg=this.config;if(!cfg.position){throw new Error('setAlign(): align can be set only when position is set');}
if(this.dom&&(align=='none')){this.dom.align='';return;}
if(this.aligns[cfg.position].include(align)){cfg.align=align;if(this.dom){if(cfg.position=='horizontal'){this.dom.align=align;if(align=='center'){this.dom.addClass('center');}
else if(align=='right'){this.dom.addClass('right');}}else{}}
return;}
throw new Error('setAlign(): incorrect align - '+align);},_render:function(containerNode){var cfg=this.config,table=document.createElement('table'),tbody=document.createElement('tbody');this.dom=GUI.Dom.extend(table);table.className=cfg.className;tbody.className=cfg.position;containerNode.appendChild(table);table.appendChild(tbody);if(cfg.position==='horizontal'){var tr=document.createElement('tr')
tbody.appendChild(tr);this.elements.each(function(elem){var td=document.createElement('td');td.className=this.itemClass;tr.appendChild(td);if(this.disabled){elem.disable();}
elem.render(td);},this);}else{this.elements.each(function(elem){var tr=document.createElement('tr'),td=document.createElement('td');td.className=this.itemClass;tbody.appendChild(tr);tr.appendChild(td);if(this.disabled){elem.disable();}
elem.render(td);});}
this.setAlign(cfg.align);return this.dom;},destroy:function(quick){GUI.Bar.prototype.destroy.call(this,quick);if(this.dom){if(!quick){GUI.destroyNode(this.dom);}
this.dom=null;}}});

(function(){Spacer=Class.create(GUI.Element,{initialize:function(config){Spacer.superclass.initialize.call(this,config);Object.extend(this.config,{id:GUI.getUniqId('x-toolbar-spacer-')});Object.extend(this.config,config);this.elementType='GUI.ToolBar.Spacer';},_render:function(to){if(!to){throw new Error('Can not render to:'+to);}
to.width='100%';}});GUI.ToolBar.Spacer=Spacer;}());

(function(){var Button=Class.create(GUI.ActiveElement,{className:'x-activeelement x-button',focusClass:'x-button-focused',pressedClass:'x-button-pressed',hoverClass:'x-button-hover',disabledClass:'x-button-disabled',lCellClass:'x-button-l',iconCellClass:'x-button-icon',textCellClass:'x-button-link',iconRightCellClass:'x-button-list',rCellClass:'x-button-r',getSelf:function(){return Button;}});Button._tplCache=new Array(8);GUI.ToolBar.Button=Button;}());

GUI.ToolBar.Separator=Class.create();Object.extend(Object.extend(GUI.ToolBar.Separator.prototype,GUI.Element.prototype),{initialize:function(config){GUI.Element.prototype.initialize.apply(this,arguments);Object.extend(this.config,{id:GUI.getUniqId('x-toolbar-separator-'),className:'x-toolbar-separator'});Object.extend(this.config,config);this.elementType='GUI.ToolBar.Separator';},_render:function(to){if(!to){throw new Error('Can not render to:'+to);}
var cfg=this.config;this.dom=document.createElement('div');this.dom.id=cfg.id;this.dom.className=cfg.className;to.appendChild(this.dom);}});

(function()
{var SimpleButton=Class.create();var superproto=GUI.Element.prototype;var prototype={initialize:function(config)
{superproto.initialize.call(this,config);this.config={id:GUI.getUniqId('simplebutton-'),holder:null,name:null,img:null,caption:null,onClick:null,visible:true};var cfg=this.config;Object.extend(cfg,config);this.clickListener=this.onClick.bindAsEventListener(this);this.addEvents({click:true});if(GUI.isFunction(cfg.onClick)){this.on('click',cfg.onClick);}
if(cfg.name){GUI.ComponentMgr.register(cfg.name,this);}
this.visible=cfg.visible;},destroy:function(fast){if(this.dom){this.unrender(fast);}
this.config.holder=null;if(this.config.name){GUI.ComponentMgr.unregister(this);}},render:function(to){if(this.dom){this.unrender();}
var cfg=this.config;var span=document.createElement('SPAN');if(!this.visible){GUI.hide(span);}
to.appendChild(span);if(GUI.isString(cfg.img)&&cfg.img.length||cfg.iconClass){var img=document.createElement('IMG');if(cfg.iconClass){img.className=cfg.iconClass;img.src=GUI.emptyImageUrl;}else{img.src=cfg.img;}
span.appendChild(img);}
if(GUI.isString(cfg.caption)&&cfg.caption.length){var link=document.createElement('A');link.href='#';span.appendChild(link);link.innerHTML=cfg.caption;}else{throw new Error("SimpleButton must have caption set!");}
this.dom=GUI.Dom.extend(span);this.attachEventListeners();},show:function(){if(!this.visible){if(this.dom){GUI.show(this.dom);}
this.visible=true;}},hide:function(){if(this.visible){if(this.dom){GUI.hide(this.dom);}
this.visible=false;}},setCaption:function(caption){this.config.caption=caption;if(this.dom){var links=this.dom.getElementsByTagName('a');if(links[0]){links[0].innerHTML=caption;}}},_enable:function(){if(this.dom){this.dom.removeClass('disabled');}},_disable:function(){if(this.dom){this.dom.addClass('disabled');}},attachEventListeners:function(){this.dom.on('click',this.onClick,this);},removeEventListeners:function(){this.dom.un('click',this.onClick,this);},onClick:function(e){e=GUI.Event.extend(e);e.preventDefault();if(!this.disabled){this.fireEvent('click',this);}}};Object.extend(SimpleButton.prototype,superproto);Object.extend(SimpleButton.prototype,prototype);GUI.ToolBar.SimpleButton=SimpleButton;})();

(function(){var ToggleButton=Class.create(GUI.ToolBar.Button,{canToggle:true,getSelf:function(){return ToggleButton;}});ToggleButton._tplCache=new Array(8);GUI.ToolBar.ToggleButton=ToggleButton;}());

(function()
{var ImageButton=Class.create();var superproto=GUI.ToolBar.SimpleButton.prototype;var prototype={initialize:function(config){superproto.initialize.call(this,config);var cfg=this.config;Object.extend(cfg,{id:GUI.getUniqId('x-imagebutton-'),name:null,hint:null,disabled:false,className:'x-imagebutton',preloadImages:true});Object.extend(cfg,config);this.img=cfg.img;this.imgDisabled=GUI.getDisabledImageUrl(cfg.img);this.imgHover=GUI.getHoverImageUrl(cfg.img);this.imgToggled=GUI.getToggledImageUrl(cfg.img);if(cfg.preloadImages){GUI.preloadImage(this.img,this.imgDisabled,this.imgHover,this.imgToggled);}
this.mouseOverListener=this.onMouseOver.bindAsEventListener(this);this.mouseOutListener=this.onMouseOut.bindAsEventListener(this);this.mouseDownListener=this.onMouseDown.bindAsEventListener(this);this.mouseUpListener=this.onMouseUp.bindAsEventListener(this);},render:function(to){if(this.dom){this.unrender();}
var cfg=this.config;var img=document.createElement('img');img.className=cfg.className;img.src=(this.disabled)?this.imgDisabled:this.img;to.appendChild(img);this.dom=img;this.attachEventListeners();},attachEventListeners:function(){superproto.attachEventListeners.call(this);Event.observe(this.dom,'mouseover',this.mouseOverListener);Event.observe(this.dom,'mouseout',this.mouseOutListener);Event.observe(this.dom,'mousedown',this.mouseDownListener);Event.observe(this.dom,'mouseup',this.mouseUpListener);},removeEventListeners:function(){superproto.removeEventListeners.call(this);Event.stopObserving(this.dom,'mouseover',this.mouseOverListener);Event.stopObserving(this.dom,'mouseout',this.mouseOutListener);Event.stopObserving(this.dom,'mousedown',this.mouseDownListener);Event.stopObserving(this.dom,'mouseup',this.mouseUpListener);},onClick:function(e){GUI.preventDefault(e);if(!this.disabled){this.fireEvent('click',this);}},onMouseDown:function(e){if(!this.disabled){this.dom.src=this.imgToggled;}},onMouseUp:function(e){if(!this.disabled){this.dom.src=this.imgHover;}},onMouseOver:function(e){if(!this.disabled){this.dom.src=this.imgHover;}},onMouseOut:function(e){if(!this.disabled){this.dom.src=this.img;}}};Object.extend(ImageButton.prototype,superproto);Object.extend(ImageButton.prototype,prototype);GUI.ToolBar.ImageButton=ImageButton;}());

(function()
{var MenuButton=Class.create();var superproto=GUI.Utils.Observable.prototype;var prototype={initialize:function(config){superproto.initialize.call(this,config);this.config={id:GUI.getUniqId('x-menubutton-'),name:null,caption:null,img:null,hint:null,disabled:false,button:GUI.ToolBar.Button,menu:null};var cfg=this.config;Object.extend(cfg,config);this.menu=new GUI.Popup.Menu(cfg.menu);this.button=new cfg.button({id:cfg.id,name:cfg.name,caption:cfg.caption,img:cfg.img,hint:cfg.hint,disabled:cfg.disabled});this.button.on('click',this.onBtnClick.bind(this));this.bodyClickListener=this.bodyClickHandler.bindAsEventListener(this);this.rendered=false;},destroy:function(){this.unrender();this.button.destroy();this.menu.destroy();},render:function(to){if(this.rendered){this.unrender();}
if(to){this.config.holder=to;}else{to=this.config.holder;}
this.button.render(to);},unrender:function(){if(this.rendered){this.button.unrender();}},attachEventListeners:function(){Event.observe((GUI.isIE)?document.body:document,'mousedown',this.bodyClickListener);},removeEventListeners:function(){Event.stopObserving((GUI.isIE)?document.body:document,'mousedown',this.bodyClickListener);},bodyClickHandler:function(e){var menu=this.menu;var btn=this.button;if(menu.dom){var target=GUI.getEventTarget(e);if(!(GUI.contains(menu.dom,target)||(btn.dom==target))){this.removeEventListeners();menu.hide();}}},onBtnClick:function(){if(this.menu.isVisible()){this.removeEventListeners();this.menu.hide();}else{this.menu.alignTo(this.button.dom,'tl-bl?');this.menu.show();this.attachEventListeners();}}};Object.extend(MenuButton.prototype,superproto);Object.extend(MenuButton.prototype,prototype);GUI.ToolBar.MenuButton=MenuButton;}());

(function(){var i18n=GUI.i18n;var Grid=Class.create(GUI.BoxComponent,{msg:i18n.GUI_GRID_NO_DATA,checkbox:false,singleSelect:false,align:'left',valign:'middle',hoverColor:'',bottomHidden:false,hintClass:'x-grid-hint',hintOffsetX:1,hintOffsetY:-4,hintDelay:50,customRowHidden:false,tbar:null,bbar:null,cutHeaderText:false,cutHeaderTextReadonly:false,_firstUpdate:true,initialize:function(config){Grid.superclass.initialize.call(this,config);},initComponent:function(){Grid.superclass.initComponent.call(this);this.config=this;this.addEvents({hdClick:true,hdMouseOver:true,hdMouseOut:true,rowMouseOver:true,rowMouseOut:true,rowClick:true,rowDblClick:true,cellMouseOver:true,cellMouseOut:true,cellMouseDown:true,cellClick:true,cellDblClick:true,customRowClick:true,customRowDblClick:true,customRowMouseOver:true,customRowMouseOut:true,customCellClick:true,customCellDblClick:true,customCellMouseOver:true,customCellMouseOut:true,sortChange:true,render:true,update:true,afterUpdate:true,noData:true,dataAvailable:true,windowResize:true});if(!this.data){this.data={};}
if(!this.sm){if(this.checkbox){this.sm=new Grid.CheckBoxSelectionModel({singleSelect:this.singleSelect});}else{this.sm=new Grid.RowSelectionModel({singleSelect:this.singleSelect});}}
this.sm.init(this);this.rows=new GUI.Utils.Collection();if(this.bbar&&!GUI.isArray(this.bbar)){this.bbar=[this.bbar];}
this.showHintDelegate=this.showHint.bind(this);},onRender:function(){var html='<div id="'+this.id+'" class="x-grid-panel">';if(this.tbar){}
html+='<div class="x-grid">'+'<div class="jsgui-grid-table-holder"></div>'+'<div id="'+this.id+'-nodata-msg" class="nodata" style="display:none;">'+
GUI.i18n.GUI_GRID_NO_DATA+'</div>'+'</div>';if(this.bbar===true){html+='<div class="x-grid-bbar"></div>';}else if(this.bbar){html+='<div class="x-grid-bbar">'+this.bbar+'</div>';}
return html;},onDestroy:function(quick){this.gridHolder=this.gridEl=this.headEl=this.bodyEl=null;},_renderBar:function(bar,to){if(GUI.isArray(bar)){for(var i=0,len=bar.length;i<len;i++){bar[i].render(to);}}else if(GUI.isFunction(bar.render)){this.bbar.render(to);}else{}},onAfterRender:function(dom){if(this.bbar){this.bbarEl=dom.findDescedent('div.x-grid-bbar');}
this.gridHolder=dom.findDescedent('div.jsgui-grid-table-holder');this.gridHolder.on('click',this.onClick,this);this.gridHolder.on('dblclick',this.onDblClick,this);this.gridHolder.on('mouseover',this.onMouseOver,this);this.gridHolder.on('mouseout',this.onMouseOut,this);this.gridHolder.on('mouseleave',this.onMouseLeave,this);this.setCutHeaderText(this.cutHeaderText);this.update();},setCutHeaderText:function(val){if(this.cutHeaderTextReadonly){val=this.cutHeaderText;}else{this.cutHeaderText=val;}
if(this.dom){this.gridHolder[val?'removeClass':'addClass']('jsgui-grid-donotcutheadertext');}},update:function(d){this.sm.clearSelections(true);if(typeof d!='undefined'){this.data.rows=d.rows;this.data.groupActions=d.groupActions;}
var data=this.data;if(data&&data.rows&&data.rows.length>0){GUI.hide(this.id+'-nodata-msg');GUI.show(this.gridHolder);var head=this.renderHeader(),body=this.renderBody();}else{var head=body='';if(!this._firstUpdate){GUI.hide(this.gridHolder);GUI.show(this.id+'-nodata-msg');}else{this._firstUpdate=false;}
this.renderHeader();}
this.gridHolder.innerHTML='<table class="x-grid">'+head+body+'</table>';this.gridEl=this.gridHolder.firstChild;this.headEl=this.gridEl.tHead;this.bodyEl=this.gridEl.tBodies[0];this.fireEvent('update',this);},switchSorting:function(col){var sorting='none';var td=this.headEl.rows[0].cells[col.domIndex];switch(col.sorting){case'asc':sorting='dsc';break;case'dsc':default:sorting='asc';break;}
this.resetSorting();col.sorting=sorting;GUI.Dom.addClass(td,'x-grid-sorting-'+sorting);this.fireEvent('sortChange',td,col.index,sorting);},setHeaderCaption:function(dataIndex,caption){var col=this.getColumnByDataIndex(dataIndex);if(col){if(col.caption!=caption){col.caption=caption;var tr=this.headEl?this.headEl.rows[0]:null;if(tr){var td=tr.cells[col.domIndex];if(td){td.getElementsByTagName('span')[0].innerHTML=caption;}}}}},getSortColumnByIndex:function(ind){var len=this.columns.length;while(len--){var col=this.columns[len];if(ind==col.index){return col;}}},setSorting:function(ind,dir){this.resetSorting();var col=this.getSortColumnByIndex(ind);if(col.sortable){col.sorting=dir;var tr=this.headEl?this.headEl.rows[0]:null;if(tr&&col.domIndex!=null){GUI.Dom.addClass(tr.cells[col.domIndex],'x-grid-sorting-'+dir);}}},resetSorting:function(){var tr=this.headEl?this.headEl.rows[0]:null;for(var h=0;h<this.visibleColumnsNum;h++){var col=this.visibleColumns[h];if(col.sortable&&(col.sorting!='none')){if(tr){GUI.Dom.removeClass(tr.cells[col.domIndex],'x-grid-sorting-'+col.sorting);}
col.sorting='none';}}},renderHeader:function(){var columns=this.data.columns,cols=new GUI.StringBuffer(),col,headers=new GUI.StringBuffer(),colsCount=columns.length,i,domIndex=0;this.visibleColumns=[];headers.append('<thead class="x-grid-head"><tr class="x-grid-row">');for(i=0;i<colsCount;i++){col=columns[i];col._index=i;col.domIndex=null;if(col.visible===false)continue;col.visible=true;this.visibleColumns[domIndex]=col;col.domIndex=domIndex++;if(col.editable&&col.editor){col.blockSelection=true;}
if(GUI.isSet(col.width)){cols.append('<col width="'+col.width+'"/>');}else{cols.append('<col/>');}
var cellCls='x-grid-cell';if(col.headerCls){cellCls+=' '+col.headerCls;}
if(typeof col.sortable=='undefined'){col.sortable=true;}
if(col.sortable){if(col.sorting=='asc'){cellCls+=' x-grid-sorting-asc';}else if(col.sorting=='dsc'){cellCls+=' x-grid-sorting-dsc';}}else{cellCls+=' not-sortable';}
var innerCls=(i+1==colsCount)?'x-grid-text-case no-brdr':'x-grid-text-case';headers.append('<td class="'+cellCls+'">');if(col.rawCaption){headers.append(col.caption+'</td>');}else if(col.sortable){headers.append('<div class="'+innerCls+'"><div class=""></div><span>'+
col.caption+'</span></div></td>');}else{headers.append('<div class="'+innerCls+'"><span>'+
col.caption+'</span></div></td>');}}
headers.append('</tr></thead>');this.visibleColumnsNum=domIndex;this.columns=columns;return cols.toString()+headers.toString();},renderBody:function(){var rows=this.data.rows,r,rowsCount=0;if(rows&&rows.length){rowsCount=rows.length;}
this.rows.each(function(row){row.destroy();});this.rows.clear();var rowConfig={grid:this,valign:this.valign,customRenderer:this.customRenderer};var gridRow=new GUI.Grid.Row(rowConfig);rowConfig.rowTemplate=gridRow.generateRowTemplate();gridRow.destroy();var rowsBuffer=new GUI.StringBuffer(),domIndex=0;rowsBuffer.append('<tbody class="x-grid-body">');for(var i=0;i<rowsCount;i++){var row=rows[i];rowConfig.id=row.id;rowConfig.index=i;rowConfig.domIndex=domIndex;rowConfig.renderer=row.renderer;gridRow=new GUI.Grid.Row(rowConfig);domIndex+=gridRow.render(rowsBuffer,row,i);this.rows.add(row.id,gridRow);}
rowsBuffer.append('</tbody>');return rowsBuffer.toString();},setColumnWidth:function(index,width){var col=this.data.columns[index];if(col&&col.visible){if(GUI.isNumber(width)){col.width=width;}else{col.width=null;}
if(this.headEl){this.gridEl.childNodes[col.domIndex].width=width;}}},getColumnWidth:function(index){var col=this.config.data.columns[index];if(col&&col.visible){if(this.headerTable){var tr=this.headerTable.firstChild.firstChild;if(tr){var td=tr.childNodes[index];return td.offsetWidth;}}}
return 0;},showHint:function(){this.hintTimer=null;if(this.hoverTr.parentNode==this.bodyEl){var div=GUI.Dom.findDescedents(this.hoverTd,'div.ovf');if(div.length){div=div[0];if(div.firstChild.offsetWidth>div.offsetWidth){this._showHint(div,div.firstChild.innerHTML);}}}else{var div=GUI.Dom.findDescedents(this.hoverTd,'div.x-grid-text-case');if(div.length){div=div[0];var span=GUI.Dom.findDescedents(div,'span');if(span.length){span=span[0];if(span.offsetWidth>div.offsetWidth){this._showHint(span,span.innerHTML);}}}}},_showHint:function(node,text){if(this.hintVisible){this.hideHint();}
if(!this.hintList){this.hintList=new GUI.Popup.Region({className:'x-region '+this.hintClass});}
this.hintList.setContent(GUI.Popup.Hint.renderHint({text:text,contentHeight:node.offsetHeight}));this.hintList.alignTo(node,'tl-tl',[this.hintOffsetX,this.hintOffsetY]);this.hintList.show();var dom=GUI.Dom.extend(this.hintList.dom);var pos=GUI.getPosition(dom);var docWidth=GUI.getViewportWidth();var hintWidth=dom.firstChild.offsetWidth;if(pos.left+hintWidth>docWidth){var newLeft=docWidth-hintWidth;this.hintList.setDimensions({left:newLeft});}
this.hintVisible=true;this.hintAssignedNode=node;dom.on('mouseleave',this.onHintMouseLeave,this);dom.on('click',this.hideHint,this);},hideHint:function(){if(this.hintVisible){this.hintList.dom.un();this.hintList.hide();this.hintVisible=false;this.hintAssignedNode=null;}},getRow:function(id){return this.rows.get(id);},getColumnByDataIndex:function(name){var len=this.columns.length,col;while(len--){col=this.columns[len];if(name==col.dataIndex){return col;};}
return false;},onClick:function(e){e=GUI.Event.extend(e);var target=e.getTarget(),td=target.findParent('td',this.gridEl,'x-grid-cell');if(td){var tr=td.parentNode;if(tr.parentNode==this.bodyEl){if(GUI.Dom.hasClass(tr,'custom')){this.fireEvent('customRowClick',this,null,e);}else{var rowId=tr.id.substring(this.id.length+5),row=this.rows.get(rowId),col=this.visibleColumns[td.cellIndex];if(col.onClick){col.onClick.call(col,this,row,td,e);}
this.fireEvent('cellClick',this,row,col,e,td);}}else{var col=this.visibleColumns[td.cellIndex];if(col.sortable){this.switchSorting(col);}
this.fireEvent('hdClick',this,col,e,td);}}},onDblClick:function(e){e=GUI.Event.extend(e);var target=e.getTarget(),td=target.findParent('td',this.gridEl,'x-grid-cell');if(td){var tr=td.parentNode;if(tr.parentNode==this.bodyEl){var rowId=tr.id.substring(this.id.length+5);if(rowId!=''){var row=this.rows.get(rowId),col=this.visibleColumns[td.cellIndex];this.fireEvent('cellDblClick',this,row,col,e,td);}else{this.fireEvent('customRowDblClick',this,null,e);}}}},onHintMouseLeave:function(){this.hideHint();},onHeadMouseOver:function(e,tr,td){if(this.hoverTd!=td){var col=this.visibleColumns[td.cellIndex];this.hoverTd=td;if(col.sortable){GUI.Dom.addClass(td,'hover');}
if(this.hintTimer){clearTimeout(this.hintTimer);this.hintTimer=null;}
this.hintTimer=setTimeout(this.showHintDelegate,this.hintDelay);}
this.hoverTr=tr;},onBodyMouseOver:function(e,tr,td){if(tr.id){var rowId=tr.id.substring(this.id.length+5);}else{var rowId='';}
if(rowId==''){if(this.hoverTr){GUI.Dom.removeClass(tr,'hover');this.hoverTr=null;}
if(this.hintTimer){clearTimeout(this.hintTimer);this.hintTimer=null;}
return;}
var
col=this.visibleColumns[td.cellIndex];if(this.hoverTr!=tr){GUI.Dom.addClass(tr,'hover');this.hoverTr=tr;}
if(this.hoverTd!=td){this.hoverTd=td;if(this.hintTimer){clearTimeout(this.hintTimer);this.hintTimer=null;}
if(col.showHint){this.hintTimer=setTimeout(this.showHintDelegate,this.hintDelay);}}
this.fireEvent('cellMouseOver',this,rowId,col,td,e);},onMouseOver:function(e){e=GUI.Event.extend(e);var target=e.getTarget(),td=target.findParent('td',this.gridEl,'x-grid-cell');if(td){var tr=td.parentNode;if(this.hoverTr&&this.hoverTr!=tr){GUI.Dom.removeClass(this.hoverTr,'hover');}
if(this.hoverTd&&this.hoverTd.parentNode&&this.hoverTd.parentNode.parentNode==this.headEl&&this.hoverTd!=td){GUI.Dom.removeClass(this.hoverTd,'hover');}
if(tr.parentNode==this.bodyEl){this.onBodyMouseOver(e,tr,td);}else if(tr.parentNode==this.headEl){this.onHeadMouseOver(e,tr,td);}}},onMouseOut:function(e){e=GUI.Event.extend(e);var target=e.target,td=target.findParent('td',this.gridEl,'x-grid-cell');if(td){var tr=td.parentNode;if(tr.id){var rowId=tr.id.substring(this.id.length+5);}else{var rowId='';}
if(tr.parentNode==this.bodyEl){if(rowId==''){}else{if(e.isMouseLeave(td)){var col=this.visibleColumns[td.cellIndex];this.fireEvent('cellMouseOut',this,rowId,col,td,e);}}}else if(tr.parentNode==this.headEl){}}},unhoverTr:function(){GUI.Dom.removeClass(this.hoverTr,'hover');this.hoverTr=null;},unhoverTd:function(){GUI.Dom.removeClass(this.hoverTd,'hover');this.hoverTd=null;},onMouseLeave:function(e){e=GUI.Event.extend(e);if(this.hintVisible){if(!e.isMouseLeave(this.hintList.dom)){return;}}
if(this.hoverTd){this.unhoverTd();}
if(this.hoverTr){this.unhoverTr();}
if(this.hintTimer){clearTimeout(this.hintTimer);this.hintTimer=null;}},onRowSelect:function(row){row.select();},onRowDeselect:function(row){row.deselect();},getMaskEl:function(){return this.gridHolder.parentNode;},setCustomRowHidden:function(val){this.customRowHidden=val;},getHolder:function(){return this.holder;}});GUI.Grid=Grid;}());

(function(){var i18n=GUI.i18n;var ActionColumn=Class.create({caption:i18n.GUI_AC_ACTION,sortable:false,align:'left',dataIndex:'actions',blockSelection:true,overflow:true,width:1,maxWidth:0,minwidth:0,imageWidth:20,lightMenu:true,rawRenderer:true,mode:'imagetext',useServerMode:true,showMenuOnHover:true,showMenuAnimation:false,showMenuDelay:400,hideMenuDelay:400,initialize:function(cfg){if(cfg){Object.extend(this,cfg);}
if(!this.id){this.id=GUI.getUniqId('x-actionbar-');}},init:function(grid){this.grid=grid;grid.addEvents({action:true});this.html=new GUI.StringBuffer();this.showMenuTask=new GUI.Utils.DelayedTask(this.showActionMenu,this);this.hideMenuTask=new GUI.Utils.DelayedTask(this.hideActionMenu,this);grid.on({scope:this,cellMouseOver:this.onGridCellMouseOver,cellMouseOut:this.onGridCellMouseOut,cellClick:this.onGridCellClick});},renderer:function(data,row,col,cell){var mode=(this.useServerMode&&data.mode)||this.mode;return this['_'+mode+'Renderer'](data,row,col,cell);},_imagetextTemplate:'<a class="x-action-{0}" href="#" hint="{1}" style="background-image:url({2});">{3}</a>',_imagetextRenderer:function(data,row,col,cell){var actions=data.items,len=actions.length,html=this.html,action;html.clear();html.append('<div class="x-actions x-actions-imagetext">');for(i=0;i<len;i++){action=actions[i];html.append('<a class="x-action-'+
action.name+(action.disabled?' disabled':'')+'" href="#" hint="'+
(action.hint||'')+'" style="background-image:url('+
(action.disabled?GUI.getDisabledImageUrl(action.img):action.img)+');">'+
action.text+'</a>');}
html.append('</div>');return html.toString();},_imageTemplate:'<a class="x-action-{0}" href="#" hint="{1}" style="background-image:url({2});"></a>',_imageRenderer:function(data,row,col,cell){var actions=data.items,len=actions.length,html=this.html,action;html.clear();html.append('<div class="x-actions x-actions-image">');for(i=0;i<len;i++){action=actions[i];html.append(this._imageTemplate.format(action.name+(action.disabled?' disabled':''),action.hint||'',(action.disabled?GUI.getDisabledImageUrl(action.img):action.img)));}
html.append('</div>');return html.toString();},_textTemplate:'<a class="x-action-{0}" href="#" hint="{1}">{2}</a>',_textRenderer:function(data,row,col,cell){var actions=data.items,len=actions.length,html=this.html,action;html.clear();html.append('<div class="x-actions x-actions-text">');for(i=0;i<len;i++){action=actions[i];html.append(this._textTemplate.format(action.name+(action.disabled?' disabled':''),action.hint||'',action.text));}
html.append('</div>');return html.toString();},_menuRenderer:function(data,row,col,cell){return'<div class="x-actions x-actions-menu"><a href="#"></a></div>';},destroy:function(){this.showMenuTask.cancel();this.hideMenuTask.cancel();this.grid.un({scope:this,cellMouseOver:this.onGridCellMouseOver,cellMouseOut:this.onGridCellMouseOut,cellClick:this.onGridCellClick});},setMode:function(mode){this.mode=mode;},showActionMenu:function(target,rowId){if(!target){return;}
var row=this.grid.rows.get(rowId),actions=row.data.actions.items;if(!this.menu){this.menu=new GUI.Popup.Menu({className:'x-grid-actions-menu',hideOnDocumentClick:true,light:this.lightMenu,animate:this.showMenuAnimation});this.menu.on({scope:this,click:this.onMenuItemClick,mouseover:this.onMenuMouseOver,mouseleave:this.onMenuMouseLeave});}
var items=[],i=actions.length;while(i--){var a=actions[i];items[i]={action:a.name,caption:a.text,img:a.img,disabled:a.disabled}}
this.menu.setItems(items);this.menu.rowId=rowId;this.menu.alignTo(target,'tr-br?');this.menu.show();},hideActionMenu:function(){if(this.menu&&this.menu.isVisible()){this.menu.hide();}},onMenuItemClick:function(menu,item){this.grid.fireEvent('action',this.grid,item.action,menu.rowId);},onGridCellClick:function(grid,row,col,event){if(col!==this)return;event.preventDefault();var target=event.getTarget();var actionBar=target.findParent('div',null,'x-actions');if(actionBar){var mode=actionBar.className.match(/x-actions-(\w+)/)[1];if(mode=='menu'){this.showMenuTask.delay(0,null,null,[target,row.id]);}else{if(!target.hasClass('disabled')){var match=target.className.match(/x-action-(\w+)/);if(match){grid.fireEvent('action',grid,match[1],row.id);}}}}},onGridCellMouseOver:function(grid,rowId,col,td,e){if((this===col)&&this.showMenuOnHover&&(this.mode=='menu')){var ac=e.target.findParent('div',td,'x-actions');if(true){this.hideMenuTask.cancel();this.showMenuTask.delay(this.showMenuDelay,null,null,[e.target,rowId]);}}},onGridCellMouseOut:function(grid,rowId,col,td,e){if((this===col)&&this.showMenuOnHover&&(this.mode=='menu')){var ac=e.target.findParent('div',td,'x-actions');if(true){this.showMenuTask.cancel();this.hideMenuTask.delay(this.hideMenuDelay);}}},onMenuMouseOver:function(menu,e){if(true){this.hideMenuTask.cancel();}},onMenuMouseLeave:function(menu,e){this.hideMenuTask.delay(this.hideMenuDelay);}});GUI.Grid.ActionColumn=ActionColumn;}());

(function()
{var EditableGrid=Class.create(GUI.Grid,{editOnClick:false,initComponent:function(){EditableGrid.superclass.initComponent.call(this);this.addEvents({beforeEdit:true,beforeApply:true,apply:true,cancel:true});if(this.editOnClick){this.on('cellClick',this.onCellClick,this);}else{this.on('cellDblClick',this.onCellClick,this);}},showEditor:function(row,col){if(col.editable&&col.editor){if(!col.editorObj){col.editorObj=new GUI.Grid.Editor({grid:this,type:col.editor,options:col.options,format:col.format});}
var value=row.data[col.dataIndex];this.fireEvent('beforeEdit',this,row,col._index,value);col.editorObj.show({node:GUI.$(row.domId).cells[col.domIndex],value:value,colIndex:col._index,row:row,editor:col.editor});}},onCellClick:function(grid,row,col,e,td){if(col.editable){this.showEditor(row,col);}}});GUI.EditableGrid=EditableGrid;}());

(function()
{var Editor=Class.create();var superproto=GUI.Popup.Region.prototype;var prototype={imgPath:window.JSGUI_IMAGES_PATH+'inlineedit/',template:'<div class="inlineedit"><div class="inlineedit-top"><div class="inlineedit-l">'+'<div class="inlineedit-r"><div class="inlineedit-c"></div></div></div></div>'+'<div class="inlineedit-mdl"><div class="inlineedit-l"><div class="inlineedit-r">'+'<div class="inlineedit-c"><div class="inlineedit-content"><table cellspacing="0"><tr>'+'<td class="input"><div id="{this.editorId}"></div><div id="tmpDivEntityDecode" style="display: none;"></div></td>'+'<td class="ico"><div>'+'<img id="{this.applyId}" src="{this.imgPath}apply.gif" alt="'+
GUI.i18n.GUI_APPLY+'" title="'+GUI.i18n.GUI_APPLY+'" width="13" height="13" />'+'<img id="{this.cancelId}" src="{this.imgPath}delete.gif" alt="'+
GUI.i18n.GUI_DELETE+'" title="'+GUI.i18n.GUI_DELETE+'" width="13" height="13" />'+'</div></td></tr></table></div></div></div></div></div>'+'<div class="inlineedit-btm"><div class="inlineedit-l"><div class="inlineedit-r">'+'<div class="inlineedit-c"></div></div></div></div></div>',initialize:function(config)
{var defCfg={grid:null,type:'text',className:'x-region x-grid-editor',options:{},format:'d/m/Y'};Object.extend(defCfg,config);superproto.initialize.call(this,defCfg);Object.extend(this.config,config);var cfg=this.config;this.editorId=GUI.getUniqId('x-grid-editor-');this.applyId=this.editorId+'-apply';this.cancelId=this.editorId+'-cancel';var tpl=new GUI.STemplate(this.template,this);this.mask=new GUI.Popup.Region();this.setContent(tpl.fetch());var modes={text:GUI.Forms.TextField,spin:GUI.Forms.SpinEdit,date:GUI.Forms.DatePicker,combo:GUI.Forms.Combo};if(modes[cfg.type]){this.editor=new modes[cfg.type]({width:'100%',css:{},options:cfg.options,format:cfg.format});}else{throw new Error("Unknow grid editor mode: ",cfg.type);}
this.applyClickListener=this.onApplyClick.bindAsEventListener(this);this.cancelClickListener=this.onCancelClick.bindAsEventListener(this);this.keyUpListener=this.onKeyUp.bindAsEventListener(this);},show:function(cfg){this.row=cfg.row;this.colIndex=cfg.colIndex;this.mask.takeDocument()
this.mask.show();this.mask.dom.style.background='white';GUI.setOpacity(this.mask.dom,0.4);var dims=GUI.getDimensions(cfg.node);if(cfg.editor=='date'&&dims.width<130){dims.width=130;}else if(dims.width<90){dims.width=90;}
dims.height=30;this.setDimensions(dims);superproto.show.call(this);this.editor.render(this.editorId);try{$('tmpDivEntityDecode').innerHTML='<textarea id="tmpTxtEntityDecode">'+cfg.value+'</textarea>';this.value=$('tmpTxtEntityDecode').value.replace(/<[^>]*>/g,'');this.editor.setValue(this.value);$('tmpDivEntityDecode').innerHTML='';}catch(e){this.value=cfg.value.replace(/<[^>]*>/g,'');;this.editor.setValue(cfg.value);}
this.alignTo(cfg.node,'l-l',GUI.isIE6?[-7,0]:[-6,1]);this.attachEventListeners();this.editor.focus();},hide:function(){this.removeEventListeners();this.editor.unrender();superproto.hide.call(this);this.mask.hide();},cleanUp:function(){this.row=null;this.colIndex=null;},attachEventListeners:function(){GUI.Event.on(this.mask.dom,'click',this.applyClickListener);GUI.Event.on($(this.applyId),'click',this.applyClickListener);GUI.Event.on($(this.cancelId),'click',this.cancelClickListener);GUI.Event.on(this.editor.dom,'keyup',this.onKeyUp,this);},removeEventListeners:function(){GUI.Event.un(this.mask.dom,'click',this.applyClickListener);GUI.Event.un($(this.applyId),'click',this.applyClickListener);GUI.Event.un($(this.cancelId),'click',this.cancelClickListener);GUI.Event.un(this.editor.dom,'keyup',this.onKeyUp,this);},onCancelClick:function(e){this.hide();var grid=this.config.grid;grid.fireEvent('cancel',grid,this.row,this.colIndex,e);this.cleanUp();},onApplyClick:function(e){var value=this.editor.getValue();if(value==this.value){return this.onCancelClick(e);}
var grid=this.config.grid;if(grid.fireEvent('beforeApply',grid,this.row,this.colIndex,value,e)!=true){return;}
this.hide();grid.fireEvent('apply',grid,this.row,this.colIndex,value,e);this.cleanUp();},onKeyUp:function(e){e=GUI.Event.extend(e);switch(e.getKey()){case e.KEY_ESC:this.onCancelClick(e);break;case e.KEY_RETURN:this.onApplyClick(e);break;default:break;}}};Object.extend(Editor.prototype,superproto);Object.extend(Editor.prototype,prototype);GUI.Grid.Editor=Editor;})();

(function()
{function getEnabledImageUrl(url){if(GUI.isString(url)){return url.replace(/^(.*)-disabled\.(jpg|gif|png|jpeg)$/i,'$1.$2');}}
var i18n=GUI.i18n;var GARenderer=Class.create({initialize:function(bar){this.bar=bar;this.grid=bar.grid;this.actions=bar;},render:function(){},update:function(){},destroy:function(){},disable:function(){},enable:function(){},disableAction:function(){console.log('Not implemented: GroupActionsBar.disableAction()');},enableAction:function(){console.log('Not implemented: GroupActionsBar.enableAction()');}});var ToolBarRenderer=Class.create(GARenderer,{initialize:function(){ToolBarRenderer.superclass.initialize.apply(this,arguments);this.id=GUI.getUniqId('x-action-');},render:function(to){var table=document.createElement('table'),tbody=document.createElement('tbody');table.className=(this.bar.disabled)?'x-actions':'x-actions disabled';table.cellspacing=0;to.appendChild(table);table.appendChild(tbody);this.table=GUI.Dom.extend(table);this.table.on('click',this.onToolbarClick,this);},update:function(){ToolBarRenderer.superclass.update.call(this);var items=this.actions.items;if(this.tr){GUI.destroyNode(this.tr);this.tr=null;}
var tr=document.createElement('tr');this.table.firstChild.appendChild(tr);this.tr=tr;for(var i=0,len=items.length;i<len;i++){var action=items[i];var td=document.createElement('td'),link=document.createElement('a');tr.appendChild(td);td.appendChild(link);link.href='#';GUI.Popup.Hint.add(link,action.text);link.id=this.id+action.name;if(action.disabled){link.className='disabled';}
switch(this.actions.mode){case'text':var span=document.createElement('span');link.appendChild(span);span.innerHTML=action.text;break;case'image':action.imgDisabled=GUI.getDisabledImageUrl(action.img);var img=document.createElement('img');img.src=(action.disabled)?action.imgDisabled:action.img;img.alt=action.text;link.appendChild(img);break;case'imagetext':action.imgDisabled=GUI.getDisabledImageUrl(action.img);var img=document.createElement('img'),span=document.createElement('span');img.src=(action.disabled)?action.imgDisabled:action.img;link.appendChild(img);link.appendChild(span);span.innerHTML=action.text;break;}}},destroy:function(){if(this.table){this.table.un('click',this.onToolbarClick,this);GUI.destroyNode(this.table);this.table=null;this.tr=null;}},onToolbarClick:function(event){event=GUI.Event.extend(event);event.stop();if(this.bar.disabled){return;}
var link=event.target.findParent('A',this.table);if(link){var name=link.id.slice(this.id.length),action=this.bar.getAction(name);if(action&&!action.disabled){var selectedRows=this.grid.sm.getSelections();this.grid.fireEvent('groupaction',this.grid,name,selectedRows);}}}});var ComboRenderer=Class.create(GARenderer,{initialize:function(){ComboRenderer.superclass.initialize.apply(this,arguments);},render:function(to){this.combo=new GUI.Forms.Combo({defaultText:GUI.i18n.GUI_SELECT,autoWidth:true,renderTo:to});this.combo.sm.on('beforeitemselect',this.onBeforeSelect,this);},update:function(){ComboRenderer.superclass.update.call(this);var items=this.actions.items;var len=items.length;var options=[];for(var i=0;i<len;i++){var action=items[i];options.push({text:action.text,value:action.name});}
var combo=this.combo;combo.clear();combo.setOptions(options);combo.doAutoWidth();if(this.bar.disabled){combo.disable();}else{combo.enable();}},destroy:function(){if(this.combo){this.combo.destroy();this.combo=null;}},onBeforeSelect:function(combo,item){this.grid.fireEvent('groupAction',this.grid,item.value,this.grid.sm.getSelections());return false;}});var MenuRenderer=Class.create(GARenderer,{initialize:function(){MenuRenderer.superclass.initialize.apply(this,arguments);},render:function(){},update:function(){MenuRenderer.superclass.update.call(this);},destroy:function(){},disable:function(){},enable:function(){}});(function()
{var GroupActionsBar=Class.create();var superproto=GUI.Utils.Observable.prototype;var prototype={initialize:function(cfg){this.items=[];if(cfg){Object.extend(this,cfg);}
this.id=GUI.getUniqId('x-action-');this._renderers={text:ToolBarRenderer,image:ToolBarRenderer,imagetext:ToolBarRenderer,combo:ComboRenderer,menu:MenuRenderer};this.disabledStack=[];this.disabled=true;if(cfg&&cfg.grid){this.setGrid(cfg.grid);}},setGrid:function(grid){this.dom=null;this.grid=grid;Object.extend(this,grid.data.groupActions);grid.addEvents({groupAction:true});grid.on('update',this.update.bind(this));grid.sm.on('selectionchange',function(sm){if(sm.getCount()>0){this.enable();}else{this.disable();}},this);},render:function(to){if(this.dom){console.log('Group actions bar already rendered!');return;}
to=GUI.$(to);if(!to){console.log('GA holder is not set:',to);return;}
var tpl='<table class="x-grid-group-actions"><tbody><tr>'+'<td class="jsgui-groupactionsbar-label">'+GUI.i18n.GUI_GROUP_ACTIONS+':</td>'+'<td class="x-grid-group-actions-holder">'+'</td></tr></tbody></table>';this.dom=GUI.Dom.append(to,tpl);GUI.Dom.extend(this.dom);this.gaHolder=this.dom.findDescedents('td.x-grid-group-actions-holder')[0];if(this.disabled){this.disabled=false;this.disable();}},update:function(){if(this.updateFromServer){var ga=this.grid.config.data.groupActions;if(ga){this.mode=ga.mode;this.items=ga.items;}else{this.items=[];}}
if(!this.dom){return;}
var rendererClass=null;if(this.mode){rendererClass=this._renderers[this.mode];}else{if(this.lastRenderer){this.lastRenderer.destroy();this.lastRenderer=null;}
return;}
if((this.lastRenderer)&&(this.lastRenderer instanceof rendererClass)){this.lastRenderer.update();}else{if(this.lastRenderer){this.lastRenderer.destroy();this.lastRenderer=null;}
if(GUI.isSet(rendererClass)){this.lastRenderer=new rendererClass(this);this.lastRenderer.render(this.gaHolder);this.lastRenderer.update();}}},destroy:function(){if(this.dom){GUI.destroyNode(this.dom);}
this.gaHolder=this.dom=null;if(this.lastRenderer){this.lastRenderer.destroy();}},disable:function(){if(this.disabled)return;this.disabled=true;var items=this.items,item,arr=[];if(items){for(var i=0,len=items.length;i<len;i++){item=items[i];if(!item.disabled){item.disabled=true;arr.push(item);}}}
this.disabledStack.push(arr);if(this.lastRenderer){this.lastRenderer.update();}},enable:function(){if(!this.disabled)return;this.disabled=false;var arr=this.disabledStack.pop();if(arr){for(var i=0,len=arr.length,item;i<len;i++){item=arr[i];if(!item.disabled){console.log('BUG? Action must be disabled');}else{item.disabled=false;}}}
if(this.lastRenderer){this.lastRenderer.update();}},getAction:function(name){var items=this.items;if(!items){return false;}
for(var i=0,len=items.length;i<len;i++){if(items[i].name==name){return items[i];}}
return false;},disableAction:function(name){var action=this.getAction(name);if(!action){return false;}
if(this.disabled){if(this.disabledStack.length){var lastDis=this.disabledStack.pop();idx=lastDis.indexOf(action);if(idx>-1){lastDis.splice(idx,1);}
this.disabledStack.push(lastDis);}}else if(!action.disabled){action.disabled=true;if(this.lastRenderer){this.lastRenderer.update();}}},enableAction:function(name){var action=this.getAction(name);if(!action){return false;}
if(this.disabled){if(this.disabledStack.length){var lastDis=this.disabledStack.pop();idx=lastDis.indexOf(action);if(idx==-1){lastDis.push(action);}
this.disabledStack.push(lastDis);}}else if(action.disabled){action.disabled=false;if(this.lastRenderer){this.lastRenderer.update();}}},setMode:function(mode){if(GUI.isString(mode)){this.updateFromServer=false;if(this.mode!=mode){this.mode=mode;this.update();}}}};Object.extend(GroupActionsBar.prototype,superproto);Object.extend(GroupActionsBar.prototype,prototype);GUI.Grid.GroupActionsBar=GroupActionsBar;}());}());

GUI.Grid.Row=Class.create({overflowCellContentTemplate:'<div class="ovf"><span class="x-grid-text" {1}>{data.{0}}</span></div>',cellContentTemplate:'<span class="x-grid-text" {1}>{data.{0}}</span>',hAligns:{left:'halign-l',center:'halign-c',right:'halign-r'},vAligns:{top:'valign-t',middle:'valign-m',bottom:'valign-b'},id:null,index:null,grid:null,valign:'middle',customRenderer:null,visible:true,selected:false,rendered:false,noSelect:false,initialize:function(cfg){if(cfg){Object.extend(this,cfg);}
this.domId=this.grid.id+'-row-'+this.id;},select:function(){if(!this.selected){GUI.addClass(this.domId,'marked');this.selected=true;}},deselect:function(){if(this.selected){GUI.removeClass(this.domId,'marked');this.selected=false;}},isSelected:function(){return this.selected;},generateRowTemplate:function(){var tpl=new GUI.StringBuffer();tpl.append('<tr id="{this.domId}" class="x-grid-row {rowCls}" >');var i,columns=this.grid.visibleColumns,len=columns.length;for(i=0;i<len;i++){var col=columns[i],cellCls='x-grid-cell';var hAlignCls=this.hAligns[col.align];if(hAlignCls){cellCls+=' '+hAlignCls;}
if(col.cellCls){cellCls+=' '+col.cellCls;}
if(col.editable){tpl.append('<td class="'+cellCls+'" hint="'+
GUI.i18n.GUI_DOUBLE_CLICK_TO_EDIT+'">');}else{tpl.append('<td class="'+cellCls+'">');}
var dataIndex=col.dataIndex;if(col.renderer)dataIndex+='_rendered';if(col.renderer&&col.rawRenderer){tpl.append('{data.'+dataIndex+'}');}else if(col.overflow){tpl.append(this.overflowCellContentTemplate.format(dataIndex,col.nowrap?' style="white-space:nowrap;"':''));}else{tpl.append(this.cellContentTemplate.format(dataIndex,col.nowrap?' style="white-space:nowrap;"':''));}
tpl.append('</td>');}
tpl.append('</tr>');return tpl.toString();},render:function(to,data,index){this.noSelect=!!data.noSelect;this.data=data.data;var rowCls='';if(index%2){rowCls+=' dark';}
var valign=data.valign||this.valign;valign=this.vAligns[valign];if(valign){rowCls+=' '+valign;}
var columns=this.grid.visibleColumns,i=columns.length,col,_data=data.data,dataIndex;var tmpNode=GUI.Dom.getFlyNode('div');while(i--){col=columns[i];if(col.renderer){dataIndex=col.dataIndex;var res=col.renderer(_data[dataIndex],this,col,tmpNode)||'';_data[dataIndex+'_rendered']=res!=null?res:'DOM';}}
var tpl=new GUI.STemplate(this.rowTemplate,this);tpl.data=this.data;tpl.rowCls=rowCls;to.append(tpl.fetch());if(data.renderer){this.customRowId=this.grid.id+'-customrow-'+this.id;to.append('<tr id="'+this.customRowId+'" class="x-grid-row custom"'+
(this.grid.customRowHidden?' style="display: none;"':'')
+'><td class="x-grid-cell" colspan="'+
this.grid.visibleColumnsNum+'">');if(this.customRenderer){var tmpNode=document.createElement('div');var res=this.customRenderer(this,columns,this.grid,tmpNode);if(res){to.append(res);}else{to.append(tmpNode.innerHTML);}}
to.append('</td></tr>');return 2;}
return 1;},update:function(data){if(!this.rendered){return false;}},destroy:function(destroyDom){this.grid=null;},show:function(){if(!this.visible){if(this.rendered){GUI.show(this.domId);}
this.visible=true;}},hide:function(){if(this.visible){if(this.rendered){GUI.hide(this.domId);}
this.visible=false;}},onClick:function(event,row){},onMouseOver:function(event,row){},onMouseOut:function(event,row){}});

GUI.Grid.RowSelectionModel=Class.create();Object.extend(Object.extend(GUI.Grid.RowSelectionModel.prototype,GUI.Utils.Observable.prototype),{initialize:function(config){GUI.Utils.Observable.prototype.initialize.call(this);this.config={singleSelect:false};Object.extend(this.config,config);this.selections=new GUI.Utils.Collection();this.last=false;this.lastActive=false;this.singleSelect=this.config.singleSelect;this.addEvents({selectionchange:true,beforerowselect:true,rowselect:true,rowdeselect:true});},init:function(grid){this.grid=grid;this.className='GUI.Grid.RowSelectionModel';this.initEvents();},initEvents:function(){this.grid.on('cellClick',function(grid,row,col,e){if(row.noSelect){return;}
var target=e.getTarget();var block=false;while(target&&(target.nodeName!='TD')){if(target.getAttribute('noselect')==true){block=true;break;}
target=target.parentNode;}
if(!(col.blockSelection||block)){if(!e.shiftKey&&!e.ctrlKey){if(row.isSelected()){this.deselectRow(row);}else{this.selectRow(row,true);}}}},this);},handleMouseDown:function(grid,row,colIndex,e){if(!GUI.isLeftClick(e)){return;};if(e.shiftKey&&this.last!==false){var last=this.last;this.selectRange(last,row,e.ctrlKey);this.last=last;}else{var isSelected=row.isSelected();if(e.ctrlKey&&isSelected){this.deselectRow(row);}else if(!isSelected||this.getCount()>1){this.selectRow(row,e.ctrlKey||e.shiftKey);}}},clearSelections:function(fast){if(fast!==true){var s=this.selections;s.each(function(row){this.deselectRow(row);},this);s.clear();}else{this.selections.clear();this.fireEvent("selectionchange",this);}
this.last=false;},getSelections:function(){return[].concat(this.selections.items);},getSelected:function(){return this.selections.itemAt(0);},getCount:function(){return this.selections.length;},selectRow:function(row,keepExisting,preventNotify){if(row.noSelect){return false;}
if(this.fireEvent("beforerowselect",this,row,keepExisting)!==false){if(!keepExisting||this.singleSelect){this.clearSelections();}
this.selections.add(row);this.last=this.lastActive=row;if(!preventNotify){this.grid.onRowSelect(row);}
this.fireEvent("rowselect",this,row);this.fireEvent("selectionchange",this);return true;}else{return false;}},selectAll:function(){this.selections.clear();var self=this;this.grid.rows.each(function(row){self.selectRow(row,true);});},selectRange:function(row1,row2,keepExisting){if(!keepExisting){this.clearSelections();}
var startRow=this.grid.rows.indexOf(row1);var endRow=this.grid.rows.indexOf(row2);if(startRow<=endRow){for(var i=startRow;i<=endRow;i++){this.selectRow(this.grid.rows.itemAt(i),true);}}else{for(var i=startRow;i>=endRow;i--){this.selectRow(this.grid.rows.itemAt(i),true);}}},deselectRow:function(row,preventNotify){if(row.noSelect){return false;}
if(this.last==row){this.last=false;}
if(this.lastActive==row){this.lastActive=false;}
if(row){this.selections.remove(row);if(!preventNotify){this.grid.onRowDeselect(row);}
this.fireEvent("rowdeselect",this,row);this.fireEvent("selectionchange",this);return true;}else{return false;}}});

GUI.Grid.CheckBoxSelectionModel=Class.create();Object.extend(Object.extend(GUI.Grid.CheckBoxSelectionModel.prototype,GUI.Grid.RowSelectionModel.prototype),{rawCaption:true,caption:'<input id="x-grid-select-all-cb" type="checkbox" />',width:23,sortable:false,align:'center',dataIndex:'checkbox',rawRenderer:true,headerCls:'checkbox',cellCls:'x-grid-sm-checkbox-cell',renderer:function(data,row,col,cell){if(!row.noSelect){var cbId=this.getCheckboxId(row.id);row.checkboxId=cbId;return'<input id="'+cbId+'" type="checkbox" class="checkbox" />';}else{return'';}},getCheckboxId:function(rowId){return this.grid.id+'-checkbox-'+rowId;},init:function(grid){GUI.Grid.RowSelectionModel.prototype.init.call(this,grid);this.className='GUI.Grid.CheckBoxSelectionModel';this.cbId=GUI.getUniqId('x-grid-select-all-cb-');this.caption='<input id="'+this.cbId+'" type="checkbox" />';grid.config.data.columns.unshift(this);},initEvents:function(){GUI.Grid.RowSelectionModel.prototype.initEvents.call(this);this.grid.on('hdClick',this.onHeaderCellClick,this);},onHeaderCellClick:function(grid,hd,e){if(hd===this&&!e.shiftKey&&!e.ctrlKey){var t=e.getTarget();if(t.nodeName=='INPUT'){if(t.checked){this.selectAll();}else{this.clearSelections();}}}},selectRow:function(row,keepExisting,preventNotify){if(GUI.Grid.RowSelectionModel.prototype.selectRow.call(this,row,keepExisting,preventNotify)){GUI.$(row.checkboxId).checked=true;if(this.selections.getCount()==this.grid.rows.getCount()){$(this.cbId).checked=true;}
return true;}else{return false;}},deselectRow:function(row,preventNotify){if(this.selections.getCount()==this.grid.rows.getCount()){$(this.cbId).checked=false;}
GUI.Grid.RowSelectionModel.prototype.deselectRow.call(this,row,preventNotify);GUI.$(row.checkboxId).checked=false;}});

(function()
{var JsonView=Class.create();var superproto=GUI.Utils.Observable.prototype;var prototype={initialize:function(config)
{this.config={id:GUI.getUniqId('x-toolbox-'),className:'x-jsonview',preTpl:'',rowTpl:'',postTpl:'',noDataTpl:'',wrapAlways:true,holder:null,rowsIndex:'rows',data:{rows:[]},visible:true,customRenderer:null,useNewTemplateEngine:false};var cfg=this.config;Object.extend(cfg,config);this.visible=cfg.visible;var tplConstructor=cfg.useNewTemplateEngine?GUI.Template:GUI.STemplate;this.noDataTpl=new tplConstructor(cfg.noDataTpl);this.preTpl=new tplConstructor(cfg.preTpl);this.rowTpl=new tplConstructor(cfg.rowTpl);this.postTpl=new tplConstructor(cfg.postTpl);this.addEvents({render:true,update:true,filterDataRow:true});superproto.initialize.call(this);},destroy:function(fast){this.unrender(fast);this.config.holder=null;},render:function(to){if(this.dom){this.unrender();}
var cfg=this.config;if(to){cfg.holder=to;}else{to=cfg.holder;}
to=$(to);var div=document.createElement('div'),innerDiv=document.createElement('div');div.className=cfg.className;if(!this.visible){GUI.hide(div);}
to.appendChild(div);div.appendChild(innerDiv);this.dom=div;this.innerEl=innerDiv;this.attachEventListeners();this.fireEvent('render',this);},unrender:function(fast){if(this.dom){this.removeEventListeners();if(!fast){GUI.destroyNode(this.dom);}
this.dom=this.innerEl=null;}},update:function(data){if(data){this.config.data=data;}else{data=this.config.data;}
if(!data[this.config.rowsIndex]){console.log('Jsonview: No rows',this,data,this.config.rowsIndex);return;}else{data.rows=data[this.config.rowsIndex];}
if(this.dom){var html=new GUI.StringBuffer();var rows=data.rows;var hasData=(rows.length>0);var wrap=hasData||this.config.wrapAlways;var newTemplate=this.config.useNewTemplateEngine;if(wrap){if(newTemplate){html.append(this.preTpl(data));}else{this.preTpl.bind(data);html.append(this.preTpl.fetch());}}
if(hasData){var renderer=this.config.customRenderer,i,len=rows.length,row;if(GUI.isFunction(renderer)){for(i=0;i<len;i++){row=rows[i];row.index=i;this.fireEvent('filterDataRow',this,row);html.append(renderer(this,row,i));}}else{for(i=0;i<len;i++){row=rows[i];row.index=i;this.fireEvent('filterDataRow',this,row);if(newTemplate){html.append(this.rowTpl(row));}else{this.rowTpl.bind(row);html.append(this.rowTpl.fetch());}}}}else{if(newTemplate){html.append(this.noDataTpl());}else{html.append(this.noDataTpl.fetch());}}
if(wrap){if(newTemplate){html.append(this.postTpl(data));}else{this.preTpl.bind(data);html.append(this.postTpl.fetch());}}
this.innerEl.innerHTML=html.toString();}
this.fireEvent('update',this,data);},show:function(){if(!this.visible){this.visible=true;if(this.dom){GUI.show(this.dom);}}},hide:function(){if(this.visible){this.visible=false;if(this.dom){GUI.hide(this.dom);}}},getHolder:function(){return this.dom;},getData:function(){return this.config.data;},attachEventListeners:function(){},removeEventListeners:function(){},clickHandler:function(e){}};Object.extend(JsonView.prototype,superproto);Object.extend(JsonView.prototype,prototype);GUI.JsonView=JsonView;}
());

GUI.Ajax={};

(function(){var observable=new GUI.Utils.Observable();observable.addEvents('invalidjson','beforerequest','requestcomplete');function _toQueryString(uri,object,prepend){switch(typeof object){case'number':case'string':case'boolean':if(prepend===''){throw new Error("At first object must be passed!");}
uri.push(prepend+'='+encodeURIComponent(object));break;case'object':if(object!==null&&object.constructor===Array){if(prepend===''){throw new Error("At first object must be passed!");}
for(var i=0,len=object.length;i<len;i++){_toQueryString(uri,object[i],prepend+'['+i+']');}}else{for(var key in object){var value=object[key];if(typeof value==='function')continue;_toQueryString(uri,value,prepend===''?key:(prepend+'['+key+']'));}}
break;}}
var isSafari=(/webkit|khtml/).test(navigator.userAgent.toLowerCase());function Request(url,options){if(typeof url==='string'){this.url=url;}else{options=url;}
if(options){this.applyOptions(options);}
this.method=this.method.toUpperCase();this.complete=false;this.data=this.data||this.postBody||this.parameters;if(typeof this.data!=='string'){this.data=this.toQueryString(this.data);}
if(this.data&&(this.method==='GET')){this.url+=((this.url.lastIndexOf('?')>-1)?"&":"?")+this.data;this.data=null;}
if(observable.fireEvent('beforeRequest',this)===false){return false;}
this.xhr=this.getTransport();if(this.username){this.xhr.open(this.method,this.url,this.async,this.username,this.password);}else{this.xhr.open(this.method,this.url,this.async);}
this.xhr.onreadystatechange=this.getBind(this.onReadyStateChange);try{this.setRequestHeaders();}catch(e){}
if(this.async&&(this.timeout>0)){this.timeoutId=setTimeout(this.getBind(this._onTimeout),this.timeout);}
try{this.xhr.send(this.data);}catch(e){}
if(!this.async){this.onReadyStateChange();}}
Request.prototype={method:'post',contentType:'application/x-www-form-urlencoded',encoding:'UTF-8',parameters:null,onComplete:null,onFailure:null,parameters:null,postBody:null,data:null,async:true,timeout:0,username:null,password:null,jsonExpected:true,complete:false,applyOptions:function(options){if(options&&typeof options=='object'){for(var property in options){this[property]=options[property];}}
return this;},getBind:function(method){var obj=this;return function(){return method.apply(obj,arguments);}},toQueryString:function(object){var uri=[];_toQueryString(uri,object,'');return uri.join('&');},abort:function(){this.xhr.onreadystatechange=this.stub;if(this.timerId){clearTimeout(this.timerId);this.timerId=null;}
this.xhr.abort();},getTransport:function(){var xhr=null,func=function(){return null;};if(window.ActiveXObject){try{xhr=new ActiveXObject('Microsoft.XMLHTTP');func=function(){return new ActiveXObject('Microsoft.XMLHTTP');};}catch(e){}}else if(window.XMLHttpRequest){xhr=new XMLHttpRequest();func=function(){return new XMLHttpRequest();};}
Request.prototype.getTransport=func;return xhr;},setRequestHeaders:function(){this.xhr.setRequestHeader('Content-Type',this.contentType+
(this.encoding?'; charset='+this.encoding:''));this.xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');this.xhr.setRequestHeader('Accept','text/javascript, text/html, application/xml, text/xml, */*');},_onTimeout:function(){if(this.xhr){this.abort();}
if(!this.complete){this.onReadyStateChange('timeout');}},onReadyStateChange:function(isTimeout){isTimeout=isTimeout=='timeout';if(this.complete||!this.xhr||((this.xhr.readyState!=4)&&(!isTimeout))){return;}
this.complete=true;var status=isTimeout&&'Timeout'||!this.isSuccessCode()&&'Failure'||'Success',handler='on'+status;if(!isTimeout&&this.timerId){clearTimeout(this.timerId);this.timerId=null;}
if(!isTimeout&&this.jsonExpected){this.responseJson=null;try{this.responseJson=this.xhr.responseText.evalJSON();}catch(e){}
if(this.responseJson==null){observable.fireEvent('invalidjson',this.xhr,this);}}
if(this[handler]){this[handler].call(this.scope,this.xhr,this);}
if(this.onComplete){this.onComplete.call(this.scope,this.xhr,this);}
observable.fireEvent('requestComplete',this);this.responseJson=null;this.xhr.onreadystatechange=this.stub;this.xhr=null;},stub:function(){},isSuccessCode:function(){try{var status=this.xhr.status;return!status&&location.protocol=="file:"||(status>=200&&status<300)||status==304||status==1223||isSafari&&status==undefined;}catch(e){}
return false;}};Request.on=observable.on.bind(observable);Request.un=observable.on.bind(observable);Request._observable=observable;if(typeof GUI==='undefined')GUI={};if(typeof GUI.Ajax==='undefined')GUI.Ajax={};GUI.Ajax.Request=Request;window.Ajax=GUI.Ajax;}());

(function(){function RequestManager(){this.requests=[];this.counter=0;var r=GUI.Ajax.Request;r.on({scope:this,beforeRequest:this.onBeforeRequest,requestComplete:this.onRequestComplete});}
RequestManager.prototype={add:function(request){this.requests[this.counter++]=request;},remove:function(request){if(this.requests.remove(request)){this.counter--;}},abortGroup:function(groupName){var i=this.counter,r;while(i--){r=this.requests[i];if(r.group==groupName){r.abort();}}},onBeforeRequest:function(request){this.add(request);},onRequestComplete:function(request){this.remove(request);}};if(typeof GUI==='undefined')GUI={};if(typeof GUI.Ajax==='undefined')GUI.Ajax={};GUI.Ajax.RequestsManager=new RequestManager();}());

(function()
{var Paging=Class.create();var superproto=GUI.Utils.Observable.prototype;var i18n=GUI.i18n;var prototype={initialize:function(config){superproto.initialize.call(this,config);this.config={holder:false,url:false,method:'post',baseParams:{},params:{},rowsPerPage:10,rendererObj:false,allowMask:true,root:null,disabled:false,maskText:i18n.GUI_LOADING,prevText:i18n.GUI_PAGING_PREV,nextText:i18n.GUI_PAGING_NEXT,comboTpl:i18n.GUI_PAGING_TPL,cls:'x-paging',align:'right'};var cfg=this.config;Object.extend(cfg,config);this.addEvents({load:true,fail:true,render:true,pageSizeChange:true});cfg.rowsPerPage=parseInt(cfg.rowsPerPage,10);this.start=0;this.total=0;this.data={};this.lastParams={};this.response='';this.mask=new GUI.Popup.Mask({text:this.config.maskText});this.disabled=cfg.disabled;this.toolbar=new GUI.ToolBar({position:'horizontal',align:cfg.align,className:cfg.cls,elements:[{name:'prevBtn',obj:new GUI.Ajax.Paging.Button({caption:cfg.prevText,onClick:this.onPrevClick.bind(this)})},{name:'combo',obj:new GUI.Forms.Combo({autoWidth:true,onChange:function(combo,key){this.loadPage(key);}.bind(this)})},{name:'nextBtn',obj:new GUI.Ajax.Paging.Button({caption:cfg.nextText,onClick:this.onNextClick.bind(this)})}]});var grid=cfg.rendererObj;if(grid){grid.on('sortChange',this.onSortChange,this);}},onSortChange:function(obj,index,sort){this.config.baseParams.sortingIndex=index;this.config.baseParams.sortingDirection=sort;this.load({});},destroy:function(quick){if(this._request&&!this._request.complete){this._request.abort();this._request=null;}
this.purgeListeners();if(this.mask){this.mask.destroy();this.mask=null;}
if(this.toolbar){this.toolbar.destroy(quick);this.toolbar=null;}
if(this.config.rendererObj){this.config.rendererObj.un('sortChange',this.onSortChange,this);this.config.rendererObj=null;}
this.config.holder=null;},render:function(holder){var cfg=this.config;if(GUI.isSet(holder)){cfg.holder=holder;}
this.update();this.toolbar.render(cfg.holder);},update:function(){var cfg=this.config,combo=this.toolbar.getElement('combo');cfg.rowsPerPage=parseInt(cfg.rowsPerPage,10);this.total=parseInt(this.total,10);combo.clear();var i,recNum,start=0,to=this.start-2*cfg.rowsPerPage+1,step=Math.ceil((to-start)/(5*cfg.rowsPerPage))*cfg.rowsPerPage;if(step<cfg.rowsPerPage){step=cfg.rowsPerPage;}
if(to>this.total){to=this.total;}
for(i=start;i<to;i+=step){recNum=i+1;combo.add({text:recNum+'-'+
((i+cfg.rowsPerPage<this.total)?(i+cfg.rowsPerPage):this.total)
+' of '+this.total,value:recNum});}
start=this.start-cfg.rowsPerPage;if(start<0){start=0;}
to=this.start+cfg.rowsPerPage+1;if(to>this.total){to=this.total;}
for(i=start;i<to;i+=cfg.rowsPerPage){recNum=i+1;combo.add({text:recNum+'-'+
((i+cfg.rowsPerPage<this.total)?(i+cfg.rowsPerPage):this.total)
+' of '+this.total,value:recNum});}
start=this.start+2*cfg.rowsPerPage;to=(this.total-this.total%cfg.rowsPerPage)-cfg.rowsPerPage;step=Math.ceil((to-start-1)/(5*cfg.rowsPerPage))*cfg.rowsPerPage;if(step<cfg.rowsPerPage){step=cfg.rowsPerPage;}
for(var i=start;i<=to;i+=step){recNum=i+1;combo.add({text:recNum+'-'+
((i+cfg.rowsPerPage<this.total)?(i+cfg.rowsPerPage):this.total)
+' of '+this.total,value:recNum});}
start=Math.floor(this.total/cfg.rowsPerPage)*cfg.rowsPerPage;if(start<this.total&&this.start<=start-2*cfg.rowsPerPage){combo.add({text:(start+1)+'-'+(this.total)+' of '+this.total,value:start+1});}
combo.doAutoWidth();if(this.start<this.total){combo.setValue(this.start+1,true);}
if(this.total>this.config.rowsPerPage){combo.enable();}else{if(combo.isEnabled()){combo.disable();}}
var prevBtn=this.toolbar.getElement('prevBtn');var nextBtn=this.toolbar.getElement('nextBtn');if(this.start<cfg.rowsPerPage){if(prevBtn.isEnabled()){prevBtn.disable();}}else{prevBtn.enable();}
if(this.start>=(this.total-cfg.rowsPerPage)){if(nextBtn.isEnabled()){nextBtn.disable();}}else{nextBtn.enable();}},disable:function(){if(this.disabled)return;this.toolbar.disable();this.disabled=true;},enable:function(){if(!this.disabled)return;this.toolbar.enable();this.disabled=false;},load:function(config){Object.extend(this.config,config);var params=Object.clone(this.config.baseParams);Object.extend(params,{start:this.start,limit:this.config.rowsPerPage});Object.extend(params,this.config.params);this.lastParams=config;this.config.params={};this.params=params;if(this.config.allowMask){var obj=this.config.rendererObj;if(GUI.isFunction(obj.mask)){obj.mask();}else{this.mask.setElement((obj.getMaskEl||obj.getHolder).call(obj));this.mask.show();}
this._load();}else{this._load();}},_load:function(){var self=this;var params=this.params;if(this._request&&!this._request.complete){this._request.abort();}
this._request=new Ajax.Request(self.config.url,{method:self.config.method,parameters:GUI.toQueryString(params),scope:this,onSuccess:this.onLoadSuccess,onFailure:this.onLoadFailure});},onLoadSuccess:function(response,request){this.response=response.responseText;this.data=request.responseJson;if(!this.data){return this.onLoadFailure(response);}
this.fireEvent('load',this,this.response,this.data);if(this.config.rendererObj){if(this.data){this.start=parseInt(this.data.start,10);this.total=parseInt(this.data.total,10);}
if(isNaN(this.start)){this.start=0;}
if(isNaN(this.total)){this.total=0;}
var data=this.data;if(this.config.root){data=this.data[root];}
var rendererObj=this.config.rendererObj;this.update();rendererObj.update(data);if(this.data.sortingIndex&&GUI.isFunction(rendererObj.setSorting)){var baseParams=this.config.baseParams;var ind=this.data.sortingIndex;var dir=this.data.sortingDirection;baseParams.sortingIndex=ind;baseParams.sortingDirection=dir;rendererObj.setSorting(ind,dir);}
if(this.config.allowMask){if(GUI.isFunction(this.config.rendererObj.mask)){this.config.rendererObj.unmask();}else{this.mask.hide();}}}},onLoadFailure:function(transport){if(this.config.allowMask){if(GUI.isFunction(this.config.rendererObj.mask)){this.config.rendererObj.unmask();}else{this.mask.hide();}}
this.fireEvent('fail',this,transport,false);this.update();},loadPage:function(number){this.load({params:{start:parseInt(number,10)-1}});},refresh:function(){this.load(this.lastParams);},onPrevClick:function(btn){if(this.start<this.config.rowsPerPage){if(btn.isEnabled()){}}else{this.load({params:{start:this.start-this.config.rowsPerPage}});}},onNextClick:function(btn){if(this.start>=(this.total-this.config.rowsPerPage)){if(btn.isEnabled()){}}else{this.load({params:{start:this.start+this.config.rowsPerPage}});}},getPageSize:function(){return this.config.rowsPerPage;},setPageSize:function(size){if(typeof size!='number'){return false;}
var oldSize=this.config.rowsPerPage;this.config.rowsPerPage=size;var remainder=this.start%size;if(remainder!==0){if((remainder*2>=size)&&((this.start+size-remainder)<this.total)){this.start+=size-remainder;}else{this.start-=remainder;}
this.start=this.start.constrain(0);}
this.fireEvent('pageSizeChange',this,size,oldSize);}};Object.extend(Paging.prototype,superproto);Object.extend(Paging.prototype,prototype);GUI.Ajax.Paging=Paging;}());

(function()
{var PagingButton=Class.create();var superproto=GUI.ToolBar.SimpleButton.prototype;var prototype={initialize:function(config){superproto.initialize.call(this,config);var cfg=this.config;Object.extend(cfg,{id:GUI.getUniqId('x-pagingbutton-'),name:null,caption:null,hint:null,disabled:false,className:'paging-button'});Object.extend(cfg,config);},render:function(to){if(this.dom){this.unrender();}
var cfg=this.config;var span=document.createElement('div');span.className=(this.disabled)?cfg.className+' disabled':cfg.className;to.appendChild(span);if(GUI.isString(cfg.caption)&&cfg.caption.length){var link=document.createElement('A');link.href='#';span.appendChild(link);var innerSpan=document.createElement('span');link.appendChild(innerSpan);innerSpan.innerHTML=cfg.caption;}else{throw new Error("SimpleButton must have caption set!");}
this.dom=GUI.Dom.extend(span);GUI.unselectable(this.dom);this.attachEventListeners();}};Object.extend(PagingButton.prototype,superproto);Object.extend(PagingButton.prototype,prototype);GUI.Ajax.Paging.Button=PagingButton;}());

(function()
{var Tree=Class.create();var superproto=GUI.Utils.Draggable.prototype;var prototype={nodeHashLength:0,initialize:function(config)
{var defCfg={dataUrl:null,method:'post',checkBox:false,inlineEdit:false,enableDd:false,alwaysExpanded:false,root:null,rootVisible:true,expandButton:false,collapseButton:false,checkParentIfChildsChecked:false,allowDisabledCheckbox:false,allowDisabledNodeSelection:false,css:{tree:'jsgui-tree',node:'jsgui-tree-node'},hintClass:'x-combotree-hint',hintOffset:[-7,2],dd:{linkedElId:null,dragElId:null,handleElId:null,targetElId:null,isTarget:true,moveOnly:false,groups:{'tree':true},clipElId:null,enableDrag:false,dropReciever:false,dragType:''},scrollable:true};Object.extend(defCfg,config);superproto.initialize.call(this,defCfg);var cfg=this.config;Object.extend(cfg,defCfg);var id=this.getId();this.contentId=id+'-content';this.hintVisible=false;this.hintAssignedNode=null;this.addEvents({beforeappend:true,append:true,beforeremove:true,remove:true,beforeinsert:true,insert:true,beforemove:true,move:true,nodemouseover:true,nodebeforemouseout:true,nodemouseout:true,nodeclick:true,nodedblclick:true,nodeDragOver:true,select:true,checkedchange:true,beforeChangeText:true,changeText:true,editingCanceled:true,beforenodeload:true,nodeLoad:true,nodeLoadFailed:true,nodeexpand:true,nodecollapse:true});this.nodeHash={};this.checkedNodes=new GUI.Utils.Collection();this.selectedNode=null;if(cfg.root){if(!(cfg.root instanceof GUI.Tree.Node)){cfg.root=new GUI.Tree.Node(cfg.root);}
this.setRootNode(cfg.root);}
this.plugins=cfg.plugins;if(this.plugins){if(GUI.isArray(this.plugins)){for(var i=0,len=this.plugins.length;i<len;i++){this.plugins[i].init(this);}}else{this.plugins.init(this);}}
GUI.ComponentMgr.register(this);},enableDD:function(){superproto.enableDD.call(this);this.config.enableDd=true;},disableDD:function(){superproto.disableDD.call(this);this.config.enableDd=false;},getId:function(){return this.config.id||(this.config.id="jsgui-cmp-"+(++GUI.Component.AUTO_ID));},isEditable:function(){return this.config.inlineEdit;},_getHtml:function(){var styles=[],classes=[this.config.css.tree],containerClasses=['jsgui-tree-container'];if(!this.isRootVisible()){containerClasses.push('jsgui-tree-hiddenroot');}
if(this.config.noPath){containerClasses.push('jsgui-tree-nopath');}
classes=classes.join(' ');containerClasses=containerClasses.join(' ');var html='<div id="'+this.config.id+'" class="'+classes+'" style="'+styles.join(';')+'">'+'<table width="100%" cellspacing="0"><tbody><tr><td style="vertical-align: top;">'+'<ul id="'+this.contentId+'" class="'+containerClasses+'">'+'</ul>'+'</td></tr></tbody></table>'+'</div>';return html;},render:function(to){if(this.rendered){this.unrender();}
var cfg=this.config;if(to){cfg.holder=to;}else{to=cfg.holder;}
to=GUI.$(to);if(!to){return false;}
this.dom=GUI.Dom.extend(GUI.Dom.append(to,this._getHtml()));this.contentEl=GUI.$(this.contentId);this.rendered=true;this.setDimensions(cfg.width,cfg.height);var s=this.dom.style;if(cfg.scrollable){s.overflow='auto';}else{s.overflow='hidden';}
this.attachEventListeners();if(this.root){this.root.render(this.contentId);}
GUI.unselectable(this.dom);this.ddConfig.linkedElId=this.contentId;this.ddConfig.targetElId=this.contentId;this.ddConfig.clipElId=cfg.id;this.initDD();},setWidth:function(w){this.setDimensions(w,undefined);},setHeight:function(h){this.setDimensions(undefined,h);},getHeight:function(){if(this.rendered&&!GUI.isNumber(this.config.height)){return this.dom.offsetHeight;}
return this.config.height;},getClientWidth:function(){return this.rendered?this.dom.clientWidth:0;},getScrollLeft:function(){return this.rendered?this.dom.scrollLeft:0;},getScrollHeight:function(){return this.rendered?this.contentEl.offsetHeight:this.config.height;},setMaxHeight:function(h){this.maxHeight=h;if(this.rendered){this.dom.style.maxHeight=h+'px';}},setDimensions:function(w,h){var s=this.dom?this.dom.style:null;if(GUI.isSet(w)){this.config.width=w;if(s){s.width=GUI.isNumber(w)?(w>0?w:0)+'px':w;}}
if(GUI.isSet(h)){this.config.height=h;if(s){s.height=GUI.isNumber(h)?(h>0?h:0)+'px':h;}}
this.fireEvent('resize',w,h);},unrender:function(){if(this.rendered){if(this.root){this.root.unrender(true);}
this.destroyDD();this.removeEventListeners();GUI.destroyNode(this.dom);this.dom=null;this.rendered=false;}},destroy:function(quick){this.purgeListeners();if(this.inlineEditor){this.inlineEditor.destroy();this.inlineEditor=null;}
if(this.root){this.root.destroy(true);this.root=null;}
if(this.rendered){this.destroyDD();this.removeEventListeners();if(!quick){GUI.destroyNode(this.dom);}
this.dom=null;this.contentEl=null;this.lineRegion=null;}
this.config.holder=null;this.nodeHash=null;GUI.ComponentMgr.unregister(this);},expandAll:function(){this.root.expand(true);},collapseAll:function(){this.root.collapse(true);},getContainer:function(){if(this.dom){return GUI.$(this.contentId);}
return null;},setRootNode:function(node){this.root=node;node.isRoot=true;this.registerNode(node);node.setOwnerTree(this);},registerNode:function(node){this.nodeHash[node.id]=node;},unregisterNode:function(node){this.unselectNode(node);this.removeFromChecked(node);delete this.nodeHash[node.id];},getNodeById:function(id){return this.nodeHash[id];},getNodesCount:function(){var i=0,id;for(id in this.nodeHash){i++;}
return i;},showHint:function(treeNode){if(this.hintVisible){if(this.hintAssignedNode==treeNode){return;}
this.hideHint();}
if(!this.hintList){this.hintList=new GUI.Popup.Region({className:'x-region '+this.config.hintClass});}
this.hintList.setContent(GUI.Popup.Hint.renderHint({text:treeNode.config.text}));var node=GUI.$(treeNode.textId);this.hintList.alignTo(node,'l-l',this.config.hintOffset);this.hintList.show();this.hintVisible=true;this.hintAssignedNode=treeNode;var dom=GUI.Dom.extend(this.hintList.dom);dom.on('mousedown',this.onHintMouseDown,this);dom.on('click',this.onHintClick,this);dom.on('mouseout',this.onHintMouseOut,this);treeNode.setOuterHandleElId(this.hintList.config.id);},onHintMouseDown:function(e){e=GUI.Event.extend(e);e.stopPropagation();},onHintClick:function(e){e=GUI.Event.extend(e);this.selectNode(this.hintAssignedNode);this.hintAssignedNode.onClick(e);this.ignoreNextMouseOver=true;this.hideHint();},onHintDblClick:function(e){e=GUI.cloneEvent(e);e.target=GUI.$(this.hintAssignedNode.textId);e=GUI.Event.extend(e);this.hintAssignedNode.onDblClick(e);this.hideHint();},onHintMouseOut:function(e){e=GUI.Event.extend(e);if(e.isMouseLeave(this.hintList.dom)){if(this.hintAssignedNode.onMouseOut(e)!==false){this.hideHint();}}},hideHint:function(){if(this.hintVisible){this.hintAssignedNode.unsetOuterHandleElId(this.hintList.config.id);var dom=this.hintList.dom;dom.un();this.hintList.hide();this.hintVisible=false;this.hintAssignedNode=null;}},setInlineEdit:function(val){val=GUI.isSet(val)?val:true;if(this.config.inlineEdit!=val){this.config.inlineEdit=val;if(val){this.root.cascade(function(node){node.setHint(GUI.i18n.GUI_DOUBLE_CLICK_TO_EDIT);});}else{this.root.cascade(function(node){node.setHint('');});}}},showEditor:function(node){if(!node.config.readOnly){GUI.scrollIntoView(this.dom,GUI.$(node.textId));if(!this.inlineEditor){this.inlineEditor=new GUI.Inline({width:170,autoApply:false});this.inlineEditor.on('apply',this.onEditorApply,this);this.inlineEditor.on('cancel',this.onEditorCancel,this);}
this.inlineEditor.show(node);}},isRootVisible:function(){return this.config.rootVisible;},selectNode:function(node,silent){if(GUI.isString(node)||GUI.isNumber(node)){node=this.getNodeById(node);}
if(!node){return;}
if(this.selectedNode!=node){if(this.selectedNode){this.unselectNode(this.selectedNode);}
this.selectedNode=node;if(node.parentNode){node.parentNode.bubble(function(){if(this.expanded){return false;}else{this.expand(false,true);}});}
node.onSelect();if(!silent){this.fireEvent('select',this,node);}}},unselectNode:function(node){node=node||this.selectedNode;if(node&&(this.selectedNode==node)){node.onUnselect();this.selectedNode=null;}},getSelectedNode:function(){return this.selectedNode;},addToChecked:function(node){this.checkedNodes.add(node);},removeFromChecked:function(node){this.checkedNodes.remove(node);},getCheckedNodes:function(ignoreDisabled){var res=[];if(ignoreDisabled){var i=0;this.checkedNodes.each(function(item){if(!item.disabled){res[i++]=item;}});}else{res=res.concat(this.checkedNodes.items);}
return res;},clearChecked:function(ignoreDisabled){var checked=this.getCheckedNodes(ignoreDisabled),i=checked.length;while(i--){checked[i].setChecked(false);}},attachEventListeners:function(){var dom=GUI.Dom.extend(this.dom.firstChild);dom.on('click',this.onClick,this);dom.on('dblclick',this.onDblClick,this);dom.on('mouseover',this.onMouseOver,this);dom.on('mouseout',this.onMouseOut,this);},removeEventListeners:function(){var dom=GUI.Dom.extend(this.dom.firstChild);dom.un('click',this.onClick,this);dom.un('dblclick',this.onDblClick,this);dom.un('mouseover',this.onMouseOver,this);dom.un('mouseout',this.onMouseOut,this);},getNode:function(e){var elem=e.target.findParent('li',this.contentEl,'jsgui-tree-node');if(elem){var match=elem.id.match(/^jsgui-tree-node-(.*)$/);if(match){return this.getNodeById(match[1]);}}
return null;},getScroll:function(){if(this.dom){var scrollDiv=this.dom.firstChild;return[scrollDiv.scrollLeft,scrollDiv.scrollTop];}},onClick:function(e){e=GUI.Event.extend(e);var node=this.getNode(e);if(!node){return;}
var target=e.target,nodeName=target.nodeName;if(nodeName=='INPUT'&&target.type=='checkbox'){this.onCheckBoxClick(node,e);}else if(nodeName=='IMG'){if((' '+target.className).indexOf(' jsgui-tree-node-expicon-')!=-1){node.onExpandIconClick(e);}else{if(target.hasClass('jsgui-tree-node-icon')){node.onIconClick(e);}
if(!node.disabled||this.config.allowDisabledNodeSelection){this.selectNode(node);}}}else if(nodeName=='A'&&target.id=='jsgui-tree-expand-all'){this.expandAll();}else if(nodeName=='A'&&target.id=='jsgui-tree-collapse-all'){this.collapseAll();}
else{if(!node.disabled||this.config.allowDisabledNodeSelection){this.selectNode(node);}}
node.onClick(e);},onCheckNode:function(node,checked){if(checked){this.addToChecked(node);}else{this.removeFromChecked(node);}
this.fireEvent('checkedchange',this,node);},onCheckBoxClick:function(node,e){if(node.disabled){return;}
var checked=GUI.$(node.checkBoxId).checked;if(checked){this.addToChecked(node);}else{this.removeFromChecked(node);}
node.setChecked(checked);if(node.parentNode&&!this.config.freeCheckbox){if(!checked){node.parentNode.bubble(function(){if(this.checked){this.setChecked(false,false,true);}else{return false;}});}else if(this.config.checkParentIfChildsChecked){node.parentNode.bubble(function(){var allChecked=true;for(var i=0,len=this.childNodes.length;i<len;i++){if(!this.childNodes[i].checked){allChecked=false;break;}}
if(!this.checked){this.setChecked(true,false,true);}else{return false;}});}}},onDblClick:function(e){e=GUI.Event.extend(e);if(e.target.nodeName=='A'){var node=this.getNode(e);if(node){node.onDblClick(e);}}},onEditorApply:function(editor,node,text){GUI.assert(node!=null,'Strange bug. Applying tree node editing changes, but node is null');var oldText=node.getText();if(false!==this.fireEvent('beforeChangeText',this,node,text,oldText)){node.setText(text);if(this.plugins){if(GUI.isArray(this.plugins)){for(var i=0,len=this.plugins.length;i<len;i++){if(GUI.isSet(this.plugins[i].actionClassPrefix)&&this.plugins[i].actionClassPrefix=='x-tree-action-name-')this.plugins.showActions('selected',node);}}else{this.plugins.showActions('selected',node);}}
this.fireEvent('changeText',this,node,text,oldText);}},onEditorCancel:function(editor,node){this.fireEvent('editingCanceled',this,node);},onMouseOver:function(e){e=GUI.Event.extend(e);if(this.DDM.dragObj){return;}
if(this.ignoreNextMouseOver){this.ignoreNextMouseOver=false;return;}
var node=this.getNode(e);if(node){this.hoverNode=node;node.onMouseOver(e);this.fireEvent('nodeMouseOver',this,node,e);}},onMouseOut:function(e){e=GUI.Event.extend(e);var node=this.getNode(e);if(node){node.onMouseOut(e);}},getLineRegion:function(){if(!this.lineRegion){this.lineRegion=new GUI.Popup.Region({content:'<div style="border-top: 1px solid #A4ACB1;"></div>',dimensions:{height:'1px'}});}
return this.lineRegion;},onDragEnter:function(e,dragObj){var p=GUI.getPosition(this.dom,true);this.getLineRegion().setDimensions({width:this.dom.offsetWidth,left:p.left});},onDragOver:function(e,dragObj,pt){if(!this.config.canDropForeignNode){if(dragObj.getOwnerTree&&dragObj.getOwnerTree()!=this){return false;}}},onNodeDragOver:function(e,dragObj,pt,node){return this.fireEvent('nodeDragOver',this,node,dragObj,e,pt);},onDragLeave:function(e,dragObj){if(this.lineRegion){this.lineRegion.hide();}},onDragDrop:function(e,dragObj){if(this.lineRegion){this.lineRegion.hide();}}};Object.extend(Tree.prototype,superproto);Object.extend(Tree.prototype,prototype);GUI.Tree=Tree;})();

(function()
{var Node=Class.create();var superproto=GUI.Utils.Draggable.prototype;var prototype={expandIconClass:'x-tree-expand-icon',imgTemplateS:'<img class="{0}" src="'+GUI.emptyImageUrl+'" alt="" />',parentNode:null,firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,initialize:function(config)
{var defCfg={text:'',disabled:false,editable:true,expanded:false,checked:false,checkBox:false,async:false,isDir:true,readOnly:false,child:[],images:{minus:'x-tree-ico-minus',minusUp:'x-tree-ico-minusup',minusBottom:'x-tree-ico-minusbottom',plus:'x-tree-ico-plusjoin',plusUp:'x-tree-ico-plusup',plusBottom:'x-tree-ico-plus',line:'x-tree-ico-join',lineBottom:'x-tree-ico-joinbottom',lineVertical:'x-tree-ico-line',folderOpen:'x-tree-ico-folderopen',folderClose:'x-tree-ico-folderclosed',file:'x-tree-ico-page',loader:'ajax-loader',dropNo:'x-tree-ico-drop-no',dropBetween:'x-tree-ico-drop-between',dropIn:'x-tree-ico-drop-in',error:'x-tree-ico-error'},dd:{linkedElId:null,dragElId:null,handleElId:null,targetElId:null,isTarget:true,moveOnly:false,groups:{'tree':true},clipElId:null,enableDrag:true,dropReciever:false,dragType:''},animate:window.GUI_FX_ANIMATION==true};Object.extend(defCfg,config);superproto.initialize.call(this,defCfg);var cfg=this.config;Object.extend(cfg,defCfg);if(typeof cfg.id=='undefined'){cfg.id=GUI.getUniqId('autogenerated-');}
this.childNodes=[];this.dom=null;this.id=cfg.id;cfg.id=GUI.getUniqId('x-node')+'-id'+this.id;this.leaf=!cfg.isDir;this.elId=cfg.id+'-el';this.indentId=cfg.id+'-indent';this.expIconId=cfg.id+'-exp-icon';this.iconId=cfg.id+'-icon';this.checkBoxId=cfg.id+'-checkbox';this.textId=cfg.id+'-text';this.containerId=cfg.id+'-container';this.wrapId=cfg.id+'-container-wrap';this.dpDropImgId=cfg.id+'-dragproxy-img';this.disabled=cfg.disabled;this.editable=cfg.editable;this.rendered=this.childrenRendered=false;this.expanded=cfg.expanded==true;this.checked=cfg.checked==true;this.addEvents({});if(GUI.isArray(cfg.child)){var i,ch,len=cfg.child.length;for(var i=0;i<len;i++){ch=new Node(cfg.child[i]);this.appendChild(ch);}}else{cfg.async=true;}
this.loaded=!cfg.async||this.leaf;},initAnimator:function(){if(!this.fx){this.fx=new Animator({duration:500,scope:this,onComplete:this.onAnimationComplete});}},onAnimationComplete:function(fx){if(fx.state){this._expand();}else{this._collapse();}},appendChild:function(node){if(this.lastChild==node){return;}
var ownerTree=this.getOwnerTree();if(ownerTree){if(false===ownerTree.fireEvent('beforeappend',ownerTree,this,node)){return false;}}
var index=this.childNodes.length,oldParent=node.parentNode,oldIndex=0;if(oldParent){oldIndex=node.getIndex();var nodeOwnerTree=node.getOwnerTree();if(nodeOwnerTree){if(false===nodeOwnerTree.fireEvent('beforemove',nodeOwnerTree,node,oldParent,oldIndex,this,index)){return false;}}
oldParent.removeChild(node);}
index=this.childNodes.length;if(index==0){this.firstChild=node;}
this.childNodes[index]=node;node.parentNode=this;var ps=this.childNodes[index-1];if(ps){node.previousSibling=ps;ps.nextSibling=node;}else{node.previousSibling=null;}
node.nextSibling=null;this.lastChild=node;node.setOwnerTree(ownerTree);if(this.childrenRendered){if(!node.rendered){node.render();}
this.updateIcons(true);}
else if(node.parentNode.rendered){if(node&&node.parentNode.rendered)this.updateIcons(true);}
if(ownerTree){ownerTree.fireEvent('append',ownerTree,this,node,index);if(oldParent){ownerTree.fireEvent('move',ownerTree,node,oldParent,oldIndex,this,index);}}
return node;},removeChild:function(node){var index=this.childNodes.indexOf(node);if(index==-1){return false;}
var nodeOwnerTree=node.getOwnerTree();if(nodeOwnerTree){if(false===nodeOwnerTree.fireEvent('beforeremove',nodeOwnerTree,this,node)){return false;}}
this.childIndent=null;this.childNodes.splice(index,1);if(node.previousSibling){node.previousSibling.nextSibling=node.nextSibling;}
if(node.nextSibling){node.nextSibling.previousSibling=node.previousSibling;}
if(this.firstChild==node){this.firstChild=node.nextSibling;}
if(this.lastChild==node){this.lastChild=node.previousSibling;}
node.setOwnerTree(null);node.parentNode=null;node.previousSibling=null;node.nextSibling=null;if(node.rendered){node.unrender();}
if(this.childrenRendered){this.updateIcons(true);}
var ownerTree=this.getOwnerTree();if(ownerTree){ownerTree.fireEvent('remove',ownerTree,this,node);}
return node;},remove:function(){if(this.parentNode){return this.parentNode.removeChild(this);}
return false;},insertBefore:function(node,refNode){if(!refNode){return this.appendChild(node);}
if(node==refNode){return false;}
var ownerTree=this.getOwnerTree();if(ownerTree){if(false===ownerTree.fireEvent('beforeinsert',ownerTree,this,node,refNode)){return false;}}
var index=this.childNodes.indexOf(refNode),oldParent=node.parentNode,refIndex=index;if(oldParent==this&&this.childNodes.indexOf(node)<index){refIndex--;}
var oldIndex=0;if(oldParent){oldIndex=node.getIndex();var nodeOwnerTree=node.getOwnerTree();if(nodeOwnerTree){if(false===nodeOwnerTree.fireEvent('beforemove',nodeOwnerTree,node,oldParent,oldIndex,this,index)){return false;}}
oldParent.removeChild(node);}
if(refIndex==0){this.firstChild=node;}
this.childNodes.splice(refIndex,0,node);node.parentNode=this;var ps=this.childNodes[refIndex-1];if(ps){node.previousSibling=ps;ps.nextSibling=node;}else{node.previousSibling=null;}
node.nextSibling=refNode;refNode.previousSibling=node;node.setOwnerTree(this.getOwnerTree());if(this.childrenRendered){if(!node.rendered){node.render();}
this.updateIcons(true);this.renderIndent(true);}
if(ownerTree){ownerTree.fireEvent('insert',ownerTree,this,node,index,refNode);if(oldParent){ownerTree.fireEvent('move',ownerTree,node,oldParent,oldIndex,this,refIndex);}}
return node;},getOwnerTree:function(){return this.ownerTree;},setOwnerTree:function(tree){if(tree!=this.ownerTree){if(this.ownerTree){if(this.config.checkBox){this.setChecked(false);}
this.ownerTree.unregisterNode(this);}
this.ownerTree=tree;if(tree){this.config.checkBox=tree.config.checkBox;}
var cs=this.childNodes;for(var i=0,len=cs.length;i<len;i++){cs[i].setOwnerTree(tree);}
if(tree){tree.registerNode(this);}}},getDepth:function(){var depth=0,p=this;while(p.parentNode){++depth;p=p.parentNode;}
return depth;},getIndex:function(){if(this.parentNode){return this.parentNode.childNodes.indexOf(this);}
return 0;},isLeaf:function(){return this.leaf===true&&this.childNodes.length==0;},isFirst:function(){return!this.parentNode?true:this.parentNode.firstChild==this;},isLast:function(){return(!this.parentNode?true:this.parentNode.lastChild==this);},isRootChild:function(){return this.parentNode&&this.parentNode.isRoot;},hasChildNodes:function(){return((!this.isLeaf())&&(this.childNodes.length>0))||!this.loaded;},getNumberOfDescedents:function(){var count=0;this.cascade(function(){count++;});return count;},contains:function(node){return node.isAncestor(this);},isAncestor:function(node){var p=this.parentNode;while(p){if(p==node){return true;}
p=p.parentNode;}
return false;},bubble:function(fn,scope,args){var p=this;while(p){if(fn.apply(scope||p,args||[p])===false){break;}
p=p.parentNode;}},cascade:function(fn,scope,args){if(fn.apply(scope||this,args||[this])!==false){var cs=this.childNodes;for(var i=0,len=cs.length;i<len;i++){cs[i].cascade(fn,scope,args);}}},getPath:function(){var p=[];this.bubble(function(node){p.push({id:node.id,text:node.config.text});});return p;},getPathString:function(includeRoot){var p=[];this.bubble(function(node){if(node.isRoot&&!includeRoot){return;}
p.unshift(node.config.text);});return p.join('/');},getChildByText:function(text){var i,node,children=this.childNodes,len=children.length;for(i=0;i<len;i++){node=children[i];if(node.getText()==text){return node;}}
return null;},_getExpIconClass:function(){var pos='';if(this.isLast()){pos='last';}else if(this.isFirst()){}
var type;if(this.isLeaf()&&!this.isRoot){type='leaf';}else{if(this.hasChildNodes()){type='dir';}else{type='leaf';}}
return'jsgui-tree-node-expicon-'+pos+type;},_getHtml:function(){var html=[],nodeId='jsgui-tree-node-'+this.id,styleClasses=[],nodeClass='jsgui-tree-node',containerClasses=['jsgui-tree-node-children-container'],expIcoClass=this._getExpIconClass(),iconClass=this.leaf?'jsgui-tree-node-icon-leaf':'jsgui-tree-node-icon';var tree=this.getOwnerTree();if(this.expanded){styleClasses.push('jsgui-tree-node-expanded');this.expand();containerClasses.push('jsgui-tree-node-expanded');}
if(this.isLast()){containerClasses.push('jsgui-tree-node-last');}
if(this.leaf){styleClasses.push('jsgui-tree-node-item-leaf');}
if(!this.parentNode){styleClasses.push('jsgui-tree-node-root');containerClasses.push('jsgui-tree-node-root');}
if(this.loading){styleClasses.push('jsgui-tree-node-loading');containerClasses.push('jsgui-tree-node-loading');}
if(this.selected){styleClasses.push('jsgui-tree-node-item-selected');}
if(this.disabled){styleClasses.push('jsgui-tree-node-disabled');}
styleClasses=styleClasses.join(' ');containerClasses=containerClasses.join(' ');html.push('<li id="'+nodeId+'" class="'+nodeClass+'">');html.push('<div id="'+this.elId+'" class="jsgui-tree-node-item '+styleClasses+'">');html.push('<img class="'+expIcoClass+'" src="'+GUI.emptyImageUrl+'" />');html.push('<img class="'+iconClass+'" src="'+GUI.emptyImageUrl+'" />');if(this.config.checkBox){html.push('<input id="'+this.checkBoxId+'" type="checkbox"'
+(this.checked?' checked="checked"':'')
+(this.disabled&&this.ownerTree.config.allowDisabledCheckbox?' disabled="disabled"':'')
+'/>');}
html.push('<a id="'+this.textId+'" href="'+('javascript:')+'" '+((this.isRoot)?'class="tree-root-node"':'')+' >'+(this.config.text||'')+'</a>');if(this.isRoot){if(tree.config.expandButton&&tree.config.collapseButton){html.push('<a href="#" class="expand-all" id="jsgui-tree-expand-all">('+GUI.i18n.GUI_EXPAND+'</a><span class="separator-expand-all">/</span><a href="#" class="collapse-all" id="jsgui-tree-collapse-all">'+GUI.i18n.GUI_COLLAPSE+')</a>');}
else if(tree.config.expandButton&&!tree.config.collapseButton){html.push('<a href="#" class="expand-all" id="jsgui-tree-expand-all">('+GUI.i18n.GUI_EXPAND+')</a>');}
else if(!tree.config.expandButton&&tree.config.collapseButton){html.push('<a href="#" class="collapse-all" id="jsgui-tree-collapse-all">('+GUI.i18n.GUI_COLLAPSE+')</a>');}}
html.push('</div>');var i,children=this.childNodes,len=children.length;html.push('<ul id="'+this.containerId+'" class="'+containerClasses+'">');if(this.loading){html.push('<span>'+this.loadingText+'</span>');}
html.push('</ul>');html.push('</li>');return html.join('');},render:function(){if(this.rendered){return;}
var tree=this.getOwnerTree(),alwaysExpanded=tree.config.alwaysExpanded,last=this.isLast(),cfg=this.config,images=cfg.images,needLoad=false,leaf,icon;if(alwaysExpanded||(!tree.isRootVisible()&&(this.isRoot||this.isRootChild()))){this.expanded=true;}
if(this.expanded){if(this.loaded){}else{needLoad=true;}}
var to=(this.parentNode)?this.parentNode.getContainer():this.ownerTree.getContainer();to=GUI.$(to);if(this.nextSibling&&this.nextSibling.rendered){this.dom=GUI.Dom.extend(GUI.Dom.insertBefore(this.nextSibling.getDom(),this._getHtml()));}else{this.dom=GUI.Dom.extend(GUI.Dom.append(to,this._getHtml()));}
this.nodeEl=this.dom.firstChild;this.containerEl=this.dom.lastChild;this.rendered=true;if(tree&&tree.isEditable()&&!this.disabled&&this.editable){this.setHint(GUI.i18n.GUI_DOUBLE_CLICK_TO_EDIT);}else if(this.disabled&&tree.config.disabledNodeHint){this.setHint(tree.config.disabledNodeHint);}
this.ddConfig.linkedElId=this.elId;this.ddConfig.targetElId=this.elId;this.ddConfig.clipElId=this.ownerTree.config.id;this.ddConfig.groups=this.ownerTree.ddConfig.groups;this.initDD();this.setHandleElId(this.elId);if(needLoad){this.load({onLoad:function(){if(this.expanded){this.expand();}}.bind(this)});}else{if(this.expanded){this.renderChildren();}}},setHint:function(hint){this.config.hint=hint;if(this.dom){GUI.Popup.Hint.add(GUI.$(this.textId),'',hint);}},renderIndent:function(deep){},getChildIndentation:function(refresh){if(refresh||!this.childIndentation){var arr=new GUI.StringBuffer(),p=this.parentNode;if(p){var parentIndent=p.getChildIndentation();if(p.isRoot&&!p.getOwnerTree().isRootVisible()){this.childIndentation='';}else{this.childIndentation=parentIndent+(this.isLast()?this.imgTemplateS.format('x-tree-ico-empty'):this.imgTemplateS.format(this.config.images.lineVertical));}}else{this.childIndentation='';}}
return this.childIndentation;},renderChildren:function(){if(!this.childrenRendered){var i,nodes=this.childNodes,len=nodes.length;for(i=0;i<len;i++){nodes[i].render();}
this.childrenRendered=true;}},destroy:function(quick){if(this._request&&!this._request.complete){this._request.abort();this._request=null;}
if(this.fx){this.fx.destroy();this.fx=null;}
for(var i=0,len=this.childNodes.length;i<len;i++){this.childNodes[i].destroy(quick);}
this.childNodes=null;if(this.dom){this.destroyDD();if(!quick){GUI.destroyNode(this.dom);}
if(this.wrapeEl){GUI.destroyNode(this.wrapEl);this.wrapEl=null;}}
this.dom=this.nodeEl=this.containerEl=null;},unrender:function(quick){if(this.dom){this.destroyDD();for(var i=0,len=this.childNodes.length;i<len;i++){this.childNodes[i].unrender(quick);}
this.childrenRendered=false;if(!quick){GUI.remove(this.dom);}
this.dom=null;this.rendered=false;}},toggle:function(){if(this.expanded){this.collapse();}else{this.expand();}},wrapContainer:function(){if(this.wrapped){return false;}
if(!this.wrapEl){this.wrapEl=document.createElement('div');s=this.wrapEl.style;s.position='relative';s.overflow='hidden';}
var cont=GUI.$(this.containerId);if(!this.expanded){var dims=GUI.getDimensions(cont,true);s.height=dims.height+'px';s.width=dims.width+'px';}
cont.parentNode.insertBefore(this.wrapEl,cont);this.wrapEl.appendChild(cont);cont.style.position='absolute';cont.style.bottom='0px';this.wrapped=true;return true;},unwrapContainer:function(){if(!this.wrapped){return;}
if(this.wrapEl.parentNode){cont=this.wrapEl.firstChild;cont.style.position='';cont.style.bottom='';this.wrapEl.parentNode.insertBefore(cont,this.wrapEl);GUI.remove(this.wrapEl);}else{console.log('bug',this);}
cont=null;this.wrapped=false;},prepareFx:function(){if(this.fx.isRunning()){return;}
this.wrapContainer();this.fx.clearSubjects();var h=GUI.getDimensions(this.containerEl,true).height;var startHeight=(GUI.isIE)?1:0;this.fx.state=this.expanded?0:1;if(this.fx.state){this.wrapEl.style.height=h+'px';}else{this.wrapEl.style.height=startHeight+'px';}
this.fx.addSubject(new NumericalStyleSubject(this.wrapEl,'height',startHeight,h));},expand:function(deep,fast){if(!this.loaded){setTimeout(function(){this.load({onLoad:function(){this.expand(deep,fast);}.bind(this)});}.bind(this),20);return;}
if(!this.expanded){this.expanded=true;if(this.rendered){if(!this.childrenRendered){this.renderChildren();}
GUI.Dom.addClass(this.nodeEl,'jsgui-tree-node-expanded');GUI.Dom.addClass(this.containerEl,'jsgui-tree-node-expanded');if(this.config.animate){if(!this.fx){this.initAnimator();}
if(!fast&&!deep){this.prepareFx();GUI.show(this.containerId);this.fx.seekTo(1.0);}else{this.fx.jumpTo(1);if(this.DDM.dragObj){this.DDM.refreshCache(this.ddConfig.groups);}}}else{if(this.DDM.dragObj){this.DDM.refreshCache(this.ddConfig.groups);}
this.fireEvent('expand',this);this.relayEvent('expand');}}}
if(deep){this.expandChildNodes(true,true);}},_expand:function(){this.unwrapContainer();if(this.DDM.dragObj){this.DDM.refreshCache(this.ddConfig.groups);}
this.fireEvent('expand',this);this.relayEvent('expand');},relayEvent:function(eventName){var ownerTree=this.ownerTree;if(ownerTree){ownerTree.fireEvent('node'+eventName,ownerTree,this);}},expandChildNodes:function(deep,fast){var cs=this.childNodes;for(var i=0,len=cs.length;i<len;i++){cs[i].expand(deep,fast);}},collapse:function(deep,fast){if(this.expanded&&!this.isRoot){this.expanded=false;if(this.rendered){if(this.config.animate){if(!this.fx){this.initAnimator();}
if(!fast&&!deep){this.prepareFx();this.fx.seekTo(0);}else{GUI.Dom.removeClass(this.nodeEl,'jsgui-tree-node-expanded');GUI.Dom.removeClass(this.containerEl,'jsgui-tree-node-expanded');this.fx.jumpTo(0);}}else{GUI.Dom.removeClass(this.nodeEl,'jsgui-tree-node-expanded');GUI.Dom.removeClass(this.containerEl,'jsgui-tree-node-expanded');this.fireEvent('expand',this);this.relayEvent('expand');}}}
if(deep){this.collapseChildNodes(deep,true);}},_collapse:function(){this.unwrapContainer();GUI.Dom.removeClass(this.nodeEl,'jsgui-tree-node-expanded');GUI.Dom.removeClass(this.containerEl,'jsgui-tree-node-expanded');this.fireEvent('expand',this);this.relayEvent('expand');},collapseChildNodes:function(deep,fast){var cs=this.childNodes;for(var i=0,len=cs.length;i<len;i++){cs[i].collapse(deep,fast);}},updateIcons:function(deep){this.nodeEl.firstChild.className=this._getExpIconClass();if(this.isLast()){GUI.Dom.addClass(this.containerEl,'jsgui-tree-node-last');}else{GUI.Dom.removeClass(this.containerEl,'jsgui-tree-node-last');}
if(deep&&this.childrenRendered){var cs=this.childNodes;for(var i=0,len=cs.length;i<len;i++){cs[i].updateIcons(deep);}}},removeChildren:function(){this.beginUpdate();if(this.hasChildNodes()){while(this.firstChild){this.removeChild(this.firstChild);}}
this.endUpdate();},loadChildren:function(data){this.removeChildren();this.beginUpdate();for(var i=0,len=data.length;i<len;i++){var ch=new GUI.Tree.Node(data[i]);this.appendChild(ch);}
this.endUpdate();this.loaded=true;},load:function(loadCfg){if(this.loading){return;}
var cfg=this.config,pid=this.id,data={parentID:pid},treeConfig=this.getOwnerTree().config;if(GUI.isString(treeConfig.postBody)){treeData=Object.fromQueryString(treeConfig.postBody);Object.extendIf(data,treeData);}
if(this.ownerTree){if(false===this.ownerTree.fireEvent('beforenodeload',this.ownerTree,this,data)){return false;}}
var onLoad=function(){};if(loadCfg){if(loadCfg.onLoad){onLoad=loadCfg.onLoad;}}
if(this.loaded||this.isLeaf()){return;}
if(this.rendered){GUI.Dom.addClass(this.nodeEl,'jsgui-tree-node-loading');}
this.loading=true;if(this._request&&!this._request.complete){this._request.abort();}
this._request=new GUI.Ajax.Request(treeConfig.dataUrl,{method:treeConfig.method,data:data,scope:this,onSuccess:this.onLoadSuccess,onFailure:this.onLoadFailure,onComplete:this.onLoadComplete,onLoadNodeCallback:onLoad});},onLoadSuccess:function(transport,request){if(!this.childNodes){return;}
var cfg=this.config;this.loading=false;try{var response=request.responseJson;if(!response||!response.done){if(this.rendered){}
return;}
var data=response.tree;this.loadChildren(data);if(this.rendered){}
request.onLoadNodeCallback();if(this.ownerTree){this.ownerTree.fireEvent('nodeLoad',this,response,this.ownerTree);}}catch(e){if(this.rendered){}
if(this.ownerTree){this.ownerTree.fireEvent('nodeLoadFailed',this,response,this.ownerTree);}
alert(e.message);throw e;}},onLoadFailure:function(){if(!this.childNodes){return;}
this.loading=false;if(this.rendered){}
if(this.ownerTree){this.ownerTree.fireEvent('nodeLoadFailed',this,this.ownerTree);}},onLoadComplete:function(){if(this.dom){GUI.Dom.removeClass(this.nodeEl,'jsgui-tree-node-loading');}},beginUpdate:function(){this.childrenRendered=false;},endUpdate:function(){if(this.rendered&&this.expanded){this.renderChildren();}},reload:function(){if(!this.isLeaf()){this.loaded=false;this.load();}},getDom:function(){return this.dom;},getContainer:function(){return GUI.$(this.containerId);},onSelect:function(){GUI.Dom.addClass(this.nodeEl,'jsgui-tree-node-item-selected');if(!this.leaf&&!this.hasChildNodes()&&!this.loading){GUI.Dom.addClass(this.nodeEl,'jsgui-tree-node-item-opened');}},onUnselect:function(){GUI.Dom.removeClass(this.nodeEl,'jsgui-tree-node-item-selected');if(!this.leaf&&!this.hasChildNodes()){GUI.Dom.removeClass(this.nodeEl,'jsgui-tree-node-item-opened');}},onExpandIconClick:function(e){if(this.hasChildNodes()){this.toggle();}},onIconClick:function(e){},toggleChecked:function(){this.setChecked(!this.checked);},setChecked:function(val,deep,ignoreDisabled){if(this.config.checkBox){if(!GUI.isSet(val)){val=true;}
val=!!val;if(!this.disabled||!ignoreDisabled){this.checked=val;if(this.rendered){GUI.$(this.checkBoxId).checked=val;}
if(this.ownerTree){this.ownerTree.onCheckNode(this,val);}}
if(deep){this.cascade(function(){this.setChecked(val,false,ignoreDisabled);});}}},getText:function(){return this.config.text;},setText:function(text){this.config.text=text;if(this.rendered){GUI.$(this.textId).innerHTML=text;}},onClick:function(e){if(!this.disabled){this.ownerTree.fireEvent('nodeclick',this.ownerTree,this,e);}},onDblClick:function(e){var tree=this.getOwnerTree();if(this.editable&&tree&&tree.isEditable()&&!this.disabled){tree.showEditor(this);}
if(!this.disabled){this.ownerTree.fireEvent('nodedblclick',this.ownerTree,this,e);}},onMouseOver:function(e){var targ=e.target,nodeEl=this.nodeEl;if(e.isMouseEnter(nodeEl)){nodeEl.addClass('jsgui-tree-node-item-hover');var textNode=GUI.$(this.textId),textWidth=textNode.offsetWidth+3,textHeight=textNode.offsetHeight,treeDom=this.ownerTree.dom,p=GUI.getRelativeOffset(textNode,treeDom),treeWidth=treeDom.clientWidth;treeHeight=treeDom.clientHeight;var treeRegion=new GUI.Utils.Region(0,treeWidth,treeHeight,0),textRegion=new GUI.Utils.Region(p[1],p[0]+textWidth,p[1]+textHeight,p[0]);if(!treeRegion.contains(textRegion)){this.ownerTree.showHint(this);}}},onMouseOut:function(e){var ownerTree=this.ownerTree;if(!ownerTree){return;}
if(false===ownerTree.fireEvent('nodeBeforeMouseOut',ownerTree,this,e)){return false;}
var nodeEl=this.nodeEl;if(e.isMouseLeave(nodeEl)){var tree=this.getOwnerTree(),hintList=this.getOwnerTree().hintList;if(hintList&&hintList.dom&&!e.isMouseLeave(hintList.dom)){return false;}else{GUI.Dom.removeClass(nodeEl,'jsgui-tree-node-item-hover');tree.hideHint();}}
ownerTree.fireEvent('nodeMouseOut',ownerTree,this,e);return false;},onBeforeDragStart:function(){return(this.ownerTree.config.enableDd&&!this.isRoot&&!this.disabled);},onDragStart:function(x,y){this.dropAccepted=false;if(!this.dragProxy){this.dragProxy=new GUI.Popup.Region({className:'x-tree-node-proxy',content:GUI.Popup.Hint.renderHint({text:'<img id="'+this.dpDropImgId+'"'+' class="'+this.config.images.dropNo+'" src="'+GUI.emptyImageUrl+'"/>'+this.config.text})});}
this.dragProxy.setDimensions({left:x+16,top:y+16});this.dragProxy.show();},onDrag:function(e,dropAccepted){var xy=e.getPageXY(),x=xy[0],y=xy[1],style=this.dragProxy.dom.style;style.left=(x+16).toString()+'px';style.top=(y+16).toString()+'px';if(!dropAccepted){this.dragCursor=false;}
if(this.dropAccepted!=this.dragCursor){var img,images=this.config.images;switch(this.dragCursor){case'before':case'after':img=images.dropBetween;break;case'in':img=images.dropIn;break;default:img=images.dropNo;break;}
GUI.$(this.dpDropImgId).setClass(img);this.dropAccepted=this.dragCursor;}},onDragEnd:function(e){this.dragProxy.hide();},onDragEnter:function(e,dragObj){this.moveDest=null;dragObj.dragCursor=null;},onDragOver:function(e,dragObj,pt){this.setHint('');var acceptDrop=false;var lr=this.getOwnerTree().getLineRegion();if(this.isLeaf()&&!dragObj.isLeaf()){lr.hide();dragObj.dragCursor=null;return false;}
if(this.isRoot||(!this.isLeaf()&&dragObj.isLeaf())){if(this.moveDest!='in'){this.moveDest='in';lr.hide();GUI.Dom.addClass(this.nodeEl,'jsgui-tree-node-item-hover');if(!this.isLeaf()&&!this.expanded&&!this.autoExpandTimer){this.autoExpandTimer=setTimeout(function(){this.expand();this.autoExpandTimer=null;}.bind(this),500);}}
dragObj.dragCursor='in';return true;}
var p=this.DDM.locationCache[this.config.id],h=p.getHeight(),y=e.getPageXY()[1],deltaY=y-p.top,oneThird=Math.round(0.33*h);if(this.isAncestor(dragObj)){lr.hide();dragObj.dragCursor=null;return false;}
if(!this.isLeaf()&&(deltaY>oneThird)&&(deltaY<2*oneThird)){if(this.moveDest!='in'){this.moveDest='in';lr.hide();GUI.Dom.addClass(this.nodeEl,'jsgui-tree-node-item-hover');if(!this.expanded&&!this.autoExpandTimer){this.autoExpandTimer=setTimeout(function(){this.expand();this.autoExpandTimer=null;}.bind(this),500);}}
dragObj.dragCursor='in';}else{var dims={top:p.top};var bypass=false;if(deltaY<=oneThird){bypass=(this.moveDest=='before');this.moveDest='before';dragObj.dragCursor='before';}else{bypass=(this.moveDest=='after');this.moveDest='after';dragObj.dragCursor='after';dims.top+=h;}
if(!bypass){lr.setDimensions(dims);lr.show();GUI.Dom.removeClass(this.nodeEl,'jsgui-tree-node-item-hover');}}
if(false===this.getOwnerTree().onNodeDragOver(e,dragObj,pt,this)){acceptDrop=false;}else{acceptDrop=true;}
return acceptDrop;},onDragLeave:function(e,dragObj){if(this.autoExpandTimer){clearTimeout(this.autoExpandTimer);this.autoExpandTimer=null;}
var style=this.nodeEl.style;style.backgroundColor='';style.borderTop='';style.borderBottom='';dragObj.dragCursor=null;},onDragDrop:function(e,dragObj){if(this.ownerTree&&this.ownerTree.isEditable()&&!this.disabled&&this.editable){this.ownerTree.root.cascade(function(node){node.setHint(GUI.i18n.GUI_DOUBLE_CLICK_TO_EDIT);});}
if(dragObj instanceof Node){if(this.id!=dragObj.id&&!this.isAncestor(dragObj)){var lr=this.getOwnerTree().lineRegion;lr.hide();if(this.isLeaf()&&!dragObj.isLeaf()){}else if(this.isRoot||(!this.isLeaf()&&dragObj.isLeaf())){this.appendChild(dragObj);this.expand();}else{switch(this.moveDest){case'before':this.parentNode.insertBefore(dragObj,this);break;case'after':this.parentNode.insertBefore(dragObj,this.nextSibling);break;case'in':if(this.isLeaf()){this.parentNode.insertBefore(dragObj,this.nextSibling);}else{var cs=this.childNodes,refNode=null,i,len;for(i=0,len=cs.length;i<len;i++){if(cs[i].isLeaf()){refNode=cs[i];break;}}
this.insertBefore(dragObj,refNode);this.expand();}
break;}}
return true;}}
return false;},onInvalidDrop:function(e){var lr=this.getOwnerTree().lineRegion;if(lr){lr.hide();}}};Object.extend(Node.prototype,superproto);Object.extend(Node.prototype,prototype);GUI.Tree.Node=Node;})();

(function(){var TreeActions=Class.create({barClass:'x-tree-actions',extraClass:'',itemClass:'x-tree-action',actionClassPrefix:'x-tree-action-name-',disabledItemClass:'x-tree-action-disabled',itemTemplate:'<img src="'+GUI.emptyImageUrl+'" class="{0} {1} {2}" style="background-image:url(\'{3}\');" hint="{4}"/>',initialize:function(cfg){if(cfg){Object.extend(this,cfg);}
this.regions={};this.nodes={};},init:function(tree){this.tree=tree;tree.addEvents({'action':true});tree.on('nodemouseover',this.onNodeMouseOver,this);tree.on('nodebeforemouseout',this.onNodeBeforeMouseOut,this);tree.on('nodemouseout',this.onNodeMouseOut,this);tree.on('select',this.onNodeSelect,this);tree.on('nodeclick',this.onNodeClick,this);},destroy:function(){for(var type in this.regions){this.hideActions(type);this.regions[type].destroy();delete this.regions[type];}
this.nodes.selected=this.nodes.hover=null;var tree=this.tree;tree.un('nodemouseover',this.onNodeMouseOver,this);tree.un('nodebeforemouseout',this.onNodeBeforeMouseOut,this);tree.un('nodemouseout',this.onNodeMouseOut,this);tree.un('select',this.onNodeSelect,this);tree.un('nodeclick',this.onNodeClick,this);this.tree=null;},onNodeMouseOver:function(tree,node,e){if(node!=this.nodes.hover&&node!=this.nodes.selected){this.showActions('hover',node);}},onNodeBeforeMouseOut:function(tree,node,e){var region=this.regions.hover;if(region&&region.dom&&!e.isMouseLeave(region.dom)){return false;}},onNodeMouseOut:function(tree,node,e){if(e.isMouseLeave(GUI.$(node.elId))){this.hideActions('hover');}},onNodeSelect:function(tree,node){if(node!=this.nodes.selected){if(node==this.nodes.hover){this.hideActions('hover',node);}
this.showActions('selected',node);}},onNodeClick:function(tree,node,e){if(node==this.nodes.selected&&e.target.hasClass(this.itemClass)&&!e.target.hasClass(this.disabledItemClass)){var actionName=e.target.className.match(new RegExp(this.actionClassPrefix+'(\\w+)'))[1];this.tree.fireEvent('action',this.tree,actionName,this.nodes.selected);}},showActions:function(type,node){var actions;if(!this.regions[type]){this.regions[type]=new GUI.Popup.Region({className:this.barClass,zIndex:4000});}
var region=this.regions[type];if(region.dom){this.hideActions(type);}
if(actions=node.config.actions){region.setContent(this.getActionsHtml(actions));var textDom=GUI.$(node.textId);if(type=='selected'){region.config.parentNode=GUI.$(node.elId);region.setDimensions({left:textDom.offsetLeft+textDom.offsetWidth,top:0});region.show();GUI.scrollIntoView(this.tree.dom,region.dom);}else if(type=='hover'){var treeDom=this.tree.dom,pos=GUI.getPosition(treeDom),treeRight=pos.left+treeDom.offsetWidth,textPos=GUI.getPosition(textDom),textRight=textPos.left+textDom.offsetWidth,nodeDom=textDom.parentNode,nodePos=GUI.getPosition(nodeDom),nodeMiddle=nodePos.top,top=nodeMiddle,left=textRight;region.setDimensions({left:left,top:top});region.show();}
var dom=GUI.Dom.extend(region.dom);if(type=='hover'){dom.on('click',this.onClick,this);dom.on('mouseout',this.onMouseOut,this);}}
this.nodes[type]=node;},hideActions:function(type){var region=this.regions[type];if(region&&region.dom){if(type=='hover'){region.dom.un('click',this.onClick,this);region.dom.un('mouseout',this.onMouseOut,this);}
region.hide();}
this.nodes[type]=null;},getActionsHtml:function(actions){var o=new GUI.StringBuffer(),action;for(var i=0,len=actions.length;i<len;i++){action=actions[i];o.append(this.itemTemplate.formatArr([this.itemClass+(action.disabled?(' '+this.disabledItemClass):''),this.extraClass,this.actionClassPrefix+action.name,(action.disabled)?GUI.getDisabledImageUrl(action.img):action.img,action.text]));}
return''+o;},onClick:function(e){e=GUI.Event.extend(e);if(e.target.nodeName=='IMG'&&!e.target.hasClass(this.disabledItemClass)){actionName=e.target.className.match(new RegExp(this.actionClassPrefix+'(\\w+)'))[1];this.tree.fireEvent('action',this.tree,actionName,this.nodes.hover);}},onMouseOut:function(e){e=GUI.Event.extend(e);if(e.isMouseLeave(this.regions.hover.dom)){if(this.nodes.hover.onMouseOut(e)!==false){this.hideActions('hover');}}}});if(!GUI.Tree.Plugins)GUI.Tree.Plugins={};GUI.Tree.Plugins.TreeActions=TreeActions;}());

(function()
{var Accordion=Class.create();var superproto=GUI.Utils.Observable.prototype;var prototype={initialize:function(config)
{superproto.initialize.call(this);this.config={id:GUI.getUniqId('accordion-'),holder:null,items:[],disable:false};var cfg=this.config;Object.extend(cfg,config);this.addEvents({});if(cfg.disable){return;}
this.currentOpened=null;this.lastHeight=null;var items=this.config.items;for(var i=0;i<items.length;i++){var item=items[i];if(item.isExpanded()){if(this.currentOpened){this.currentOpened.collapse();}
this.currentOpened=item;}
item.on('collapse',this.onItemCollapse.bind(this));item.on('expand',this.onItemExpand.bind(this));}},getQuickBarHeight:function(){var items=this.config.items;var len=items.length;var h=GUI.getClientHeight(GUI.$(this.config.holder).parentNode);h-=(len-1)*28;return(h<0)?0:h;},updateItemsHeight:function(){var items=this.config.items;var len=items.length;var h=this.getQuickBarHeight();if(this.lastHeight!=h){this.lastHeight=h;while(len--){items[len].setHeight(h);}}},destroy:function(quick){var items=this.config.items;var len=items.length
for(var i=0;i<len;i++){items[i].destroy(quick);}
if(this.attachedEvent){GUI.Event.unWindowResize(this.onWindowResize,this);this.attachedEvent=null;}
this.config.items=null;this.config.holder=null;},render:function(to){if(to){this.config.holder=to;}
var items=this.config.items;var len=items.length
if(!this.config.disable){var h=this.getQuickBarHeight(),holder=GUI.$(this.config.holder);for(var i=0;i<len;i++){items[i].setHeight(h);var qbHolder=document.createElement('div');holder.appendChild(qbHolder);items[i].render(qbHolder);}
GUI.Event.onWindowResize(this.onWindowResize,this);this.attachedEvent=true;}else{for(var i=0;i<len;i++){items[i].render(this.config.holder);}}},onWindowResize:function(e){this.updateItemsHeight();},onItemExpand:function(item){if(this.currentOpened){this.currentOpened.collapse();}
this.currentOpened=item;},onItemCollapse:function(item){this.currentOpened=null;}};Object.extend(Accordion.prototype,superproto);Object.extend(Accordion.prototype,prototype);GUI.Accordion=Accordion;})();

(function()
{var AppLayout=Class.create();var superproto=GUI.Utils.Draggable.prototype;var prototype={imgPath:window.JSGUI_IMAGES_PATH+'x-layout/',template:'<table id="{cfg.id}" class="x-layout"><col /><tbody>'+'<tr id="{this.headerTrId}" class="x-layout-header">'+'<td class="x-layout-header">'+'<div class="x-layout-header">'+'<a class="jsgui-applayout-header-logo" target="_blank" href="{cfg.logoHref}">'+'<img src="{cfg.logoImg}" />'+'</a>'+'<div id="{this.headerMenuId}" class="header-menu"></div>'+'</div></td></tr>'+'<tr id="{this.mainMenuTrId}" class="x-layout-mainmenu">'+'<td class="x-layout-mainmenu">'+'<div id="{this.mainMenuId}" class="x-layout-mainmenu"></div></td></tr>'+'<tr class="x-layout-middle"><td class="x-layout-middle">'+'<table id="{cfg.id}-layout-data" class="x-layout-data"><col/><col/><col/>'+'<tr class="x-layout-data"><td class="left-side" style="width: {cfg.leftSideWidth}px;">'+'<div class="left-side" style="width: {cfg.leftSideWidth}px;">'+'<div id="{this.leftSideId}" class="left-side-container"></div></div></td>'+'<td id="{this.delimiterId}" class="delimiter"><div class="delimiter">'+'<a href="#"><img src="{imgPath}/layout-delimiter-ico.gif" alt="" /></div></a></td>'+'<td class="mainpad"><div class="mainpad">'+'<div id="{this.mainPadId}" class="mainpad-container"></div></div></td></tr></table></td></tr>'+'<tr id="{this.footerTrId}" class="x-layout-footer"><td class="x-layout-footer">'+'<div class="x-layout-footer"><div class="footer"><div id="{this.footerId}" class="footer-in">'+'</div></div></div></div></td></tr></tbody></table>',initialize:function(config){var defCfg={id:GUI.getUniqId('layout-'),holder:document.body,className:'layout',name:null,items:{},minWidth:600,minHeight:300,minLeftSideWidth:50,leftSideWidth:200,rememberLeftSideState:true,lazyRender:false,destroyOnHide:false,animate:true,transition:'elastic',logoHref:'',logoClass:'',dd:{linkedElId:null,dragElId:null,handleElId:null,isTarget:false,moveOnly:true,groups:{'default':true},enableDrag:false,dropReciever:false,dragType:''}};Object.extend(defCfg,config);superproto.initialize.call(this);Object.extend(this.config,defCfg);var cfg=this.config;this.constrainedWidth=this.constrainedHeight=false;this.placeholders=null;this.content={};this.layouts={};this.delimiterIconR=this.imgPath+'layout-delimiter-icoR.gif';this.delimiterIcon=this.imgPath+'layout-delimiter-ico.gif';this.headerId=GUI.getUniqId('header-');this.headerMenuId=GUI.getUniqId('headermenu-');this.centerId=GUI.getUniqId('center-');this.mainMenuId=GUI.getUniqId('mainmenu-');this.leftSideId=GUI.getUniqId('leftside-container-');this.delimiterId=GUI.getUniqId('delimiter-');this.mainPadId=GUI.getUniqId('mainpad-container-');this.footerId=GUI.getUniqId('footer-');this.headerTrId=GUI.getUniqId('header-tr--');this.mainMenuTrId=GUI.getUniqId('mainmenu-tr-');this.footerTrId=GUI.getUniqId('footer-tr-');cfg.dd.linkedElId=this.delimiterId;cfg.dd.handleElId=this.delimiterId;this.ddConfig=this.config.dd;this.leftSideOpened=true;this.leftSideDisabled=false;this.delimiterClickListener=this.delimiterClickHandler.bindAsEventListener(this);this.addEvents({resize:true});if(!cfg.lazyRender){this.render();}
if(cfg.animate){var self=this;this.addEvents({fxComplete:true});var fxConfig={duration:500,onComplete:function(){self.fireEvent('fxComplete',this);}};if(cfg.transition=='elastic'){fxConfig.transition=Animator.tx.elastic;}else if(cfg.transition=='easeinout'){fxConfig.transition=Animator.tx.easeInOut;}
this.fx=new Animator(fxConfig);if(this.leftSideOpened){this.fx.state=1.0;}
this.on('fxComplete',function(fx){if(!fx.state){this._hideLeftSide();}else{this._showLeftSide();}});}
if(cfg.name){GUI.ComponentMgr.register(cfg.name,this);}},destroy:function(){this.destroyDD();if(this.config.name){GUI.ComponentMgr.unregister(this);}},render:function(){if(this.dom){this.removeEventListeners();GUI.remove(this.dom);this.dom=null;}
this.visible=false;var cfg=this.config,tpl=new GUI.STemplate(this.template,this);tpl.cfg=cfg;tpl.imgPath=this.imgPath;document.documentElement.style.overflow='hidden';document.body.style.overflow='hidden';GUI.Dom.append(GUI.$(cfg.holder),tpl.fetch());this.dom=$(cfg.id);this.layoutDataTableEl=GUI.$(cfg.id+'-layout-data');this.placeholders={headermenu:$(this.headerMenuId),mainmenu:$(this.mainMenuId),left:$(this.leftSideId),main:$(this.mainPadId),footer:$(this.footerId)};var phNames=['headermenu','mainmenu','left','main','footer'],i=phNames.length;while(i--){this.placeholders[phNames[i]].addClass('jsgui-applayout-placeholder');}
if(GUI.isArray(cfg.items)&&cfg.items.length){var i=cfg.items.length;while(i--){var item=cfg.items[i];this.renderItem(item.ph,item.content);}}
this.attachEventListeners();this.onWindowResize(GUI.getViewportWidth(),GUI.getViewportHeight());this.initDD();this.setHandleElId(this.delimiterId);},renderItem:function(ph,content){var holder=this.getPlaceholder(ph);if(holder){this.content[ph]=content;if(GUI.isString(content)){holder.innerHTML=content;}else if(GUI.isArray(content)){for(var i=0,len=content.length;i<len;i++){content[i].render(holder);}}else if(GUI.isObject(content)){content.render(holder);}}},add:function(layout){var name=layout.name;var sides=layout.sides;if(!this.layouts[name]){this.layouts[name]=layout;}
for(var ph in sides){var holder=this.getPlaceholder(ph);if(holder){var id=GUI.getUniqId('x-layout-');sides[ph].id=id;var div=document.createElement('DIV');div.id=id;div.className='jsgui-applayout-item';GUI.hide(div);holder.appendChild(div);var content=sides[ph].content;if(GUI.isString(content)){div.innerHTML=content;}else if(GUI.isArray(content)){for(var i=0,len=content.length;i<len;i++){content[i].render(div);}}else if(GUI.isObject(content)){content.render(div);}}}
if(sides.left&&sides.left.hidden){this.layouts[name].leftHidden=true;}
if(sides.left&&sides.left.disabled){this.layouts[name].leftDisabled=true;}
if(layout.visible){this.show(name);}},show:function(name){this.currentLayout=name;var l=this.layouts[name];if(!l){console.log("Trying to switch to undefined layout: "+name);return 0;}
if(l.leftDisabled&&!this.leftSideDisabled){this.disableLeftSide();}else if(!l.leftDisabled&&this.leftSideDisabled){this.enableLeftSide();}
if(!l.leftDisabled&&this.config.rememberLeftSideState){if(l.leftHidden&&this.leftSideOpened){this.hideLeftSide();}else if(!(l.leftHidden||this.leftSideOpened)){this.showLeftSide();}}
var s=l.sides;if(s){for(var ph in s){if((ph=='left')&&(l.leftDisabled||(l.leftHidden&&this.config.rememberLeftSideState))){continue;}
GUI.show($(s[ph].id));}}
return 1;},hide:function(name){var l=this.layouts[name];if(!l){console.log("Trying to hide undefined layout: "+name);return 0;}
var s=l.sides;if(s){for(var ph in s){GUI.hide(s[ph].id);}}
this.currentLayout=null;},updatePlaceholder:function(ph,content){var holder=this.getPlaceholder(ph);if(holder){var oldContent=this.content[ph];if(oldContent){if(GUI.isArray(oldContent)){for(var i=0,len=oldContent.length;i<len;i++){if(!GUI.isString(oldContent)&&GUI.isFunction(oldContent.destroy)){oldContent.destroy();}}}else if(!GUI.isString(oldContent)&&GUI.isFunction(oldContent.destroy)){oldContent.destroy();}}
this.renderItem(ph,content);}},getPlaceholder:function(name){return this.placeholders[name.toLowerCase()];},getDom:function(){return this.dom;},attachEventListeners:function(){GUI.Event.onWindowResize(this.onWindowResize,this);Event.observe($(this.delimiterId),'click',this.delimiterClickListener);},removeEventListeners:function(){GUI.Event.unWindowResize(this.onWindowResize,this);$(this.delimiterId).stopObserving('click',this.delimiterClickListener);},onWindowResize:function(w,h){var minWidth=this.config.minWidth;var minHeight=this.config.minHeight;if(w<minWidth){this.constrainedWidth=true;}else if(this.constrainedWidth){this.constrainedWidth=false;}
if(h<minHeight){h=minHeight-10;}
var subHeight=$(this.headerTrId).offsetHeight
+$(this.mainMenuTrId).offsetHeight
+$(this.footerTrId).offsetHeight;var height=(h-subHeight).constrain(0);GUI.setFullHeight($(this.mainPadId),height);GUI.setFullHeight($(this.leftSideId),height);this.layoutDataTableEl.style.width=w+'px';},disableLeftSide:function(){if(this.leftSideDisabled){return;}
var delim=GUI.$(this.delimiterId);GUI.hide(delim.firstChild);GUI.hide(delim);delim.style.width='0px';if(this.config.animate&&this.fx){this.fx.seekTo(0);}else{this._hideLeftSide();}
GUI.$(this.mainPadId).parentNode.parentNode.style.width='100%';this.leftSideDisabled=true;},enableLeftSide:function(){if(!this.leftSideDisabled){return;}
GUI.$(this.mainPadId).parentNode.parentNode.style.width='';var delim=GUI.$(this.delimiterId);delim.style.width='';GUI.show(delim);GUI.show(delim.firstChild);if(this.leftSideOpened){GUI.show($(this.leftSideId).parentNode);if(this.config.animate&&this.fx){this.fx.seekTo(1);}else{this._showLeftSide();}}
this.leftSideDisabled=false;},prepareFx:function(){if(this.fx.isRunning()){return;}
var lsDiv=GUI.$(this.leftSideId).parentNode;this.fx.clearSubjects();this.fx.addSubject(new NumericalStyleSubject(lsDiv,'width',0,this.config.leftSideWidth));this.fx.addSubject(new NumericalStyleSubject(lsDiv.parentNode,'width',0,this.config.leftSideWidth));},hideLeftSide:function(){this.leftSideOpened=false;$(this.delimiterId).firstChild.firstChild.firstChild.src=this.delimiterIconR;if(this.currentLayout){var l=this.layouts[this.currentLayout];l.leftHidden=true;}
if(this.config.animate&&this.fx){this.prepareFx();this.fx.seekTo(0);}else{this._hideLeftSide();}},_hideLeftSide:function(){GUI.hide($(this.leftSideId).parentNode);$(this.leftSideId).parentNode.style.width='0px';$(this.leftSideId).parentNode.parentNode.style.width='0px';},showLeftSide:function(){GUI.show($(this.leftSideId).parentNode);$(this.delimiterId).firstChild.firstChild.firstChild.src=this.delimiterIcon;this.leftSideOpened=true;if(this.currentLayout){var l=this.layouts[this.currentLayout];l.leftHidden=false;if(l.sides.left){GUI.show($(l.sides.left.id));}}
if(this.config.animate&&this.fx){this.prepareFx();this.fx.seekTo(1);}else{this._showLeftSide();}},_showLeftSide:function(){this.setLeftSideWidth(this.config.leftSideWidth,false);},getLeftSideWidth:function(){return this.config.leftSideWidth;},setLeftSideWidth:function(width,silent){var oldWidth=this.config.leftSideWidth,newWidth=width,l=this.layouts[this.currentLayout];this.config.leftSideWidth=width;if(this.dom){var lsDiv=GUI.$(this.leftSideId).parentNode;if(GUI.isNumber(width)){width=width.toString()+'px';}
lsDiv.parentNode.style.width=width;lsDiv.style.width=width;}
if(!silent){if(l.sides&&l.sides.left&&l.sides.left.onResize){l.sides.left.onResize(newWidth,oldWidth);}
this.fireEvent('leftResize',this,newWidth,oldWidth);}},delimiterClickHandler:function(e){e=GUI.Event.extend(e);e.stop();if(this.leftSideOpened){this.hideLeftSide();}else{this.showLeftSide();}},onBeforeDragStart:function(){return this.leftSideOpened;},onDragStart:function(){this.dragProxy=new GUI.Popup.Region({className:'x-delimiter-proxy'});this.dragProxy.show();this.dragProxy.takeRegion(GUI.$(this.delimiterId));this._delimOffsetLeft=GUI.$(this.delimiterId).offsetLeft;},onDrag:function(e){var x=e.getPageXY()[0],style=this.dragProxy.dom.style;x=x.constrain(this.config.minLeftSideWidth);style.left=x+'px';},onDragEnd:function(e){if(e){var x=e.getPageXY()[0];x=x.constrain(this.config.minLeftSideWidth);this.setLeftSideWidth(x);}
this.dragProxy.hide();}};Object.extend(AppLayout.prototype,superproto);Object.extend(AppLayout.prototype,prototype);GUI.AppLayout=AppLayout;})();

(function()
{var Calendar=Class.create();var superproto=GUI.Utils.Observable.prototype;var i18n=GUI.i18n;var prototype={imgPath:window.JSGUI_IMAGES_PATH+'x-layout/',template:'<table class="x-calendar"><tr class="x-cal-top fs"><td><div class="x-cal-l">'+'<div class="x-cal-r"><div class="x-cal-c"></div></div></div></td></tr>'+'<tr class="x-cal-mdl"><td><div class="x-cal-l"><div class="x-cal-r">'+'<div class="x-cal-c"><div class="x-cal-container"><table class="x-cal-filter">'+'<tr><td class="x-cal-filter-td" id="{this.monthComboId}"></td>'+'<td class="x-cal-filter-td" id="{this.yearComboId}"></td></tr>'+'</table><!-- days --><table id="{this.daysTableId}" class="x-cal-days">'+'<thead id="{this.daysHeadId}"></thead><tbody id="{this.daysBodyId}"></tbody>'+'</table><!-- buttons --><table class="x-cal-buttons"><tr>'+'<td class="x-cal-separator"></td><td class="left-btn">'+'<div id={this.prevBtnId} class="x-cal-btn-l"><div class="x-cal-btn-r">'+'<div class="x-cal-btn-c"><span>{cfg.prevMonth}</span></div></div></div></td>'+'<td class="right-btn"><div id={this.nextBtnId} class="x-cal-btn-l">'+'<div class="x-cal-btn-r"><div class="x-cal-btn-c"><span>{cfg.nextMonth}</span>'+'</div></div></div></td></tr><tr><td class="x-cal-separator"></td>'+'<td colspan="2" class="x-cal-btn-today">'+'<div id={this.todayBtnId} class="x-cal-btn-l"><div class="x-cal-btn-r">'+'<div class="x-cal-btn-c"><span>{cfg.today}</span></div></div></div></td></tr>'+'</table></div></div></div></div></td></tr><tr class="x-cal-btm fs"><td>'+'<div class="x-cal-l"><div class="x-cal-r"><div class="x-cal-c"></div></div>'+'</div></td></tr></table>',initialize:function(config)
{superproto.initialize.call(this);this.config={id:GUI.getUniqId('calendar-'),holder:null,visible:true,date:null,disabled:[],events:[],offset:0,daysOfWeek:[i18n.GUI_SU,i18n.GUI_MO,i18n.GUI_TU,i18n.GUI_WE,i18n.GUI_TH,i18n.GUI_FR,i18n.GUI_SA],monthNames:[i18n.GUI_JANUARY,i18n.GUI_FEBRUARY,i18n.GUI_MARCH,i18n.GUI_APRIL,i18n.GUI_MAY,i18n.GUI_JUNE,i18n.GUI_JULY,i18n.GUI_AUGUST,i18n.GUI_SEPTEMBER,i18n.GUI_OCTOBER,i18n.GUI_NOVEMBER,i18n.GUI_DECEMBER],nextMonth:i18n.GUI_NEXT_MONTH,prevMonth:i18n.GUI_PREV_MONTH,today:i18n.GUI_TODAY};var cfg=this.config;Object.extend(cfg,config);this.setDate((cfg.date)?cfg.date:new Date());this.baseId=cfg.id+'-day';this.daysTableId=cfg.id+'-days';this.daysHeadId=cfg.id+'-days-head';this.daysBodyId=cfg.id+'-days-body';this.monthComboId=cfg.id+'-monthcombo';this.yearComboId=cfg.id+'-yearcombo';this.nextBtnId=cfg.id+'-btn-next';this.prevBtnId=cfg.id+'-btn-prev';this.todayBtnId=cfg.id+'-btn-today';this.visible=cfg.visible;this.dayClickListener=this.dayClickHandler.bindAsEventListener(this);this.nextBtnClickListener=this.nextBtnClickHandler.bindAsEventListener(this);this.prevBtnClickListener=this.prevBtnClickHandler.bindAsEventListener(this);this.todayBtnClickListener=this.todayBtnClickHandler.bindAsEventListener(this);this.mouseOverListener=this.onMouseOver.bindAsEventListener(this);this.mouseOutListener=this.onMouseOut.bindAsEventListener(this);this.addEvents({change:true,dayClick:true});},destroy:function(){if(!this.dom){return;}
this.removeEventListeners();GUI.destroyNode(this.dom);this.config.holder=null;this.dom=null;},unrender:function(){if(this.dom){this.removeEventListeners();this.monthCombo.destroy(true);this.yearCombo.destroy(true);GUI.destroyNode(this.dom);this.dom=null;}},render:function(to){if(this.dom){GUI.destroyNode(this.dom);this.dom=null;}
var cfg=this.config;var div=document.createElement('DIV');div.className='x-calendar';GUI.Dom.extend(div);if(GUI.isString(cfg.style)){div.addClass(cfg.style);}
var tpl=new GUI.STemplate(this.template,this);tpl.cfg=cfg;tpl.imgPath=this.imgPath;if(to){cfg.holder=to;}
GUI.hide(div);$(cfg.holder).appendChild(div);div.innerHTML=tpl.fetch();this.dom=div;this.monthCombo=new GUI.Forms.Combo({width:82,listWidth:82});var monthes=[];var mNames=this.config.monthNames;for(var i=0;i<mNames.length;i++){monthes.push({text:mNames[i],value:i});}
this.monthCombo.setOptions(monthes);this.monthCombo.select(this.curMonth);this.monthCombo.render($(this.monthComboId));this.monthCombo.on('change',this.onMonthChange.bind(this));this.yearCombo=new GUI.Forms.SpinEdit({width:78,min:1900,max:2099});this.yearCombo.setValue(this.curYear);this.yearCombo.render($(this.yearComboId));this.yearCombo.on('change',this.onYearChange.bind(this));this.update();if(this.visible){GUI.show(div);}
this.attachEventListeners();},onMonthChange:function(combo,val){this.curMonth=val;this.update();},onYearChange:function(combo,val){this.curYear=val;this.update();},getFirstDay:function(year,month){var firstDate=new Date(year,month,1);return firstDate.getDay();},getMonthLen:function(theYear,theMonth){var nextMonth=new Date(theYear,theMonth+1,1);nextMonth.setHours(nextMonth.getHours()-3);return nextMonth.getDate();},update:function(){var date=this.date;var selectedDayNum=date.getDate();this.monthCombo.select(this.curMonth);this.yearCombo.setValue(this.curYear);var offset=this.config.offset;var startIndex=this.getFirstDay(this.curYear,this.curMonth)-offset;if(startIndex<0){startIndex+=7;}
var days=this.getMonthLen(this.curYear,this.curMonth);var prevDays=this.getMonthLen(this.curYear,this.curMonth-1);var thead=document.createElement('thead');thead.id=this.daysHeadId;var tr=document.createElement('TR');var td=document.createElement('TD');td.className='x-cal-separator';thead.appendChild(tr);tr.appendChild(td);var len=7;var last=(offset>0)?(offset-1):(offset+6);var index=offset;while(len--){var td=document.createElement('TD');tr.appendChild(td);if(index>6){index-=7;}
if(index==offset){td.className='firstday';}else if(index==last){td.className='lastday';}
var day=document.createTextNode(this.config.daysOfWeek[index]);td.appendChild(day);index++;}
var oldThead=$(this.daysHeadId);GUI.replace(oldThead,thead);var tbody=document.createElement('tbody');tbody.id=this.daysBodyId;var rows=6;var index=0;for(var row=0;row<rows;row++){var tr=document.createElement('TR');var td=document.createElement('TD');td.className='x-cal-separator';tbody.appendChild(tr);tr.appendChild(td);for(var col=0;col<7;col++,index++){var td=document.createElement('TD');tr.appendChild(td);var dayNum=index-startIndex+1;if(dayNum>=1&&dayNum<=days){if(dayNum==selectedDayNum){GUI.Dom.addClass(td,'eventday');}
var day=document.createTextNode(dayNum);td.appendChild(day);td.id=this.baseId+dayNum;}else{GUI.Dom.addClass(td,'disable');var day=(dayNum>days)?(dayNum-days):(prevDays+dayNum);day=document.createTextNode(day);td.appendChild(day);}}}
var oldTbody=$(this.daysBodyId);GUI.replace(oldTbody,tbody);var today=new Date();if(this.curYear==today.getFullYear()&&this.curMonth==today.getMonth()){var day=today.getDate();var cell=GUI.$(this.baseId+day);if(cell){cell.addClass('today');cell.innerHTML='<div><i>'+day+'</i></div>';}}},show:function(){if(!this.visible){if(this.dom){GUI.show(this.dom);}
this.visible=true;}},hide:function(){if(this.visible){if(this.dom){GUI.hide(this.dom);}
this.visible=false;}},prepareFx:function(){if(!this.config.height&&!this.fx.isRunning()){if(this.contentHeight==null){this.updateContentHeight();this.fx.clearSubjects();this.fx.addSubject(new NumericalStyleSubject($(this.contentId),'height',0,this.contentHeight));}
if(this.collapsed){this.fx.state=1.0;}}},attachEventListeners:function(){Event.observe($(this.daysTableId),'click',this.dayClickListener);Event.observe($(this.nextBtnId),'click',this.nextBtnClickListener);Event.observe($(this.prevBtnId),'click',this.prevBtnClickListener);Event.observe($(this.todayBtnId),'click',this.todayBtnClickListener);if(GUI.isIE){Event.observe(GUI.$(this.daysTableId),'mouseover',this.mouseOverListener);Event.observe(GUI.$(this.daysTableId),'mouseout',this.mouseOutListener);}},removeEventListeners:function(){Event.stopObserving($(this.daysTableId),'click',this.dayClickListener);Event.stopObserving($(this.nextBtnId),'click',this.nextBtnClickListener);Event.stopObserving($(this.prevBtnId),'click',this.prevBtnClickListener);Event.stopObserving($(this.todayBtnId),'click',this.todayBtnClickListener);if(GUI.isIE){Event.stopObserving(GUI.$(this.daysTableId),'mouseover',this.mouseOverListener);Event.stopObserving(GUI.$(this.daysTableId),'mouseout',this.mouseOutListener);}},setDate:function(date){this.date=new Date(date.toDateString());this.curYear=date.getFullYear();this.curMonth=date.getMonth();this.curDay=date.getDate();if(this.dom){this.update();}},dayClickHandler:function(e){e=GUI.Event.extend(e);var td=e.target.findParent('TD',GUI.$(this.daysTableId));if(td){GUI.Dom.extend(td);if(td.parentNode.parentNode.tagName.toLowerCase()=='thead'){return;}
if(td.hasClass('today')){var day=parseInt(td.firstChild.firstChild.innerHTML,10);}else{var day=parseInt(td.innerHTML,10);}
if(day&&!td.hasClass('disable')){this.curDay=day;this.date=new Date(this.curYear,this.curMonth,day);this.fireEvent('change',this,this.date);this.fireEvent('dayClick',this,this.date);}}},nextBtnClickHandler:function(e){var newDate=new Date(this.curYear,this.curMonth+1,this.curDay);this.setDate(newDate);},prevBtnClickHandler:function(e){var newDate=new Date(this.curYear,this.curMonth-1,this.curDay);this.setDate(newDate);},todayBtnClickHandler:function(e){var date=new Date();if((this.curYear==date.getFullYear())&&(this.curMonth==date.getMonth())){this.setDate(date);this.fireEvent('change',this,this.date);this.fireEvent('dayClick',this,this.date);}else{this.setDate(date);}},getEventCell:function(e){var target=GUI.getEventTarget(e);return GUI.findParentByTag(target,'td',GUI.$(this.daysBodyId));},onMouseOver:function(e){var td=this.getEventCell(e);if(td){if(td.parentNode.parentNode.tagName.toLowerCase()=='thead'){return;}
if(GUI.isMouseEnter(td,e)){GUI.Dom.addClass(td,'hover');}}},onMouseOut:function(e){var td=this.getEventCell(e);if(td){if(td.parentNode.parentNode.tagName.toLowerCase()=='thead'){return;}
if(GUI.isMouseLeave(td,e)){GUI.Dom.removeClass(td,'hover');}}}};Object.extend(Calendar.prototype,superproto);Object.extend(Calendar.prototype,prototype);GUI.Calendar=Calendar;})();

(function()
{var ColorPanel=Class.create(GUI.Utils.Observable,{cls:'x-colorpanel',visible:true,holder:null,value:null,style:null,clickEvent:'click',imgPath:window.JSGUI_IMAGES_PATH+'x-layout/',columns:10,rgbRe:/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i,hexRe:/^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,template:'<div class="<% print(data.cls); if (data.style) { print(" " + data.style); } %>">'+'<table class="x-calendar">'+'<tr class="x-cal-top"><td>'+'<div class="x-cal-l"><div class="x-cal-r"><div class="x-cal-c"></div></div></div>'+'</td></tr>'+'<tr class="x-cal-mdl"><td>'+'<div class="x-cal-l"><div class="x-cal-r"><div class="x-cal-c">'+'<div id="<%=data.phId%>" class="x-colpick">'+'<table>'+'<thead><tr><td colspan="<%=data.columns%>"><span><%=i18n.GUI_THEME_COLORS%></span></td></tr></thead>'+'<tbody>'+'<tr class="x-colpick-fewcol">'+'<% for (var i=0, len=data.columns; i<len; i++) { %>'+'<td><a style="background-color: #<%=data.themeColors[i] %>;"></a></td>'+'<% } %>'+'</tr>'+'<tr class="x-colpick-manycol">'+'<% for (var i=0, j, rows, index, columns=data.columns; i<columns; i++) { '+'rows = Math.ceil(data.themeColors.length / columns); %>'+'<td>'+'<% for (j = 1; j < rows; j++) {'+'index = i + j * columns; %>'+'<a '+'<% if (j == 1) { %>class="fst"<% }'+'else if (j == rows) { %>class="lst" <% } %>'+' style="background-color: #<%=data.themeColors[index] %>;"></a>'+'<% } %>'+'</td>'+'<% } %>'+'</tr>'+'</tbody>'+'<tfoot>'+'<tr class="x-colpick-ftr-ttl"><td colspan="<%=data.columns%>"><span><%=i18n.GUI_STANDARD_COLORS%></span></td></tr>'+'<tr class="x-colpick-defcol">'+'<% for (var i=0, len=data.columns; i<len; i++) { %>'+'<td><a style="background-color: #<%=data.defaultColors[i] %>;"></a></td>'+'<% } %>'+'</tr>'+'</tfoot>'+'</table>'+'</div></div></div></div></td></tr>'+'<tr class="x-cal-btm"><td>'+'<div class="x-cal-l"><div class="x-cal-r"><div class="x-cal-c"></div></div></div>'+'</td></tr></table></div>',elementType:'GUI.ColorPanel',initialize:function(config)
{this.themeColors=['ffffff','000000','eeece1','1f497d','4f81bd','c0504d','9bbb59','8064a2','4bacc6','fff000','f2f2f2','7f7f7f','ddd9c3','c6d9f0','dbe5f1','f2dcdb','ebf1dd','e5e0ec','dbeef3','fdeada','d8d8d8','595959','c4bd97','8db3e2','b8cce4','e5b9b7','d7e3bc','ccc1d9','b7dde8','fbd5b5','bfbfbf','3f3f3f','938953','548dd4','95b3d7','d99694','c3d69b','b2a2c7','92cddc','fac08f','a5a5a5','262626','494429','17365d','366092','953734','76923c','5f497a','31859b','e36c09','7f7f7f','0c0c0c','1d1b10','0f243e','244061','632423','4f6128','3f3151','205867','974806'];this.defaultColors=['c00000','f00000','ffc000','ff0000','92d050','00b050','00b0f0','0070c0','002060','7030a0'];this.id=GUI.getUniqId('colorpanel-');this.addEvents({select:true});if(config){Object.extend(this,config);}
ColorPanel.superclass.initialize.call(this);this.phId=this.id+'-ph';},destroy:function(){this.purgeListeners();if(this.dom){this.removeEventListeners();GUI.destroyNode(this.dom);this.dom=this.phEl=null;}},render:function(to){if(this.dom){this.unrender();}
var html=GUI.Template(this.template,{data:this,i18n:GUI.i18n},this.elementType);this.dom=GUI.Dom.append(GUI.$(to),html);GUI.Dom.extend(this.dom);this.phEl=GUI.$(this.phId);if(!this.visible){GUI.hide(this.dom);}
this.attachEventListeners();},unrender:function(){if(this.dom){this.removeEventListeners();GUI.destroyNode(this.dom);this.dom=this.phEl=null;}},show:function(){if(!this.visible){if(this.dom){GUI.show(this.dom);}
this.visible=true;}},hide:function(){if(this.visible){if(this.dom){GUI.hide(this.dom);}
this.visible=false;}},attachEventListeners:function(){this.phEl.on(this.clickEvent,this.colorClickHandler,this);},removeEventListeners:function(){this.phEl.un(this.clickEvent,this.colorClickHandler,this);},setColor:function(color){this.value=color;if(this.dom){}},toColorPart:function(number){if(number>255){number=255;}
var digits=number.toString(16);if(number<16){return'0'+digits;}
return digits;},parseColor:function(string){var color='',match;if(match=this.rgbRe.exec(string)){var part;for(var i=1;i<=3;i++){part=Math.max(0,Math.min(255,parseInt(match[i])));color+=this.toColorPart(part);}
return color;}
if(match=this.hexRe.exec(string)){if(match[1].length==3){for(var i=0;i<3;i++){color+=match[1].charAt(i)+match[1].charAt(i);}
return color;}
return match[1];}
return false;},colorClickHandler:function(e){e=GUI.Event.extend(e);e.preventDefault();var target=e.target,bgColor=target.style.backgroundColor;if((target.nodeName==='A')&&bgColor){var value=this.parseColor(bgColor);if(value){this.setColor(value);this.fireEvent('select',this,this.value);}}}});GUI.ColorPanel=ColorPanel;})();

(function()
{var Container=Class.create(GUI.Utils.Observable,{elementType:'GUI.Container',imgPath:window.JSGUI_IMAGES_PATH+'x-layout/',template:'<table class="<%=data.cls%>"><tr><td><div class="x-main-container-top"><div class="x-main-container-l">'+'<div class="x-main-container-r"><div class="x-main-container-c"/></div></div></div></div>'+'<div class="x-main-container-mdl"><div class="x-main-container-l">'+'<div class="x-main-container-r"><div class="x-main-container-c">'+'<div class="main-pad-header"><table class="pad-header"><tr><td class="pad-header">'+'<% if (data.captionImage) { %>'+'<img class="pad-header" alt="" src="<%=data.captionImage%>" />'+'<% } %>'+'<span id="<%=data.captionId%>" class="pad-title"><%=data.caption%></span>'+'</td><td id="<%=data.toolBoxId%>" rowspan="2" class="ico"></td></tr>'+'<tr><td><div id="<%=data.pathId%>"></div></td></tr></table></div>'+'<div id="<%=data.containerId%>" class="x-main-container-holder"></div>'+'</div></div></div></div>'+'<div class="x-main-container-btm">'+'<div class="x-main-container-l"><div class="x-main-container-r">'+'<div class="x-main-container-c"/></div></div></div></td></tr></table>',name:null,caption:'',captionImage:null,path:null,icon:null,content:'',visible:true,cls:'x-main-container',initialize:function(config){if(config){Object.extend(this,config);}
Container.superclass.initialize.call(this);this.getId();this.toolBoxId=this.id+'-toolbox';this.containerId=this.id+'-container';this.captionId=this.id+'-container-caption';this.pathId=this.id+'-container-path';if(this.toolbox){this.toolBox=new GUI.ToolBox(this.toolbox);}
this.addEvents({});if(this.name){GUI.ComponentMgr.register(this.name,this);}else{GUI.ComponentMgr.register(this);}},getId:function(){return this.id||(this.id="jsgui-cmp-"+(++GUI.Component.AUTO_ID));},destroy:function(){if(this.dom){this.removeEventListeners();if(this.toolBox){this.toolBox.destroy(true);}
GUI.destroyNode(this.dom);this.dom=this.pathEl=this.captionEl=this.content=null;}
GUI.ComponentMgr.unregister(this);GUI.destroyObject(this);},render:function(to){if(this.dom){this.removeEventListeners();GUI.destroyNode(this.dom);this.dom=null;}
var cfg=this.config;var div=document.createElement('DIV');div.id=this.id;div.className=this.cls;if(!this.visible){GUI.hide(div);}
var html=GUI.Template(this.template,{data:this},this.elementType);to=GUI.$(to);if(GUI.isIE){to.appendChild(div);div.innerHTML=html;}else{div.innerHTML=html;to.appendChild(div);}
this.dom=div;this.captionEl=GUI.$(this.captionId);this.pathEl=GUI.$(this.pathId);if(this.toolBox){this.toolBox.render(this.toolBoxId);}
this.renderContent();if(this.icon){this.captionEl.style.backgroundImage='url('+this.icon+')';}
this.attachEventListeners();this.rendered=true;},renderPath:function(){if(GUI.isArray(this.path)&&this.dom){if(this.path.length){var o=[],item,i;for(i=0,len=this.path.length;i<len-1;i++){item=this.path[i];o.push('<li><a id="'+item.id+'" href="#">'+item.name+'</a></li>');}
if(i==len-1){item=this.path[i];o.push('<li>'+item.name+'</li>');}
o='<ul class="main-pad-header-menu">'+
o.join('<li><img src="'+this.imgPath+'mainpad-header-ttl-seprtr.gif" alt="" /></li>')+'</ul>';this.pathEl.innerHTML=o;}else{this.pathEl.innerHTML='';}}},setPath:function(path){if(GUI.isArray(path)&&path.length){this.path=path;var len=path.length;while(len--){path[len].id=GUI.getUniqId('x-path-');}}
this.renderPath();},onPathClick:function(e){e=GUI.Event.extend(e);e.preventDefault();var target=e.target,itemNode=target&&target.findParent('A',GUI.$(this.pathId));if(itemNode){var path=this.path,len=path.length;while(len--){var elem=path[len];if(elem.id==itemNode.id){if(GUI.isFunction(elem.onClick)){elem.onClick(elem);}}}}},show:function(){if(this.dom&&!this.visible){GUI.show(this.dom);this.visible=true;}},hide:function(){if(this.dom&&this.visible){GUI.hide(this.dom);this.visible=false;}},renderContent:function(content){var cfg=this.config;if(content){cfg.content=content;}
if(GUI.isString(this.content)){GUI.$(this.containerId).innerHTML=this.content;}else if(GUI.isFunction(this.content.render)){this.content.render(this.containerId);}},getContentId:function(){return this.containerId;},setCaption:function(caption){this.caption=caption;if(this.dom){this.captionEl.innerHTML=caption;}},attachEventListeners:function(){this.pathEl.on('click',this.onPathClick,this);},removeEventListeners:function(){this.pathEl.un('click',this.onPathClick,this);},getDom:function(){return this.dom;},setSize:function(size){}});GUI.Container=Container;})();

(function(){var GridFiltersLayout=Class.create(GUI.Utils.Draggable,{initialize:function(config){var defCfg={holder:null,toolbar:null,filtertabs:null,grid:null,editable:false,paging:null,loadOnRender:true,resizer:false,toolbarId:GUI.getUniqId('gfl-toolbar-'),tabbarId:GUI.getUniqId('gfl-tabbar-'),panelId:GUI.getUniqId('gfl-panel-'),gridId:GUI.getUniqId('gfl-grid-'),dd:{linkedElId:null,dragElId:null,handleElId:null,isTarget:false,moveOnly:true,groups:{'default':true},enableDrag:false,dropReciever:false,dragType:''}};Object.extend(defCfg,config);GridFiltersLayout.superclass.initialize.call(this,defCfg);var cfg=this.config;this.id=GUI.getUniqId('x-globalfilterslayout-');this.resizeElId=this.id+'-resizeEl';cfg.dd.linkedElId=this.resizeElId;cfg.dd.handleElId=this.resizeElId;this.ddConfig=this.config.dd;this.hasToolbar=!!cfg.toolbar;this.hasTabs=(!!cfg.filtertabs)?(!!cfg.filtertabs.length):false;this.toolbar=null;this.tabbar=null;this.filterToolbars=new GUI.Utils.Collection();this.grid=null;this.paging=null;GUI.ComponentMgr.register(this);GUI.registerObject(this);},destroy:function(){if(this.resizer){this.resizer.destroy(true);}
this.filterToolbars.each(function(item){item.destroy(true);});this.filterToolbars.clear();this.filterToolbars=null;if(this.toolbar){this.toolbar.destroy(true);this.toolbar=null;}
if(this.tabbar){this.tabbar.destroy(true);this.tabbar=null;}
if(this.groupActions){this.groupActions.destroy(true);this.groupActions=null;}
if(this.paging){this.paging.destroy(true);this.paging=null;}
if(this.grid){this.grid.destroy(true);this.grid=null;}
var holder=GUI.$(this.config.holder);if(holder){holder.innerHTML='';}
holder=null;GUI.ComponentMgr.unregister(this);GUI.destroyObject(this);},render:function(elem){var cfg=this.config;if(elem!==undefined){cfg.holder=elem;}
var o=[];o.push('<div class="x-cont-l">');o.push('<div class="x-cont-r">');o.push('<div class="x-cont-c">');o.push('<!-- content -->');o.push('<div class="cnt">');if(this.hasTabs||this.hasToolbar){o.push('<table class="gridmenu">');o.push('<tbody><tr class="gridmenu-top"><td class="gridmenu-l"><div></div></td>');o.push('<td class="gridmenu-c gridmenu-toolbar" id="'+cfg.toolbarId+'"></td>');o.push('<td class="gridmenu-c gridmenu-filtertabs" id="'+cfg.tabbarId+'">');o.push('</td><td class="gridmenu-r"><div></div></td></tr>');o.push('<tr class="gridmenu-btm"><td colspan="4" class="gridmenu-c">');o.push('<div class="gridmenu-btm-case-wrap">');o.push('<div class="gridmenu-btm-case" id="'+cfg.panelId+'">');o.push('</div></div></td></tr></tbody></table>');}
o.push('<!-- grid -->');o.push('<div class="x-cont-gridholder" id="'+cfg.gridId+'"></div>');o.push('<!-- /grid -->');o.push('</div>');o.push('</div>');o.push('</div>');o.push('</div>');o=o.join('');$(cfg.holder).innerHTML=o;GUI.addClass($(cfg.holder),'x-filter-grid');if(this.hasToolbar&&(cfg.toolbar instanceof GUI.ToolBar)){this.toolbar=cfg.toolbar;var toolbarHolder=GUI.$(cfg.toolbarId);this.toolbar.render(toolbarHolder);if(!this.hasTabs){toolbarHolder.style.width='100%';}}
if(this.hasTabs){this.tabbar=new GUI.TabBar({className:'x-tabbar x-filters',position:'top',align:'right'});var tabCfg,bar;var panel=$(cfg.panelId);for(var i=0,len=cfg.filtertabs.length;i<len;i++){var cont=document.createElement('div');cont.id=GUI.getUniqId('gfl-filter-cont-');cont.className='cont';cont.style.display='none';panel.appendChild(cont);tabCfg=Object.clone(cfg.filtertabs[i]);tabCfg.assigned=cont.id;if(tabCfg.bar){if(GUI.isArray(tabCfg.bar)){for(var j=0;j<tabCfg.bar.length;j++){bar=tabCfg.bar[j];this.addFilterBar(bar,cont.id);}
GUI.addClass(cont,'x-filter-toolbars');}else{bar=tabCfg.bar;this.addFilterBar(bar,cont.id);}
var clrDiv=document.createElement('div');clrDiv.className='clear';cont.appendChild(clrDiv);delete tabCfg.bar;}
this.tabbar.add(tabCfg.name,new GUI.TabBar.FilterTab(tabCfg));}
var tabbarHolder=GUI.$(cfg.tabbarId);if(!this.hasToolbar){tabbarHolder.style.width='100%';}
this.tabbar.render(tabbarHolder);}
if(cfg.grid){var gridClass=(cfg.editable)?GUI.EditableGrid:GUI.Grid;var plugins,ga;if(GUI.isArray(plugins=cfg.grid.plugins)){var i=plugins.length,ga;while(i--){if(plugins[i]instanceof GUI.Grid.GroupActionsBar){ga=plugins[i];plugins.splice(i,1);break;}}}
ga=cfg.groupActions||ga;if(ga||cfg.paging){cfg.grid.bbar='<table class="bottommenu"><tbody><tr>'+'<td class="bottommenu-l" id="'+this.id+'-group-actions"></td>'+'<td class="bottommenu-r" id="'+this.id+'-paging"></td></tr></tbody></table>';}
this.grid=new gridClass(cfg.grid);if(ga){ga.setGrid(this.grid);this.groupActions=ga;}
this.grid.render(cfg.gridId);if(ga){ga.render(this.id+'-group-actions');ga.update();}
if(cfg.paging){var pagingCfg={};Object.extend(pagingCfg,cfg.paging);pagingCfg.rendererObj=this.grid;this.paging=new GUI.Ajax.Paging(pagingCfg);this.paging.render(this.id+'-paging');if(cfg.loadOnRender){this.paging.load({});}
if(cfg.resizer){this.resizer=new GUI.PagingResizer({paging:this.paging});this.resizer.render(GUI.$(cfg.gridId).parentNode);}}}},addFilterBar:function(bar,id){if(bar.obj instanceof GUI.ToolBar){this.filterToolbars.add(bar.name,bar.obj);bar.obj.render(id);}},getFilterBar:function(name){return this.filterToolbars.get(name);},getId:function(){return this.id;}});window.GridFiltersLayout=GridFiltersLayout;}());

(function()
{var HeaderMenu=Class.create();var superproto=GUI.ToolBar.prototype;var prototype={initialize:function(config){superproto.initialize.call(this,config);var cfg=this.config;Object.extend(cfg,{id:GUI.getUniqId('x-headermenu-'),className:'x-headermenu',position:'horizontal'});Object.extend(this.config,config);if(!GUI.isSet(cfg.align)){cfg.align=(cfg.position=='horizontal')?'left':'top';}
this.elementType='GUI.HeaderMenu';this.addEvents({});},add:function(name,elem){GUI.Bar.prototype.add.apply(this,arguments);if(!this.rendered)return;var li=document.createElement('LI');li.className='header-menu';this.dom.appendChild(li);elem.render(li);},remove:function(key){if(this.rendered){}
GUI.Bar.prototype.remove.apply(this,arguments);},setPosition:function(pos){throw new Error('No setPosition() in HeaderMenu!');},setAlign:function(align){throw new Error('No setAlign() in HeaderMenu!');},_render:function(containerNode){var cfg=this.config;var list=document.createElement('ul');this.dom=list;list.className=this.config.className;containerNode.appendChild(list);this.elements.each(function(elem){var item=document.createElement('li');item.className='x-headermenu';list.appendChild(item);elem.render(item);});GUI.unselectable(this.dom);return this.dom;}};Object.extend(HeaderMenu.prototype,superproto);Object.extend(HeaderMenu.prototype,prototype);GUI.HeaderMenu=HeaderMenu;}());

(function()
{var Informer=Class.create(GUI.Utils.Observable,{types:{error:'error',info:'info',help:'help'},small:false,type:'error',caption:'',text:'',holder:null,cls:'x-informer',autoHide:false,hideDelay:5,visible:true,elementType:'GUI.Informer',hideOnClick:false,closeButton:false,timerId:null,template:'<div id="<%=id%>" class="<%=cls%>" <%=style%> ><div class="informer-top">'+'<div class="informer-r"><div class="inform-r"></div></div></div>'+'<div class="informer-mdl"><div class="informer-container">'+'<img class="informer-icon" src="'+GUI.emptyImageUrl+'" alt="" />'+'<%=icons%>'+'<span class="inform informer-caption"></span>'+'<div class="informer-container-p"></div>'+'</div></div><div class="informer-btm"><div class="informer-r">'+'<div class="inform-r"></div></div></div>',renderMethod:'append',initialize:function(config){if(config){Object.extend(this,config);}
this.getId();this.hideDelegate=this.hide.bind(this);this.addEvents('click');Informer.superclass.initialize.call(this);GUI.ComponentMgr.register(this);GUI.registerObject(this);},getId:function(){return this.id||(this.id=GUI.getUniqId('x-informer-'));},destroy:function(){GUI.ComponentMgr.unregister(this);this.unrender();},render:function(to){if(to){this.holder=to;}else{to=this.holder;}
to=GUI.$(to);if(!to){throw new Error('Holder is null');}
var tpl={},cls=this.cls,clsplus=this.types[this.type];if(clsplus){cls+=' '+clsplus;if(this.small){cls+='-small';}}
tpl.id=this.id;tpl.cls=cls;tpl.style=(!this.visible)?'style="display: none;"':'';tpl.icons=this.closeButton?'<img width="17" height="17" class="x-informer-button-close" src="'+GUI.emptyImageUrl+'" alt="" />':'';this.dom=GUI.Dom[this.renderMethod](to,GUI.Template(this.template,tpl,this.elementType));GUI.Dom.extend(this.dom);this.rendered=true;if(this.caption){this.setCaption(this.caption);}
if(this.text){this.setText(this.text);}
if(this.hideOnClick){this.dom.on('click',this.onClick,this);GUI.Popup.Hint.add(this.dom,GUI.i18n.GUI_CLICK_TO_HIDE);this.dom.setAttribute('followmouse','true');}else if(this.closeButton){this._closeBtnEl=this.dom.findDescedent('img.x-informer-button-close');GUI.$(this._closeBtnEl).on('click',this.onClick,this);}},onClick:function(){this.hide();this.fireEvent('click',this);},unrender:function(){if(!this.rendered){return;}
this.dom.un();if(this._closeBtnEl){this._closeBtnEl.un();}
GUI.destroyNode(this.dom);this.dom=this.captionEl=this.textEl=this._closeBtnEl=null;this.rendered=false;},show:function(cfg){if(this.dom){this.hide();}
if(cfg){Object.extend(this,cfg);}
this.visible=true;this.render();if(this.autoHide){this.timerId=window.setTimeout(this.hideDelegate,this.hideDelay*1000);}},hide:function(){if(this.timerId){window.clearTimeout(this.timerId);this.timerId=null;}
this.unrender();this.visible=false;},setType:function(type){this.type=type;if(this.dom){var cls=this.cls;var clsplus=this.types[this.type];if(clsplus){cls+=' '+clsplus;if(this.small){cls+='-small';}}
this.dom.className=cls;}},setCaption:function(caption){this.caption=caption;if(this.dom){if(this.captionEl||(this.captionEl=this.dom.findDescedents('span.informer-caption')[0])){this.captionEl.innerHTML=caption;}}},setText:function(text){this.text=text;if(this.dom){if(this.textEl||(this.textEl=this.dom.findDescedents('div.informer-container-p')[0])){this.textEl.innerHTML=text;}}},isDisplayed:function(){return!!this.dom&&this.visible;}});GUI.Informer=Informer;}());

(function()
{var Layout=Class.create();var superproto=GUI.Utils.Observable.prototype;var prototype={initialize:function(config)
{superproto.initialize.call(this);this.config={name:null,headermenu:null,menu:null,layouts:null,footer:'',rememberLeftSideState:true,advSearchBtn:false,leftSideWidth:200};var cfg=this.config;Object.extend(cfg,config);if(cfg.name){GUI.ComponentMgr.register(cfg.name,this);}
this.addEvents({layoutChange:true,beforeLayoutChange:true,afterRender:true,sameLayout:true});},render:function(){var cfg=this.config;var items=[];if(GUI.isArray(cfg.menu)){this.mainMenu=new GUI.MainMenu({items:cfg.menu,onClick:this.handleMenuClick.bind(this),advSearchBtn:cfg.advSearchBtn});items.push({ph:'mainmenu',content:this.mainMenu});}else if(cfg.menu instanceof GUI.MainMenu){this.mainMenu=cfg.menu;this.mainMenu.on('click',this.handleMenuClick.bind(this));items.push({ph:'mainmenu',content:this.mainMenu});}
if(GUI.isArray(cfg.headermenu)){this.headerMenu=new GUI.HeaderMenu({elements:cfg.headermenu});items.push({ph:'headermenu',content:this.headerMenu});}
if(GUI.isString(cfg.footer)){items.push({ph:'footer',content:cfg.footer});}
this.layout=new GUI.AppLayout({leftSideWidth:cfg.leftSideWidth,rememberLeftSideState:cfg.rememberLeftSideState,items:items,logoHref:cfg.logoHref,logoImg:cfg.logoImg});this.layouts={};if(GUI.isArray(cfg.layouts)){var i=cfg.layouts.length;while(i--){var layout=cfg.layouts[i];this.layouts[layout.name]=layout;this.layout.add(layout);if(layout.visible){this.currentLayout=layout.name;}}}
this.fireEvent('afterRender',this);},destroy:function(){if(this.config.name){GUI.ComponentMgr.unregister(this);}},switchTo:function(name){if(this.currentLayout==name){this.fireEvent('sameLayout',this,name);return;}
if(!this.fireEvent('beforeLayoutChange',this,this.currentLayout,name)){return;}
if(this.currentLayout){this.layout.hide(this.currentLayout);}
if(this.layout.show(name)){var oldLayout=this.currentLayout;this.currentLayout=name;this.fireEvent('layoutChange',this,oldLayout,name);}else{this.currentLayout=null;}},handleMenuClick:function(menu,item){var name=item.connectedLayout;if(name){this.switchTo(name);}}};Object.extend(Layout.prototype,superproto);Object.extend(Layout.prototype,prototype);GUI.Layout=Layout;})();

(function()
{var MainMenu=Class.create(GUI.Utils.Observable,{imgPath:window.JSGUI_IMAGES_PATH+'x-mainmenu/',initialize:function(config)
{MainMenu.superclass.initialize.call(this);this.config={id:GUI.getUniqId('x-menu-'),className:'mainmenu',classNameAutocompliter:'autocompliterMainMenu',items:[],openOnHover:false,searchBar:true,advSearchBtn:false,autocompliterAdvSearch:false,showDescription:true};var cfg=this.config;Object.extend(cfg,config);this._indexById={};this._indexByName={};var i=cfg.items.length;while(i--){var item=cfg.items[i];var id=GUI.getUniqId('x-mainmenu-item-');item.id=id;this._indexById[id]=i;if(item.name){this._indexByName[item.name]=item;}
if(item.sub){item.sub=new GUI.Popup.Menu(item.sub);}}
this.searchInputId=cfg.id+'-search-input';this.searchButtonId=cfg.id+'-search-button';this.advSearchButtonId=cfg.id+'-advsearch-button';if(cfg.autocompliterAdvSearch){this.searchAutocompliterId=cfg.id+'-search-autocompliter';this.autocompliter=new GUI.Forms.Autocompleter(cfg.paramsAutocompliter);}
this.addEvents({click:true,search:true,advsearch:true});if(GUI.isFunction(cfg.onClick)){this.on('click',cfg.onClick);}},render:function(to){if(this.dom){this.removeEventListeners();GUI.destroyNode(this.dom);this.dom=null;}
this.visible=false;var cfg=this.config;var o=[];o.push('<table class="',cfg.className,'"><tbody><tr class="mainmenu">');for(var i=0,len=cfg.items.length;i<len;i++){var item=cfg.items[i];o.push('<td class="mainmenu"');if(item.hidden){o.push(' style="display:none;"');}
o.push('><div id="',item.id,'" class="button"><div class="button-r">');o.push('<div class="button-c"><a class="mainmenu" href="#">',item.caption,'</a></div>');o.push('</div></div></td>');if(i<len-1){o.push('<td');if(item.hidden){o.push(' style="display:none;"');}
o.push('><div class="mainmenu-sep"></div></td>');}}
o.push('<td class="search-bar">');if(cfg.searchBar){o.push('<div class="search-bar"><table class="search-bar"><tr class="searchbar">');o.push('<td class="search-bar"><img class="search-bar-left" src="'+GUI.emptyImageUrl+'" alt="" title="" /></td>');if(cfg.autocompliterAdvSearch){o.push('<td class="search-bar '+cfg.classNameAutocompliter+'" id="'+this.searchAutocompliterId+'"></td>');}
else{o.push('<td class="search-bar"><input class="search-bar" id="'+this.searchInputId+'"  name="" type="text" /></td>');}
o.push('<td class="search-bar"><img id="'+this.searchButtonId+'" class="search-btn" src="'+GUI.emptyImageUrl+'" alt="" title="" /></td>');if(cfg.advSearchBtn){o.push('<td><img id="'+this.advSearchButtonId+'" class="advsearch-btn" src="'+GUI.emptyImageUrl+'" alt="" title="" />');}
o.push('</tr></table><div class="clear"></div></div>');}
o.push('</td></tr></tbody></table>');to.innerHTML=o.join('');this.dom=$(to);this.attachEventListeners();if(cfg.searchBar&&cfg.autocompliterAdvSearch){this.autocompliter.render(this.searchAutocompliterId);}},getItemByName:function(name){return this._indexByName[name];},hideItem:function(name){var item=this.getItemByName(name);if(item){item.hidden=true;if(this.dom){var td=GUI.$(item.id).parentNode;GUI.hide(td);if(td.nextSibling&&!td.nextSibling.className){GUI.hide(td.nextSibling);}}}},showItem:function(name){var item=this.getItemByName(name);if(item){item.hidden=false;if(this.dom){var td=GUI.$(item.id).parentNode;GUI.show(td);if(td.nextSibling&&!td.nextSibling.className){GUI.show(td.nextSibling);}}}},showSubMenu:function(itemId){var item=this.getItemById(itemId),sub=item.sub;if(this.subMenu&&(this.subMenu!=sub)){this.hideSubMenu();}
var itemNode=GUI.$(itemId);sub.alignTo(itemNode,'tl-bl?',GUI.isIE?[-2,-3]:[-2,-3]);sub.show(this,itemId);this.subMenu=sub;this.activeItem=itemId;itemNode.addClass('active');},hideSubMenu:function(){if(this.subMenu){this.subMenu.hide();this.subMenu=null;}},hideParent:function(){},onChildHide:function(menu){if(this.activeItem){GUI.$(this.activeItem).removeClass('active');this.activeItem=null;}},getRootMenu:function(){return this;},setShowDescription:function(val){this.config.showDescription=val;},getItemById:function(id){var index=this._indexById[id];if(GUI.isNumber(index)){return this.config.items[this._indexById[id]];}
return false;},attachEventListeners:function(){GUI.Dom.extend(this.dom);this.dom.on('click',this.menuClickHandler,this);this.dom.on('mouseover',this.mouseOverHandler,this);this.dom.on('mouseout',this.mouseOutHandler,this);if(this.config.searchBar){if(!this.config.autocompliterAdvSearch)GUI.$(this.searchInputId).on('keyup',this.searchKeyUpHandler,this);GUI.$(this.searchButtonId).on('click',this.searchClickHandler,this);if(this.config.advSearchBtn){GUI.$(this.advSearchButtonId).on('click',this.advSearchClickHandler,this);}}},removeEventListeners:function(){this.dom.un();if(this.config.searchBar){if(!this.config.autocompliterAdvSearch)GUI.$(this.searchInputId).un('keyup',this.searchKeyUpHandler,this);GUI.$(this.searchButtonId).un('click',this.searchClickHandler,this);if(this.config.advSearchBtn){GUI.$(this.advSearchButtonId).un('click',this.advSearchClickHandler,this);}}},menuClickHandler:function(e){e=new GUI.ExtendedEvent(e);e.stop();var itemDiv=e.getTarget().findParent('DIV',this.dom,'button');if(!itemDiv){return;}
var item=this.getItemById(itemDiv.id);if(item.sub&&!this.config.openOnHover){this.showSubMenu(itemDiv.id);}else{if(GUI.isFunction(item.handler)){item.handler(item);}}
this.fireEvent('click',this,item);},mouseOverHandler:function(e){e=GUI.Event.extend(e);var itemDiv=e.target.findParent('div',this.dom,'button');if(itemDiv&&e.isMouseEnter(itemDiv)){var item=this.getItemById(itemDiv.id);if(this.subMenu&&(this.subMenu!=item.sub)){}
if(item.sub){if(!item.sub.isVisible()&&this.config.openOnHover){this.showSubMenu(itemDiv.id);}}
if(GUI.isIE){itemDiv.addClass('hover');}}},mouseOutHandler:function(e){e=GUI.Event.extend(e);var itemDiv=e.target.findParent('DIV',this.dom,'button');if(itemDiv&&e.isMouseLeave(itemDiv)){if(GUI.isIE){itemDiv.removeClass('hover');}
if(this.subMenu&&this.subMenu.dom){var relatedTarget=e.getRelatedTarget();if(!GUI.contains(this.subMenu.dom,relatedTarget)){this.hideSubMenu();}}}},searchClickHandler:function(e){if(this.config.autocompliterAdvSearch){this.fireEvent('search',this,this.autocompliter.getValue());}
else{this.fireEvent('search',this,GUI.$(this.searchInputId).value);}},searchKeyUpHandler:function(e){e=GUI.Event.extend(e);if(e.getKey()==e.KEY_RETURN){if(this.config.autocompliterAdvSearch)this.fireEvent('search',this,this.autocompliter.getValue());else this.fireEvent('search',this,GUI.$(this.searchInputId).value);}},advSearchClickHandler:function(e){if(this.config.autocompliterAdvSearch){this.fireEvent('advsearch',this,this.autocompliter.getValue());}
else{this.fireEvent('advsearch',this,GUI.$(this.searchInputId).value);}},getDom:function(){return this.dom;}});GUI.MainMenu=MainMenu;})();

(function()
{var QuickBar=Class.create();var superproto=GUI.Utils.Observable.prototype;var prototype={imgPath:window.JSGUI_IMAGES_PATH+'x-layout/',template:'<div class="quickbar-top"><div class="quickbar-l"><div class="quickbar-r">'+'<div class="quickbar-c"></div></div></div></div><div class="quickbar-mdl">'+'<div id="{this.titleId}" class="quickbar-title"><div class="quickbar-l">'+'<div class="quickbar-r"><div class="quickbar-c">'+'<table class="quickbar-title"><col/><col/><col/><col/><tr>'+'<td class="quickbar-title-l"><div class="title-l"></div></td>'+'<td class="quickbar-title-text"><div class="title-text" id="{this.captionId}">{icon}{cfg.caption}</div></td>'+'<td id="{this.toolBoxId}" class="quickbar-title-ico"></td>'+'<td class="quickbar-title-r"><div class="title-r"></div></td></tr>'+'</table></div></div></div></div>'+'<div class="quickbar-l"><div class="quickbar-r"><div class="quickbar-c">'+'<div class="quickbar-content-holder"><div id="{this.contentId}" class="quickbar-content">'+'<div id="{this.bodyId}" class="quickbar-content-case" >'+'<div class="quickbar-tools"><div id="{this.toolbarId}" class="quickbar-toolbar"></div></div>'+'<div class="quickbar-content-data-holder">'+'<div id="{this.contentDataId}" class="{cfg.contentcls}" style="{cfg.contentStyle}">'+'{cfg.content}</div></div></div></div></div></div></div></div></div>'+'<div class="quickbar-btm"><div class="quickbar-l"><div class="quickbar-r">'+'<div class="quickbar-c"></div></div></div></div>',initialize:function(config)
{superproto.initialize.call(this);this.config={holder:null,height:null,icon:null,caption:'',content:'',visible:true,lazyRender:true,canCollapse:true,collapsableCls:'quickbar-collapsable',collapsed:false,animate:window.GUI_FX_ANIMATION==true,style:null,contentcls:'quickbar-content-data',contentStyle:'',toolbar:null,toolbarHeight:null,headerHeight:null,hiddenTitle:false,name:null,toolbox:null,reserveSpaceForAnimation:false};var cfg=this.config;Object.extend(cfg,config);var id=this.getId();this.titleId=id+'-title';this.captionId=id+'-caption';this.imgId=id+'-ico';this.bodyId=id+'-body';this.toolbarId=id+'-toolbar';this.toolBoxId=id+'-toolbox';this.contentId=id+'-content';this.contentDataId=id+'-contentdata';this.visible=cfg.visible;this.iconOpen=this.imgPath+'quickbar-ico-open.gif';this.iconClose=this.imgPath+'quickbar-ico-close.gif';if(!cfg.style){cfg.headerHeight=28;}else if(cfg.style.indexOf('quickbar-blue')>=0){cfg.headerHeight=28;this.iconOpen=this.imgPath+'quickbar-ico-open3.gif';this.iconClose=this.imgPath+'quickbar-ico-close3.gif';}else if(cfg.style.indexOf('quickbar-gray')>=0){cfg.headerHeight=33;}else if(cfg.style.indexOf('quickbar-light-blue')>=0){cfg.headerHeight=28;this.iconOpen=this.imgPath+'quickbar-ico-open2.gif';this.iconClose=this.imgPath+'quickbar-ico-close2.gif';}else if(cfg.style.indexOf('quickbar-light')>=0){cfg.headerHeight=28;this.iconOpen=this.imgPath+'quickbar-ico-open2.gif';this.iconClose=this.imgPath+'quickbar-ico-close2.gif';}else if(cfg.style.indexOf('quickbar-light-green')>=0){cfg.headerHeight=28;this.iconOpen=this.imgPath+'quickbar-ico-open2.gif';this.iconClose=this.imgPath+'quickbar-ico-close2.gif';}else if(cfg.style.indexOf('quickbar-cloud')>=0){cfg.headerHeight=28;this.iconOpen=this.imgPath+'quickbar-ico-open2.gif';this.iconClose=this.imgPath+'quickbar-ico-close2.gif';}else if(cfg.style.indexOf('quickbar-sky')>=0){cfg.headerHeight=28;this.iconOpen=this.imgPath+'quickbar-ico-open2.gif';this.iconClose=this.imgPath+'quickbar-ico-close2.gif';}else if(cfg.style.indexOf('quickbar-orange')>=0){cfg.headerHeight=28;this.iconOpen=this.imgPath+'quickbar-ico-open2.gif';this.iconClose=this.imgPath+'quickbar-ico-close2.gif';}else{if(!GUI.isNumber(cfg.headerHeight)){throw new Error('Quickbar: You have to specify headerHeight when using custom style: '+cfg.style);}}
this.bodyHeight=null;this.toolbar=null;this.collapsed=cfg.collapsed;if(GUI.isArray(cfg.toolbar)){if(!GUI.isSet(cfg.toolbarHeight)){throw new Error('Quickbar: You have to specify toolbarHeight when using toolbar!');}
this.toolbar=new GUI.ToolBar({elements:cfg.toolbar});}else{cfg.toolbarHeight=0;}
if(cfg.toolbox){var toolBoxCfg=Object.clone(cfg.toolbox);}else{var toolBoxCfg={items:[]};}
if(cfg.canCollapse){toolBoxCfg.items.push({name:'collapse',iconClass:'quickbar-icon-collapse',hidden:true,scope:this,onClick:this.clickHandler});toolBoxCfg.items.push({name:'expand',iconClass:'quickbar-icon-expand',hidden:true,scope:this,onClick:this.clickHandler});}
if(cfg.toolbox||cfg.canCollapse){this.toolBox=new GUI.ToolBox(toolBoxCfg);}
this.addEvents({collapse:true,expand:true,resize:true});if(cfg.animate){var self=this;this.addEvents({fxComplete:true});var fxConfig={duration:500,scope:this,onComplete:function(fx){this.fireEvent('fxComplete',fx);}};this.fx=new Animator(fxConfig);this.on('fxComplete',function(fx){if(fx.state){this._expand();}else{this._collapse();}});}
if(!cfg.lazyRender){this.render();}
if(cfg.name){GUI.ComponentMgr.register(cfg.name,this);}else{GUI.ComponentMgr.register(this);}},getId:function(){return this.config.id||(this.config.id="jsgui-cmp-"+(++GUI.Component.AUTO_ID));},destroy:function(quick){this.config.holder=null;if(this.fx){this.fx.destroy();this.fx=null;}
GUI.ComponentMgr.unregister(this);if(this.toolbar){this.toolbar.destroy(true);this.toolbar=null;}
if(this.toolBox){this.toolBox.destroy(true);this.toolBox=null;}
this.purgeListeners();this.outerDiv=null;if(this.dom){this.removeEventListeners();if(!quick){GUI.destroyNode(this.dom);}
this.dom=null;}},render:function(to){if(this.dom){this.removeEventListeners();GUI.destroyNode(this.dom);this.dom=null;}
var cfg=this.config;var table=document.createElement('TABLE');table.id=this.getId();table.className='quickbar';var tbody=document.createElement('TBODY');var tr=document.createElement('TR');var td=document.createElement('TD');var div=document.createElement('DIV');div.className="quickbar";this.outerDiv=div;GUI.hide(table);if(to){cfg.holder=to;}
$(cfg.holder).appendChild(table);table.appendChild(tbody);tbody.appendChild(tr);tr.appendChild(td);td.appendChild(div);this.dom=GUI.Dom.extend(table);if(GUI.isString(cfg.style)){GUI.Dom.addClass(div,cfg.style);}
var tpl=new GUI.STemplate(this.template,this);tpl.cfg=cfg;tpl.imgPath=this.imgPath;tpl.toolBox=(this.toolBox)?('<div id="'+this.toolBoxId+'"></div>'):'';if(GUI.isString(cfg.icon)&&cfg.icon.length){tpl.icon='<img src="'+cfg.icon+'" align="absmiddle" alt=""/>';}else{tpl.icon='';}
if(cfg.hiddenTitle&&this.collapsed){this.collapsed=false;}
if(cfg.canCollapse){GUI.Dom.addClass(div,cfg.collapsableCls);if(this.collapsed){this.toolBox.hideItem('collapse');this.toolBox.showItem('expand');}else{GUI.Dom.addClass(this.dom,'open');this.toolBox.hideItem('expand');this.toolBox.showItem('collapse');}}
div.innerHTML=tpl.fetch();this.setScrollable(this.config.scrollable);if(cfg.hiddenTitle){GUI.hide(this.titleId);}
if(this.toolbar){this.toolbar.render(this.toolbarId);var clearDiv=document.createElement('div');clearDiv.className='clear';$(this.toolbarId).appendChild(clearDiv);}
if(cfg.canCollapse&&this.collapsed){GUI.hide(this.bodyId);}
if(this.toolBox){this.toolBox.render(this.toolBoxId);}
this.setDimensions(cfg.width,cfg.height);if(this.visible){GUI.show(table);}
this.attachEventListeners();GUI.unselectable(this.titleId);this.rendered=true;},updateContentHeight:function(){var h=this.collapsed?GUI.getFullHeight($(this.bodyId)):$(this.bodyId).getHeight();this.bodyHeight=h;},getBodyHeightFromFull:function(height){height-=this.config.headerHeight;height-=GUI.getVerticalPadding(this.dom);return(height>=0)?height:0;},getFullHeightFromBody:function(height){height+=this.config.headerHeight;height+=GUI.getVerticalPadding(this.dom);return height;},setDimensions:function(width,height){var contentWidth,contentHeight;if(GUI.isSet(width)){this.config.width=width;if(this.dom){var s=$(this.contentDataId).parentNode.style;if(GUI.isNumber(width)){contentWidth=width-2;contentWidth=contentWidth.constrain(0);if(GUI.isBorderBox){s.width=contentWidth+2+'px';}else{s.width=contentWidth+'px';}
if(!GUI.isSet(this.config.scrollable)){this.setScrollable(true);}}else{s.width=contentWidth=width;}}}
if(GUI.isSet(height)){this.config.height=height;if(this.dom){var s=$(this.contentDataId).parentNode.style;if(GUI.isNumber(height)){contentHeight=this.getBodyHeightFromFull(height)-this.config.toolbarHeight-1;contentHeight=contentHeight.constrain(0);s.height=contentHeight+'px';if(!GUI.isSet(this.config.scrollable)){this.setScrollable(true);}}else{s.height=contentHeight=height;}}}
this.fireEvent('resize',width,height);this.fireEvent('contentresize',contentWidth,contentHeight);},fireContentResize:function(){var cfg=this.config,dims={width:cfg.width-2,height:this.getBodyHeightFromFull(cfg.height)-cfg.toolbarHeight-1};if(GUI.isIE){dims.height--;}
this.fireEvent('contentresize',dims.width,dims.height);},setHeight:function(height){this.setDimensions(undefined,height);},setWidth:function(width){this.setDimensions(width,undefined);},setScrollable:function(scr){scr=GUI.isSet(scr)?!!scr:true;this.config.scrollable=scr;if(this.dom){$(this.contentDataId).parentNode.style.overflow=scr?'auto':'hidden';}},show:function(){if(this.dom&&!this.visible){GUI.show(this.dom);this.visible=true;}},hide:function(){if(this.dom&&this.visible){GUI.hide(this.dom);this.visible=false;}},prepareFx:function(){if(this.fx.isRunning()){return;}
var startHeight=(GUI.isIE)?1:0;if(this.config.height){this.fx.clearSubjects();this.fx.addSubject(new NumericalStyleSubject($(this.bodyId),'height',startHeight,this.getBodyHeightFromFull(this.config.height)));}else{if(this.bodyHeight==null){this.updateContentHeight();this.fx.clearSubjects();if(!GUI.isNumber(this.bodyHeight)){alert(this.bodyHeight);}
this.fx.addSubject(new NumericalStyleSubject($(this.bodyId),'height',startHeight,this.bodyHeight));}}
if(this.config.reserveSpaceForAnimation){if(this.config.height!==undefined){var h=this.config.height;}else if(!this.collapsed){var h=GUI.getDimensions(this.outerDiv).width;}else{var h=this.outerDiv.offsetHeight;}
this.outerDiv.style.height=h+'px';}
$(this.contentDataId).parentNode.style.overflow='hidden';if(this.collapsed){this.fx.state=1.0;}},isCollapsed:function(){return this.collapsed;},isExpanded:function(){return!this.collapsed;},collapse:function(){if(!this.config.canCollapse){return 0;}
if(!this.collapsed){if(this.dom){this.toolBox.hideItem('collapse');this.toolBox.showItem('expand');GUI.removeClass(this.dom,'open');this.collapsed=true;if(this.config.animate&&this.fx){this.prepareFx();this.fx.seekTo(0);this.fireEvent('collapse',this);}else{this._collapse();this.fireEvent('collapse',this);}}else{this.collapsed=true;this.fireEvent('collapse',this);}}},_collapse:function(){GUI.hide($(this.bodyId));$(this.bodyId).style.height='';if(!this.config.height){this.suspendEvents();this.setHeight('');this.resumeEvents();}
if(this.config.reserveSpaceForAnimation){this.outerDiv.style.height='';}},expand:function(){if(!this.config.canCollapse){return 0;}
if(this.collapsed){if(this.dom){if(this.config.animate&&this.fx){}
this.toolBox.hideItem('expand');this.toolBox.showItem('collapse');GUI.addClass(this.dom,'open');this.collapsed=false;var cont=GUI.getScrollableContainer(this.dom);if(this.config.animate&&this.fx){this.prepareFx();$(this.bodyId).style.height=(GUI.isIE)?'1px':'0';GUI.show($(this.bodyId));this.fx.seekTo(1);this.fireEvent('expand',this);}else{GUI.show($(this.bodyId));this._expand();this.fireEvent('expand',this);}}else{this.collapsed=false;this.fireEvent('expand',this);}}},fitHeight:function(elem,cont){if(!this.config.height){this.updateContentHeight();}
var eHeight=(this.config.height)?this.config.height:this.getFullHeightFromBody(this.bodyHeight);this.bodyHeight=null;this.dom.parentNode.style.height=GUI.getInnerNodesHeight(this.dom.parentNode)
-this.dom.offsetHeight
+1+eHeight+'px';if(!cont)cont=elem.parentNode;var cTop=cont.scrollTop;var cHeight=$(cont).offsetHeight;var off=GUI.getRelativeOffset(elem,cont);if((off[1]>=cTop)&&(off[1]+eHeight<=cTop+cHeight)){return true;}
if(eHeight<cHeight){cont.scrollTop=off[1]-cHeight+eHeight;}else{cont.scrollTop=off[1];}
return false;},_expand:function(){if(!this.config.height){this.suspendEvents();this.setHeight('');this.resumeEvents();}
$(this.bodyId).style.height='';if(this.config.height){$(this.contentDataId).parentNode.style.overflow='auto';}
GUI.repaint(this.dom);if(this.config.reserveSpaceForAnimation){this.outerDiv.style.height='';}},setCaption:function(text){var cfg=this.config;cfg.caption=text;if(this.dom&&GUI.isString(text)){if(GUI.isString(cfg.icon)&&cfg.icon.length){var icon='<img src="'+cfg.icon+'" align="absmiddle" alt=""/>';}else{var icon='';}
$(this.captionId).innerHTML=icon+text;}},setContent:function(content){this.config.content=content;if(this.dom&&GUI.isString(content)){$(this.contentDataId).innerHTML=content;}
if(!this.config.height){this.bodyHeight=null;}},getContentHolder:function(){return GUI.$(this.contentDataId);},attachEventListeners:function(){if(this.config.canCollapse){var title=GUI.Dom.findDescedents(this.dom,'table.quickbar-title');if(title.length){GUI.Event.on(title[0],'click',this.clickHandler,this);}
title=null;}},removeEventListeners:function(){if(this.config.canCollapse){var title=GUI.Dom.findDescedents(this.dom,'table.quickbar-title');if(title.length){GUI.Event.un(title[0],'click',this.clickHandler,this);}}},clickHandler:function(e){if(this.collapsed){this.expand();}else{this.collapse();}},onResize:function(w,h){},getDom:function(){return this.dom;}};Object.extend(QuickBar.prototype,superproto);Object.extend(QuickBar.prototype,prototype);GUI.QuickBar=QuickBar;})();

(function()
{var Wizard=Class.create();var superproto=GUI.Utils.Observable.prototype;var i18n=GUI.i18n;var prototype={tabTemplate:'<div id="{0}" class="wizard-tab">'+'<div class="wizard-tab-top"><div class="tab-top"></div></div>'+'<div class="wizard-tab-data-case"><div class="wizard-tab-data">'+'<table><tbody><tr>'+'<td class="wizard-tab-radio"><div class="tab-radio"></div></td>'+'<td class="wizard-tab-content"><span class="tab-content">{1}</span>'+'<span class="title">{2}</span>'+'<div id="{0}-info" class="wizard-tab-description">{3}</div>'+'</td></tr></tbody></table></div></div>'+'<div class="wizard-tab-btm"><div class="tab-btm"></div></div></div>',initialize:function(config)
{superproto.initialize.call(this);this.config={id:GUI.getUniqId('x-wizard-'),className:'x-wizard',steps:null,stepTpl:i18n.GUI_WIZARD_TPL,holder:null,name:null,onRender:null,onNextStep:null,onPrevStep:null,onLastStep:null,onBeforeNextStep:null,onBeforePrevStep:null,onBeforeLastStep:null};var cfg=this.config;Object.extend(cfg,config);this.currentStep=-1;this.tabsId=cfg.id+'-tabs';this.addEvents({nextStep:true,prevStep:true,beforeNextStep:true,beforePrevStep:true,render:true,beforeLastStep:true,lastStep:true});if(GUI.isFunction(cfg.onRender)){this.on('render',cfg.onRender);}
if(GUI.isFunction(cfg.onNextStep)){this.on('nextStep',cfg.onNextStep);}
if(GUI.isFunction(cfg.onPrevStep)){this.on('prevStep',cfg.onPrevStep);}
if(GUI.isFunction(cfg.onLastStep)){this.on('lastStep',cfg.onLastStep);}
if(GUI.isFunction(cfg.onBeforeNextStep)){this.on('beforeNextStep',cfg.onBeforeNextStep);}
if(GUI.isFunction(cfg.onBeforePrevStep)){this.on('beforePrevStep',cfg.onBeforePrevStep);}
if(GUI.isFunction(cfg.onBeforeLastStep)){this.on('beforeLastStep',cfg.onBeforeLastStep);}
if(cfg.name){GUI.ComponentMgr.register(cfg.name,this);}},destroy:function(){if(this.dom){this.removeEventListeners();GUI.remove(this.dom);this.dom=null;}},getTabHtml:function(tab){return this.tabTemplate.format(tab.id,tab.shortTitle,tab.title,tab.info||'');},render:function(to){if(this.dom){this.removeEventListeners();GUI.remove(this.dom);this.dom=null;}
this.visible=false;var cfg=this.config;if(to){cfg.holder=to;}else if(cfg.holder){to=cfg.holder;}
to=$(to);if(!to){throw new Error("Wizard: Can't render to null");}
var o=[];o.push('<div id="',cfg.id,'" class="',cfg.className,'">');o.push('<div class="wizard-tabs">');o.push('<div id="',this.tabsId,'" class="wizard-tabs-container">');var tabsHtml=[];var contentHtml=[];for(var i=0,len=cfg.steps.length;i<len;i++){var step=cfg.steps[i];step.number=i+1;step.id=cfg.id+'-step-'+step.number.toString();step.tabId=step.id+'-tab';step.contentId=step.id+'-content';tabsHtml.push(this.getTabHtml({id:step.tabId,shortTitle:step.shortTitle,title:step.title,info:step.descr,step:step.number,hidden:step.hidden}));contentHtml.push('<div id="',step.id,'" class="wizard-content" style="display: none;">');contentHtml.push('<table class="wizard-content-title"><tbody><tr class="content-title">');contentHtml.push('<td class="wizard-content-title-name"><span class="title-name"><b>',step.title,'</b></span>');contentHtml.push('</td><td class="wizard-content-paging"><span class="content-paging">');var tpl=GUI.STemplate(this.config.stepTpl);tpl.step=step.number;tpl.total=len;contentHtml.push(tpl.fetch());contentHtml.push('</span></td></tr></tbody></table>');contentHtml.push('<div id="',step.contentId,'">');if(GUI.isString(step.content)){contentHtml.push(step.content);}
contentHtml.push('</div>');contentHtml.push('</div>');}
o.push(tabsHtml.join(''));o.push('</div></div>');o.push('<div class="wizard-content-container">');o.push(contentHtml.join(''));o.push('</div>');o.push('<div class="clear"/>');if(GUI.isIE){this.dom=$(to);to.innerHTML=o.join('');}else{to.innerHTML=o.join('');this.dom=$(to);}
this.attachEventListeners();this.nextStep();this.fireEvent('render',this);},getStepTabNode:function(step){if(this.dom&&step.id){return GUI.$(step.id+'-tab');}},getStepContentNode:function(step){if(GUI.isString(step)){step=this.getStep(step);}
if(this.dom&&step.id){return GUI.$(step.id+'-content');}},setStep:function(num){if(this.currentStep==num)return;if(this.currentStep>-1&&this.currentStep<this.config.steps.length){var oldStep=this.config.steps[this.currentStep];GUI.removeClass(oldStep.tabId,'active');GUI.hide(oldStep.id);}
this.currentStep=num;if(num>-1&&num<this.config.steps.length){var newStep=this.config.steps[num];if(newStep){GUI.addClass(newStep.tabId,'active');GUI.show(newStep.id);}}},nextStep:function(){if(this.currentStep==this.config.steps.length)return;var curS
