/*
 * Copyright (c) 2005-2006, Image Matters LLC. All Rights Reserved.
 * 
 * This software is distributed under the terms of the LICENSE file
 * included with the program and available here:
 * 
 * http://www.imagemattersllc.com/legal-notice/LICENSE-userSmartsGX.html
 */
namespace("userSmarts.wt.widgets");namespace("userSmarts.wt.widgets");namespace("userSmarts.wt.widgets");userSmarts.wt.widgets.Display=function(root){if(userSmarts.wt.widgets.Display.inst===null){userSmarts.wt.widgets.Display.inst=this;}
this.window=window;this.shells=[];this.root=root;if(!this.root){this.root=document.getElementById("display")||document.documentElement.getElementsByTagName("BODY")[0];}
this.listener=connect(this.window,"onresize",this,this.onResize);};userSmarts.wt.widgets.Display.prototype.getShells=function(){return this.shells;};userSmarts.wt.widgets.Display.prototype.getHiddenDiv=function(){if(!this.hiddenDiv){this.hiddenDiv=$("testSizeDiv");}
if(!this.hiddenDiv){var div=this.hiddenDiv=DIV({id:"testSizeDiv",style:"position:fixed; left:0; top:0; width:100%; height:100%; visibility:hidden; z-index:-1"});div.style.position="fixed";div.style.left="0px";div.style.top="0px";div.style.width="100%";div.style.height="100%";}
document.body.appendChild(this.hiddenDiv);return this.hiddenDiv;};userSmarts.wt.widgets.Display.prototype.getWidth=function(){return userSmarts.util.Browser.getViewWidth();};userSmarts.wt.widgets.Display.prototype.getHeight=function(){return userSmarts.util.Browser.getViewHeight();};userSmarts.wt.widgets.Display.prototype.getNewSize=function(){var result={height:this.getHeight(),width:this.getWidth()};return result;};userSmarts.wt.widgets.Display.prototype.onResize=function(){var shells=this.shells;for(var i=0;i<shells.length;++i){var shell=shells[i];if(shell){var node=shell.node;if(node){node.oldDisplay=node.style.display;node.style.display="none";}}}
var size=this.getNewSize();for(var i=0;i<shells.length;++i){var shell=shells[i];if(shell){shell.setBounds(0,0,size.width,size.height);shell.update();shell.node.style.display=shell.node.oldDisplay;}}};userSmarts.wt.widgets.Display.getDefault=function(){if(!userSmarts.wt.widgets.Display.inst){userSmarts.wt.widgets.Display.inst=new userSmarts.wt.widgets.Display();}
return userSmarts.wt.widgets.Display.inst;};namespace("userSmarts.wt.widgets");userSmarts.wt.widgets.Control=Class.create(Bean);$prototype.initialize=function(superClass,properties){properties=setdefault(properties||{},{size:{width:0,height:0},margin:{left:0,right:0,top:0,bottom:0},padding:{left:0,right:0,top:0,bottom:0},border:{style:"none",left:0,right:0,top:0,bottom:0},layoutData:{width:"*",height:"*"},stale:false});superClass.call(this,properties);if(this.parent instanceof userSmarts.wt.widgets.Composite){this.parent.add(this);}};$prototype.setParent=function(parent){this.parent=parent;};$prototype.getParent=function(){return this.parent;};$prototype.dispose=function(){this.disposed=true;this.node=null;};$prototype.isDisposed=function(){return this.disposed;};$prototype.isVisible=function(){var result=this.visible!==false;if(result&&this.parent){result=this.parent.isVisible();}
return result;};$prototype.getShell=function(){return this.getParent().getShell();};$prototype.getSize=function(){return this.size;};$prototype.setSize=function(w,h){var width=w||0;var height=h||0;if(!this.size){this.size={};}
var modified=!(this.size.width==width&&this.size.height==height);this.size.width=width||0;this.size.height=height||0;if(this.size.width<0)this.size.width=1;if(this.size.height<1)this.size.height=1;var node=this.getNode();node.style.width=this.size.width+(userSmarts.util.Browser.isIE?this.padding.left+this.padding.right:0)+"px";node.style.height=this.size.height+(userSmarts.util.Browser.isIE?this.padding.top+this.padding.bottom:0)+"px";return modified;};$prototype.setLocation=function(left,top){var modified=!(this.left==left&&this.top==top);this.left=Math.max(left||0,0);this.top=Math.max(top||0,0);var node=this.getNode();node.style.left=left+"px";node.style.top=top+"px";node.style.position="absolute";return modified;};$prototype.getLocation=function(){return{left:this.left,top:this.y};};$prototype.setBounds=function(left,top,width,height){var modified;var width=width||0;var height=height||0;if(width>0){width-=((this.margin.left||0)+(this.margin.right||0)+
(this.padding.left||0)+(this.padding.right||0)+
(this.border.left||0)+(this.border.right||0));}
if(height>0){height-=((this.margin.top||0)+(this.margin.bottom||0)+
(this.padding.top||0)+(this.padding.bottom||0)+
(this.border.top||0)+(this.border.bottom||0));}
left=(left||0);top=(top||0);modified=this.setLocation(left,top);modified=this.setSize(width,height)||modified;if(this.updateOnBoundsChange){if(modified&&this.isVisible()){this.update();}}};$prototype.getBounds=function(){return{x:this.left,y:this.top,width:this.size.width,height:this.size.height};};$prototype.getNode=function(){if(!this.node){var atts={};if(this["class"]){atts["class"]=this["class"];}
if(this.style){atts.style=this.style;}
if(this.id){atts.id=this.id;}
this.node=createDOM(this.nodeName||"div",atts);var m=this.margin;var p=this.padding;var b=this.border;var s=this.node.style;s.position="absolute";s.marginLeft=m.left+"px";s.marginRight=m.right+"px";s.marginTop=m.top+"px";s.marginBottom=m.bottom+"px";s.paddingLeft=p.left+"px";s.paddingRight=p.right+"px";s.paddingTop=p.top+"px";s.paddingBottom=p.bottom+"px";s.borderStyle=b.style
s.borderLeftWidth=b.left+"px";s.borderRightWidth=b.right+"px";s.borderTopWidth=b.top+"px";s.borderBottomWidth=b.bottom+"px";this.initNode();}
return this.node;};$prototype.initNode=function(){this.update();};$prototype.update=function(){};$prototype.paint=function(){return this.getNode();};$prototype.repaint=function(){this.update();};$prototype.setLayoutData=function(layoutData){this.layoutData=layoutData;};$prototype.getLayoutData=function(){return this.layoutData;};$prototype.setVisibility=function(visible){this.visible=visible;if(this.node){this.node.style.display=visible?"block":"none";}};namespace("userSmarts.wt.widgets");$namespace.Composite=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){this.children=[];superClass.call(this,properties||{});};$prototype.update=function(){if(!this.node)return;this.layout();var nodes=[];for(var i=0;i<this.children.length;++i){var child=this.children[i];if(child.visible===undefined||child.visible===true){try{child.update();}catch(e){}}
var node=child.getNode();nodes.push(node);}
replaceChildNodes(this.node,nodes);};$prototype.getClientArea=function(){return this.getBounds();};$prototype.layout=function(){if(this._layout){this._layout.layout(this);}};$prototype.setLayout=function(layout){this._layout=layout;};$prototype.getLayout=function(layout){return this._layout;};$prototype.getChildren=function(layout){return this.children;};$prototype.removeAll=function(){var children=this.getChildren();var len=children.length;for(var i=0;i<len;++i){try{children.pop().dispose();}catch(e){}}
this.children=[];};$prototype.remove=function(child){try{var index=-1;for(var i=0;i<this.children.length;++i){if(child==this.children[i]){index=i;break;}}
if(index>=0){this.children.splice(index,1);}
if(child){var node=child.getNode();if(node){this.getNode().removeChild(node);}}
return child;}catch(e){var childName=child['class']||child.id||"";var parentName=this['class']||this.id||"";getLogger().logError("Error removing child "+
childName+" to composite "+parentName+": ",e);}};$prototype.add=function(child){var result=-1;var childName=child['class']||child.id||"";var parentName=this['class']||this.id||"";var node;try{node=child.getNode();}catch(e){getLogger().logError("Error getting child node for appending child "+
childName+" to composite "+parentName+": ",e);return result;}
if(node){try{this.getNode().appendChild(node);}catch(e){getLogger().logError("Error appending child "+
childName+" node to composite "+parentName+": ",e);return result;}
try{this.append("children",child);result=this.children.length-1;}catch(e){getLogger().logError("Error adding child "+
childName+" to composite "+parentName+": ",e);}}
return result;};$prototype.replace=function(newChild,oldChild){try{var index=-1;for(var i=0;i<this.children.length;++i){if(oldChild==this.children[i]){index=i;break;}}
if(index>=0){this.children.splice(index,1,newChild);}
if(oldChild){var node=oldChild.getNode();if(node&&newChild){this.getNode().replaceChild(newChild.getNode(),node);}else{this.getNode().removeChild(node);}}
return oldChild;}catch(e){logError("Error removing child from composite");}};$prototype.dispose=function(){var children=this.children;var length=children.length;for(var i=0;i<length;++i){try{children[i].dispose();}catch(e){}}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.PlaceHolderControl=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){superClass.call(this,properties||{});};$prototype.update=function(){var content=this.content;if(content instanceof userSmarts.wt.widgets.Control){var location=content.getLocation();if(location&&this.size.width>0&&this.size.height>0){content.setBounds(location.left,location.top,this.size.width,this.size.height);}
try{var node=content.getNode();content.update();replaceChildNodes(this.node,node);}catch(e){replaceChildNodes(this.node,DIV(null,"Error rendering view"));}}};namespace("userSmarts.wt.widgets");$namespace.RoundedControl=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=properties||{};properties.border={"style":"none",top:0,left:0,right:0,bottom:0};superClass.call(this,properties);};$prototype.initNode=function(){var node=this.node;var bg=this['class']+"bg";var bbg=this['class']+"bbg";var bt=B({'class':"rcbt"},B({'class':'rcbt1 '+bbg},B()),B({'class':'rcbt2 '+bbg},B()),B({'class':'rcbt3 '+bbg}),B({'class':'rcbt4 '+bbg}),B({'class':'rcbt5 '+bbg}));node.appendChild(bt);var width=(parseInt(node.style.width)||1)+"px";var height=((parseInt(node.style.height)||11)-10)+"px";var content=DIV({"class":"rcc "+bg});content.style.width=width;content.style.height=height;node.appendChild(content);this.content=content;var bb=B({'class':"rcbb"},B({'class':'rcbb5 '+bbg}),B({'class':'rcbb4 '+bbg}),B({'class':'rcbb3 '+bbg}),B({'class':'rcbb2 '+bbg},B()),B({'class':'rcbb1 '+bbg},B()));node.appendChild(bb);};$prototype.setSize=function(width,height){userSmarts.wt.widgets.Control.prototype.setSize.call(this,width,height);var cw=this.size.width-(userSmarts.util.Browser.isIE?10:20);cw-=parseInt(this.content.style.borderLeftWidth)||0;cw-=parseInt(this.content.style.borderRightWidth)||0;cw-=parseInt(this.content.style.paddingLeft)||0;cw-=parseInt(this.content.style.paddingRight)||0;cw=Math.max(1,cw);var ch=this.size.height;ch-=10;ch=Math.max(1,ch);this.content.style.width=cw+"px";this.content.style.height=ch+"px";};$namespace.RoundedComposite=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{});properties.innerPadding=properties.padding||{top:0,left:0,right:0,bottom:0};properties.padding={top:0,left:0,right:0,bottom:0};properties.innerMargin=properties.margin||{top:0,left:0,right:0,bottom:0};properties.margin={top:0,left:0,right:0,bottom:0};properties.border={"style":"none",top:0,left:0,right:0,bottom:0};properties["_layout"]=new userSmarts.wt.layout.RowLayout({type:"vertical"});superClass.call(this,properties);};$prototype.initNode=function(){var node=this.node;var bg=this['class']+"bg";var bbg=this['class']+"bbg";var bt=B({'class':"rcbt"},B({'class':'rcbt1 '+bbg},B()),B({'class':'rcbt2 '+bbg},B()),B({'class':'rcbt3 '+bbg}),B({'class':'rcbt4 '+bbg}),B({'class':'rcbt5 '+bbg}));node.appendChild(bt);var width=(parseInt(node.style.width)||1);var height=((parseInt(node.style.height)||11)-15);width-=(this.innerPadding.left+this.innerPadding.right);width-=(this.innerMargin.left+this.innerMargin.right);height-=(this.innerPadding.top+this.innerPadding.top);height-=(this.innerMargin.top+this.innerMargin.top);this.content=new userSmarts.wt.widgets.Composite({'class':"bcc"+bg,size:{width:width,height:height},padding:this.innerPadding,margin:this.innerMargin,_layout:new userSmarts.wt.layout.RowLayout({type:"vertical"})});this.node.appendChild(this.content.getNode());var bb=B({'class':"rcbb"},B({'class':'rcbb5 '+bbg}),B({'class':'rcbb4 '+bbg}),B({'class':'rcbb3 '+bbg}),B({'class':'rcbb2 '+bbg},B()),B({'class':'rcbb1 '+bbg},B()));node.appendChild(bb);this.bb=bb;};$prototype.add=function(control){if(control instanceof userSmarts.wt.widgets.Control){this.content.add(control);}};$prototype.remove=function(control){if(control instanceof userSmarts.wt.widgets.Control){this.content.remove(control);}};$prototype.update=function(){this.content.update();};$prototype.setLayout=function(layout){this.content.setLayout(layout);};$prototype.getChildren=function(){return this.content.getChildren();};$prototype.setSize=function(width,height){userSmarts.wt.widgets.Control.prototype.setSize.call(this,width,height);var cw=this.size.width-(userSmarts.util.Browser.isIE?2:1);cw=Math.max(1,cw);var ch=this.size.height;ch=Math.max(1,ch);ch-=10;if(userSmarts.util.Browser.isIE){cw+=1;}
this.bb.style.position="absolute";this.bb.style.top=ch+"px";this.bb.style.left="0px";this.bb.style.width=cw+"px";if(!userSmarts.util.Browser.isIE){cw-=this.content.border.left;cw-=this.content.border.right;cw-=this.content.padding.left;cw-=this.content.padding.right;cw-=this.content.margin.left;cw-=this.content.margin.right;}
cw+=1;cw=Math.max(1,cw);ch-=this.content.border.top;ch-=this.content.border.bottom;ch-=this.content.padding.top;ch-=this.content.padding.bottom;ch-=this.content.margin.top;ch-=this.content.margin.bottom;ch-=5;ch=Math.max(1,ch);this.content.setSize(cw,ch);this.content.update();};namespace("userSmarts.wt.widgets");userSmarts.wt.widgets.Layout=function(properties){if(isPrototype(arguments)){return;}
Bean.call(this,properties);};userSmarts.wt.widgets.Layout.inheritsFrom(Bean);userSmarts.wt.widgets.Layout.VERTICAL="vertical";userSmarts.wt.widgets.Layout.HORIZONTAL="horizontal";userSmarts.wt.widgets.Layout.prototype.layout=function(composite){var width=composite.getWidth();var height=composite.getHeight();};namespace("userSmarts.wt.widgets");$namespace.Shell=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);if(this.parent){this.display=this.parent.getDisplay();}
if(!this.display){this.display=userSmarts.wt.widgets.Display.getDefault();}
if(!this.node){this.node=this.display.root;}
if(!this.parent){this.display.getShells().push(this);}};$prototype.close=function(){};$prototype.getShell=function(){return this;};$prototype.getShells=function(){return this.shells;};$prototype.getDisplay=function(){return this.display;};$prototype.getStyle=function(){return this.style;};namespace("userSmarts.wt.widgets");NodeWrapper=function(node){this.rowNode=node;};NodeWrapper.prototype.getNode=function(){return this.rowNode;};NodeWrapper.prototype.getName=function(){return(this.rowNode.localName||this.rowNode.nodeName);};NodeWrapper.prototype.getValue=function(){return scrapeText(this.rowNode);};NodeWrapper.prototype.getChildren=function(){return this.rowNode.childNodes;};NodeWrapper.prototype.equals=function(row){var result=false;if(row){if(row instanceof NodeWrapper){var node1=this.getNode();var node2=row.getNode();var id1=DOMUtils.getChildText(node1,"id");var id2=DOMUtils.getChildText(node2,"id");result=(id1==id2);}}
return result;};NodeWrapper.prototype.dispose=function(){this.rowNode=null;};namespace("userSmarts.wt.widgets");userSmarts.wt.widgets.TreeNode=function(label,parent){if(isPrototype(arguments)){return;}
this.label=label;this.parent=parent;this.children=[];this.uid=new Date().getTime()+Math.random();};userSmarts.wt.widgets.TreeNode.prototype.getLabel=function(){return this.label;};userSmarts.wt.widgets.TreeNode.prototype.getParent=function(){return this.parent;};userSmarts.wt.widgets.TreeNode.prototype.addNode=function(node){this.children.push(node);};userSmarts.wt.widgets.TreeNode.prototype.hasChildren=function(){return(this.children.length!==0);};userSmarts.wt.widgets.TreeNode.prototype.getChildren=function(){return this.children;};userSmarts.wt.widgets.TreeNode.prototype.hasChild=function(child){for(var i=0;i<this.children.length;i++){if(this.children[i].uid.equals(child.uid)){return true;}}
return false;};userSmarts.wt.widgets.TreeNode.prototype.equals=function(node){return node.uid&&(this.uid==node.uid);};userSmarts.wt.widgets.TreeNode.prototype.toString=function(){return this.label;};namespace("userSmarts.wt.widgets");$namespace.TreeModel=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$prototype.setSource=function(source){this.source=source;};$prototype.getRoot=function(){return this.source;};$prototype.getLabel=function(element){return element.getLabel();};$prototype.hasChildren=function(element){return element.hasChildren();};$prototype.getChildren=function(element){return element.getChildren();};$prototype.getParent=function(element){return element.getParent();};$prototype.getClassName=function(element,expanded){return this.getIconClassName(element,expanded);};$prototype.getIconClassName=function(element,expanded){if(this.hasChildren(element)){if(expanded===true){return'folder-open';}else if(expanded===false){return'folder-closed';}else{return'folder';}}else{return'file';}};$prototype.getLabelClassName=function(element,expanded){return'';};$prototype.compareNodes=function(element1,element2){return element1.equals(element2);};namespace("userSmarts.wt.widgets");$namespace.BeanTreeModel=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);setdefault(this,{root:{}});};$prototype.getRoot=function(){return this.root;};$prototype.getLabel=function(node){return node.label||"";};$prototype.hasChildren=function(node){return(node.iterable&&node[node.iterable].length>0);};$prototype.getChildren=function(node){return node[node.iterable]||[];};$prototype.getParent=function(node){return(node)?node.parent:null;};$prototype.getClassName=function(node,expanded){var result=node['class'];if(!result){if(this.hasChildren(node)){if(expanded===true){result='folder-open';}else if(expanded===false){result='folder-closed';}else{result='folder';}}else{result='file';}}
return result;};$prototype.getSelectionHandler=function(node){return node.onselect||function(){alert("selected!");};};$prototype.compareNodes=function(node1,node2){return node1.equals(node2);};namespace("userSmarts.wt.widgets");$namespace.DOMTreeModel=Class.create(Bean);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{useAttributes:false});superClass.call(this,properties);this.rootListener=connect(this,"root",this,this.onRootChange);};$prototype.onRootChange=function(event){var root=event.newValue;if(!isXmlNode(root)){this.root=null;return;}
if(root.nodeType==9){this.root=root.documentElement;}};$prototype.setRoot=function(root){this.setProperty("root",root);};$prototype.getRoot=function(){return this.root;};$prototype.hasChildren=function(element){var result=false;if(element){var children=DOMUtils.getChildren(element);result=children.length>0;}
return result;};$prototype.getChildren=function(element){var children=DOMUtils.getChildren(element);return children;};$prototype.getParent=function(element){return DOMUtils.getParent(element);};$prototype.getLabel=function(element){if(this.useAttributes){if(element){return getNodeAttribute(element,"label");}}else{return DOMUtils.getName(element);}};$prototype.getClassName=function(element,expanded){return this.getIconClassName(element,expanded);};$prototype.getIconClassName=function(element,expanded){if(this.getRoot()==element){return'root';}
if(this.hasChildren(element)){if(expanded){return'folder-open';}else if(!expanded){return'folder-closed';}else{return'folder';}}else{return'file';}};$prototype.getSelectionHandler=function(element){return function(node){alert(node+' is selected');};};$prototype.compareNodes=function(element1,element2){return(element1==element2);};$prototype.dispose=function(){if(this.rootListener){disconnect(this.rootListener);this.rootListener=null;}
this.root=null;userSmarts.wt.widgets.TreeModel.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.MenuTreeModel=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$prototype.setSource=function(source){this.source=source;};$prototype.getRoot=function(){return this.source;};$prototype.getLabel=function(element){return(element.getLabel)?element.getLabel():element;};$prototype.hasChildren=function(element){return(element.hasChildren)?element.hasChildren():false;};$prototype.getChildren=function(element){return(element.getChildren)?element.getChildren():[];};$prototype.getParent=function(element){return(element.getParent)?element.getParent():null;};$prototype.getClassName=function(element,expanded){return'';};$prototype.getSelectionHandler=function(element){return null;};$prototype.compareNodes=function(element1,element2){return element1.equals(element2);};namespace("userSmarts.wt.widgets");userSmarts.wt.widgets.DOMMenuTreeModel=function(){if(isPrototype(arguments)){return;}
Bean.call(this,{});new URLChangeListener(this,"source","document");this.addChangeListener(bind(this.onSourceChange,this),"document");};userSmarts.wt.widgets.DOMMenuTreeModel.inheritsFrom(Bean);userSmarts.wt.widgets.DOMMenuTreeModel.prototype.onSourceChange=function(event){this.setSource(event.newValue);};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.setSource=function(source){this.source=source;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getRoot=function(){return(this.source)?this.source.documentElement:null;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getLabel=function(element){if(!element){return"";}
return element.localName||element.baseName;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.hasChildren=function(element){if(!element){return false;}
for(var i=0;i<element.childNodes.length;i++){if(element.childNodes[i].nodeType==Node.ELEMENT_NODE){return true;}}
return false;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getChildren=function(element){var children=[];for(var i=0;i<element.childNodes.length;i++){if(element.childNodes[i].nodeType==Node.ELEMENT_NODE){children.push(element.childNodes[i]);}}
return children;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getParent=function(element){if(!element){return null;}
return element.parentNode;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getClassName=function(element,expanded){return'';};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getSelectionHandler=function(element){return null;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.compareNodes=function(element1,element2){return(element1==element2);};namespace("userSmarts.wt.widgets");$namespace.TreeWidget=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{selected:null,loadAll:false,"class":'tree'});superClass.call(this,properties);connect(this,"model",this,this.onModelChange);if(this.model){this.model.tree=this;this.touch("model");}};$prototype.setModel=function(model){this.setProperty("model",model);};$prototype.getModel=function(){return this.model;};$prototype.onModified=function(event){this.update();};$prototype.onModelChange=function(event){if(!this.modifiedSub){disconnect(this.modifiedSub);}
this.model.tree=this;this.modifiedSub=connect(this.model,"modelChanged",this,this.onModified);this.update();};$prototype.cleanupNode=function(node){if(node.source){node.source=null;}
return node.childNodes;};$prototype.dispose=function(){if(this.node){nodeWalk(this.node,this.cleanupNode);}
if(this.modifiedSub){disconnect(this.modifiedSub);this.modifiedSub=null;}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};$prototype.initNode=function(){this.update();connect(this.node,"onclick",this,this.onClick);}
$prototype.update=function(){if(arguments.length==1){this.updateNode(arguments[0]);logDebug("Please call updateNode instead.");return;}
if(!this.model)return;var root=this.model.getRoot();var node=this.getNode();var subtree;if(root){if(!this.hideRoot){subtree=this.buildNode(root,null,true,true);this.loadChildren(subtree);}else{subtree=DIV();subtree.isLast=true;subtree.isHidden=true;subtree.source=root;this.loadChildren(subtree,true);}
if(subtree){replaceChildNodes(node,subtree);if(this.selected){this.select(this.selected);}}}else{replaceChildNodes(node,[]);this.selected=null;}};$prototype.buildNode=function(element,parent,showOpen,isLast){if(!element){return null;}
if(!showOpen){showOpen=false;}
var nodeLabel=this.model.getLabel(element);var node=document.createElement("div");node.className="tree-node";node.source=element;node.isLast=isLast;node.hasChildrenLoaded=false;node.expanded=(this.loadAll||showOpen)?true:false;if(this.selected&&typeof(this.model.compareNodes)=='function'&&this.model.compareNodes(this.selected,element)){this.selectNodeQuiet(node);}
this.pad(node,parent,showOpen);var iconClass=this.model.getIconClassName(element,showOpen);var labelClass=this.model.getLabelClassName(element,showOpen);if(typeof(this.model.isCheckable)!='undefined'&&this.model.isCheckable(element)){var checkbox=INPUT({'type':'checkbox'});checkbox.defaultChecked=this.model.isChecked(element)||false;checkbox.style.height='10px';checkbox.style.width='10px';checkbox.style.verticalAlign='middle';checkbox.style.marginLeft='0px';checkbox.style.marginRight='3px';node.appendChild(checkbox);}
var theme=userSmarts.runtime.Platform.getTheme();var icon=theme.getImage(iconClass);if(!icon){icon=theme.getImage("image.spacer",IMG({alt:"O"}));icon.className=iconClass;}
addElementClass(icon,"icon");icon.style.cursor="pointer";node.appendChild(icon);var label=document.createElement("span");label.className="label"+(labelClass?" "+labelClass:"");label.appendChild(document.createTextNode(nodeLabel));node.appendChild(label);return node;};$prototype.loadChildren=function(node,nopad){var element=node.source;var parent=nopad?null:node;if(this.model.hasChildren(element)){var children=this.model.getChildren(element);var last=children.length-1;var length=children.length;for(var i=0;i<length;i++){var child=this.buildNode(children[i],parent,this.loadAll,i==last);node.appendChild(child);if(this.loadAll){this.loadChildren(child);}}}
node.hasChildrenLoaded=true;};$prototype.onClick=function(event){var target=event.target();var node=target.parentNode;var element=node.source;var tree=this;if(!node){return;}
if(!target.ispad){if(typeof target.defaultChecked!="undefined"){this.setProperty("checked",{node:node.source,value:target.checked});}else{tree.selectNode(node);}}else if(target.isparent){var padding=target;if(node.expanded){tree.collapseNode(node);var cname=node.isLast?'expand.bottom':'expand';var theme=userSmarts.runtime.Platform.getTheme();var pi=theme.getImage("image.tree."+cname);target.style.background=pi.style.background;}else{tree.expandNode(node);var cname=node.isLast?'collapse.bottom':'collapse';var theme=userSmarts.runtime.Platform.getTheme();var pi=theme.getImage("image.tree."+cname);target.style.background=pi.style.background;}}
event.stopPropagation();};$prototype.pad=function(node,parent,showOpen){var tree=this;var composite=this.model.hasChildren(node.source);var cname=(composite?(this.loadAll||showOpen?'collapse':'expand'):'join');if(node.isLast)cname+=".bottom";var theme=userSmarts.runtime.Platform.getTheme();var padding=theme.getImage("image.tree."+cname);padding.ispad=true;if(composite){padding.isparent=true;}
node.insertBefore(padding,node.firstChild);while(parent&&parent.source&&!parent.isHidden){cname='empty';if(!parent.isLast){cname='line';}
var theme=userSmarts.runtime.Platform.getTheme();var padding=theme.getImage("image.tree."+cname);padding.ispad=true;node.insertBefore(padding,node.firstChild);parent=parent.parentNode;}};$prototype.select=function(element){var node=this.getTreeNode(element);this.selectNode(node);};$prototype.selectNode=function(node){if(!node)return;if(this.selectedNode){removeElementClass(this.selectedNode,'selected-tree-node');}
if(node!=this.selectedNode){addElementClass(node,'selected-tree-node');this.setProperty("selected",node.source);this.setProperty("selectedNode",node);}else{this.setProperty("selected",null);this.setProperty("selectedNode",null);}};$prototype.selectNodeQuiet=function(node){if(!node)return;if(this.selectedNode){removeElementClass(this.selectedNode,'selected-tree-node');}
addElementClass(node,'selected-tree-node');this.selected=node.source;this.selectedNode=node;};$prototype.findIcon=function(node){for(var i=0;i<node.childNodes.length;++i){var child=node.childNodes[i];if(hasElementClass(child,"icon"))
return child;}
return null;};$prototype.expand=function(element){var node=this.getTreeNode(element);if(!node)return;this.expandNode(node);};$prototype.expandNode=function(node){if(!node)return;if(!node.hasChildrenLoaded){this.loadChildren(node);}
node.expanded=true;node.source.expanded=true;var icon=this.findIcon(node);if(icon){var iconClass=this.model.getIconClassName(node.source,true);var theme=userSmarts.runtime.Platform.getTheme();var ic=theme.getImage(iconClass);if(ic){icon.style.background=ic.style.background;}else{icon.className="icon "+iconClass;}}
for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes[i];if(hasElementClass(child,"tree-node")&&child.style){child.style.display='block';}}};$prototype.collapse=function(element){var node=this.getTreeNode(element);this.collapseNode(node);};$prototype.collapseNode=function(node){if(!node||!node.expanded)return;node.expanded=false;node.source.expanded=true;var icon=this.findIcon(node);if(icon){var iconClass=this.model.getIconClassName(node.source,false);var theme=userSmarts.runtime.Platform.getTheme();var ic=theme.getImage(iconClass);if(ic){icon.style.background=ic.style.background;}else{icon.className="icon "+iconClass;}}
for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes[i];if(hasElementClass(child,"tree-node")&&child.style){child.style.display='none';}}};$prototype.updateNode=function(node){if(!node.source){node=this.getTreeNode(node);}
if(!node||!node.source){return;}
var parent=node.parentNode;var newChild=this.buildNode(node.source,parent,true,node.isLast);parent.replaceChild(newChild,node);this.loadChildren(newChild);};$prototype.getTreeNode=function(element,parent){if(!parent&&this.model){parent=this.node;}
if(parent.source==element){return parent;}
var children=parent.childNodes;var length=children.length;for(var i=0;i<length;++i){var child=children[i];if(child.source==element){return child;}}
var foundNode;for(var i=0;i<length;++i){var child=children[i];if(child.source){foundNode=this.getTreeNode(element,child);if(foundNode){return foundNode;}}}
return null;};$namespace.Tree=Class.create(userSmarts.wt.widgets.TreeWidget);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};namespace("userSmarts.wt.widgets");userSmarts.wt.widgets.CheckableTreeWidget=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{selected:null,imageBase:"../../images/tree/",loadAll:false});userSmarts.wt.widgets.TreeWidget.apply(this,[properties]);};userSmarts.wt.widgets.CheckableTreeWidget.inheritsFrom(userSmarts.wt.widgets.TreeWidget);userSmarts.wt.widgets.CheckableTreeWidget.prototype.recursivelyBuildTree=function(element,parent,level,showOpen){if(!element){return null;}else if(!showOpen){showOpen=false;}
var nodeLabel=this.model.getLabel(element);var node=DIV({'id':nodeLabel,'class':'tree-node'});node.source=element;node.style.verticalAlign='middle';node.hasChildrenLoaded=false;this.pad(element,node,level,showOpen);var tree=this;if(typeof(this.model.isCheckable)!='undefined'&&this.model.isCheckable(element)){var checkbox=INPUT({'type':'checkbox'});checkbox.defaultChecked=this.model.isChecked(element)||false;checkbox.style.height='10px';checkbox.style.width='10px';checkbox.style.verticalAlign='middle';checkbox.style.marginLeft='0px';checkbox.style.marginRight='3px';checkbox.onclick=bind(function(elem,cb){this.setProperty("checked",{node:elem,value:cb.checked});},this,element,checkbox);node.appendChild(checkbox);}
var className=this.model.getClassName(element,showOpen);var icon=IMG({'src':this.getBlankImage(),'class':className});node.icon=icon;node.appendChild(icon);var label=SPAN({'class':'label'});label.appendChild(document.createTextNode(nodeLabel));node.label=label;label.onclick=bind(this.select,this,element);node.appendChild(label);if(this.loadAll||showOpen){if(this.model.hasChildren(element)){var children=this.model.getChildren(element);for(var i=0;i<children.length;i++){node.appendChild(this.recursivelyBuildTree(children[i],node,level+1,this.loadAll));}}
node.hasChildrenLoaded=true;}
return node;};namespace("userSmarts.wt.widgets");$namespace.TabFolder=Class.create($namespace.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{items:[],"class":"tabbox"});superClass.call(this,properties);this.tabControl=new userSmarts.wt.widgets.Composite({parent:this,"class":"tabs",layoutData:{width:"100%",height:25}});this.tabControl.getNode().style.overflow="hidden";this.toolbar=new userSmarts.wt.widgets.PlaceHolderControl({parent:this,"class":"wt-toolbar",layoutData:{width:"100%",height:21}});this.panels=new userSmarts.wt.widgets.Composite({parent:this,"class":"wt-tabpanels",layoutData:{width:"100%",height:'*'}});this.panels.setLayout(new userSmarts.wt.layout.StackLayout());this.tabControl.setLayout(new userSmarts.wt.layout.RowLayout({type:"horizontal"}));this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));};$prototype.isEmpty=function(){return this.items.length==0;};$prototype.addItem=function(tabItem){tabItem.layoutData={width:"*",height:"100%"};this.items.push(tabItem);this.tabControl.add(tabItem);this.panels.add(tabItem.getControl()||new userSmarts.wt.widgets.Control());if(!this.selected){this.setSelection(tabItem);}};$prototype.removeItem=function(tabItem){tabItem=this.resolve(tabItem);if(tabItem){var control=tabItem.getControl();this.items.remove(tabItem);this.tabControl.remove(tabItem);this.panels.remove(control);this.setSelection(0);}
return tabItem;};$prototype.setSelection=function(tabItem){var previous=this.selected;tabItem=this.resolve(tabItem);if(previous!=tabItem){if(previous instanceof userSmarts.wt.widgets.TabItem){previous.setProperty("selected",false);}
if(tabItem instanceof Bean){tabItem.setProperty("selected",true);}
this.setProperty("selected",tabItem);this.update();}};$prototype.resolve=function(tabItem){if(typeof tabItem=="number"){tabItem=this.items[tabItem];}else if(typeof tabItem=="string"){for(var i=0;i<this.items.length;++i){if(this.items[i].name==tabItem){tabItem=this.items[i];break;}}}else if(!(tabItem instanceof userSmarts.wt.widgets.TabItem)){tabItem=null;}
return tabItem;};$prototype.update=function(){if(!this.toolbar){return;}
var tbNode=null;var tabItem=this.selected;this.panels.getLayout().topControl=tabItem?tabItem.getControl():null;this.panels.layout();userSmarts.wt.widgets.Composite.prototype.update.apply(this);if(tabItem){var toolbar=tabItem.getToolbar();if(toolbar){this.toolbar.content=toolbar;this.toolbar.update();}}};namespace("userSmarts.wt.widgets");$namespace.TabItem=Class.create($namespace.Control);$prototype.initialize=function(superClass,properties){var parent=properties.parent;var doLeftBorder=true;if(parent&&typeof(parent.isEmpty)=="function"&&parent.isEmpty()){doLeftBorder=false;}
properties=setdefault(properties,{text:"",nodeName:"span","class":"tab",padding:{top:2,bottom:2,left:2,right:2},margin:{top:0,bottom:0,left:(doLeftBorder?1:0),right:0},selectedClassName:"selected-tab"});properties.parent=null;superClass.call(this,properties);this.parent=parent;if(parent instanceof userSmarts.wt.widgets.TabFolder){parent.addItem(this);}};$prototype.getText=function(){return this.text;};$prototype.setText=function(text){this.text=text;this.update();}
$prototype.getImage=function(){return this.image;};$prototype.getControl=function(){return this.control;};$prototype.getToolbar=function(){return this.toolbar;};$prototype.onClick=function(event){this.parent.setSelection(this);};$prototype.onClose=function(event){if(typeof this.close=="function"){this.close();}
event.stopPropagation();};$prototype.initNode=function(){this.listener=connect(this.node,"onclick",this,this.onClick);this.node.style.overflow="hidden";};$prototype.update=function(){var nodes=[];var left=5;var imgKey=this.getImage();if(imgKey){var img;var theme=userSmarts.runtime.Platform.getTheme();if(theme){img=theme.getImage(imgKey,null);}
if(!img){img=IMG({src:imgKey,alt:"X"});}
img.style.position="absolute";img.style.left=left+"px";img.style.width="16px";img.style.height="16px";nodes.push(img);left+=16;}
var txtWidth=this.size.width-16;txtWidth-=(this.padding.left-this.padding.right);txtWidth-=(this.border.left-this.border.right);if(imgKey)txtWidth-=16;if(this.isCloseable())txtWidth-=16;txtWidth=Math.floor(txtWidth);txtWidth=Math.max(txtWidth,10);var txtHeight=this.size.height;txtHeight-=(this.padding.top-this.padding.bottom);txtHeight-=(this.border.top-this.border.bottom);var txt=DIV({},this.getText()||"");txt.style.position="absolute";txt.style.left=left+"px";txt.style.marginLeft="3px";txt.style.marginRight="3px";txt.style.width=txtWidth+"px";txt.style.height=txtHeight+"px";txt.style.overflow="hidden";nodes.push(txt);left+=txtWidth+10;if(this.isCloseable()){var closeImg=this.getCloseImage();this.closeListener=connect(closeImg,"onclick",this,this.onClose);closeImg.style.position="absolute";closeImg.style.left=left+"px";closeImg.style.width="16px";closeImg.style.height="16px";nodes.push(closeImg);}
replaceChildNodes(this.node,nodes);if(this.selected){addElementClass(this.getNode(),this.getSelectedClassName());}else{removeElementClass(this.getNode(),this.getSelectedClassName());}};$prototype.getSelectedClassName=function(){return this.selectedClassName;};$prototype.isCloseable=function(){return this.closeable||false;};$prototype.getCloseImage=function(){var image;var theme=userSmarts.runtime.Platform.getTheme();if(theme){image=theme.getImage("image.close",null);}
if(!image){var src=src=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/icons/close_icon.gif');image=IMG({src:src});}
if(image){image.alt="(X)";image.style.cursor="pointer";image.title="Close";}
return image;};$prototype.setSize=function(width,height){var modified=userSmarts.wt.widgets.Control.prototype.setSize.call(this,width,height);if(userSmarts.util.Browser.isIE){var node=this.getNode();node.style.width=(this.size.width+4)+"px";node.style.height=(this.size.height+2)+"px";}
return modified;};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
if(this.closeListener){disconnect(this.closeListener);this.closeListener=null;}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.TableModel=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);setdefault(this,{columns:[],items:{},modified:new Date(),maximumRows:25,currentRow:0,buffer:[],pageSize:10});if(this.items instanceof Bean){this.items.connect("modified",this,this.onItemsChanged);}};$prototype.onItemsChanged=function(event){this.items=event.newValue;this.populate();};$prototype.addColumn=function(column){if(!this.columns)this.columns=[];column.index=this.columns.length;this.columns.push(column);};$prototype.getLabel=function(column,row){return column.getLabel(row);};$prototype.getClassName=function(column,row){return"";};$prototype.getColumnLabel=function(column,row){return column.label;};$prototype.getImage=function(column,row){if(column&&typeof(column.getImage)=='function'){return column.getImage(row);}else{return null;}};$prototype.getColumnClassName=function(column,row){return"";};$prototype.getColumns=function(){return this.columns;};$prototype.hideColumn=function(col){var column;if(typeof(col)=="number"){column=this.columns[col];}else{column=col;}
column.visible=false;};$prototype.showColumn=function(col){var column;if(typeof(col)=="number"){column=this.columns[col];}else{column=col;}
column.visible=true;};$prototype.isColumnVisible=function(col){var column;if(typeof(col)=="number"){column=this.columns[col];}else{column=col;}
return!(column.visible===false);};$prototype.getRows=function(){return this.buffer;};$prototype.isSelected=function(row){return this.selectedRow==row;};$prototype.setMaxRows=function(maxRows){this.maximumRows=maxRows*1;};$prototype.getMaxRows=function(){return this.maximumRows;};$prototype.setPageSize=function(pageSize){this.pageSize=pageSize*1;};$prototype.getPageSize=function(){return this.pageSize;};$prototype.nextPage=function(){return this.populate(this.currentRow+this.pageSize);};$prototype.previousPage=function(){return this.populate(this.currentRow-this.pageSize);};$prototype.size=function(){return(this.items.length)?this.items.length:0;};$prototype.getOffset=function(){return this.currentRow;};$prototype.populate=function(position){if(position!==undefined&&position!==null&&(position>=0&&position<this.size())){this.currentRow=position*1;}
var l=this.buffer.length;for(var i=0;i<l;i++){this.buffer.shift();}
var items=this.items;var size=this.size();var ps=this.pageSize||items.length;if(size<(this.currentRow+this.pageSize)){ps=size-this.currentRow;}
if(typeof(items.slice)!="undefined"){this.buffer=items.slice(this.currentRow,(this.currentRow+ps));}else{getLogger().logError("TableModel.populate() - Items are not array-like");}
var deferred=new Deferred();deferred.size=function(){return ps;};deferred.addCallback(bind(function(property,value){this.setProperty(property,value);},this,'modified'));deferred.callback(this.items);return deferred;};$prototype.compare=function(row1,row2){var column=this.getColumns[0];if(column){return column.compare(row1,row2);}else{return(row1==row2)?0:-1;}
return-1;};$prototype.sort=function(column){if(column&&typeof(column.compare)=='function'){this.sortAsc=(typeof(this.sortAsc)=='undefined')?true:!this.sortAsc;var l=0;var r=0;if(this.buffer&&this.buffer.length){r=this.buffer.length-1;}else if(this.items&&this.items.length){r=this.items.length-1;}
this.sortItems(column,l,r,this.sortAsc);this.setProperty("modified",true);}};$prototype.sortItems=function(column,left,right,flag){var items;if(this.buffer&&this.buffer.length){items=this.buffer;}else if(this.items&&this.items.length){items=this.items;}else{return;}
var l_hold=left;var r_hold=right;var pivot=items[left];while(left<right){if(flag){while((column.compare(items[right],pivot)>=0)&&(left<right)){--right;}}else{while((column.compare(items[right],pivot)<=0)&&(left<right)){--right;}}
if(left!=right){items[left]=items[right];++left;}
if(flag){while((column.compare(items[left],pivot)<=0)&&(left<right)){++left;}}else{while((column.compare(items[left],pivot)>=0)&&(left<right)){++left;}}
if(left!=right){items[right]=items[left];--right;}}
items[left]=pivot;pivot=left;left=l_hold;right=r_hold;if(left<pivot){this.sortItems(column,left,pivot-1,flag);}
if(right>pivot){this.sortItems(column,pivot+1,right,flag);}};$prototype.dispose=function(){var rows=this.getRows();for(var i=0;i<rows.length;++i){if(typeof(rows[i].dispose)=="function"){rows[i].dispose();rows[i]=null;}}
var cols=this.getColumns();for(var i=0;i<cols.length;++i){if(typeof(cols[i].dispose)=="function"){cols[i].dispose();cols[i]=null;}}
this.items=null;this.buffer=null;this.source=null;};namespace("userSmarts.wt.widgets");$namespace.DOMTableModel=Class.create(userSmarts.wt.widgets.TableModel);$prototype.initialize=function(superclass,properties){setdefault(properties,{root:null,matches:0,depth:0,nodeOffset:0,nodeNames:[]});superclass.call(this,properties);this.rootListener=connect(this,'root',this.onRootChange);};$prototype.onRootChange=function(event){var root=event.newValue;if(!isXmlNode(root)){this.root=null;return;}
if(root.nodeType==9){root=root.documentElement;}
this.populate(0);};$prototype.getLabel=function(column,row){return column.getLabel(row);};$prototype.getClassName=function(column,row){return"dom-table-cell";};$prototype.getColumnLabel=function(column,row){return column.getColumnLabel();};$prototype.getColumnClassName=function(column,row){return"dom-table-column";};$prototype.getColumns=function(){return this.columns;};$prototype.getRows=function(){return this.buffer;};$prototype.size=function(){return this.matches||0;};$prototype.populate=function(position){if(position!==undefined&&position!==null&&(position>=0&&position<this.size())){this.currentRow=position*1;}
if(this.root){this.buffer=[];if(this.nodeNames.length>0){for(var i=0;i<this.nodeNames.length;++i){var results=DOMUtils.getChildren(this.root,this.nodeNames[i]);for(var j=0;j<results.length;++j){this.buffer.push(new NodeWrapper(results[j]));}}}else{var results=DOMUtils.getChildren(this.root);for(var i=0;i<results.length;++i){this.buffer.push(new NodeWrapper(results[i]));}}}else{this.loadCallback(null);}};$prototype.dispose=function(){if(this.rootListener){disconnect(this.rootListener);this.rootListener=null;}
this.root=null;userSmarts.wt.widgets.TableModel.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.TableColumn=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$prototype.getLabel=function(row){var result="";if(this.name){result=row[this.name];}
return result;};$prototype.getImage=function(row){var result=null;if(this.image){if(typeof(this.image)=="string"){result=userSmarts.runtime.Platform.getTheme().getImage(this.image);}else if(typeof(this.image.appendChild)!="undefined"){result=this.image;}}
return result;};$prototype.compare=function(row1,row2){if(this.name){var rv1=row1[this.name];var rv2=row2[this.name];if(typeof(rv1)=='string'&&typeof(rv2)=='string'){try{rv1=parseInt(rv1);}catch(Error){rv1=row1[this.name];}
if(isNaN(rv1))rv1=row1[this.name];try{rv2=parseInt(rv2);}catch(Error){rv2=row2[this.name];}
if(isNaN(rv2))rv2=row2[this.name];if(rv1>rv2){return 1;}else if(rv1<rv2){return-1;}else if(rv1==rv2){return 0;}}else if(typeof(rv1.compare)=='function'){return rv1.compare(rv2);}}
return-1;};$prototype.dispose=function(){this.name=null;if(this.image){this.image=null;delete this.image;}
if(this.format){this.format=null;delete this.format;}
Bean.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.DOMTableColumn=Class.create($namespace.TableColumn);$prototype.initialize=function(superclass,properties){setdefault(properties,{isAttr:false,fallback:""});superclass.call(this,properties);if(this.isAttr){this.name=this.name+"@"+this.attrName;}};$prototype.getNodeValue=function(row,path){var node=row.getNode();var nodePath=path.split("/");var step;for(var n=0;n<nodePath.length;++n){step=nodePath[n];if(step.length>0){if(step.indexOf("@")>=0){if(step.indexOf("@")>0){var nodeName=step.substring(0,step.indexOf("@"));node=DOMUtils.getChild(node,nodeName);}
var attrName=step.substring(step.indexOf("@")+1,step.length);return(node)?getNodeAttribute(node,attrName):null;}
node=DOMUtils.getChild(node,step);if(node==null){return null;}}}
if(node){return(node.childNodes.length>1)?"[node]":scrapeText(node);}
return null;};$prototype.getLabel=function(row,name){var result="";var tagName=name||this.name;if(tagName&&row){result=this.getNodeValue(row,tagName);}
if(!result){result=this.fallback;}else{if(this.format&&typeof(this.format.format)=="function"){result=this.format.format(result);}}
return result;};$prototype.isAttribute=function(){return(this.isAttr&&this.attrName)||this.name.indexOf("@")>=0;};$prototype.getColumnLabel=function(row){return this.label;};$prototype.compare=function(row1,row2){if(this.name){var rv1=this.getLabel(row1);var rv2=this.getLabel(row2);if(typeof(rv1)=='string'&&typeof(rv2)=='string'){try{rv1=parseInt(rv1);}catch(Error){rv1=this.getLabel(row1);}
if(isNaN(rv1))rv1=this.getLabel(row1);try{rv2=parseInt(rv2);}catch(Error){rv2=this.getLabel(row2);}
if(isNaN(rv2))rv2=this.getLabel(row2);if(rv1>rv2){return 1;}else if(rv1<rv2){return-1;}else if(rv1==rv2){return 0;}}else if(typeof(rv1.compare)=='function'){return rv1.compare(rv2);}}
return-1;};$prototype.dispose=function(){userSmarts.wt.widgets.TableColumn.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.TablePageControl=Class.create($namespace.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':"wt-table-controls",updateOnBoundsChange:true,layoutData:{width:"100%",height:"25px"},_layout:new userSmarts.wt.layout.RowLayout({type:"horizontal"}),minimum:false,showLabel:true});this.table=this.table||properties.parent;superClass.call(this,properties);};$prototype.initNode=function(){this.node.style.overflow="hidden";this.pageSizeDT={facets:{enumeration:[{label:"5",value:5},{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100}]}};this.selectedPageSize=this.table.model?this.table.model.getPageSize():10;var theme=userSmarts.runtime.Platform.getTheme();this.nextLink=theme.getImage("image.page.next");this.nextLink.title="Next Page";this.nextListener=connect(this.nextLink,"onclick",this,this.onNextPage);this.prevLink=theme.getImage("image.page.previous");this.prevLink.title="Previous Page";this.prevListener=connect(this.prevLink,"onclick",this,this.onPreviousPage);this.firstLink=theme.getImage("image.page.first");this.firstLink.title="First Page";this.firstListener=connect(this.firstLink,"onclick",this,this.onFirstPage);this.lastLink=theme.getImage("image.page.last");this.lastLink.title="Last Page";this.lastListener=connect(this.lastLink,"onclick",this,this.onLastPage);if(this.showLabel){this.label=new userSmarts.wt.forms.Label({'class':"wt-table-controls-label",parent:this,layoutData:{width:"*",height:"100%"},value:""});this.label.getNode().style.overflow="hidden";new userSmarts.wt.action.VerticalSeparator({parent:this});}
var len=determineLabelWidth("Page Size:","wt-table-controls-label");var pl=new userSmarts.wt.forms.Label({'class':"wt-table-controls-label",parent:this,layoutData:{width:len+5,height:"100%"},margin:{top:0,left:3,right:0,bottom:0},value:"Page Size: "});pl.getNode().style.overflow="hidden";this.selector=new userSmarts.wt.forms.SelectControl({parent:this,layoutData:{width:80,height:"100%"},margin:{top:0,left:0,right:5,bottom:0},datatype:this.pageSizeDT,binding:new BeanPropertyBinding(this,"selectedPageSize")});this.selector.getNode().style.textAlign="right";this.selector.getNode().style.overflow="hidden";this.pageSizeListener=connect(this,"selectedPageSize",this,this.onPageSizeChange);new userSmarts.wt.action.VerticalSeparator({parent:this});var paging=new userSmarts.wt.widgets.Control({'class':'link-holder',parent:this,layoutData:{width:64,height:"100%"}});paging.getNode().appendChild(this.firstLink);paging.getNode().appendChild(this.prevLink);paging.getNode().appendChild(this.nextLink);paging.getNode().appendChild(this.lastLink);if(this.showLabel){new userSmarts.wt.action.VerticalSeparator({parent:this});new userSmarts.wt.forms.Label({'class':"wt-table-controls-label",parent:this,layoutData:{width:25,height:"100%"},value:""});}
this.update();};$prototype.update=function(){var model=this.table.model;if(!model)return;var results=[];var start=model.getOffset();var end=model.size();var pageSize=model.getPageSize()||end;var pageIndex=Math.floor((start+1)/pageSize);if(pageSize!=this.selectedPageSize){this.selector.setValue(pageSize);}
if(this.showLabel){var descriptor="No results";if(end>0){descriptor=(this.minimum?"":"Displaying ")+(pageIndex*pageSize+1)+" - "+
((pageIndex*pageSize+pageSize<end)?pageIndex*pageSize+pageSize:end)+" of "+end+
(this.minimum?"":" results");}
this.label.setValue(descriptor);}
var theme=userSmarts.runtime.Platform.getTheme();if((start+pageSize)>=end){var i=theme.getImage("image.page.next.disabled");this.nextLink.src=i.src;this.nextLink.style.background=i.style.background;i=theme.getImage("image.page.last.disabled");this.lastLink.src=i.src;this.lastLink.style.background=i.style.background;}else{var i=theme.getImage("image.page.next");this.nextLink.src=i.src;this.nextLink.style.background=i.style.background;i=theme.getImage("image.page.last");this.lastLink.src=i.src;this.lastLink.style.background=i.style.background;}
if(start>0){var i=theme.getImage("image.page.previous");this.prevLink.src=i.src;this.prevLink.style.background=i.style.background;i=theme.getImage("image.page.first");this.firstLink.src=i.src;this.firstLink.style.background=i.style.background;}else{var i=theme.getImage("image.page.previous.disabled");this.prevLink.src=i.src;this.prevLink.style.background=i.style.background;i=theme.getImage("image.page.first.disabled");this.firstLink.src=i.src;this.firstLink.style.background=i.style.background;}
userSmarts.wt.widgets.Composite.prototype.update.call(this);};$prototype.onNextPage=function(){var model=this.table.model;model.nextPage();};$prototype.onPreviousPage=function(){var model=this.table.model;model.previousPage();};$prototype.onFirstPage=function(){var model=this.table.model;model.populate(0);};$prototype.onLastPage=function(){var model=this.table.model;var size=model.size();var pageSize=model.getPageSize();var position=Math.max(0,size-pageSize)+1;model.populate(position);};$prototype.onPageSizeChange=function(event){var value=event.newValue*1;var model=this.table.model;if(model){var currentFirstElementInPage=model.getOffset();var newCurrentPageIndex=Math.floor(currentFirstElementInPage/value);var newCurrentPageOffset=0;var currentFirstElementInNewPage=(newCurrentPageIndex*value)+newCurrentPageOffset;model.setPageSize(value);model.populate(currentFirstElementInNewPage);}};$prototype.dispose=function(){if(this.pageSizeListener){disconnect(this.pageSizeListener);this.pageSizeListener=null;}
if(this.nextListener){disconnect(this.nextListener);this.nextListener=null;}
if(this.prevListener){disconnect(this.prevListener);this.prevListener=null;}
if(this.firstListener){disconnect(this.firstListener);this.firstListener=null;}
if(this.lastListener){disconnect(this.lastListener);this.lastListener=null;}
userSmarts.wt.widgets.Composite.prototype.dispose.call(this);};$prototype.getIcon=function(key){var theme=userSmarts.runtime.Platform.getTheme();if(theme){return theme.get(key);}
return"";};$namespace.ModalPageControls=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':"wt-table-controls",layoutData:{width:"100%",height:20},label:"[edit]",minimum:false});superClass.call(this,properties);};$prototype.initNode=function(){var node=this.node;node.appendChild(SPAN({},this.label));node.style.cursor="pointer";node.style.overflow="hidden";connect(node,"onclick",this,this.showControls);this.callback=bind(this.onDialogClosed,this);};$prototype.update=function(){var model=this.parent.model;if(!model)return;var start=model.getOffset();var end=model.size();var pageSize=model.getPageSize()||end;var pageIndex=Math.floor((start+1)/pageSize);var descriptor="No results";if(end>0){descriptor=(this.minimum?"":"Displaying ")+(pageIndex*pageSize+1)+" - "+
((pageIndex*pageSize+pageSize<end)?pageIndex*pageSize+pageSize:end)+" of "+end+
(this.minimum?"":" results");}
replaceChildNodes(this.node,SPAN({},descriptor,"  ",this.label));if(this.dialog){this.dialog.refresh();}};$prototype.showControls=function(){if(!this.dialog){var pos=elementPosition(this.getParent().getNode());pos.y+=this.getParent().getSize().height;pos.y-=(this.size.height+50);this.dialog=new userSmarts.wt.dialogs.PageControlDialog({table:this.parent});this.dialog.setPosition(pos.x,pos.y);var deferred=this.dialog.open();deferred.addCallback(this.callback);}else{if(this.dialog.isOpen()){this.dialog.onCancel();}
this.dialog=null;}};$prototype.onDialogClosed=function(){this.dialog=null;};namespace("userSmarts.wt.widgets");$namespace.Table=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{"class":"wt-table",updateOnBoundsChange:true,showFooter:true,allowSelection:true});superClass.call(this,properties);this.modelChangeListener=connect(this,"model",this,this.onModelChange);this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));new userSmarts.wt.widgets.InnerTable({parent:this,allowSelection:this.allowSelection});if(this.showFooter){new userSmarts.wt.widgets.TablePageControl({parent:this});}
this.touch("model");};$prototype.setModel=function(model){this.model=model;this.onModelChange(null);};$prototype.onModelChange=function(event){if(this.modelsub){disconnect(this.modelsub);}
if(this.model){this.modelsub=connect(this.model,"modified",this,this.onModelModified);}
this.update();};$prototype.onModelModified=function(event){this.update();};$prototype.getSelection=function(){return this.selected;};$prototype.select=function(rowObj){if(rowObj){var tr=rowObj.node;if(tr){if(this.selected){this.deselect(this.selected);}
addElementClass(tr,'selected');this.setProperty("selected",rowObj);}}};$prototype.deselect=function(rowObj){if(rowObj){var tr=rowObj.node;if(tr){removeElementClass(tr,'selected');this.setProperty("selected",null);}}};$prototype.isSelected=function(rowObj){var result=false;if(this.selected){if(typeof(this.selected.equals)=="function"){return this.selected.equals(rowObj);}else if(this.selected.id&&rowObj.id){result=this.selected.id==rowObj.id;}else{result=this.selected==rowObj;}}
return result;};$prototype.dispose=function(){if(this.modelChangeListener){disconnect(this.modelChangeListener);this.modelChangeListener=null;}
if(this.modelsub){disconnect(this.modelsub);this.modelsub=null;}
userSmarts.wt.widgets.Composite.prototype.dispose.call(this);};$namespace.InnerTable=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{allowSelection:true,layoutData:{width:"*",height:"*"}});this.table=properties.table||properties.parent;superClass.call(this,properties);};$prototype.initNode=function(){if(this.allowSelection){this.listener=connect(this.node,"onclick",this,this.onClick);}};$prototype.update=function(){var node=this.getNode();node.style.overflow="auto";var thead=THEAD();var body=TBODY();var selected=null;var model=this.table.model;if(!model){thead.appendChild(TR({},TD({},"")));body.appendChild(TR({},TD({},"")));}else{var items=model.getRows()||[];var len=items.length;var tr=TR();thead.appendChild(tr);var cols=model.getColumns();var ncols=cols.length;var numVisibleCols=ncols;for(var i=0;i<ncols;++i){var col=cols[i];if(model.isColumnVisible(col)){var td=this.createColumnHeader(col,i);tr.appendChild(td);}else{--numVisibleCols;}}
if(len==0){var row=TR(null,TD({colspan:numVisibleCols}));body.appendChild(row);}else{for(var i=0;i<len;++i){var row=items[i];if(!selected&&this.table.isSelected(row)){selected=row;}
var tr=TR();for(var j=0;j<ncols;++j){var column=cols[j];if(model.isColumnVisible(column)){var td=TD({'class':model.getClassName(column)},model.getLabel(column,row));if(column.width)td.style.width=column.width+"px";td.row=row;tr.appendChild(td);row.node=tr;}}
if((this.table.selected&&this.table.selected==row)||model.isSelected(row)){addElementClass(tr,'selected');}
body.appendChild(tr);}}}
replaceChildNodes(node,TABLE({"class":"wt-inner-table"},thead,body));if(selected){this.table.select(selected);}else{this.table.setProperty("selected",null);}};$prototype.createColumnHeader=function(column,columnIndex){var model=this.table.model;var labelValue=model.getColumnLabel(column);var label;if(labelValue){label=SPAN({'class':'table-header-cell'},labelValue);}else{label='';}
var td=TD({'class':model.getColumnClassName(column)},label);if(column.width)td.style.width=column.width+"px";td.columnIndex=columnIndex;connect(td,"onclick",this,this.onColumnClick);return td;};$prototype.onClick=function(evt){var source=evt.target();var row=source.row;if(row){var tr=source.parentNode;row.node=tr;if(this.table.isSelected(row)){this.table.deselect(row);}else{this.table.select(row);}}};$prototype.onColumnClick=function(evt){var model=this.table.model;var source=evt.target();var columnIndex=source.columnIndex;if(typeof(columnIndex)=='number'){var columns=model.getColumns();if(columnIndex>=0&&columnIndex<columns.length){var column=columns[columnIndex];model.sort(column);}}};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.CTable=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=properties||{};if(typeof(properties.showFooter)=="boolean"){properties.showPaging=properties.showFooter;}
delete properties.showFooter;properties=setdefault(properties,{"class":"wt-table",updateOnBoundsChange:true,showPaging:true,allowSelection:true,cellPadding:0,cellSpacing:0});properties.cellPadding=Math.max(0,properties.cellPadding);properties.cellSpacing=Math.max(0,properties.cellSpacing);superClass.call(this,properties);this.modelChangeListener=this.connect("model",this,this.onModelChange);};$prototype.initNode=function(){this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));this.header=new userSmarts.wt.widgets.Composite({parent:this,"class":"wt-table-header",layoutData:{width:"100%",height:25},_layout:new userSmarts.wt.layout.HorizontalRowLayout()});this.header.connect("childBoundsChanged",this,this.refreshBody);this.body=new userSmarts.wt.widgets.Control({parent:this,"class":"wt-inner-table",layoutData:{width:"100%",height:"*"}});if(this.allowSelection){this.clickListener=connect(this.body.getNode(),"onclick",this,this.onClick);}
if(this.showPaging){new userSmarts.wt.widgets.TablePageControl({parent:this,border:{style:"solid",top:1,left:0,right:0,bottom:0}});}
var icon=null;var theme=userSmarts.runtime.Platform.getTheme();if(theme){icon=theme.getImage("image.busy");}else{icon="...";}
this.loadingDIV=DIV({},icon);this.loadingDIV.style.position="absolute";this.loadingDIV.style.width="20px";this.loadingDIV.style.height="20px";this.loadingDIV.style.padding="2px";this.loadingDIV.style.backgroundColor="#eeeeee";this.loadingDIV.style.border="2px solid #6599DF";this.rowMap={};this.touch("model");};$prototype.setModel=function(model){this.model=model;this.onModelChange(null);};$prototype.onModelChange=function(event){if(this.modelModifiedListener){disconnect(this.modelModifiedListener);}
if(this.modelPopulatingListener){disconnect(this.modelPopulatingListener);}
if(this.model){this.modelModifiedListener=this.model.connect("modified",this,this.onModelModified);this.modelPopulatingListener=this.model.connect("populating",this,this.showLoading);}
this.update();};$prototype.onModelModified=function(event){this.update();};$prototype.getSelection=function(){return this.selected;};$prototype.select=function(rowObj){if(rowObj){var tr=this.findRowNode(rowObj);if(tr){if(this.selected){this.deselect(this.selected);}
addElementClass(tr,'selected');this.setProperty("selected",rowObj);}}};$prototype.deselect=function(rowObj){if(rowObj){var tr=this.findRowNode(rowObj);if(tr){removeElementClass(tr,'selected');this.setProperty("selected",null);}}};$prototype.isSelected=function(rowObj){var result=false;if(this.selected){if(typeof(this.selected.equals)=="function"){return this.selected.equals(rowObj);}else if(this.selected.id&&rowObj.id){result=this.selected.id==rowObj.id;}else{result=this.selected==rowObj;}}
return result;};$prototype.showLoading=function(bool){if(bool===true){if(this.node.parentNode){this.loadingDIV.style.top=(this.size.height/2-13)+"px";this.loadingDIV.style.left=(this.size.width/2-13)+"px";this.getNode().appendChild(this.loadingDIV);}}else{if(this.node.parentNode){try{this.getNode().removeChild(this.loadingDIV);}catch(e){}}}}
$prototype.getVisibleColumns=function(){var result=[];var model=this.model;if(model){var cols=model.getColumns();var ncols=cols.length;for(var i=0;i<ncols;++i){if(model.isColumnVisible(cols[i])){result.push(cols[i]);}}}
return result;};$prototype.getColumnWidth=function(col){var result=0;var model=this.model;if(model){var hci=0;var cols=this.getVisibleColumns();for(var i=0;i<cols.length;++i){if(col==cols[i]){result=this.header.getChildren()[hci].getSize().width;}else{hci+=2;}}}
return result;};$prototype.getNumberOfVisibleColumns=function(){var result=this.getVisibleColumns().length;return result;};$prototype.refreshHeader=function(){var model=this.model;if(!model)return;var cols=this.getVisibleColumns();var ncols=cols.length;var percWidth=ncols>0?(100/ncols):0;var header=this.header;var headerCells=header.getChildren();if(headerCells.length!=(ncols*2-1)){header.removeAll();var first=true;for(var i=0;i<ncols;++i){var col=cols[i];if(first)first=false;else{new userSmarts.wt.action.VerticalResizeSeparator({parent:header,layoutData:{width:1,height:"100%"},padding:{top:0,left:0,right:0,bottom:0},margin:{top:0,left:0,right:0,bottom:0},border:{style:"none",top:0,left:0,right:0,bottom:0}});}
new userSmarts.wt.forms.Label({parent:header,'class':'table-header-cell',layoutData:{width:percWidth,height:100,units:{width:"%",height:"%"}},value:model.getColumnLabel(col)});}
header.layout();}else{var hci=0;for(var i=0;i<ncols;++i){var col=cols[i];headerCells[hci].setValue(model.getColumnLabel(col));hci+=2;}}};$prototype.refreshBody=function(){var selected=null;var bodyNode=this.body.getNode();bodyNode.style.overflow="auto";var parentWidth=parseInt(bodyNode.style.width);this.rowMap={};bodyNode.innerHTML="";var model=this.model;if(model){var items=model.getRows()||[];var len=items.length;var rowHeight=25;var estHeight=rowHeight*len;var parentHeight=parseInt(bodyNode.style.height);if(estHeight>parentHeight){parentWidth-=17;}else if(estHeight<parentHeight){rowHeight=Math.min(parentHeight/len,35);}
var rowWidth=parentWidth;var top=0;var left=0;var rowStrs=[];for(var i=0;i<len;++i){var row=items[i];row.position=i;if(!selected&&this.isSelected(row)){selected=row;}
var rowStr=this.buildRow(row,top,left,rowWidth,rowHeight);rowStrs.push(rowStr);top+=rowHeight;left=0;}
bodyNode.innerHTML=rowStrs.join("");if(selected){this.select(selected);}else{this.setProperty("selected",null);}}};$prototype.buildRow=function(row,top,left,width,height){var model=this.model;var cols=this.getVisibleColumns();var ncols=cols.length;var className="wt-table-row";if((this.selected&&this.selected==row)||model.isSelected(row)){className+=" selected";}
var w=width-(this.cellSpacing>0?0:2);var h=height;var rowNode="<div class='"+className+"' style='";rowNode+="position:absolute; top:"+top+"; left:"+left;rowNode+="; width:"+w+"; height:"+h+";overflow:hidden";rowNode+="' row='"+row.position+"'>";var colWidth=0;for(var j=0;j<ncols;++j){var col=cols[j];if(j<(ncols-1)){colWidth=this.getColumnWidth(col);colWidth+=1;}else{colWidth=width-left;}
var icon=model.getImage(col,row);var label=model.getLabel(col,row);var className=model.getClassName(col);if(icon&&label){label="<span>"+DOMUtils.outerHTML(icon)+
((typeof(label)=="string")?label:DOMUtils.outerHTML(label))+"</span>";}else if(icon){label="<span>"+DOMUtils.outerHTML(icon)+"</span>";}
var cell=this.createCell(left,0,colWidth,height,label,className,rowNode);rowNode+=cell;left+=colWidth;}
rowNode+="</div>";return rowNode;};$prototype.createCell=function(left,top,width,height,content,className){var btop=1;var bleft=1;var bright=1;var bbottom=1;if(this.cellSpacing==0&&parent){bleft=(parent.childNodes.length>0)?0:1;btop=(parent.previousSibling)?0:1;}
var cellOffset=((this.cellSpacing*2)+(this.cellPadding*2)+2);var w=width-cellOffset;var h=height-cellOffset;if(userSmarts.util.Browser.isIE){w+=((this.cellSpacing*2)+(this.cellPadding*2));h+=((this.cellSpacing*2)+(this.cellPadding*2));}
var cell="<div class='"+(className||"wt-table-cell")+"' style='";cell+="position:absolute; top:"+top+"; left:"+left;cell+="; width:"+w+"; height:"+h+";overflow:hidden";cell+="; margin:"+this.cellSpacing+"px; padding:"+this.cellPadding+"px";cell+="; border-top-width:"+btop+"px; border-left-width:"+bleft+"px";cell+="; border-right-width:"+bright+"px; border-bottom-width:"+btop+"px";cell+="; border-style:solid;";if(this.allowSelection)cell+="cursor:pointer;";cell+="'>"+content+"</div>";return cell;}
$prototype.update=function(){userSmarts.wt.widgets.Composite.prototype.update.call(this);this.refreshHeader();this.refreshBody();};$prototype.onClick=function(event){var source=event.target();if(!source||source==this.node||source==this.body.getNode())return;while(!hasElementClass(source,"wt-table-row")){source=source.parentNode;}
var rowpos=parseInt(source.getAttribute("row"));if(typeof(rowpos)!="number")return;var row=this.model.getRows()[rowpos];if(!row)return;if(this.isSelected(row)){this.deselect(row);}else{this.select(row);}};$prototype.findRowNode=function(rowObj){var node=this.rowMap[rowObj.position||0];if(node)return node;else{var rows=this.body.getNode().childNodes;for(var i=0;i<rows.length;++i){var position=parseInt(rows[i].getAttribute("row"));if(position==rowObj.position){this.rowMap[rowObj]=rows[i];return rows[i];}}}
return null;};$prototype.onColumnClick=function(evt){var model=this.model;var source=evt.target();var columnIndex=source.columnIndex;if(typeof(columnIndex)=='number'){var columns=model.getColumns();if(columnIndex>=0&&columnIndex<columns.length){var column=columns[columnIndex];model.sort(column);}}};$prototype.dispose=function(){if(this.modelChangeListener){disconnect(this.modelChangeListener);this.modelChangeListener=null;}
if(this.modelModifiedListener){disconnect(this.modelModifiedListener);this.modelModifiedListener=null;}
if(this.clickListener){disconnect(this.clickListener);this.clickListener=null;}
this.rowMap=null;userSmarts.wt.widgets.Composite.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.List=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'wt-list',updateOnBoundsChange:true,showFooter:true,autoExpand:false,allowSelection:true});superClass.call(this,properties);this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));if(this.useInnerDIVs){this.innerList=new userSmarts.wt.widgets.InnerList({parent:this,autoExpand:this.autoExpand,allowSelection:this.allowSelection});}else{this.innerList=new userSmarts.wt.widgets.InnerHTMLList({parent:this,autoExpand:this.autoExpand,allowSelection:this.allowSelection});}
if(this.showFooter!=false){this.pageControls=new userSmarts.wt.widgets.TablePageControl({parent:this,minimum:true});}
this.modelChangeListener=connect(this,'model',this,this.onModelChange);this.touch("model");};$prototype.setModel=function(model){if(this.modelModifiedListener){disconnect(this.modelModifiedListener);}
if(model&&model instanceof userSmarts.wt.widgets.TableModel){this.modelModifiedListener=connect(model,'modified',this,this.update);this.modelPopulatingListener=connect(model,'populating',this,this.showLoading);model.populate(0);}
this.model=model;};$prototype.showLoading=function(){this.innerList.showLoading(true);};$prototype.onModelChange=function(event){this.setModel(event.newValue);};$prototype.select=function(rowObj,fire){if(rowObj){var entry=this.innerList.findRowNode(rowObj);if(entry){addElementClass(entry,'selected');if(fire!=false){this.setProperty("selected",rowObj);}else{this.selected=rowObj;}}}};$prototype.unselect=function(rowObj,fire){if(rowObj){var entry=this.innerList.findRowNode(rowObj);if(entry){removeElementClass(entry,'selected');if(fire!=false){this.setProperty("selected",null);}else{this.selected=null;}}}};$prototype.getSelected=function(){return this.selected;};$prototype.isSelected=function(row){var result=false;var selected=this.getSelected();if(selected){if(typeof(selected.equals)=="function"){return selected.equals(row);}else{result=selected==row;}}
return result;};$prototype.selectAndExpand=function(rowObj,fire){if(rowObj){var entry=this.innerList.findRowNode(rowObj);if(entry){addElementClass(entry,'selected');if(!this.innerList.isExpanded(rowObj)){this.innerList.expand(rowObj);}
if(fire!=false){this.setProperty("selected",rowObj);}else{this.selected=rowObj;}}}};$prototype.unselectAndCollapse=function(rowObj,fire){if(rowObj){var entry=this.innerList.findRowNode(rowObj);if(entry){removeElementClass(entry,'selected');if(this.innerList.isExpanded(rowObj)){this.innerList.collapse(rowObj);}
if(fire!=false){this.setProperty("selected",null);}else{this.selected=null;}}}};$prototype.toggleNode=function(row){var source=this.innerList.findRowNode(row);var content=source.childNodes[1];if(content.style.display!="none"){content.style.display="none";}else{content.style.display="block";}};$prototype.collapse=function(row){if(this.isSelected(row)){this.unselect(row);}
this.innerList.collapse(row);};$prototype.expand=function(row){this.innerList.expand(row);};$prototype.showFullPageControls=function(value){if(this.pageControls){this.pageControls.minimum=!(value===true);this.pageControls.update();}};$prototype.dispose=function(){if(this.modelChangeListener){disconnect(this.modelChangeListener);this.modelChangeListener=null;}
if(this.modelModifiedListener){disconnect(this.modelModifiedListener);this.modelModifiedListener=null;}
userSmarts.wt.widgets.Composite.prototype.dispose.call(this);};$namespace.InnerList=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{autoExpand:false,allowSelection:true,layoutData:{width:"*",height:"*"}});this.list=properties.list||properties.parent;this['class']="wt-inner-list";var icon=null;var theme=userSmarts.runtime.Platform.getTheme();if(theme){icon=theme.getImage("image.busy");}else{icon="...";}
this.loadingDIV=DIV({},icon);this.loadingDIV.style.position="absolute";this.loadingDIV.style.width="20px";this.loadingDIV.style.height="20px";this.loadingDIV.style.padding="2px";this.loadingDIV.style.backgroundColor="#eeeeee";this.loadingDIV.style.border="2px solid #6599DF";superClass.call(this,properties);};$prototype.showLoading=function(bool){if(bool===true){if(this.node.parentNode){this.loadingDIV.style.top=(this.size.height/2-13)+"px";this.loadingDIV.style.left=(this.size.width/2-13)+"px";this.node.appendChild(this.loadingDIV);}}else{try{this.node.removeChild(this.loadingDIV);}catch(e){}}}
$prototype.update=function(){if(this.entryListeners){for(var i=0;i<this.entryListeners.length;++i){disconnect(this.entryListeners[i]);this.entryListeners[i]=null;}}
this.entryListeners=[];var entries=[];if(this.list.model){var entry;var selectedEntry;var rows=this.list.model.getRows();for(var i=0;i<rows.length;++i){var row=rows[i];if(!selectedEntry&&this.list.isSelected(row)){selectedEntry=row;}
row.position=i;entry=this.buildEntry(row);addElementClass(entry,((i%2)==0)?"even":"odd");if(entry){entries.push(entry);if(this.autoExpand){this.expand(row);}}}}
replaceChildNodes(this.getNode(),entries);if(selectedEntry){this.list.select(selectedEntry);this.expand(selectedEntry);}else{this.list.selected=null;}};$prototype.buildEntry=function(row){if(!row){return null;}
var entry=DIV({'class':'wt-list-entry'});if(this.allowSelection){this.entryListeners.push(connect(entry,'onclick',this,this.onClick));}
entry.setAttribute("row",row.position+"");row.listNode=entry;row.hasExpandedContents=false;var model=this.list.model;var titleDIV;var title;var item;var image;var className;var cols=model.getColumns();var length=cols.length;for(var i=0;i<length;++i){if(cols[i].visible!=false){title=model.getLabel(cols[i],row);if(title){image=model.getImage(cols[i],row);if(image){image.style.width="16px";image.style.height="16px";titleDIV=DIV({'class':'wt-list-title'},image,title);}else{titleDIV=DIV({'class':'wt-list-title'},title);}
className=model.getColumnClassName(cols[i],row);if(className){addElementClass(titleDIV,className);}
entry.appendChild(titleDIV);}
break;}}
return entry;};$prototype.buildExpandedContents=function(row){var model=this.list.model;if(!row.hasExpandedContents){var content=DIV({'class':'wt-list-content'});var listNode=this.findRowNode(row);if(listNode){listNode.appendChild(content);row.hasExpandedContents=true;}
var cols=model.getColumns();var foundTitle=false;for(var i=0;i<cols.length;++i){if(cols[i].visible!=false){if(!foundTitle){foundTitle=true;}else{var item=model.getColumnLabel(cols[i],row);var value=model.getLabel(cols[i],row);if(typeof(value)=="string"||typeof(value)=="number"){if(item){item+=": "+value;}else{item=value;}
if(item){content.appendChild(DIV({'class':'wt-list-content-item'},item));}}else if(value&&typeof(value.appendChild)!="undefined"){content.appendChild(DIV({'class':'wt-list-content-item'},item||" ",value));}}}}}}
$prototype.onClick=function(event){var source=event.src();if(!source)return;var rowpos=parseInt(source.getAttribute("row"));if(typeof(rowpos)!="number")return;var row=this.list.model.getRows()[rowpos];if(!row)return;if(this.list.isSelected(row)){try{this.list.unselectAndCollapse(row);}catch(e){alert("Error unselecting item in the list, "+e);}}else{try{if(this.list.getSelected()){this.list.unselectAndCollapse(this.list.getSelected(),false);}
this.list.selectAndExpand(row);}catch(e){alert("Error selecting item in the list, "+e);}}};$prototype.isExpanded=function(row){var entry=this.findRowNode(row);if(!entry)return false;var content=entry.childNodes[1];var result=content&&content.style.display!="none";return result;};$prototype.expand=function(row){if(!row.hasExpandedContents){this.buildExpandedContents(row);}
var entry=this.findRowNode(row);if(entry.childNodes.length>1){var content=entry.childNodes[1];content.style.display="block";}};$prototype.collapse=function(row){if(this.list.isSelected(row)){this.list.unselect(row);}
var entry=this.findRowNode(row);if(entry.childNodes.length>1){var content=entry.childNodes[1];if(content){content.style.display="none";}}};$prototype.findRowNode=function(rowObj){if(rowObj.listNode){return rowObj.listNode;}else{var entries=this.getNode().childNodes;for(var i=0;i<entries.length;++i){var position=parseInt(entries[i].getAttribute("row"));if(position==rowObj.position){rowObj.listNode=entries[i];return entries[i];}}}
return null;};$prototype.dispose=function(){if(this.entryListeners){for(var i=0;i<this.entryListeners.length;++i){disconnect(this.entryListeners[i]);this.entryListeners[i]=null;}}
this.entryListeners=null;userSmarts.wt.widgets.Control.prototype.dispose.call(this);};$namespace.InnerHTMLList=Class.create(userSmarts.wt.widgets.InnerList);$prototype.initialize=function(superClass,properties){this.rowMap={};superClass.call(this,properties);};$prototype.update=function(){if(!this.listener&&this.allowSelection){this.listener=connect(this.node,"onclick",this,this.onClick);}
this.rowMap={};this.node.innerHTML="";var entries=[];var selected;if(this.list.model){var rows=this.list.model.getRows();for(var i=0;i<rows.length;++i){var row=rows[i];if(!selected&&this.list.isSelected(row)){selected=row;}
row.position=i;this.buildEntry(row,entries);}}
this.node.innerHTML=entries.join("");if(selected){this.list.select(selected);this.expand(selected);}else{this.list.selected=null;}
this.showLoading(false);};$prototype.buildEntry=function(row,coll){if(!row)return null;var entry="<div class='wt-list-entry'";entry+=" row='"+row.position+"'>";var content="<div class='wt-list-content'"+
(this.autoExpand?"":" style='display:none;'")+">";var foundTitle=false;var model=this.list.model;var cols=model.getColumns();var length=cols.length;for(var i=0;i<length;++i){if(cols[i].visible!=false){if(!foundTitle){var title=model.getLabel(cols[i],row);if(title){var className=model.getColumnClassName(cols[i],row);entry+="<div class='wt-list-title "+(className||"")+"'>";var image=model.getImage(cols[i],row);if(image){image.style.width="16px";image.style.height="16px";entry+=DOMUtils.outerHTML(image);}
entry+=title;entry+="</div>";foundTitle=true;}}else{var item=model.getColumnLabel(cols[i],row);var value=model.getLabel(cols[i],row);if(typeof(value)=="string"||typeof(value)=="number"){if(item)item+=": "+value;else item=value;if(item){content+="<div class='wt-list-content-item'>"+item+"</div>";}}else if(value&&typeof(value.appendChild)!="undefined"){content+="<div class='wt-list-content-item'>"+(item||" ")+DOMUtils.outerHTML(value)+"</div>";}}}}
content+="</div>";entry+=content+"</div>"
coll.push(entry);row.hasExpandedContents=true;return entry;};$prototype.buildExpandedContents=function(row){}
$prototype.onClick=function(event){var source=event.target();if(!source||!hasElementClass(source,"wt-list-title"))return;while(!hasElementClass(source,"wt-list-entry")){source=source.parentNode;}
var rowpos=parseInt(source.getAttribute("row"));if(typeof(rowpos)!="number")return;var row=this.list.model.getRows()[rowpos];if(!row)return;if(this.list.isSelected(row)){try{this.list.unselectAndCollapse(row);}catch(e){alert("Error unselecting item in the list, "+e);}}else{try{if(this.list.getSelected()){this.list.unselectAndCollapse(this.list.getSelected(),false);}
this.list.selectAndExpand(row);}catch(e){alert("Error selecting item in the list, "+e);}}};$prototype.findRowNode=function(rowObj){var node=this.rowMap[rowObj.position||0];if(node)return node;else{var entries=this.getNode().childNodes;for(var i=0;i<entries.length;++i){var position=parseInt(entries[i].getAttribute("row"));if(position==rowObj.position){this.rowMap[rowObj]=entries[i];return entries[i];}}}
return null;};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
this.rowMap=null;userSmarts.wt.widgets.Control.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.SimpleList=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'simple-list',updateOnBoundsChange:true,showFooter:true,allowSelection:true,rowComparator:null});superClass.call(this,properties);this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));this.innerList=new userSmarts.wt.widgets.SimpleInnerList({parent:this,allowSelection:this.allowSelection});if(this.showFooter!=false){if(this.showFooterInPopUp){new userSmarts.wt.widgets.ModalPageControls({parent:this});}else{this.pageControls=new userSmarts.wt.widgets.TablePageControl({parent:this,minimum:true});}}
this.modelChangeListener=connect(this,'model',this,this.onModelChange);this.touch("model");};$prototype.setModel=function(model){if(this.modelModifiedListener){disconnect(this.modelModifiedListener);}
if(model&&model instanceof userSmarts.wt.widgets.TableModel){this.modelModifiedListener=connect(model,'modified',this,this.update);this.modelPopulatingListener=connect(model,'populating',this,this.showLoading);model.populate(model.getOffset());}
this.model=model;};$prototype.showLoading=function(){this.innerList.showLoading(true);};$prototype.onModelChange=function(event){this.setModel(event.newValue);};$prototype.select=function(rowObj,fire){if(!rowObj){this.selected=null;return;}
var previous=this.getSelected();var entry=this.findNode(rowObj);if(!entry)return;addElementClass(entry,'selected');this.scrollIntoView(entry);if(fire!=false){this.setProperty("selected",rowObj);}else{this.selected=rowObj;}
this.unselectAll(rowObj);};$prototype.unselectAll=function(except){var rows=this.model.getRows();for(var i=0;i<rows.length;++i){if(except&&((this.rowComparator&&this.rowComparator(except,rows[i]))||(typeof(except.equals)=="function"&&except.equals(rows[i]))||(except==rows[i]))){continue;}
var entry=this.findNode(rows[i]);if(entry){removeElementClass(entry,"selected");}}
this.selected=except;};$prototype.unselect=function(rowObj,fire){if(!rowObj)return;var entry=this.findNode(rowObj);if(!entry)return;removeElementClass(entry,'selected');if(fire!=false){this.setProperty("selected",null);}else{this.selected=null;}};$prototype.getSelected=function(){return this.selected;};$prototype.isSelected=function(row){var result=false;var selected=this.getSelected();if(selected){if(typeof(selected.equals)=="function"){return selected.equals(row);}else if(this.rowComparator){return this.rowComparator(this.selected,row);}else{result=selected==row;}}
return result;};$prototype.scrollIntoView=function(entryNode){if(!entryNode)return;var parentNode=entryNode.parentNode;if(parentNode){var height=parseInt(parentNode.style.height);var scroll=parseInt(parentNode.scrollTop);var top=parseInt(entryNode.offsetTop);if(top>=0&&((top>(scroll+height))||(top<scroll))){parentNode.scrollTop=top;}}};$prototype.showFullPageControls=function(value){if(this.pageControls){this.pageControls.minimum=!(value===true);this.pageControls.update();}};$prototype.update=function(){var selected=this.getSelected();userSmarts.wt.widgets.Composite.prototype.update.call(this);if(selected){var node=this.findNode(selected,true);if(node){this.scrollIntoView(node);var position=parseInt(node.getAttribute("row"));selected=this.model.getRows()[position];this.select(selected,false);}}};$prototype.findNode=function(rowObj,forceNew){var node=(forceNew?null:this.innerList.findRowNode(rowObj));if(!node){var rows=this.model.getRows();for(var i=0;i<rows.length;++i){if(this.rowComparator){if(this.rowComparator(rowObj,rows[i])){node=this.innerList.findRowNode(rows[i]);}}else if(typeof(rowObj.equals)=="function"){if(rowObj.equals(rows[i])){node=this.innerList.findRowNode(rows[i]);}}else if(rowObj==rows[i]){node=this.innerList.findRowNode(rows[i]);}
if(node)break;}}
return node;}
$prototype.dispose=function(){if(this.modelChangeListener){disconnect(this.modelChangeListener);this.modelChangeListener=null;}
if(this.modelModifiedListener){disconnect(this.modelModifiedListener);this.modelModifiedListener=null;}
userSmarts.wt.widgets.Composite.prototype.dispose.call(this);};$namespace.SimpleInnerList=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{allowSelection:true,layoutData:{width:"*",height:"*"}});this.list=properties.list||properties.parent;this['class']="simple-inner-list";var icon=null;var theme=userSmarts.runtime.Platform.getTheme();if(theme){icon=theme.getImage("image.busy");}else{icon="...";}
this.loadingDIV=DIV({},icon);this.loadingDIV.style.position="absolute";this.loadingDIV.style.width="20px";this.loadingDIV.style.height="20px";this.loadingDIV.style.padding="2px";this.loadingDIV.style.backgroundColor="#eeeeee";this.loadingDIV.style.border="2px solid #6599DF";superClass.call(this,properties);};$prototype.showLoading=function(bool){if(bool===true){if(this.node.parentNode){this.loadingDIV.style.top=(this.size.height/2-13)+"px";this.loadingDIV.style.left=(this.size.width/2-13)+"px";this.parent.getNode().appendChild(this.loadingDIV);}}else{}}
$prototype.update=function(){if(this.entryListeners){for(var i=0;i<this.entryListeners.length;++i){disconnect(this.entryListeners[i]);this.entryListeners[i]=null;}}
this.entryListeners=[];var entries=[];if(this.list.model){var entry;var selectedEntry;var rows=this.list.model.getRows();for(var i=0;i<rows.length;++i){var row=rows[i];if(!selectedEntry&&this.list.isSelected(row)){selectedEntry=row;}
row.position=i;entry=this.buildEntry(row);addElementClass(entry,((i%2)==0)?"even":"odd");if(entry){entries.push(entry);}}}
replaceChildNodes(this.getNode(),entries);if(selectedEntry){this.list.select(selectedEntry,false);}else{this.list.selected=null;}};$prototype.buildEntry=function(row){if(!row)return null;var entry=DIV({'class':'listed-item'});if(this.allowSelection){this.entryListeners.push(connect(entry,'onclick',this,this.onClick));}
entry.setAttribute("row",row.position+"");row.listNode=entry;var model=this.list.model;var titleDIV;var title;var item;var image;var className;var column=model.getColumns()[0];title=model.getLabel(column,row);if(title){image=model.getImage(column,row);if(image){image.style.width="16px";image.style.height="16px";titleDIV=DIV({'class':'listed-item-title'},image,title);}else{titleDIV=DIV({'class':'listed-item-title'},title);}
entry.appendChild(titleDIV);}
return entry;};$prototype.onClick=function(event){var source=event.src();if(!source)return;var rowpos=parseInt(source.getAttribute("row"));if(typeof(rowpos)!="number")return;var row=this.list.model.getRows()[rowpos];if(!row)return;if(this.list.isSelected(row)){try{this.list.unselect(row);}catch(e){getLogger().logError("Error unselecting item in the list",e);}}else{try{this.list.select(row);}catch(e){getLogger().logError("Error selecting item in the list",e);}}};$prototype.findRowNode=function(rowObj){if(rowObj.listNode){return rowObj.listNode;}else{var entries=this.getNode().childNodes;for(var i=0;i<entries.length;++i){var position=parseInt(entries[i].getAttribute("row"));if(position==rowObj.position){rowObj.listNode=entries[i];return entries[i];}}}
return null;};$prototype.dispose=function(){if(this.entryListeners){for(var i=0;i<this.entryListeners.length;++i){disconnect(this.entryListeners[i]);this.entryListeners[i]=null;}}
this.entryListeners=null;userSmarts.wt.widgets.Control.prototype.dispose.call(this);};$namespace.SimpleInnerHTMLList=Class.create(userSmarts.wt.widgets.SimpleInnerList);$prototype.initialize=function(superClass,properties){this.rowMap={};superClass.call(this,properties);};$prototype.showLoading=function(bool){if(bool===true){if(this.node.parentNode){this.loadingDIV.style.top=(this.size.height/2-13)+"px";this.loadingDIV.style.left=(this.size.width/2-13)+"px";this.parent.getNode().appendChild(this.loadingDIV);}}else{try{this.parent.getNode().removeChild(this.loadingDIV);}catch(e){}}}
$prototype.update=function(){if(!this.listener&&this.allowSelection){this.listener=connect(this.node,"onclick",this,this.onClick);}
this.rowMap={};this.node.innerHTML="";var entries=[];var selected;if(this.list.model){var rows=this.list.model.getRows();for(var i=0;i<rows.length;++i){var row=rows[i];if(!selected&&this.list.isSelected(row)){selected=row;}
row.position=i;this.buildEntry(row,entries);}}
this.node.innerHTML=entries.join("");if(selected){this.list.select(selected);this.expand(selected);}else{this.list.selected=null;}
this.showLoading(false);};$prototype.buildEntry=function(row){if(!row)return null;var entry="<div class='listed-item'";entry+=" row='"+row.position+"'>";var foundTitle=false;var model=this.list.model;var cols=model.getColumns();var length=cols.length;for(var i=0;i<length;++i){if(cols[i].visible!=false){if(!foundTitle){title=model.getLabel(cols[i],row);if(title){var className=model.getColumnClassName(cols[i],row);entry+="<div class='listed-item-title "+(className||"")+"'>";image=model.getImage(cols[i],row);if(image){image.style.width="16px";image.style.height="16px";entry+=DOMUtils.outerHTML(image);}
entry+=title;entry+="</div>";foundTitle=true;break;}}}}
entry+="</div>"
coll.push(entry);return entry;};$prototype.onClick=function(event){var source=event.target();if(!source||!hasElementClass(source,"listed-item-title"))return;while(!hasElementClass(source,"listed-item")){source=source.parentNode;}
var rowpos=parseInt(source.getAttribute("row"));if(typeof(rowpos)!="number")return;var row=this.list.model.getRows()[rowpos];if(!row)return;if(this.list.isSelected(row)){try{this.list.unselect(row);}catch(e){getLogger().logError("Error unselecting item in the list",e);}}else{try{this.list.select(row);}catch(e){getLogger().logError("Error selecting item in the list",e);}}};$prototype.findRowNode=function(rowObj){var node=this.rowMap[rowObj.position||0];if(node)return node;else{var entries=this.getNode().childNodes;for(var i=0;i<entries.length;++i){var position=parseInt(entries[i].getAttribute("row"));if(position==rowObj.position){this.rowMap[rowObj]=entries[i];return entries[i];}}}
return null;};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
this.rowMap=null;userSmarts.wt.widgets.Control.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");userSmarts.wt.widgets.Clock=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){superClass.call(properties);this.tick=bind(userSmarts.wt.widgets.Clock.prototype.tick,this);};$prototype.initNode=function(){var content=this.content=document.createTextNode(toISOTimestamp(new Date()));this.node.appendChild(content);this.start();};$prototype.update=function(){var content=document.createTextNode(toISOTimestamp(new Date()));this.node.replaceChild(content,this.content);this.content=content;};$prototype.start=function(){if(!this.running){this.running=true;this.tick();}};$prototype.stop=function(){this.running=false;};$prototype.tick=function(){this.update();if(this.running){this.timer=setTimeout(this.tick,1000);}};namespace("userSmarts.wt.widgets");$namespace.CSlider=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'cslider',top:0,left:0,handleDimension:7,min:0,max:1,value:0.5,type:"horizontal",showValue:true,displaySize:30});superClass.call(this,properties);this['class']="cslider";if(!this.parent){if(typeof(this.top)=="number"&&typeof(this.left)=="number"){this.setLocation(this.left,this.top);}
if(this.size){this.setSize(this.size.width,this.size.height);}}};$prototype.getAvailableWidth=function(){var width=this.size.width||0;if(this.showValue&&this.type!="vertical"){width-=this.displaySize;}
width-=((this.padding.left+this.margin.left+this.border.left)||0);width-=((this.padding.right+this.margin.right+this.border.right)||0);return Math.max(this.handleDimension+5,width);};$prototype.getAvailableHeight=function(){var height=this.size.height||0;if(this.showValue&&this.type=="vertical"){height-=this.displaySize;}
height-=((this.padding.top+this.margin.top+this.border.top)||0);height-=((this.padding.bottom+this.margin.bottom+this.border.bottom)||0);return Math.max(this.handleDimension+5,height);};$prototype.determinePosition=function(){var size=(this.type=="vertical")?this.getAvailableHeight():this.getAvailableWidth();var value=(this.value*size);value=Math.min(value,size);value=Math.max(value,0);return value;};$prototype.onValueChange=function(position){var pt;var size;if(this.type=="vertical"){pt=position.top;size=this.getAvailableHeight();}else{pt=position.left;size=this.getAvailableWidth();}
var cpt=pt;if(cpt>0){if((pt+this.handleDimension)>=size){cpt=size;}else{cpt=pt+(this.handleDimension/2);}}
var perc=(cpt/size)*(this.max-this.min);perc=Math.min(this.max,perc);perc=Math.max(this.min,perc);perc=roundDecimal(perc,2);if(this.binding){this.binding.setValue(perc);}
this.setProperty("value",perc);if(this.showValue){replaceChildNodes(this.valueDisplay,this.value);}};$prototype.getValue=function(){return this.value;};$prototype.setValue=function(value){this.value=value;};$prototype.updateInlay=function(){var node=this.node;if(!this.inlay){this.inlay=DIV({'class':"slider-inlay"});node.appendChild(this.inlay);}
var top;var left;var width;var height;var aw=this.getAvailableWidth();var ah=this.getAvailableHeight();if(this.type=="vertical"){width=1;height=ah-this.handleDimension;top=this.padding.top+this.margin.top+this.border.top+(this.handleDimension*0.5);left=this.size.width;left-=(this.padding.right+this.margin.right-this.border.right);left*=0.5;}else{width=aw-this.handleDimension;height=1;top=this.size.height;top-=(this.padding.bottom+this.margin.bottom+this.border.bottom);top*=0.5;left=this.padding.left+this.margin.left+this.border.left+(this.handleDimension*0.5);}
this.inlay.style.position="absolute";this.inlay.style.top=top+"px";this.inlay.style.left=left+"px";this.inlay.style.width=width+"px";this.inlay.style.height=height+"px";};$prototype.updateHandle=function(){var node=this.node;var wrapper;if(!this.handle){this.handle=DIV({'class':'slider-handle'});if(this.showValue){wrapper=DIV({});wrapper.style.position="absolute";wrapper.style.top=this.padding.top+this.margin.top+this.border.top+"px";wrapper.style.left=this.padding.left+this.margin.left+this.border.left+"px";wrapper.appendChild(this.handle);node.appendChild(wrapper);}else{node.appendChild(this.handle);}
this.dragHandler=new userSmarts.util.DragHandler();this.dragHandler.init(this.handle);this.dragHandler.connect(this,this.onValueChange);this.dragHandler.constrainToParent=true;this.dragHandler.lockX=(this.type=="vertical");this.dragHandler.lockY=(this.type=="horizontal");}
var top;var left;var width;var height;wrapper=wrapper||this.handle.parentNode;wrapper.style.width=this.getAvailableWidth()+"px";wrapper.style.height=this.getAvailableHeight()+"px";if(this.type=="vertical"){width=this.getAvailableWidth()-2;height=this.handleDimension-2;left=0;top=this.determinePosition();top=Math.max(0,top-(this.handleDimension/2));}else{width=this.handleDimension-2;height=this.getAvailableHeight()-2;top=0;left=this.determinePosition();left=Math.max(0,left-(this.handleDimension/2));}
this.handle.style.position="absolute";this.handle.style.top=top+"px";this.handle.style.left=left+'px';this.handle.style.width=width+"px";this.handle.style.height=height+"px";};$prototype.update=function(){this.updateInlay();this.updateHandle();var node=this.node;if(this.showValue){if(!this.valueDisplay){this.valueDisplay=DIV({'class':'slider-display'});node.appendChild(this.valueDisplay);}
var top;var left;var width;var height;if(this.type=="vertical"){left=this.padding.left+this.margin.left+this.border.left;top=this.getAvailableHeight()+5;width=this.getAvailableWidth()-5;height=this.displaySize;}else{top=this.padding.top+this.margin.top+this.border.top+1;left=this.getAvailableWidth();width=this.displaySize;height=this.getAvailableHeight();}
this.valueDisplay.style.position="absolute";this.valueDisplay.style.top=top+"px";this.valueDisplay.style.left=left+"px";this.valueDisplay.style.width=width+"px";this.valueDisplay.style.height=height+"px";replaceChildNodes(this.valueDisplay,this.value);}
if(userSmarts.util.Browser.isIE){this.inlay.style.height="2px";this.inlay.style.overflowY="hidden";}};$prototype.dispose=function(){this.dragHandler.dispose();userSmarts.wt.widgets.Control.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.Calendar=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'calendar',date:new Date(),daysOfWeek:["S","M","T","W","T","F","S"],monthsOfYear:["January","February","March","April","May","June","July","August","September","October","November","December"],_layout:new userSmarts.wt.layout.RowLayout({type:"vertical"}),updateOnBoundsChange:true,layoutData:{width:"100%",height:"100%"}});if(properties.day){properties.date.setDate(Math.min(Math.max(properties.day,1),31));}
if(properties.month){properties.date.setMonth(Math.min(Math.max(properties.month,0),12));}
if(properties.year){properties.date.setFullYear(properties.year);}
properties.year=properties.month=properties.day=null;superClass.call(this,properties);};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
if(this.prevListener){disconnect(this.prevListener);this.prevListener=null;}
if(this.nextListener){disconnect(this.nextListener);this.nextListener=null;}
userSmarts.wt.widgets.Composite.prototype.dispose.call(this);};$prototype.initNode=function(){this.buildControls();this.buildTitleBar();this.contentBar=new userSmarts.wt.widgets.Composite({'class':'calendar-content',parent:this,updateOnBoundsChange:true,padding:{top:1,left:1,right:1,bottom:1},border:{style:'none',top:0,left:0,right:0,bottom:0},layoutData:{width:"100%",height:"*"},_layout:new userSmarts.wt.layout.GridLayout({columns:7})});this.listener=connect(this.contentBar.getNode(),"onclick",this,this.onDateSelected);this.updateContents();};$prototype.buildTitleBar=function(){this.titleBar=new userSmarts.wt.widgets.Composite({'class':'calendar-titlebar',parent:this,updateOnBoundsChange:true,padding:{top:1,left:1,right:1,bottom:1},border:{style:'solid',top:0,left:0,right:0,bottom:0},layoutData:{width:"100%",height:25},_layout:new userSmarts.wt.layout.RowLayout({type:"horizontal"})});for(var d=0;d<7;d++){var tbard=new userSmarts.wt.widgets.Control({'class':'calendar-title',parent:this.titleBar,updateOnBoundsChange:true,margin:{top:0.4,left:0.4,right:0.4,bottom:0.4},border:{style:'solid',top:1,left:1,right:1,bottom:1},layoutData:{width:"*",height:"100%"}});tbard.getNode().appendChild(document.createTextNode(this.daysOfWeek[d]))}};$prototype.buildControls=function(){this.controlBar=new userSmarts.wt.widgets.Composite({'class':'calendar-controls',parent:this,updateOnBoundsChange:true,margin:{top:5,left:0,right:0,bottom:0},padding:{top:1,left:1,right:1,bottom:1},layoutData:{width:"100%",height:25},_layout:new userSmarts.wt.layout.RowLayout({type:"horizontal"})});var cbard=new userSmarts.wt.widgets.Control({parent:this.controlBar,updateOnBoundsChange:true,layoutData:{width:30,height:"100%"}});var prev=SPAN({},"prev");prev.style.cursor="pointer";this.prevListener=connect(prev,"onclick",this,this.onPrev);cbard.getNode().appendChild(prev);cbard=new userSmarts.wt.widgets.Control({parent:this.controlBar,updateOnBoundsChange:true,layoutData:{width:"*",height:"100%"}});cbard=new userSmarts.wt.widgets.Control({parent:this.controlBar,updateOnBoundsChange:true,layoutData:{width:30,height:"100%"}});var next=SPAN({},"next");next.style.cursor="pointer";this.nextListener=connect(next,"onclick",this,this.onNext);cbard.getNode().appendChild(next);};$prototype.updateContents=function(){this.contentBar.children=[];replaceChildNodes(this.contentBar.getNode(),[]);var dc=this.date.getDate();var cells=this.getCellContents();var row;var col;var span;for(var d=0;d<cells.length;++d){row=Math.floor(d/7);col=(d%7);var cbard=new userSmarts.wt.widgets.Control({'class':'calendar-cell',parent:this.contentBar,updateOnBoundsChange:true,padding:{top:0,left:0,right:0,bottom:0},margin:{top:0.6,left:0.4,right:0.4,bottom:0.6},border:{style:'solid',top:1,left:1,right:1,bottom:1},layoutData:{width:"*",height:"100%"}});span=SPAN({},cells[d]);cbard.getNode().appendChild(span);if(dc==cells[d]*1){addElementClass(cbard.getNode(),"selected");this.selectedNode=cbard.getNode();}else if(cells[d]==""){addElementClass(cbard.getNode(),"empty");}}
this.contentBar.update();var mlabelText=this.monthsOfYear[this.date.getMonth()]+" "+this.date.getFullYear();var mlabel=document.createTextNode(mlabelText);replaceChildNodes(this.controlBar.children[1].getNode(),mlabel);};$prototype.getNumberOfDaysInMonth=function(){var month=this.date.getMonth();if(month==8||month==3||month==5||month==10){return 30;}else if(month==1){var year=this.date.getFullYear();if(year%4==0){return 29;}else{return 28;}}else{return 31;}};$prototype.getCellContents=function(){var results=[];var date=new Date();date.setFullYear(this.date.getFullYear(),this.date.getMonth(),1);var fdom=date.getDay();var ldom=this.getNumberOfDaysInMonth();var start=0;var end=42;for(var c=start;c<end;++c){if(c<fdom||c>(fdom+ldom-1)){results.push("");}else{results.push(((c-fdom)+1)+"");}}
return results;};$prototype.getDate=function(){return this.date;};$prototype.nextYear=function(){this.date.setYear(this.date.getYear()+1);this.updateContents();};$prototype.previousYear=function(){this.date.setYear(this.date.getYear()-1);this.updateContents();};$prototype.nextMonth=function(){this.date.setMonth(this.date.getMonth()+1);this.updateContents();};$prototype.previousMonth=function(){this.date.setMonth(this.date.getMonth()-1);this.updateContents();};$prototype.nextDay=function(){this.date.setDate(this.date.getDate()+1);this.updateContents();};$prototype.previousDate=function(){this.date.setDate(this.date.getDate()-1);this.updateContents();};$prototype.onDateSelected=function(event){var target=event.target();if(!hasElementClass(target,"calendar-cell")){target=target.parentNode;}
if(hasElementClass(target,"calendar-cell")){var day=Coerce.toInteger(scrapeText(target),-1);if(day>0){this.date.setDate(day);removeElementClass(this.selectedNode,"selected");addElementClass(target,"selected");this.selectedNode=target;this.setProperty("selected",this.date);}}};$prototype.onPrev=function(event){this.previousMonth();};$prototype.onNext=function(event){this.nextMonth();};namespace("userSmarts.wt.widgets");$namespace.ColorPalette=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{selected:"#000000",borderSize:1,borderColor:"#ffffff",selectedBorderColor:"#ff0000",layoutData:{width:"100%",height:"100%"}});superClass.call(this,properties);};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};$prototype.initNode=function(){this.initColors();var blockDim=15;var adj=blockDim+(this.borderSize*2);var node=this.node;var rows=7;var cols=10;for(var r=0;r<rows;++r){for(var c=0;c<cols;++c){var div=DIV({id:this.colors[r][c]});div.style.backgroundColor=this.colors[r][c];div.style.position="absolute";div.style.top=r*adj+"px";div.style.left=c*adj+"px";div.style.width=blockDim+"px";div.style.height=blockDim+"px";div.style.border=this.borderSize+"px solid "+this.borderColor;node.appendChild(div);}}
this.listener=connect(node,"onclick",this,this.onClick);};$prototype.initColors=function(){this.colors=[];this.colors[0]=["#FFFFFF","#FFCCCC","#FFCC99","#FFFF99","#FFFFCC","#99FF99","#99FFFF","#CCFFFF","#CCCCFF","#FFCCFF"];this.colors[1]=["#CCCCCC","#FF6666","#FF9966","#FFFF66","#FFFF33","#66FF99","#33FFFF","#66FFFF","#9999FF","#FF99FF"];this.colors[2]=["#C0C0C0","#FF0000","#FF9900","#FFCC66","#FFFF00","#33FF33","#66CCCC","#33CCFF","#6666CC","#CC66CC"];this.colors[3]=["#999999","#CC0000","#FF6600","#FFCC33","#FFCC00","#33CC00","#00CCCC","#3366FF","#6633FF","#CC33CC"];this.colors[4]=["#666666","#990000","#CC6600","#CC9933","#999900","#009900","#339999","#3333FF","#6600CC","#993399"];this.colors[5]=["#333333","#660000","#993300","#996633","#666600","#006600","#336666","#000099","#333399","#663366"];this.colors[6]=["#000000","#330000","#663300","#663333","#333300","#003300","#003333","#000066","#330099","#330033"];};$prototype.onClick=function(evt){var source=evt.target();if(this.selectedDIV){this.selectedDIV.style.border=this.borderSize+"px solid "+this.borderColor;}
source.style.border=this.borderSize+"px solid "+this.selectedBorderColor;this.selectedDIV=source;this.setProperty('selected',source.id);};$prototype.getSelected=function(){return this.selected;};namespace("userSmarts.wt.widgets");$namespace.RichText=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{id:"rich-text-"+Math.random(),'class':'rich-text',layoutData:{width:'100%',height:'100%'},updateOnBoundsChange:true,content:"",readOnly:false,useCSS:false,_layout:new userSmarts.wt.layout.VerticalRowLayout()});var ua=navigator.userAgent.toLowerCase();this.isIE=((ua.indexOf("msie")!=-1)&&(ua.indexOf("opera")==-1)&&(ua.indexOf("webtv")==-1));this.isGecko=(ua.indexOf("gecko")!=-1);this.isSafari=(ua.indexOf("safari")!=-1);this.isKonqueror=(ua.indexOf("konqueror")!=-1);if(document.getElementById&&document.designMode&&!this.isSafari&&!this.isKonqueror){properties.isRichText=true;}
superClass.call(this,properties);};$namespace.RichText.COMMAND_BOLD="bold";$namespace.RichText.COMMAND_ITALIC="italic";$namespace.RichText.COMMAND_UNDERLINE="underline";$namespace.RichText.COMMAND_STRIKETHRU="strikethrough";$namespace.RichText.COMMAND_SUBSCRIPT="subscript";$namespace.RichText.COMMAND_SUPERSCRIPT="superscript";$namespace.RichText.COMMAND_JUSTIFY_LEFT="justifyleft";$namespace.RichText.COMMAND_JUSTIFY_CENTER="justifycenter";$namespace.RichText.COMMAND_JUSTIFY_RIGHT="justifyright";$namespace.RichText.COMMAND_JUSTIFY_FULL="justifyfull";$namespace.RichText.COMMAND_OUTDENT="outdent";$namespace.RichText.COMMAND_INDENT="indent";$namespace.RichText.COMMAND_ORDERED_LIST="insertorderedlist";$namespace.RichText.COMMAND_UNORDERED_LIST="insertunorderedlist";$namespace.RichText.COMMAND_HORIZ_RULE="inserthorizontalrule";$namespace.RichText.COMMAND_FOREGROUND_COLOR="forecolor";$namespace.RichText.COMMAND_BACKGROUND_COLOR=userSmarts.util.Browser.isIE?"backColor":"hiliteColor";$namespace.RichText.COMMAND_UNDO="undo";$namespace.RichText.COMMAND_REDO="redo";$namespace.RichText.COMMAND_REMOVE_FORMAT="removeformat";$namespace.RichText.COMMAND_INSERT_LINK="CreateLink";$namespace.RichText.COMMAND_INSERT_TABLE="table";$namespace.RichText.FORMAT_BLOCK="formatblock";$namespace.RichText.FORMAT_BLOCK_P="p";$namespace.RichText.FORMAT_BLOCK_P_REGEXP=/Normal|p/;$namespace.RichText.FORMAT_BLOCK_H1="h1";$namespace.RichText.FORMAT_BLOCK_H1_RE=/Heading 1|h1/;$namespace.RichText.FORMAT_BLOCK_H2="h2";$namespace.RichText.FORMAT_BLOCK_H2_RE=/Heading 2|h2/;$namespace.RichText.FORMAT_BLOCK_H3="h3";$namespace.RichText.FORMAT_BLOCK_H3_RE=/Heading 3|h3/;$namespace.RichText.FORMAT_BLOCK_H4="h4";$namespace.RichText.FORMAT_BLOCK_H4_RE=/Heading 4|h4/;$namespace.RichText.FORMAT_BLOCK_H5="h5";$namespace.RichText.FORMAT_BLOCK_H5_RE=/Heading 5|h5/;$namespace.RichText.FORMAT_BLOCK_H6="h6";$namespace.RichText.FORMAT_BLOCK_H6_RE=/Heading 6|h6/;$namespace.RichText.FORMAT_BLOCK_ADDRESS="address";$namespace.RichText.FORMAT_BLOCK_ADDRESS_REGEXP=/Address|address/;$namespace.RichText.FORMAT_BLOCK_PRE="pre";$namespace.RichText.FORMAT_BLOCK_PRE_REGEXP=/Formatted|pre/;$namespace.RichText.FORMAT_BLOCK_DEFAULT=$namespace.RichText.FORMAT_BLOCK_P;$namespace.RichText.FONT_NAME="fontname";$namespace.RichText.FONT_NAME_ARIAL='Arial,Helvetica,sans-serif';$namespace.RichText.FONT_NAME_COURIER='Courier New,Courier,mono';$namespace.RichText.FONT_NAME_TIMES='Times New Roman,Times,serif';$namespace.RichText.FONT_NAME_VERDANA='Verdana,Arial,Helvetica,sans-serif';$namespace.RichText.FONT_NAME_DEFAULT=$namespace.RichText.FONT_NAME_TIMES;$namespace.RichText.FONT_SIZE="fontsize";$namespace.RichText.FONT_SIZE_1="1";$namespace.RichText.FONT_SIZE_2="2";$namespace.RichText.FONT_SIZE_3="3";$namespace.RichText.FONT_SIZE_4="4";$namespace.RichText.FONT_SIZE_5="5";$namespace.RichText.FONT_SIZE_6="6";$namespace.RichText.FONT_SIZE_7="7";$namespace.RichText.FONT_SIZE_DEFAULT=$namespace.RichText.FONT_SIZE_3;$prototype.initNode=function(){this.mouseUpCallback=bind(this.onMouseUp,this);this.cursorCallback=bind(this.getCursorPosition,this);this.changeCallback=bind(this.onEditorChange,this);if(this.isRichText){if(!(this.readOnly)){var toolbars=new userSmarts.wt.widgets.RichTextToolbar({parent:this});this.toolbar=toolbars;new userSmarts.wt.action.HorizontalResizeSeparator({parent:this});}
this.editSection=new userSmarts.wt.widgets.IFRAME({parent:this,id:this.id+".edit",layoutData:{width:'100%',height:"*"},padding:{top:2,left:0,right:0,bottom:0}});this.iframeID=this.editSection.getIFRAME().id;this.htmlPre="<html id=\""+this.getIFRAME().id+"\">\n<head>\n<style>\n"+"body {\n background: #FFFFFF;\n margin: 0px;\n padding: 0px;\n}\n"+"</style>\n</head>\n<body>\n";this.htmlPost="\n</body>\n</html>";this.loadedListener=connect(this.editSection,"loaded",this,this.onIFRAMEReady);}else{new userSmarts.wt.forms.TextAreaControl({parent:this,layoutData:{width:"100%",height:"100%"}});}
this.update();};$prototype.update=function(){if(this.editSection){this.editSection.observe();}
userSmarts.wt.widgets.Composite.prototype.update.call(this);};$prototype.getDocument=function(){return this.editSection.getDocument();};$prototype.getWindow=function(){return this.editSection.getWindow();};$prototype.setContent=function(html){this.editSection.setContent(html);};$prototype.setDesignMode=function(state){if(userSmarts.util.Browser.isIE){var doc=this.getDocument();if(!this.readOnly&&doc.designMode!=state){doc.designMode=state;}}else{var iframe=document.getElementById(this.iframeID);if(!this.readOnly&&iframe.contentDocument.designMode!=state){iframe.contentDocument.designMode=state;}}};$prototype.isDesignModeEnabled=function(){return this.getDesignMode().toLowerCase()=="on";};$prototype.getDesignMode=function(){var state="off";if(userSmarts.util.Browser.isIE){var doc=this.getDocument();if(doc)state=doc.designMode;}else{var iframe=document.getElementById(this.iframeID);if(iframe)state=iframe.contentDocument.designMode;}
return state;};$prototype.isEnabled=function(){return this.enabled;};$prototype.setEnabled=function(enabled){this.enabled=(enabled===true);};$prototype.getIFRAME=function(){return this.editSection.getIFRAME();};$prototype.getHidden=function(){return this.editSection.getHidden();};$prototype.isEnabled=function(){if(!this.readOnly)return false;return this.isDesignModeEnabled();};$prototype.getValue=function(skipUpdate){if(!skipUpdate)this.onEditorChange();return this.content;};$prototype.onIFRAMEReady=function(){this.editSection.ignore();this.onLoaded();};$prototype.onLoaded=function(evt){this.initialized=false;if(!this.content&&this.binding){this.content=this.binding.getValue();}
this.getDocument().open();this.getDocument().close();this.setDesignMode("on");this.content=this.content||"";this.content.trim();this.content=this.content.replace(/<b>/gi,"<span style=\"font-weight:bold;\">").replace(/<\/b>/gi,"</span>");this.content=this.content.replace(/<i>/gi,"<span style=\"font-style:italic;\">").replace(/<\/i>/gi,"</span>");this.content=this.content.replace(/<u>/gi,"<span style=\"text-decoration:underline;\">").replace(/<\/u>/gi,"</span>");this.setContent(this.htmlPre+this.content+this.htmlPost);if(!userSmarts.util.Browser.isIE){this.execCommand('useCSS',this.useCSS);}
if(userSmarts.util.Browser.isIE){if(!this.keyboardListener)this.keyboardListener=bind(this.keyUpListener,this);this.addEventHandler("keyup",this.keyboardListener);}else{if(!this.keyboardListener)this.keyboardListener=bind(this.keyPressHandler,this);this.addEventHandler("keypress",this.keyboardListener);}
if(this.mouseUpCallback){this.removeEventHandler("mouseup",this.mouseUpCallback);}
this.addEventHandler("mouseup",this.mouseUpCallback);this.initialized=true;};$prototype.keyUpListener=function(){var iframe=this.getIFRAME();var event=iframe.contentWindow.event;if(event.ctrlKey){this.handleFormattingKey(event);}else{if(event.keyCode>=37&&event.keyCode<=40){setTimeout(this.cursorCallback,100);}}
this.updateContent();};$prototype.keyPressHandler=function(event){if(!event)return;if(event.ctrlKey){this.handleFormattingKey(event);try{event.preventDefault();event.stopPropagation();}catch(e){}}else{if(event.keyCode>=37&&event.keyCode<=40){setTimeout(this.cursorCallback,100);}}
this.updateContent();};$prototype.handleFormattingKey=function(event){var rt=userSmarts.wt.widgets.RichText;var isIE=userSmarts.util.Browser.isIE;var code=(userSmarts.util.Browser.isIE)?event.keyCode:event.charCode;var key=String.fromCharCode(code).toLowerCase();switch(key){case'b':this.toggleButtonState(rt.COMMAND_BOLD,!isIE);break;case'i':this.toggleButtonState(rt.COMMAND_ITALIC,!isIE);break;case'u':this.toggleButtonState(rt.COMMAND_UNDERLINE,!isIE);break;case'z':this.execCommand(rt.COMMAND_UNDO);break;case'y':this.execCommand(rt.COMMAND_REDO);break;};};$prototype.updateContent=function(){setTimeout(this.changeCallback,100);};$prototype.onEditorChange=function(){if(!this.isRichText)return;try{var readOnly=!this.isDesignModeEnabled();if(this.isRichText&&!readOnly){var hiddenField=this.getHidden();if(hiddenField.value==null)hiddenField.value="";var doc=this.getDocument();if(doc.body){hiddenField.value=doc.body.innerHTML;}
if(this.stripHTML(hiddenField.value.replace("&nbsp;"," "))==""&&hiddenField.value.toLowerCase().search("<hr")==-1&&hiddenField.value.toLowerCase().search("<img")==-1)hiddenField.value="";if(escape(hiddenField.value)=="%3Cbr%3E%0D%0A%0D%0A%0D%0A")hiddenField.value="";this.content=hiddenField.value;if(this.binding){this.binding.setValue(this.content);}}}catch(e){getLogger().logError("Error handling editor content change",e);}
if(this.initialized){this.setProperty("modified",true);}};$prototype.execCommand=function(command,option){try{this.getWindow().focus();this.getDocument().execCommand(command,false,option);this.getWindow().focus();this.onEditorChange();}catch(e){getLogger().logError("Error executing RTE command '"+command+"'",e);}};$prototype.isCommandApplied=function(command){if(this.getWindow()){this.getWindow().focus();try{return this.getDocument().queryCommandState(command);}catch(e){return false;}}
return false;};$prototype.chooseColor=function(command){if(!this.colorCallback){this.colorCallback=bind(this.setColor,this,command);}
var dialog=new userSmarts.wt.dialogs.ColorDialog();var def=dialog.open();def.addCallback(this.colorCallback);};$prototype.setColor=function(command,color){if(color){this.setRange();if(document.all){var sel=frames[this.iframeID].document.selection;if(sel!=null){var newRng=sel.createRange();newRng=this.range;newRng.select();}}
this.execCommand(command,color);}
this.colorCallback=null;};$prototype.setRange=function(){if(document.all){var selection=frames[this.iframeID].document.selection;if(selection!=null){this.range=selection.createRange();}}else{var selection=document.getElementById(this.iframeID).contentWindow.getSelection();this.range=selection.getRangeAt(selection.rangeCount-1).cloneRange();}};$prototype.insertHTML=function(html){this.getWindow().focus();if(userSmarts.util.Browser.isIE){this.getDocument().selection.createRange().pasteHTML(html);}else{this.getDocument().execCommand('insertHTML',false,html);}};$prototype.stripHTML=function(oldString){var newString=oldString.replace(/(<([^>]+)>)/ig,"");newString=newString.replace(/\r\n/g," ");newString=newString.replace(/\n/g," ");newString=newString.replace(/\r/g," ");newString=this.trim(newString);return newString;};$prototype.trim=function(inputString){if(typeof inputString!="string")return inputString;var retValue=inputString;var ch=retValue.substring(0,1);while(ch==" "){retValue=retValue.substring(1,retValue.length);ch=retValue.substring(0,1);}
ch=retValue.substring(retValue.length-1,retValue.length);while(ch==" "){retValue=retValue.substring(0,retValue.length-1);ch=retValue.substring(retValue.length-1,retValue.length);}
while(retValue.indexOf("  ")!=-1){retValue=retValue.substring(0,retValue.indexOf("  "))+
retValue.substring(retValue.indexOf("  ")+1,retValue.length);}
return retValue;};$prototype.addEventHandler=function(eventType,handler){var iframe=this.editSection.getIFRAME();if(userSmarts.util.Browser.isIE){if(eventType=="blur"||eventType=="focus"){iframe.attachEvent("on"+eventType,handler);}else{iframe.contentWindow.document.attachEvent("on"+eventType,handler);}}else{iframe.contentDocument.addEventListener(eventType,handler,false);}};$prototype.removeEventHandler=function(eventType,handler){var iframe=this.editSection.getIFRAME();if(userSmarts.util.Browser.isIE){if(eventType=="blur"||eventType=="focus"){iframe.detachEvent("on"+eventType,handler);}else{iframe.contentWindow.document.detachEvent("on"+eventType,handler);}}else{iframe.contentDocument.removeEventListener(eventType,handler,false);}};$prototype.onMouseUp=function(event){var elem;if(userSmarts.util.Browser.isIE){event=this.getIFRAME().contentWindow.event;elem=event.srcElement;}else{elem=event.target;}
this.updateToolbarState(elem);};$prototype.toggleButtonState=function(cmd,fireEvent){try{var button=this.toolbar.getButton(cmd);if(button){var state=button.getSelection();button.setSelection(!state,fireEvent);}}catch(e){}};$prototype.matchButtonState=function(cmd,fireEvent){var state=this.isCommandApplied(cmd);this.updateButtonState(cmd,state,fireEvent);};$prototype.updateButtonState=function(cmd,state,fireEvent){try{var button=this.toolbar.getButton(cmd);if(button)button.setSelection(state,fireEvent);}catch(e){}};$prototype.updateToolbarState=function(elem){if(!elem)return;var rt=userSmarts.wt.widgets.RichText;this.matchButtonState(rt.COMMAND_BOLD,false);this.matchButtonState(rt.COMMAND_ITALIC,false);this.matchButtonState(rt.COMMAND_UNDERLINE,false);this.matchButtonState(rt.COMMAND_SUBSCRIPT,false);this.matchButtonState(rt.COMMAND_SUPERSCRIPT,false);this.matchButtonState(rt.COMMAND_ORDERED_LIST,false);this.matchButtonState(rt.COMMAND_UNORDERED_LIST,false);this.matchButtonState(rt.COMMAND_JUSTIFY_LEFT,false);this.matchButtonState(rt.COMMAND_JUSTIFY_CENTER,false);this.matchButtonState(rt.COMMAND_JUSTIFY_RIGHT,false);this.matchButtonState(rt.COMMAND_JUSTIFY_FULL,false);var fontName=this.getDocument().queryCommandValue(rt.FONT_NAME);fontName=fontName||rt.FONT_NAME_DEFAULT;if(userSmarts.util.Browser.isIE){if(rt.FONT_NAME_ARIAL.indexOf(fontName)>=0){fontName=rt.FONT_NAME_ARIAL;}else if(rt.FONT_NAME_COURIER.indexOf(fontName)>=0){fontName=rt.FONT_NAME_COURIER;}else if(rt.FONT_NAME_TIMES.indexOf(fontName)>=0){fontName=rt.FONT_NAME_TIMES;}else if(rt.FONT_NAME_VERDANA.indexOf(fontName)>=0){fontName=rt.FONT_NAME_VERDANA;}}
var fontSize=this.getDocument().queryCommandValue(rt.FONT_SIZE);fontSize=fontSize||rt.FONT_SIZE_DEFAULT;var formatBlock=this.getDocument().queryCommandValue(rt.FORMAT_BLOCK);formatBlock=formatBlock||rt.FORMAT_BLOCK_DEFAULT;if(userSmarts.util.Browser.isIE){formatBlock=formatBlock.replace("Heading ","h");formatBlock=formatBlock.replace("Formatted","pre");formatBlock=formatBlock.replace("Normal","p");formatBlock=formatBlock.replace("Paragraph","h");formatBlock=formatBlock.toLowerCase();if(formatBlock=="bulleted list"){this.updateButtonState(rt.COMMAND_UNORDERED_LIST,true,false);formatBlock=rt.FORMAT_BLOCK_DEFAULT;}else if(formatBlock=="numbered list"){this.updateButtonState(rt.COMMAND_ORDERED_LIST,true,false);formatBlock=rt.FORMAT_BLOCK_DEFAULT;}}
formatBlock="<"+formatBlock+">";try{this.toolbar.getSelector(rt.FONT_NAME).setValue(fontName);}catch(e){}
try{this.toolbar.getSelector(rt.FONT_SIZE).setValue(fontSize);}catch(e){}
try{this.toolbar.getSelector(rt.FORMAT_BLOCK).setValue(formatBlock);}catch(e){}};$prototype.getCursorPosition=function(){var elem=this.getParentElementOfSelection();this.updateToolbarState(elem);};$prototype.getParentElementOfSelection=function(){if(userSmarts.util.Browser.isIE){var doc=this.getDocument();var selection=doc.selection;var range=selection.createRange();if(selection.type=="None"||selection.type=="Text"){return selection.createRange().parentElement();}else if(selection.type=="Control"){return selection.createRange().item(0);}else{return doc.body;}}else{var selection=this.getWindow().getSelection();if(selection.isCollapsed)return selection.anchorNode;}
return null;};$prototype.dispose=function(){if(this.keyboardListener){if(userSmarts.util.Browser.isIE){this.removeEventHandler("keyup",this.keyboardListener);}else{this.removeEventHandler("keypress",this.keyboardListener);}
this.keyboardListener=null;}
if(this.loadedListener){disconnect(this.loadedListener);this.loadedListener=null;}
if(this.mouseUpCallback){this.removeEventHandler("mouseup",this.mouseUpCallback);this.mouseUpCallback=null;}
this.cursorCallback=this.changeCallback=null;userSmarts.wt.widgets.Composite.prototype.dispose.call(this);};$namespace.IFRAME=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{layoutData:{width:"100%",height:"100%"},updateOnBoundsChange:true,ignoring:false});superClass.call(this,properties);this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));};$prototype.initNode=function(){this.iframeID=this.id+".iframe";this.iframe=new userSmarts.wt.widgets.Control({parent:this,nodeName:"IFRAME",id:this.iframeID,src:null,layoutData:{width:'100%',height:"*"},updateOnBoundsChange:true});this.observe();this.hidden=INPUT({type:'hidden'});this.hidden.value=this.content;this.update();};$prototype.getIFRAME=function(){return this.iframe.getNode();};$prototype.getHidden=function(){return this.hidden;};$prototype.onIFRAMELoaded=function(evt){if(!this.ignoring){this.setProperty("loaded",true);}else{if(this.loaded&&this.getDocument()&&this.getDocument().body&&this.getDocument().body.childNodes.length==0){if(this.getHidden().value&&this.getHidden().value.length>0){this.setContent(this.getHidden().value);}}}};$prototype.ignore=function(){this.ignoring=true;};$prototype.observe=function(){this.ignoring=false;if(!this.listener){this.listener=connect(this.getIFRAME(),"onload",this,this.onIFRAMELoaded);}};$prototype.getDocument=function(){if(this.getWindow()){return this.getWindow().document;}
return null;};$prototype.getWindow=function(){var w=(document.all)?frames[this.iframeID]:this.getIFRAME().contentWindow;return w;};$prototype.setContent=function(html){try{var doc=this.getDocument();doc.open();doc.write(html);doc.close();}catch(e){getLogger().logError("Error updating IFRAME content",e);}};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
userSmarts.wt.widgets.Composite.prototype.dispose.call(this);};$namespace.RichTextToolbar=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{parent:this,'class':'rte-toolbar',padding:{top:2,left:2,right:2,bottom:2},border:{style:"solid",top:0,left:0,right:0,bottom:1},layoutData:{width:"100%",height:30},updateOnBoundsChange:true,_layout:new userSmarts.wt.layout.WrappingRowLayout({spacing:3,maxHeight:23})});superClass.call(this,properties);};$prototype.initNode=function(){this.insertTableCallback=bind(this.onInsertTable,this);this.addControls();};$prototype.addControls=function(){this.styleSelector=new userSmarts.wt.forms.SelectControl({parent:this,id:this.id+".select.style",layoutData:{width:125,height:22},validator:this,validationFunc:"selectStyle",options:[OPTION({value:'<p>',selected:true},'Paragraph <p>'),OPTION({value:'<h1>'},'Heading 1 <h1>'),OPTION({value:'<h2>'},'Heading 2 <h2>'),OPTION({value:'<h3>'},'Heading 3 <h3>'),OPTION({value:'<h4>'},'Heading 4 <h4>'),OPTION({value:'<h5>'},'Heading 5 <h5>'),OPTION({value:'<h6>'},'Heading 6 <h6>'),OPTION({value:'<address>'},'Address <ADDR>'),OPTION({value:'<pre>'},'Formatted <pre>')]});if(userSmarts.util.Browser.isIE){this.styleSelector.getNode().unselectable="on";}
var sep=new userSmarts.wt.action.VerticalSeparator({parent:this});sep.getNode().style.borderColor="#999999";this.fontSelector=new userSmarts.wt.forms.SelectControl({parent:this,id:this.id+".select.font",layoutData:{width:150,height:22},validator:this,validationFunc:"selectFont",options:[OPTION({value:'Arial,Helvetica,sans-serif',selected:true},'Arial'),OPTION({value:'Courier New,Courier,mono'},'Courier New'),OPTION({value:'Times New Roman,Times,serif'},'Times New Roman'),OPTION({value:'Verdana,Arial,Helvetica,sans-serif'},'Verdana')]});if(userSmarts.util.Browser.isIE){this.fontSelector.getNode().unselectable="on";}
sep=new userSmarts.wt.action.VerticalSeparator({parent:this});sep.getNode().style.borderColor="#999999";this.sizeSelector=new userSmarts.wt.forms.SelectControl({parent:this,id:this.id+".select.size",layoutData:{width:100,height:22},validator:this,validationFunc:"selectSize",options:[OPTION({value:'1'},'x-small'),OPTION({value:'2'},'small'),OPTION({value:'3',selected:true},'medium'),OPTION({value:'4'},'large'),OPTION({value:'5'},'x-large'),OPTION({value:'6'},'xx-large'),OPTION({value:'7'},'xxx-large')]});if(userSmarts.util.Browser.isIE){this.sizeSelector.getNode().unselectable="on";}
var rt=userSmarts.wt.widgets.RichText;this.createButton(rt.COMMAND_UNDO,"image.undo",this.doUndo,"Undo");this.createButton(rt.COMMAND_REDO,"image.redo",this.doRedo,"Redo");sep=new userSmarts.wt.action.VerticalSeparator({parent:this});sep.getNode().style.borderColor="#999999";var button=this.createButton(rt.COMMAND_BOLD,"B",this.setBold,"Bold",true);button.style.fontWeight="bold";button=this.createButton(rt.COMMAND_ITALIC,"I",this.setItalics,"Italics",true);button.style.fontStyle="italic";button=this.createButton(rt.COMMAND_UNDERLINE,"U",this.setUnderline,"Underline",true);button.style.textDecoration="underline";this.createButton(rt.COMMAND_SUPERSCRIPT,"image.superscript",this.superScript,"Superscript",true);this.createButton(rt.COMMAND_SUBSCRIPT,"image.subscript",this.subScript,"Subscript",true);this.createButton(rt.COMMAND_FOREGROUND_COLOR,"image.font.color",this.changeForegroundColor,"Font Color");this.createButton(rt.COMMAND_BACKGROUND_COLOR,"image.color",this.changeBackgroundColor,"Background Color");sep=new userSmarts.wt.action.VerticalSeparator({parent:this});sep.getNode().style.borderColor="#999999";this.createButton(rt.COMMAND_JUSTIFY_LEFT,"image.align.left",this.justifyLeft,"Justify Left",true);this.createButton(rt.COMMAND_JUSTIFY_CENTER,"image.align.center",this.justifyCenter,"Justify Center",true);this.createButton(rt.COMMAND_JUSTIFY_RIGHT,"image.align.right",this.justifyLeft,"Justify Right",true);this.createButton(rt.COMMAND_JUSTIFY_FULL,"image.align.full",this.justifyFull,"Justify Full",true);this.createButton(rt.COMMAND_OUTDENT,"image.indent.remove",this.outdent,"Outdent");this.createButton(rt.COMMAND_INDENT,"image.indent.add",this.indent,"Indent");sep=new userSmarts.wt.action.VerticalSeparator({parent:this});sep.getNode().style.borderColor="#999999";this.createButton(rt.COMMAND_ORDERED_LIST,"image.list.ordered",this.insertOrderedList,"Insert Numbered List",true);this.createButton(rt.COMMAND_UNORDERED_LIST,"image.list.unordered",this.insertUnorderedList,"Insert Bulleted List",true);sep=new userSmarts.wt.action.VerticalSeparator({parent:this});sep.getNode().style.borderColor="#999999";this.createButton(rt.COMMAND_INSERT_LINK,"image.link.insert",this.createLink,"Insert Link");this.createButton(rt.COMMAND_INSERT_TABLE,"image.table",this.insertTable,"Insert Table",true);sep=new userSmarts.wt.action.VerticalSeparator({parent:this});sep.getNode().style.borderColor="#999999";this.createButton(rt.COMMAND_REMOVE_FORMAT,"image.delete",this.removeFormatting,"Remove Formatting");this.node.style.overflow="hidden";this.node.style.backgroundColor="#dddddd";};$prototype.getRichTextControl=function(){return this.parent;};$prototype.selectStyle=function(value){if(value){this.execCommand(userSmarts.wt.widgets.RichText.FORMAT_BLOCK,value);}};$prototype.selectFont=function(value){if(value){this.execCommand(userSmarts.wt.widgets.RichText.FONT_NAME,value);}};$prototype.selectSize=function(value){if(value){this.execCommand(userSmarts.wt.widgets.RichText.FONT_SIZE,value);}};$prototype.setBold=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_BOLD,'');};$prototype.setItalics=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_ITALIC,'');};$prototype.setUnderline=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_UNDERLINE,'');};$prototype.superScript=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_SUPERSCRIPT,'');};$prototype.subScript=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_SUBSCRIPT,'');};$prototype.justifyLeft=function(){var rt=userSmarts.wt.widgets.RichText;this.execCommand(rt.COMMAND_JUSTIFY_LEFT,'');this.getButton(rt.COMMAND_JUSTIFY_CENTER).setSelection(false,false);this.getButton(rt.COMMAND_JUSTIFY_RIGHT).setSelection(false,false);this.getButton(rt.COMMAND_JUSTIFY_FULL).setSelection(false,false);};$prototype.justifyCenter=function(){var rt=userSmarts.wt.widgets.RichText;this.execCommand(rt.COMMAND_JUSTIFY_CENTER,'');this.getButton(rt.COMMAND_JUSTIFY_LEFT).setSelection(false,false);this.getButton(rt.COMMAND_JUSTIFY_RIGHT).setSelection(false,false);this.getButton(rt.COMMAND_JUSTIFY_FULL).setSelection(false,false);};$prototype.justifyRight=function(){var rt=userSmarts.wt.widgets.RichText;this.execCommand(rt.COMMAND_JUSTIFY_RIGHT,'');this.getButton(rt.COMMAND_JUSTIFY_LEFT).setSelection(false,false);this.getButton(rt.COMMAND_JUSTIFY_CENTER).setSelection(false,false);this.getButton(rt.COMMAND_JUSTIFY_FULL).setSelection(false,false);};$prototype.justifyFull=function(){var rt=userSmarts.wt.widgets.RichText;this.execCommand(rt.COMMAND_JUSTIFY_FULL,'');this.getButton(rt.COMMAND_JUSTIFY_LEFT).setSelection(false,false);this.getButton(rt.COMMAND_JUSTIFY_CENTER).setSelection(false,false);this.getButton(rt.COMMAND_JUSTIFY_RIGHT).setSelection(false,false);};$prototype.removeFormatting=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_REMOVE_FORMAT,'');};$prototype.insertOrderedList=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_ORDERED_LIST,'');};$prototype.insertUnorderedList=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_UNORDERED_LIST,'');};$prototype.outdent=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_OUTDENT,'');};$prototype.indent=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_INDENT,'');};$prototype.insertImage=function(){var imagePath=prompt('Enter Image URL:','http://');if((imagePath!=null)&&(imagePath!="")){this.execCommand('InsertImage',imagePath);}};$prototype.changeForegroundColor=function(){this.getRichTextControl().chooseColor(userSmarts.wt.widgets.RichText.COMMAND_FOREGROUND_COLOR);};$prototype.changeBackgroundColor=function(){this.getRichTextControl().chooseColor(userSmarts.wt.widgets.RichText.COMMAND_BACKGROUND_COLOR);};$prototype.createLink=function(){var url=prompt("Enter URL:","");if(url){try{this.execCommand("Unlink",null);this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_INSERT_LINK,url);}catch(e){}}};$prototype.insertTable=function(){var button=this.getButton(userSmarts.wt.widgets.RichText.COMMAND_INSERT_TABLE);if(!button.getSelection()){if(this.tableDialog&&this.tableDialog.isOpen()){this.tableDialog.close();}
return;}
var position=elementPosition(button.getNode());position.y+=button.getSize().height;var dialog=new userSmarts.wt.dialogs.TableCreatorPopup();var maxx=getWindowWidth();var maxy=getWindowHeight();if(position.x+dialog.width>=maxx)position.x-=(dialog.width-button.getSize().width);if(position.y+dialog.height>=maxy)position.y-=(dialog.height+button.getSize().height);dialog.setPosition(position.x,position.y);var def=dialog.open();def.addCallback(this.insertTableCallback);this.tableDialog=dialog;};$prototype.onInsertTable=function(table){if(table){this.getRichTextControl().insertHTML(table);}
var button=this.getButton(userSmarts.wt.widgets.RichText.COMMAND_INSERT_TABLE);button.setSelection(false,false);};$prototype.doUndo=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_UNDO);};$prototype.doRedo=function(){this.execCommand(userSmarts.wt.widgets.RichText.COMMAND_REDO);};$prototype.execCommand=function(cmd,value){this.getRichTextControl().execCommand(cmd,value);};$prototype.createButton=function(id,label,func,tooltip,stateful){var button=new userSmarts.wt.widgets.Button({parent:this,label:label,id:id,tooltip:tooltip,stateful:stateful});button.addSelectionListener(bind(func,this));return button.getNode();};$prototype.getButton=function(id){var children=this.getChildren();for(var i=0;i<children.length;++i){if(children[i].id==id){return children[i];}}
return null;};$prototype.getSelector=function(id){if(id==userSmarts.wt.widgets.RichText.FONT_NAME){return this.fontSelector;}else if(id==userSmarts.wt.widgets.RichText.FONT_SIZE){return this.sizeSelector;}else if(id==userSmarts.wt.widgets.RichText.FORMAT_BLOCK){return this.styleSelector;}
return null;};$namespace.Button=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=properties||{};properties.layoutData={width:(userSmarts.util.Browser.isIE?25:22),height:(userSmarts.util.Browser.isIE?25:22)};properties.border={style:"solid",top:1,left:1,right:1,bottom:1};if(typeof(properties.enabled)=="undefined"){properties.enabled=true;}
superClass.call(this,properties);};$prototype.initNode=function(){this.listeners=[];var img=userSmarts.runtime.Platform.getTheme().getImage(this.label);if(img){img.style.position="absolute";img.style.top=(userSmarts.util.Browser.isIE?"1px":"3px");img.style.left=(userSmarts.util.Browser.isIE?"2px":"3px");img.style.width="16px";img.style.height="16px";this.node.appendChild(img);}else{this.node.style.textAlign="center";this.node.appendChild(document.createTextNode(this.label));}
var node=this.node;node.style.cursor="pointer";node.style.backgroundColor="#dddddd";node.style.borderColor="#dddddd";if(this.tooltip)node.title=this.tooltip;if(userSmarts.util.Browser.isIE)node.unselectable="on";this.setEnabled(this.enabled);};$prototype.setEnabled=function(bool){this.enabled=(bool===true);if(!this.enabled){if(this.listener){disconnect(this.listener);this.listener=null;}
if(this.mouseOutListener){disconnect(this.mouseOutListener);this.mouseOutListener=null;}
if(this.mouseOverListener){disconnect(this.mouseOverListener);this.mouseOverListener=null;}
this.node.onmousedown=null;this.node.onmouseup=null;}else{if(!this.mouseOverListener){this.mouseOverListener=connect(this.node,"onmouseover",this,this.onMouseOver);}
if(!this.mouseOutListener){this.mouseOutListener=connect(this.node,"onmouseout",this,this.onMouseOut);}
if(!this.listener){if(!this.stateful){this.node.onmousedown=function(){this.style.borderColor="#999999 #eeeeee #eeeeee #999999";}
this.node.onmouseup=function(){this.style.borderColor="#dddddd";}
this.listener=connect(this.node,"onclick",this,this.fireSelectionEvent);}else{this.listener=connect(this.node,"onclick",this,this.toggleSelection);}}}};$prototype.isEnabled=function(){return this.enabled;};$prototype.addSelectionListener=function(listener){this.listeners.push(listener);};$prototype.removeSelectionListener=function(listener){};$prototype.fireSelectionEvent=function(evt){if(evt){evt.preventDefault();evt.stopPropagation();}
for(var i=0;i<this.listeners.length;++i){this.listeners[i].call(this);}};$prototype.toggleSelection=function(evt){evt.preventDefault();evt.stopPropagation();this.setSelection(!this.getSelection());};$prototype.setSelection=function(bool,fire){if(!this.enabled)return;if(this.stateful){if(this.pressed===bool)return;this.pressed=(bool===true);this.node.style.borderColor=this.pressed?"#999999 #eeeeee #eeeeee #999999":"#dddddd";}
if(fire!==false){this.fireSelectionEvent();}};$prototype.getSelection=function(){if(this.stateful){return this.pressed||false;}
return false;};$prototype.onMouseOver=function(evt){if(!this.pressed){this.node.style.backgroundColor="#eeeeee";this.node.style.borderColor="#ffffff #999999 #999999 #ffffff"}
evt.preventDefault();evt.stopPropagation();};$prototype.onMouseOut=function(evt){this.node.style.backgroundColor="#dddddd";if(!this.pressed){this.node.style.borderColor="#dddddd";}
evt.preventDefault();evt.stopPropagation();};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
if(this.mouseOutListener){disconnect(this.mouseOutListener);this.mouseOutListener=null;}
if(this.mouseOverListener){disconnect(this.mouseOverListener);this.mouseOverListener=null;}
this.node.onmousedown=null;this.node.onmouseup=null;userSmarts.wt.widgets.Control.prototype.dispose.call(this);};namespace("userSmarts.wt.widgets");$namespace.TimePeriodComposite=Class.create($namespace.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{isRange:true,_layout:new userSmarts.wt.layout.RowLayout({type:"horizontal"}),listeners:[]});superClass.call(this,properties);this.startDateCallback=bind(this.updateStartDate,this);this.endDateCallback=bind(this.updateEndDate,this);};$prototype.initNode=function(){this.listeners.push(connect(this,"*",this,this.onDateChange));this.dateFormat=new SimpleDateFormat();this.timeFormat=new SimpleTimeFormat();if(!this.startTime){this.startTime=new Date();}
if(this.isRange){if(!this.endTime){this.endTime=this.startTime.clone();}}
this.startDateField=new userSmarts.wt.forms.FieldControl({parent:this,layoutData:{width:"*",height:"100%"},validator:this,validationFunc:"validateStartDate",binding:new DatePropertyBinding(this,"startTime"),format:this.dateFormat});this.listeners.push(connect(this.startDateField.getNode(),"onclick",this,this.promptForStartDate));this.startTimeField=new userSmarts.wt.forms.FieldControl({parent:this,layoutData:{width:"*",height:"100%"},validator:this,validationFunc:"validateStartTime",binding:new TimePropertyBinding(this,"startTime"),format:this.timeFormat});this.separator=new userSmarts.wt.widgets.Control({parent:this,layoutData:{width:30,height:"100%"}});this.separator.getNode().style.textAlign="center";this.separator.getNode().appendChild(document.createTextNode(" to "));this.separator.setVisibility(this.isRange);this.endDateField=new userSmarts.wt.forms.FieldControl({parent:this,layoutData:{width:"*",height:"100%"},validator:this,validationFunc:"validateEndDate",binding:new DatePropertyBinding(this,"endTime"),format:this.dateFormat});this.listeners.push(connect(this.endDateField.getNode(),"onclick",this,this.promptForEndDate));this.endTimeField=new userSmarts.wt.forms.FieldControl({parent:this,layoutData:{width:"*",height:"100%"},validator:this,validationFunc:"validateEndTime",binding:new TimePropertyBinding(this,"endTime"),format:this.timeFormat});if(!this.isRange){this.endDateField.setVisibility(false);this.endTimeField.setVisibility(false);}
var isRangeControl=new userSmarts.wt.widgets.Control({parent:this,layoutData:{width:"75",height:"100%"}});var cb=INPUT({type:"checkbox"});cb.defaultChecked=cb.checked=this.isRange;this.listeners.push(connect(cb,"onclick",this,this.updateRange));isRangeControl.getNode().appendChild(cb);isRangeControl.getNode().appendChild(document.createTextNode(" Range"));this.rangeCB=cb;};$prototype.updateRange=function(){this.isRange=this.rangeCB.checked;this.endDateField.setVisibility(this.isRange);this.endTimeField.setVisibility(this.isRange);this.separator.setVisibility(this.isRange);if(this.isRange){this.setProperty("endTime",this.startTime.clone());}else{this.setProperty("endTime",null);}};$prototype.promptForStartDate=function(){if(this.startDateDialog&&this.startDateDialog.isOpen()){this.startDateDialog.close();}
this.startDateDialog=new userSmarts.wt.dialogs.CalendarDialog({showTitle:false,autoClose:true,height:200,date:this.startDateField.getValue()});var position=elementPosition(this.startDateField.getNode());this.startDateDialog.setPosition(position.x,position.y+25);var deferred=this.startDateDialog.open();deferred.addCallback(this.startDateCallback);};$prototype.promptForEndDate=function(){if(this.endDateDialog&&this.endDateDialog.isOpen()){this.endDateDialog.close();}
this.endDateDialog=new userSmarts.wt.dialogs.CalendarDialog({showTitle:false,autoClose:true,height:200,date:this.endDateField.getValue()});var position=elementPosition(this.endDateField.getNode());this.endDateDialog.setPosition(position.x,position.y+25);var deferred=this.endDateDialog.open();deferred.addCallback(this.endDateCallback);};$prototype.validateStartDate=function(newStartDate){if(!this.isRange)return null;var endDate=this.endTime;newStartDate.setHours(this.startTime.getHours());newStartDate.setMinutes(this.startTime.getMinutes());newStartDate.setSeconds(this.startTime.getSeconds());this.updateTimeForDST(newStartDate,this.startTime);if(endDate&&newStartDate.isAfter(endDate)){this.endDateField.setValue(newStartDate,false);this.endTimeField.setValue(newStartDate,false);}
return null;};$prototype.updateTimeForDST=function(dateTime,previousDateTime){var nststr=previousDateTime.toString();var dstBefore=(nststr.indexOf("Daylight")>0||nststr.indexOf("DT")>0);nststr=dateTime.toString();var dstAfter=(nststr.indexOf("Daylight")>0||nststr.indexOf("DT")>0);if(dstAfter!=dstBefore){if(dstBefore&&!dstAfter){dateTime.setHours(dateTime.getHours()-1);}else{dateTime.setHours(dateTime.getHours()+1);}}};$prototype.validateStartTime=function(newStartTime,updateInput){var nststr=newStartTime.toString();var dstBefore=(nststr.indexOf("Daylight")>0||nststr.indexOf("DT")>0);newStartTime.setFullYear(this.startTime.getFullYear());newStartTime.setMonth(this.startTime.getMonth());newStartTime.setDate(this.startTime.getDate());nststr=newStartTime.toString();var dstAfter=(nststr.indexOf("Daylight")>0||nststr.indexOf("DT")>0);if(dstAfter!=dstBefore){if(dstBefore&&!dstAfter){newStartTime.setHours(newStartTime.getHours()-1);}else{newStartTime.setHours(newStartTime.getHours()+1);}}
if(!this.isRange)return null;var endTime=this.endTime;if(endTime){if(newStartTime.isAfter(endTime)){this.endTimeField.setValue(newStartTime,false);}}
if(updateInput!==false){this.startTimeField.setValue(newStartTime,false);}
return null;};$prototype.validateEndDate=function(newEndDate){var startDate=this.startTime;newEndDate.setHours(this.endTime.getHours());newEndDate.setMinutes(this.endTime.getMinutes());newEndDate.setSeconds(this.endTime.getSeconds());this.updateTimeForDST(newEndDate,this.endTime);if(startDate&&newEndDate.isBefore(startDate)){this.startDateField.setValue(newEndDate,false);this.startTimeField.setValue(newEndDate,false);}
return null;};$prototype.validateEndTime=function(newEndTime,updateInput){var netstr=newEndTime.toString();var dstBefore=(netstr.indexOf("Daylight")>0||netstr.indexOf("DT")>0);newEndTime.setFullYear(this.endTime.getFullYear());newEndTime.setMonth(this.endTime.getMonth());newEndTime.setDate(this.endTime.getDate());netstr=newEndTime.toString();var dstAfter=(netstr.indexOf("Daylight")>0||netstr.indexOf("DT")>0);if(dstAfter!=dstBefore){if(dstBefore&&!dstAfter){newEndTime.setHours(newEndTime.getHours()-1);}else{newEndTime.setHours(newEndTime.getHours()+1);}}
var startTime=this.startTime;if(startTime){if(newEndTime.isBefore(startTime)){this.startTimeField.setValue(newEndTime,false);}}
if(updateInput!==false){this.endTimeField.setValue(newEndTime,false);}
return null;};$prototype.getStartTime=function(){var startTime;if(this.startDateField){this.startDateField.getValue();}else{startTime=this.startTime;}
return startTime;};$prototype.setStartTime=function(date){this.setProperty("startTime",date);};$prototype.getEndTime=function(){var endTime;if(this.endDateField){endTime=this.endDateField.getValue();}else{endTime=this.endTime;}
return endTime;};$prototype.setEndTime=function(date){this.setProperty("endTime",date);};$prototype.isTimeRange=function(){return this.isRange;};$prototype.onDateChange=function(event){var property=event.propertyName;if(property=="startTime"||property=="endTime"){this.setProperty("modified",true);}};$prototype.updateStartDate=function(date){this.startDateField.setValue(date);};$prototype.updateEndDate=function(date){this.endDateField.setValue(date);};$prototype.dispose=function(){for(var i=0;i<this.listeners.length;++i){disconnect(this.listeners[i]);this.listeners[i]=null;}
this.startDateCallback=null;this.endDateCallback=null;userSmarts.wt.widgets.Composite.prototype.dispose.call(this);};function SimpleDateFormat(){}
SimpleDateFormat.prototype.format=function(obj){var result="";if(typeof(obj)=='string'){obj=this.parseObject(obj);}
if(obj&&typeof(obj.toUTCString)=="function"){var month=obj.getMonth()+1;if(month<10)month="0"+month;var day=obj.getDate();if(day<10)day="0"+day;result=month+"/"+day+"/"+obj.getFullYear();}
return result;};SimpleDateFormat.prototype.parseObject=function(text){if(text){var parts=text.split("/");if(parts.length==3){var value=new Date();value.setMonth((parts[0]*1)-1);value.setDate(parts[1]*1);value.setFullYear(parts[2]*1);return value;}}};function SimpleTimeFormat(){this.timezones={"GMT":0,"CET":1,"NST":-3,"AST":-4,"EST":-5,"CST":-6,"MST":-7,"PST":-8,"AKST":-9,"HAST":-10,"HST":-10,"BST":-11};this.dstimezones={"GMT":0,"CEDT":1,"NDT":-2,"ADT":-3,"EDT":-4,"CDT":-5,"MDT":-6,"PDT":-7,"AKDT":-8,"HADT":-9};}
SimpleTimeFormat.prototype.isUnderDST=function(date){var str=date.toString();return str.indexOf("Daylight")>0||str.indexOf("DT")>0;}
SimpleTimeFormat.prototype.format=function(obj){var result="";if(obj&&typeof(obj.toUTCString)=="function"){var seconds=obj.getSeconds();if(seconds<10)seconds="0"+seconds;var minutes=obj.getMinutes();if(minutes<10)minutes="0"+minutes;var hours=obj.getHours();if(hours<10)hours="0"+hours;result=hours+":"+minutes+":"+seconds;var dst=this.isUnderDST(obj);var tzo=-1*(obj.getTimezoneOffset()/60);var zones=dst?this.dstimezones:this.timezones;for(var id in zones){if(zones[id]==tzo){result+=" "+id;break;}}}
return result;};SimpleTimeFormat.prototype.parseObject=function(text){if(text){var result=new Date();var timeStr;var timeExpr=/^\d{1,2}(([:]\d{2})?([:]\d{2}))?/;var matches=text.match(timeExpr);if(matches&&matches.length>0){timeStr=matches[0];}else{timeStr="12:00:00";}
var hours=0;var minutes=0;var seconds=0;var tparts=timeStr.split(":");if(tparts.length>0){hours=tparts[0]*1;hours=Math.min(Math.max(hours,0),23);}
if(tparts.length>1){var minutes=tparts[1]*1;minutes=Math.min(Math.max(minutes,0),59);}
if(tparts.length>2){var seconds=tparts[2]*1;seconds=Math.min(Math.max(seconds,0),59);}
var meridian;var merExpr=/[aApP][mM]?/;matches=text.match(merExpr);if(matches&&matches.length>0){meridian=matches[0];if(meridian=="pm"&&hours<12){hours+=12;}else if(meridian=="am"&&hours==12){hours=0;}}
result.setHours(hours);result.setMinutes(minutes);result.setSeconds(seconds);var zoneExpr=/(([\-A-Z0-9a-z]{3,4})|(GMT[\-\+]\d{4})){1}$/;var matches=text.match(zoneExpr);if(matches&&matches.length>0){this.applyTimeZone(result,matches[0]);}
return result;}};SimpleTimeFormat.prototype.applyTimeZone=function(time,input){var gmtStr;var tzExpr=/([-A-Z0-9a-z]{3,4})/;var matches=input.match(tzExpr);if(matches&&matches.length>0){gmtStr=this.lookUpTimeZoneOffset(matches[0]);}else{var gmtExpr=/GMT[\-\+]\d{4}?/;matches=input.match(gmtExpr);if(matches&&matches.length>0){gmtStr=matches[0];}}
if(gmtStr){var sep=(gmtStr.indexOf("+")>0)?"+":"-";var parts=gmtStr.split(sep);var offset=parts[1];var hourOffset=offset.substring(1,2)*(sep=="+"?1:-1);var minOffset=offset.substring(2,4)*(sep=="+"?1:-1);hourOffset=(-1*(time.getTimezoneOffset()/60))-hourOffset;time.setHours(time.getHours()+hourOffset);time.setMinutes(time.getMinutes()+minOffset);}else{var hourOffset=(-1*(time.getTimezoneOffset()/60));time.setHours(time.getHours()+hourOffset);}};SimpleTimeFormat.prototype.lookUpTimeZoneOffset=function(timezoneId){if(timezoneId=="GDT")return"GMT-0000";if(timezoneId=="GMT")return"GMT-0000";if(timezoneId=="NST")return"GMT-0330";if(timezoneId=="NDT")return"GMT-0230";if(timezoneId=="AST")return"GMT-0400";if(timezoneId=="ADT")return"GMT-0300";if(timezoneId=="EST")return"GMT-0500";if(timezoneId=="EDT")return"GMT-0400";if(timezoneId=="CST")return"GMT-0600";if(timezoneId=="CDT")return"GMT-0500";if(timezoneId=="MST")return"GMT-0700";if(timezoneId=="MDT")return"GMT-0600";if(timezoneId=="PST")return"GMT-0800";if(timezoneId=="PDT")return"GMT-0700";if(timezoneId=="AKST")return"GMT-0900";if(timezoneId=="AKDT")return"GMT-0800";if(timezoneId=="YST")return"GMT-0900";if(timezoneId=="YDT")return"GMT-0800";if(timezoneId=="HST"||timezoneId=="HAST")return"GMT-1000";if(timezoneId=="HDT"||timezoneId=="HADT")return"GMT-0900";if(timezoneId=="BST")return"GMT-1100";if(timezoneId=="CET")return"GMT+0100";if(timezoneId=="CEDT")return"GMT+0100";if(timezoneId=="YW1")return"GMT-0100";if(timezoneId=="YW2")return"GMT-0200";if(timezoneId=="Z-13")return"GMT+1300";if(timezoneId=="ZE10")return"GMT+1000";if(timezoneId=="ZE11")return"GMT+1100";if(timezoneId=="ZE12")return"GMT+1200";if(timezoneId=="ZE2")return"GMT+0200";if(timezoneId=="ZE3")return"GMT+0300";if(timezoneId=="ZE3B")return"GMT+0330";if(timezoneId=="ZE4")return"GMT+0400";if(timezoneId=="ZE4B")return"GMT+0430";if(timezoneId=="ZE5")return"GMT+0500";if(timezoneId=="ZE5B")return"GMT+0530";if(timezoneId=="ZE5C")return"GMT+0545";if(timezoneId=="ZE6")return"GMT+0600";if(timezoneId=="ZE6B")return"GMT+0630";if(timezoneId=="ZE7")return"GMT+0700";if(timezoneId=="ZE8")return"GMT+0800";if(timezoneId=="ZE9")return"GMT+0900";if(timezoneId=="ZE9B")return"GMT+0930";if(timezoneId=="ZW1")return"GMT-0100";if(timezoneId=="ZW12")return"GMT-1200";if(timezoneId=="ZW2")return"GMT-0200";if(timezoneId=="ZW3")return"GMT-0300";};SimpleTimeFormat.prototype.isDaylightSavingAffected=function(){var rightNow=new Date();var date1=new Date(rightNow.getFullYear(),0,1,0,0,0,0);var date2=new Date(rightNow.getFullYear(),6,1,0,0,0,0);var temp=date1.toGMTString();var date3=new Date(temp.substring(0,temp.lastIndexOf(" ")-1));var temp=date2.toGMTString();var date4=new Date(temp.substring(0,temp.lastIndexOf(" ")-1));var hoursDiffStdTime=(date1-date3)/(1000*60*60);var hoursDiffDaylightTime=(date2-date4)/(1000*60*60);if(hoursDiffDaylightTime==hoursDiffStdTime){return false;}else{return true;}};DatePropertyBinding=Class.create(BeanPropertyBinding2);$prototype.initialize=function(superClass,bean,dateProperty){superClass.call(this,bean,dateProperty,{useGettersSetters:false});};DatePropertyBinding.prototype.setValue=function(value){if(typeof this.bean.setProperty=="function"){if(value){var date=this.bean.getProperty(this.propertyName);if(date){date.setFullYear(value.getFullYear());date.setMonth(value.getMonth());date.setDate(value.getDate());this.bean.touch(this.propertyName);}else{this.bean.setProperty(this.propertyName,value);}}else{this.bean.setProperty(this.propertyName,value);}}else{if(value){var date=this.bean[this.propertyName];if(date){date.setFullYear(value.getFullYear());date.setMonth(value.getMonth());date.setDate(value.getDate());}else{this.bean[this.propertyName]=value;}}else{this.bean[this.propertyName]=value;}}};TimePropertyBinding=Class.create(BeanPropertyBinding2);$prototype.initialize=function(superClass,bean,dateProperty){superClass.call(this,bean,dateProperty,{useGettersSetters:false});};TimePropertyBinding.prototype.setValue=function(value){if(typeof this.bean.setProperty=="function"){if(value){var date=this.bean.getProperty(this.propertyName);if(date){date.setHours(value.getHours());date.setMinutes(value.getMinutes());date.setSeconds(value.getSeconds());this.bean.touch(this.propertyName);}else{this.bean.setProperty(this.propertyName,value);}}else{this.bean.setProperty(this.propertyName,value);}}else{if(value){var date=this.bean[this.propertyName];if(date){date.setHours(value.getHours());date.setMinutes(value.getMinutes());date.setSeconds(value.getSeconds());}else{this.bean[this.propertyName]=value;}}else{this.bean[this.propertyName]=value;}}};if(!Date.prototype.clone){Date.prototype.clone=function(){result=new Date();result.setFullYear(this.getFullYear());result.setMonth(this.getMonth());result.setDate(this.getDate());result.setHours(this.getHours());result.setMinutes(this.getMinutes());result.setSeconds(this.getSeconds());return result;}};namespace("userSmarts.wt.action");namespace("userSmarts.wt.action");namespace("userSmarts.wt.action");userSmarts.wt.action.ContributionItem=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties||{},{nodeName:"span","class":"contribution-item"});superClass.call(this,properties);};$prototype.getId=function(){return this.id;};$prototype.execute=function(){};userSmarts.wt.action.ContributionItemGroup=Class.create(userSmarts.wt.action.ContributionItem);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);this.items=[];};$prototype.size=function(){return this.items.length;};$prototype.addContributionItem=function(item){this.items.push(item);};$prototype.getContributionItems=function(){return this.item;};namespace("userSmarts.wt.action");userSmarts.wt.action.ContributionManager=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{"class":'widget-bar',items:[]});superClass.call(this,properties);};$prototype.addItem=function(item){if(item instanceof userSmarts.wt.widgets.Control){this.items.push(item);}else if(item.nodeType){addElementClass(item,'widget-item');var widget={paint:function(context){return item;},update:function(context){}};this.addItem(widget);}else if(typeof(item)=='string'){this.addItem(SPAN({'class':'widget-item'},item));}else{logWarning("ContributionManager.addItem :: Unable to add item, item is not of either type Control, Node or String");}};$prototype.update=function(){var renderedItems=[];for(var i=0;i<this.items.length;++i){var item=this.items[i];item.update();renderedItems.push(item.getNode());}
replaceChildNodes(this.getNode(),renderedItems);};namespace("userSmarts.wt.action");$namespace.Action=Class.create(userSmarts.wt.action.ContributionItem);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{id:'',enabled:true,showText:false,text:"",'class':properties.className||'action-item',nodeName:"SPAN",border:{style:"solid",top:1,left:1,right:1,bottom:1},margin:{left:5,right:5,top:0,bottom:0},listeners:[]});superClass.call(this,properties);};$prototype.execute=function(){if(typeof(this.run)=='function'){try{this.run();}catch(e){alert("Error trying to "+this.text+"\n"+e);}}};$prototype.run=function(){};$prototype.getId=function(){return this.id;};$prototype.setId=function(id){this.id=id;};$prototype.getClassName=function(){return this['class'];};$prototype.setClassName=function(className){this['class']=className;};$prototype.getImage=function(){return this.image;};$prototype.setImage=function(image){this.image=image;};$prototype.getDisabledImage=function(){return this.disabledImage;};$prototype.setDisabledImage=function(image){this.disabledImage=image;};$prototype.getText=function(){return this.text;};$prototype.setText=function(text){this.text=text;};$prototype.getToolTipText=function(){return this.toolTipText;};$prototype.setToolTipText=function(text){this.toolTipText=text;};$prototype.getAccelerator=function(){return this.accelerator;};$prototype.setAccelerator=function(key){this.accelerator=key;};$prototype.isShowText=function(){return this.showText===true;};$prototype.isEnabled=function(){return this.enabled;};$prototype.setEnabled=function(bool){this.setProperty("enabled",(bool===true));this.update();};$prototype.getCurrentIcon=function(){var icon=(this.enabled||!this.getDisabledImage())?this.getImage():this.getDisabledImage();return userSmarts.runtime.Platform.getTheme().getImage(icon);};$prototype.initNode=function(){var node=this.node;node.style.position="relative";node.style.cursor="pointer";this.listeners.push(connect(this.node,'onmouseover',this,this.onOver));this.listeners.push(connect(this.node,'onmouseout',this,this.onOut));this.icon=IMG({'class':this.getClassName()+"-icon"});this.icon.style.marginRight="2px";this.icon.style.width="16px";this.icon.style.height="16px";node.appendChild(this.icon);if(this.isShowText()){node.appendChild(document.createTextNode(this.getText()));}
this.update();};$prototype.update=function(){var node=this.getNode();var enabled=this.isEnabled();node.title=this.getToolTipText()+(enabled?"":" (DISABLED)");if(enabled&&!this.clickListener){this.clickListener=connect(node,'onclick',this,this.execute);}else if(!enabled&&this.clickListener){disconnect(this.clickListener);this.clickListener=null;}
this.icon.alt=this.getText();var icon=this.getCurrentIcon();if(icon){this.icon.src=icon.src;this.icon.style.background=icon.style.background;}};$prototype.toString=function(){return"[Action id='"+this.getId()+"']";};$prototype.onOver=function(event){if(this.node){this.node.className=this.getClassName()+"-hover";}};$prototype.onOut=function(event){if(this.node){this.node.className=this.getClassName();}};$prototype.dispose=function(){for(var l=0;l<this.listeners.length;++l){disconnect(this.listeners[l]);this.listeners[l]=null;}
if(this.clickListener){disconnect(this.clickListener);this.clickListener=null;}};namespace("userSmarts.wt.action");$namespace.StatefulAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{checked:false,checkedClassName:'action-item-checked'});superClass.call(this,properties);};$prototype.getClassName=function(){var className;if(this.checked){className=this.getCheckedClassName();}else{className=userSmarts.wt.action.Action.prototype.getClassName.call(this);}
return className;};$prototype.getCheckedClassName=function(){return this.checkedClassName;};$prototype.setCheckedClassName=function(className){this.checkedClassName=className;};$prototype.getCheckedImage=function(){return this.checkedImage;};$prototype.getDisabledCheckedImage=function(){return this.disabledCheckedImage;}
$prototype.getCurrentIcon=function(){var result=null;if(this.isChecked()){var icon=null;if(this.isEnabled()){icon=this.getCheckedImage()||this.getImage();}else{icon=this.getDisabledCheckedImage()||this.getDisabledImage()||this.getImage();}
result=userSmarts.runtime.Platform.getTheme().getImage(icon);}else{result=userSmarts.wt.action.Action.prototype.getCurrentIcon.call(this);}
return result;};$prototype.getText=function(){var text=this.isChecked()?this.getCheckedText()||this.text:this.text;return text;};$prototype.getCheckedText=function(){return this.checkedText;}
$prototype.setCheckedText=function(text){this.checkedText=text;};$prototype.setChecked=function(bool){this.setProperty("checked",(bool===true));this.update();};$prototype.isChecked=function(){return this.checked;};$prototype.execute=function(){var method=null;var checked=this.isChecked();if(checked){method="stop";}else{method="run";}
this.setChecked(!checked);if(typeof(this[method])=="function"){try{this[method]();}catch(e){getLogger().logError("Error trying to "+method+" '"+this.text+"': "+e);}}};$prototype.stop=function(){this.run();};$prototype.update=function(){userSmarts.wt.action.Action.prototype.update.call(this);var className=this.getClassName();if(this.isChecked()){className=this.getCheckedClassName()||className;}
this.node.className=className;var text=this.isChecked()?this.getCheckedText()||this.getText():this.getText();replaceChildNodes(this.node,[this.icon,document.createTextNode(text)]);};namespace("userSmarts.wt.action");$namespace.ActionContribution=Class.create(userSmarts.wt.action.ContributionItem);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'action-item',margin:{top:0,left:0,right:0,bottom:1},padding:{top:0,left:2,right:2,bottom:0},border:{style:"solid",top:1,left:1,right:1,bottom:1},layoutData:{width:75,height:"100%"}});superClass.call(this,properties);this.listeners=[];if(this.action){this.listeners.push(connect(this.action,"*",this,this.onActionChange));if(!this.text){this.text=this.action.getText();}
if(!this.toolTipText){this.toolTipText=this.action.getToolTipText();}
if(!this.imageDesc){this.imageDesc=this.action.getImage();}
if(!this.disabledImageDesc){this.disabledImageDesc=this.action.getDisabledImage();}
if(this.action instanceof userSmarts.wt.action.StatefulAction){this.text=this.action.text;if(!this.checkedText){this.checkedText=this.action.getCheckedText();}
if(!this.checkedImageDesc){this.checkedImageDesc=this.action.getCheckedImage();}
if(!this.disabledImageDesc){this.disabledCheckedImageDesc=this.action.getDisabledCheckedImage();}}}};$prototype.getId=function(){return this.action.getId();};$prototype.isEnabled=function(){return this.action&&this.action.isEnabled();};$prototype.getImageDescriptor=function(){return this.imageDesc;};$prototype.getDisabledImageDescriptor=function(){return this.disabledImageDesc;};$prototype.getCheckedImageDescriptor=function(){return this.checkedImageDesc;};$prototype.getDisabledCheckedImageDescriptor=function(){return this.disabledCheckedImageDesc;};$prototype.getText=function(){if(this.action instanceof userSmarts.wt.action.StatefulAction){if(this.action.isChecked()){return this.checkedText||this.text;}}
return this.text;};$prototype.getToolTipText=function(){return this.toolTipText;};$prototype.onActionChange=function(event){var property=event.property;var value=event.newValue;if(this.node){this.update();}};$prototype.getClassName=function(){if(this.action instanceof userSmarts.wt.action.StatefulAction){return this['class']+(this.action.isChecked()?"-checked":"");}else{return this['class'];}};$prototype.getImage=function(){var desc;if(this.action instanceof userSmarts.wt.action.StatefulAction){var id=this.getImageDescriptor();var did=this.getDisabledImageDescriptor();var cid=this.getCheckedImageDescriptor();var dcid=this.getDisabledCheckedImageDescriptor();if(this.isEnabled()){desc=this.action.isChecked()?cid||id:id;}else{desc=this.action.isChecked()?dcid||did||id:did||id;}}else{if(this.isEnabled()){desc=this.getImageDescriptor();}else{desc=this.getDisabledImageDescriptor()||this.getImageDescriptor();}}
var theme=userSmarts.runtime.Platform.getTheme();return theme.getImage(desc);};$prototype.initNode=function(){var node=this.node;node.style.cursor="pointer";node.style.textAlign="center";node.style.overflow="hidden";this.listeners.push(connect(node,'onmouseover',this,this.onOver));this.listeners.push(connect(node,'onmouseout',this,this.onOut));this.icon=IMG({'class':this.getClassName()+"-icon"});this.icon.style.width="16px";this.icon.style.height="16px";this.icon.style.position="absolute";this.icon.style.top="0px";this.icon.style.left="0px";node.appendChild(this.icon);var len=determineLabelWidth(this.getText(),this['class']);this.layoutData.width=len+40;if(this.getText()){var txt=SPAN({},this.getText());txt.style.position="absolute";txt.style.top="0px";txt.style.left="18px";this.textNode=txt;node.appendChild(txt);}
this.update();};$prototype.update=function(){var node=this.getNode();var enabled=this.isEnabled();node.className=this.getClassName();node.title=this.getToolTipText()+(enabled?"":" (DISABLED)");if(enabled&&!this.clickListener){this.clickListener=connect(node,'onclick',this,this.onClick);}else if(!enabled&&this.clickListener){disconnect(this.clickListener);this.clickListener=null;}
var img=this.getImage();if(img){this.icon.src=img.src;this.icon.style.background=img.style.background;if(!this.isEnabled()){this.icon.style.opacity='0.5';this.icon.style.filter='alpha(opacity=50)';}else{this.icon.style.opacity='1.0';this.icon.style.filter='alpha(opacity=100)';}}
var text=Coerce.toString(this.getText(),"");this.icon.alt=text;this.textNode.innerHTML=text;};$prototype.toString=function(){return"[Action id='"+this.getId()+"']";};$prototype.onOver=function(event){if(this.node){this.node.className=this.getClassName()+"-hover";}};$prototype.onOut=function(event){if(this.node){this.node.className=this.getClassName();}};$prototype.dispose=function(){for(var l=0;l<this.listeners.length;++l){disconnect(this.listeners[l]);this.listeners[l]=null;}
if(this.clickListener){disconnect(this.clickListener);this.clickListener=null;}};$prototype.onClick=function(event){if(this.action){this.action.execute();}};namespace("userSmarts.wt.action");$namespace.MenuBarActionContribution=Class.create($namespace.ActionContribution);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{nodeName:"DIV",'class':'action-item',border:{style:"none",top:1,left:1,right:1,bottom:1},margin:{top:5,left:3,right:3,bottom:0}});superClass.call(this,properties);};$prototype.initNode=function(){var node=this.node;node.style.position="relative";node.style.cursor="pointer";node.style.overflow="hidden";this.listeners.push(connect(node,'onmouseover',this,this.onOver));this.listeners.push(connect(node,'onmouseout',this,this.onOut));if(this.action instanceof userSmarts.wt.action.StatefulAction){this.checkbox=INPUT({type:"checkbox"});this.checkbox.disabled=true;node.appendChild(this.checkbox);}else{var img=userSmarts.runtime.Platform.getTheme().getImage("image.spacer");img.style.height="16px";img.style.width="16px";img.alt="  ";node.appendChild(img);}
this.icon=IMG({'class':this.getClassName()+"-icon"});this.icon.style.width="16px";this.icon.style.height="16px";node.appendChild(this.icon);if(this.getText()){var txt=SPAN({},this.getText());this.textNode=txt;node.appendChild(txt);}
this.update();};$prototype.update=function(){userSmarts.wt.action.ActionContribution.prototype.update.call(this);if(this.checkbox){this.checkbox.checked=this.checkbox.defaultChecked=this.action.isChecked();}};namespace("userSmarts.wt.action");userSmarts.wt.action.StatusLineManager=function(properties){Bean.call(this,properties);this.clearFunc=bind(this.clear,this);};userSmarts.wt.action.StatusLineManager.inheritsFrom(Bean);userSmarts.wt.action.StatusLineManager.prototype.setMessage=function(text){if(this.clearTimer){clearTimeout(this.clearTimer);}
if(text&&text!==""){this.appendToDisplay(text);this.clearTimer=setTimeout(this.clearFunc,4000);}else{this.clear();}};userSmarts.wt.action.StatusLineManager.prototype.getMessage=function(){var sb=$("statusBar");if(sb){return sb.childNodes[0];}
return null;};userSmarts.wt.action.StatusLineManager.prototype.paint=function(){return DIV();};userSmarts.wt.action.StatusLineManager.prototype.clear=function(){this.appendToDisplay("");this.clearTimer=null;};userSmarts.wt.action.StatusLineManager.prototype.appendToDisplay=function(args){var sb=$("statusBar");if(sb){replaceChildNodes(sb,args);}};namespace("userSmarts.wt.action");userSmarts.wt.action.ToolbarManager=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'action-toolbar',layoutData:{width:"*",height:"*"},items:[],_layout:new userSmarts.wt.layout.ToolbarLayout()});superClass.call(this,properties);};$prototype.add=function(item){var child=null;if(item instanceof userSmarts.wt.action.Action){child=new userSmarts.wt.action.ActionContribution({action:item});}else if(item instanceof userSmarts.wt.action.ActionContribution){child=item;}
else if(item instanceof userSmarts.wt.widgets.Control){child=item;}
if(child){userSmarts.wt.widgets.Composite.prototype.add.call(this,child);}};$prototype.remove=function(itemId){var child=null;if(typeof(itemId)=="string"){for(var i=0;i<this.items.length;i++){if(this.items[i].getId()==itemId){child=this.items[i];break;}}}else if(itemId instanceof userSmarts.wt.widgets.Control){child=itemId;}
if(child){userSmarts.wt.widgets.Composite.prototype.remove.call(this,child);}};$prototype.getItems=function(){return this.items;};$prototype.isEmpty=function(){return(this.items.length===0);};$prototype.removeAll=function(){this.children=[];};namespace("userSmarts.wt.action");$namespace.MenuBarManager=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':"menu-bar",items:[],layoutData:{width:1,height:"100%"},padding:{top:2,left:0,right:0,bottom:0}});superClass.call(this,properties);this.closeListener=bind(this.onMenuClose,this);};$prototype.initNode=function(){var node=this.node;node.title="Toggle Menubar";var icon=this.getIcon();icon.className="action-item";icon.style.borderStyle="none";icon.style.cursor="pointer";icon.style.display="none";this.listener=connect(node,"onclick",this,this.toggleMenu);node.appendChild(icon);};$prototype.getIcon=function(){var theme=userSmarts.runtime.Platform.getTheme();var img=theme.getImage("image.selector");return img;};$prototype.updateIcon=function(){var src=null;var theme=userSmarts.runtime.Platform.getTheme();if(this.menu){var img=theme.getImage("image.selector.selected");}else{var img=theme.getImage("image.selector");}
this.node.replaceChild(img,this.node.childNodes[0]);};$prototype.toggleMenu=function(){if(this.menu){this.menu.close();this.menu=null;}else{this.menu=new userSmarts.wt.dialogs.MenuBar({items:this.getItems()});var position=elementPosition(this.getNode());var x=Math.max(position.x-this.menu.width+this.size.width,0);var y=position.y+this.size.height;var windowHeight=Math.max(getWindowHeight(),100);if((y+this.menu.height)>(windowHeight-5)){y=position.y-this.menu.height;}
this.menu.setPosition(x,y);var def=this.menu.open();def.addCallback(this.closeListener);}
this.updateIcon();};$prototype.onMenuClose=function(){this.menu=null;this.updateIcon();};$prototype.add=function(item){if(item instanceof userSmarts.wt.action.Action){this.items.push(new userSmarts.wt.action.MenuBarActionContribution({action:item}));}
else{this.items.push(item);}
if(!this.isVisible()){this.setVisibility(true);}};$prototype.remove=function(itemId){var item;for(var i=0;i<this.items.length;i++){item=this.items[i];if(item.getId()==itemId){this.items.slice(i,1);break;}}
if(this.isEmpty()){this.setVisibility(false);}};$prototype.getItems=function(){return this.items;};$prototype.isEmpty=function(){return(this.items.length===0);};$prototype.removeAll=function(){this.items=[];this.setVisibility(false);};$prototype.isVisible=function(){return this.getLayoutData().width>1;};$prototype.setVisibility=function(visible){if(visible===true){this.getLayoutData().width=25;this.getNode().childNodes[0].style.display="inline";}else{this.getLayoutData().width=1;this.getNode().childNodes[0].style.display="none";}};$prototype.isOpen=function(){return this.menu!=null;};$prototype.close=function(){if(this.isOpen()){this.toggleMenu();}};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};namespace("userSmarts.wt.action");$namespace.ConfigureTableAction=Class.create(userSmarts.wt.action.StatefulAction);$prototype.initialize=function(superClass,properties){if(isPrototype(arguments))return;properties=setdefault(properties,{id:'confTableAction',text:"Configure",toolTipText:'Configure table columns',image:"image.table.configure"});superClass.call(this,properties);};$prototype.run=function(){if(!this.isChecked())return;var model;if(this.model){model=this.model;}else if(this.control.model){model=this.control.model;}
if(model){var dialog=new userSmarts.wt.dialogs.ConfigureTableDialog({model:model});var deferred=dialog.open();deferred.addCallback(bind(function(){this.setChecked(false);},this));}else{this.setChecked(false);}};namespace("userSmarts.wt.action");$namespace.SortOnColumnAction=Class.create(userSmarts.wt.action.StatefulAction);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{id:'sortOnColAction',text:"Sort Items",checkedText:"Unsort Items",toolTipText:'Select a column to sort on',image:"image.table.configure"});superClass.call(this,properties);this.callback=bind(this.onDialogClosed,this);};$prototype.run=function(){var checked=this.isChecked();if(!checked){var model=this.control.model;if(model){model.sort(null);}}else{var model=this.control.model;if(model){var dialog=new userSmarts.wt.dialogs.SelectColumnDialog({model:model});var def=dialog.open();def.addCallback(this.callback);}else{getLogger().logWarning("SortOnColumnAction.run() - Control has no model!");}}};$prototype.onDialogClosed=function(column){var model=this.control.model;if(model){model.sort(column);}
if(!column)this.setChecked(false);};namespace("userSmarts.wt.action");userSmarts.wt.action.RefreshTableAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=properties||{};setdefault(properties,{adapter:this,id:'refTableAction',text:"Refresh Table",toolTipText:'Refresh Table',image:"image.refresh"});superClass.call(this,properties);};$prototype.run=function(){var model=null;if(this.model){model=this.model;}else if(this.control){model=this.control.model;}
if(model){model.populate(model.getOffset());}};namespace("userSmarts.wt.action");userSmarts.wt.action.OpenToolbarSelectorAction=Class.create(userSmarts.wt.action.StatefulAction);$prototype.initialize=function(superClass,properties){properties=properties||{};setdefault(properties,{id:'openTBSelectorAction',text:"Show Menu",toolTipText:'Show Toolbar Items'});superClass.call(this,properties);var theme=userSmarts.runtime.Platform.getTheme();if(theme){this.image=theme.get("image.obj.selector");}else{this.image=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/icons/selector.png');}
this.run=this.runMethod;};$prototype.runMethod=function(){if(!this.isChecked()){this.setChecked(false);if(this.dialog){this.dialog.close();}
return;}
if(this.site&&this.site instanceof userSmarts.ui.WorkbenchSite){var tbmgr=this.site.getActionBars().getToolbarManager();var count=tbmgr.getItems().length-1;var heightPerIcon=16;var totalHeight=count*16+(2*count);var dialog=new userSmarts.wt.dialogs.ToolbarMenu({toolbarManager:tbmgr,height:totalHeight});var deferred=dialog.open();deferred.addCallback(bind(function(){this.setChecked(false);},this));this.dialog=dialog;this.setChecked(true);}};namespace("userSmarts.wt.action");userSmarts.wt.action.RefreshListAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=properties||{};setdefault(properties,{adapter:this,id:'refListAction',text:"Refresh List",toolTipText:'Refresh List',image:"image.refresh"});userSmarts.wt.action.Action.call(this,properties);this.run=this.runMethod;};$prototype.runMethod=function(){var model=null;if(this.model){model=this.model;}else if(this.list){model=this.list.model;}
if(model){model.populate(model.getOffset());}};namespace("userSmarts.wt.action");userSmarts.wt.action.ExpandListAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=properties||{};setdefault(properties,{adapter:this,id:'expListAction',text:"Expand All Items",toolTipText:'Expand List',image:"image.list.expand"});superClass.call(this,properties);this.run=this.runMethod;};$prototype.runMethod=function(){var list=null;if(this.list){list=this.list;}
if(list&&list.model){var rows=list.model.getRows();for(var i=0;i<rows.length;++i){list.expand(rows[i]);}}};namespace("userSmarts.wt.action");userSmarts.wt.action.CollapseListAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=properties||{};setdefault(properties,{adapter:this,id:'expListAction',text:"Collapse All Items",toolTipText:'Collapse List',image:"image.list.collapse"});superClass.call(this,properties);this.run=this.runMethod;};$prototype.runMethod=function(){var list=null;if(this.list){list=this.list;}
if(list&&list.model){var rows=list.model.getRows();for(var i=0;i<rows.length;++i){list.collapse(rows[i]);}}};namespace("userSmarts.wt.action");$namespace.SaveEditorAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{id:'userSmarts.wt.action.saveeditor',text:'Save',toolTipText:'Save Changes to Editor',image:"image.save"});superClass.call(this,properties);};$prototype.run=function(){if(this.editor){this.editor.doSave();}};namespace("userSmarts.wt.action");$namespace.HorizontalSeparator=Class.create($namespace.ContributionItem);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{nodeName:"DIV",'class':"separator",layoutData:{width:"95%",height:2},border:{style:"solid",top:1,left:0,right:0,bottom:1},margin:{top:5,left:0,right:0,bottom:0}});superClass.call(this,properties);};$prototype.initNode=function(){this.node.style.position="relative";this.node.style.width="99%";this.node.style.height="0px";this.node.style.borderColor="#CCCCCC #CCCCCC #FFFFFF #CCCCCC";if(userSmarts.util.Browser.isIE){this.node.style.height="2px";this.node.style.overflowY="hidden";}};namespace("userSmarts.wt.action");$namespace.VerticalSeparator=Class.create($namespace.ContributionItem);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{nodeName:"DIV",'class':"separator",layoutData:{width:7,height:"99%"},border:{style:"solid",top:0,left:1,right:0,bottom:0},margin:{top:0,left:2,right:2,bottom:0}});superClass.call(this,properties);};$prototype.initNode=function(){this.node.style.position="relative";this.node.style.height="95%";this.node.style.width="0px";};namespace("userSmarts.wt.action");$namespace.HorizontalResizeSeparator=Class.create($namespace.HorizontalSeparator);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{layoutData:{width:"100%",height:3},margin:{top:0,left:0,right:0,bottom:0},padding:{top:1,left:0,right:0,bottom:1},border:{style:"none",top:0,left:0,right:0,bottom:0}});superClass.call(this,properties);};$prototype.initNode=function(){this.node.style.cursor="pointer";var dragger=new userSmarts.wt.action.ResizeSeparatorHandler({cursor:"s-resize",lockX:true,separator:this});dragger.init(this.node);userSmarts.wt.action.HorizontalSeparator.prototype.initNode.call(this);};namespace("userSmarts.wt.action");$namespace.VerticalResizeSeparator=Class.create($namespace.VerticalSeparator);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{layoutData:{width:3,height:"100%"},margin:{top:0,left:0,right:0,bottom:0},padding:{top:0,left:1,right:1,bottom:0},border:{style:"none",top:0,left:0,right:0,bottom:0}});superClass.call(this,properties);};$prototype.initNode=function(){this.node.style.cursor="pointer";var dragger=new userSmarts.wt.action.ResizeSeparatorHandler({cursor:"e-resize",lockY:true,separator:this});dragger.init(this.node);userSmarts.wt.action.VerticalSeparator.prototype.initNode.call(this);};namespace("userSmarts.wt.action");$namespace.ResizeSeparatorHandler=Class.create();$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{lockX:false,lockY:false,cursor:"e-resize"});setdefault(this,properties);this.move=null;this.down=null;this.offset=null;this.target=null;this.listener=null;this.listeners=[];};$prototype.connect=function(listener,listenerFunc){if(listenerFunc){this.listeners.push(connect(this,"modified",listener,listenerFunc));}else{this.listeners.push(connect(this,"modified",listener));}};$prototype.init=function(elem,hook){this.target=elem;var el=(hook)?hook:elem;if(el){el.style.cursor=this.cursor;this.listener=connect(el,'onmousedown',this,this.start);}
if(this.isDisposed){this.listeners=[];this.isDisposed=false;}
this.dummy=DIV();this.dummy.style.position="absolute";this.dummy.style.border="1px dotted black";};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
for(var l=0;l<this.listeners.length;++l){disconnect(this.listeners[l]);this.listeners[l]=null;}
this.listeners=null;this.isDisposed=true;this.target=null;this.dummy=null;};$prototype.start=function(e){e.stop();if(!this.target)return;if(this.move)return;var beforeSeparator;var afterSeparator;var index=-1;var separator=this.separator;var parent=separator.getParent();var siblings=parent.getChildren();for(var i=0;i<siblings.length;++i){if(siblings[i]==separator){index=i;break;}else if(siblings[i]instanceof userSmarts.wt.action.VerticalSeparator||siblings[i]instanceof userSmarts.wt.action.HorizontalSeparator){beforeSeparator=siblings[i];}}
for(var i=index+1;i<siblings.length;++i){if(siblings[i]instanceof userSmarts.wt.action.VerticalSeparator||siblings[i]instanceof userSmarts.wt.action.HorizontalSeparator){afterSeparator=siblings[i];break;}}
var parentNode=parent.getNode();var min;if(beforeSeparator){min=elementPosition(beforeSeparator.getNode());min.x+=10;min.y+=10;}else{min=elementPosition(parentNode);min.x+=10;min.y+=10;}
var max;if(afterSeparator){max=elementPosition(afterSeparator.getNode());max.x-=5;max.y-=5;}else{max={x:min.x+parseInt(parentNode.style.width),y:min.y+parseInt(parentNode.style.height)};max.x-=30;max.y-=30;}
this.bounds={minX:min.x,maxX:max.x,minY:min.y,maxY:max.y};var pos=elementPosition(this.target);this.offset=this.diff(e.mouse().page,pos);this.move=connect(document,'onmousemove',this,this.drag);this.down=connect(document,'onmouseup',this,this.stop);this.showDummy();};$prototype.drag=function(e){e.stop();if(this.target&&this.move){var pos=this.diff(e.mouse().page,this.offset);this.update(pos);}else{this.stop();}};$prototype.stop=function(e){try{var separator=this.separator;var parent=separator.getParent();var parentSize=parent.getSize();var dummyPos=elementPosition(this.dummy);this.hideDummy();var offset=this.diff(dummyPos,elementPosition(this.target));var beforeSibling;var afterSibling;var index=-1;var siblings=parent.getChildren();for(var i=0;i<siblings.length;++i){if(siblings[i]==separator){index=i;break;}}
if(index>0)beforeSibling=siblings[index-1];if(index>=0&&index<siblings.length-1){afterSibling=siblings[index+1];}
if(beforeSibling){this.adjustDimensions(beforeSibling,offset,true);}
if(afterSibling){offset.x*=-1;offset.y*=-1;this.adjustDimensions(afterSibling,offset,false);}
parent.update();parent.setProperty("childBoundsChanged",true);}catch(e){getLogger().logError("Error resizing layout:\n"+e);}
disconnect(this.move);this.move=null;disconnect(this.down);this.down=null;};$prototype.determinePercentage=function(perc,parentSize,offset){var percValue=perc/100;var percChange=Math.abs(offset)/parentSize;if(offset<0)percChange*=-1;percValue+=percChange;percValue*=100;return percValue;};$prototype.adjustDimensions=function(control,offset,changeUnits){var parentSize=control.getParent().getSize();var ld=control.getLayoutData();if(this.lockY){var width=ld.width;if(ld.units.width=="%"){ld.width=this.determinePercentage(width,parentSize.width,offset.x);}else if(ld.units.width!="*"){ld.width=width+offset.x;}else if(changeUnits&&ld.units.width=="*"){ld.width=control.getSize().width+offset.x;ld.units.width="px";}}else if(this.lockX){var height=ld.height;if(ld.units.height=="%"){ld.height=this.determinePercentage(height,parentSize.height,offset.y);}else if(ld.units.height!="*"){ld.height=height+offset.y;}else if(changeUnits&&ld.units.height=="*"){ld.height=control.getSize().height+offset.y;ld.units.height="px";}}};$prototype.diff=function(lhs,rhs){return{x:lhs.x-rhs.x,y:lhs.y-rhs.y};};$prototype.update=function(pos){if(!this.target){this.stop();return;}
try{var isUndefNull=MochiKit.Base.isUndefinedOrNull;if(!isUndefNull(pos.x)&&!this.lockX){if(pos.x>this.bounds.minX&&pos.x<this.bounds.maxX){this.dummy.style.left=pos.x+"px";}}
if(!isUndefNull(pos.y)&&!this.lockY){if(pos.y>this.bounds.minY&&pos.y<this.bounds.maxY){this.dummy.style.top=pos.y+"px";}}}catch(e){this.stop();getLogger().logError("Error resizing, cause: "+e);}};$prototype.showDummy=function(){var position=elementPosition(this.target)||{x:parseInt(this.target.style.left),y:parseInt(this.target.style.top)};this.dummy.style.top=position.y+"px";this.dummy.style.left=position.x+"px";this.dummy.style.width=this.target.style.width;this.dummy.style.height=this.target.style.height;document.body.appendChild(this.dummy);};$prototype.hideDummy=function(){document.body.removeChild(this.dummy);};namespace("userSmarts.wt.dialogs");namespace("userSmarts.wt.dialogs");namespace("userSmarts.wt.dialogs");$namespace.Dialog=Class.create();$prototype.initialize=function(superClass,properties){var defaultWidth=200;var defaultHeight=150;var defaultTop=0;var defaultLeft=0;if(!properties.top&&!properties.left){var cx=getWindowWidth()/2;var cy=getWindowHeight()/2;var ox=(properties.width|defaultWidth)/2;var oy=(properties.height|defaultHeight)/2;defaultTop=cy-oy;defaultLeft=cx-ox;}
var predefaultModal=properties.modal;var preDefaultShowTitle=properties.showTitle;var preDefaultShowButtons=properties.showButtons;var preDefaultTables=properties.useTables;properties=setdefault(properties,{modal:true,useTables:false,showTitle:true,showButtons:true,enableKeys:false,disableDrag:false,'class':'dialog',title:"Dialog",position:{x:defaultLeft,y:defaultTop},width:defaultWidth,height:defaultHeight,margin:{left:0,right:0,top:0,bottom:0},padding:{left:2,right:2,top:2,bottom:2},border:{style:"solid",left:1,right:1,top:1,bottom:1}});if(predefaultModal===false){properties.modal=false;}
if(preDefaultShowTitle===false){properties.showTitle=false;}
if(preDefaultShowButtons===false){properties.showButtons=false;}
if(preDefaultTables===false){properties.useTables=false;}
setdefault(this,properties);this.opened=false;};$prototype.open=function(){this.deferred=new Deferred();this.dialogDiv=this.paint();this.dialogDiv.style.display="none";$("display").appendChild(this.dialogDiv);this.dialogDiv.style.display="block";this.focus();this.opened=true;return this.deferred;};$prototype.close=function(){if(this.dragHandler){this.dragHandler.dispose();this.dragHandler=null;}
if(this.keyListener){disconnect(this.keyListener);this.keyListener=null;}
if(this.cancelListener){disconnect(this.cancelListener);this.cancelListener=null;}
if(this.okListener){disconnect(this.okListener);this.okListener=null;}
if(this.dialogDiv){this.dialogDiv.style.display="none";$("display").removeChild(this.dialogDiv);this.dialogDiv=null;}
this.opened=false;};$prototype.isOpen=function(){return this.opened===true;};$prototype.okPressed=function(){if(this.deferred){this.deferred.callback(true);this.deferred=null;}};$prototype.cancelPressed=function(){if(this.deferred){this.deferred.callback(false);this.deferred=null;}};$prototype.getTitleBar=function(){return this.titleBar;};$prototype.getDialogArea=function(){return this.dialogArea;};$prototype.getButtonBar=function(){return this.buttonBar;};$prototype.getOKButton=function(){return this.okButton;};$prototype.getCancelButton=function(){return this.cancelButton;};$prototype.createDialogArea=function(parent){var result=DIV();if(this.description){result.innerHTML=this.description.replace(/\n/,"<BR/>");}
parent.appendChild(result);};$prototype.setPosition=function(x,y){this.position.x=x;this.position.y=y;if(this.useTables){if(this.innerTable){if(this.modal===true){this.dialogDiv.style.top="0px";this.dialogDiv.style.left="0px";}else{this.dialogDiv.style.top=x+"px";this.dialogDiv.style.left=y+"px";}}}else{var wrapper=this.dialogDiv;if(this.dialogDiv){var wtop=y;var wleft=x;var dtop=0;var dleft=0;var dialog;if(this.modal===true){wtop=0;wleft=0;wwidth=getWindowWidth();wheight=getWindowHeight();dtop=(wheight/2)-(this.height/2);dleft=(wwidth/2)-(this.width/2);dialog=wrapper.childNodes[1];}else{dialog=wrapper.childNodes[0];}
wrapper.style.top=wtop+"px";wrapper.style.left=wleft+"px";dialog.style.top=dtop+"px";dialog.style.left=dleft+"px";}}};$prototype.setSize=function(width,height){this.width=parseInt(width);this.height=parseInt(height);if(this.useTables){if(this.innerTable){this.innerTable.setAttribute("width",this.width);this.innerTable.setAttribute("height",this.height);}}else{var wrapper=this.dialogDiv;if(this.dialogDiv){var dialog;if(this.modal===false){wrapper.style.width=this.width+"px";wrapper.style.height=this.height+"px";dialog=wrapper.childNodes[0];}else{dialog=wrapper.childNodes[1];}
dialog.style.width=this.width+"px";dialog.style.height=this.height+"px";}}};$prototype.onOk=function(){this.okPressed();this.close();};$prototype.onCancel=function(){this.cancelPressed();this.close();};$prototype.focus=function(){};$prototype.createButtonBar=function(parent){var cancelBtn=BUTTON(null,"Cancel");cancelBtn.style.width="75px";this.cancelListener=connect(cancelBtn,'onclick',this,this.onCancel);this.cancelButton=cancelBtn;parent.appendChild(cancelBtn);var okBtn=BUTTON(null,"OK");okBtn.style.width="75px";this.okListener=connect(okBtn,'onclick',this,this.onOk);this.okButton=okBtn;parent.appendChild(okBtn);};$prototype.paint=function(){var node=(this.useTables===true)?this.renderWithTables():this.renderWithDivs();if(this.enableKeys){this.keyListener=connect(node,"onkeydown",this,this.onKeyPressed);}
return node;};$prototype.renderWithTables=function(){var className=this['class'];var thead=THEAD();var tbody=TBODY();var tfoot=TFOOT();var innerTable=TABLE({'class':className,width:this.width+'',height:this.height+'',cellspacing:'0',cellSpacing:'0',cellpadding:'5',cellPadding:'5',border:'1',align:'center',valign:'middle'},thead,tbody,tfoot);this.innerTable=innerTable;if(this.showTitle){this.titleBar=TD({width:'100%',align:'left'},this.title);thead.appendChild(TR({'class':className+'-titlearea'},this.titleBar));}
if(this.showButtons){this.buttonBar=TD({width:'100%'});this.createButtonBar(this.buttonBar);tfoot.appendChild(TR({'class':className+'-buttonbar'},this.buttonBar));}
this.dialogArea=TD({width:'100%'});this.createDialogArea(this.dialogArea);tbody.appendChild(TR({'class':className+'-dialogarea'},this.dialogArea));var top=this.position.y;var left=this.position.x;var width=this.width;var height=this.height;if(this.modal===true){var outerTable=TABLE({width:'100%',height:'100%'},TBODY({},TR(null,TD({vAlign:'center',valign:'center',align:'center'},innerTable))));top=0;left=0;width=getWindowWidth();height=getWindowHeight();}
var dialogDiv=DIV();if(this.modal===true){dialogDiv.className=className+'-modal-container';}else{dialogDiv.className=className+'-container';}
dialogDiv.style.position="absolute";dialogDiv.style.top=top+"px";dialogDiv.style.left=left+"px";dialogDiv.style.width=width+"px";dialogDiv.style.height=height+"px";dialogDiv.style.textAlign="center";dialogDiv.style.verticalAlign="middle";if(this.modal===true){dialogDiv.appendChild(outerTable);}else{dialogDiv.appendChild(innerTable);}
return dialogDiv;};$prototype.renderWithDivs=function(){var className=this['class'];var width=this.width;var height=this.height;var wtop=this.position.y;var wleft=this.position.x;var wwidth=width;var wheight=height;var dtop=0;var dleft=0;var wclassName=className+"-container";if(this.modal===true){wclassName=className+"-modal-container";wtop=0;wleft=0;wwidth=getWindowWidth();wheight=getWindowHeight();dtop=(wheight/2)-(this.height/2);dleft=(wwidth/2)-(this.width/2);}
var wrapper=DIV({'class':wclassName});wrapper.style.position="absolute";wrapper.style.top=wtop+"px";wrapper.style.left=wleft+"px";wrapper.style.width=wwidth+"px";wrapper.style.height=wheight+"px";wrapper.style.textAlign="center";if(this.modal===true){var blocker=DIV({'class':className+'-blocker'});blocker.style.position="absolute";blocker.style.top="0px";blocker.style.left="0px";blocker.style.width=wwidth+"px";blocker.style.height=wheight+"px";wrapper.appendChild(blocker);}
width-=this.border.left;width-=this.border.right;height-=this.border.top;height-=this.border.bottom;var div=DIV({'class':className});div.style.position="absolute";div.style.top=dtop+"px";div.style.left=dleft+"px";div.style.borderStyle=this.border.style;div.style.borderTopWidth=this.border.top+"px";div.style.borderBottomWidth=this.border.bottom+"px";div.style.borderLeftWidth=this.border.left+"px";div.style.borderRightWidth=this.border.right+"px";div.style.width=width+"px";div.style.height=height+"px";wrapper.appendChild(div);var icon;if(this.image){var theme=userSmarts.runtime.Platform.getTheme();if(theme){icon=theme.getImage(this.image,null);if(icon){icon.style.marginRight="2px";}}}
if(this.showTitle){var tb=DIV({'class':className+'-titlearea'},(icon?icon:""),this.title);tb.style.height="25px";tb.style.width=(parseInt(div.style.width)-4)+"px";tb.style.borderStyle="solid";tb.style.borderBottomWidth="1px";tb.style.borderTopWidth="1px";tb.style.borderRightWidth="1px";tb.style.borderLeftWidth="1px";tb.style.paddingTop="2px";tb.style.paddingBottom="2px";tb.style.paddingLeft="2px";tb.style.paddingRight="0px";tb.style.overflow="hidden";div.appendChild(tb);this.titleBar=tb;height-=31;if(!this.disableDrag){this.dragHandler=new userSmarts.util.DragHandler();if(this.modal===true){this.dragHandler.init(div,this.titleBar);}else{this.dragHandler.init(wrapper,this.titleBar);}}}
if(this.showButtons)height-=27;width-=2;width-=this.margin.left;width-=this.margin.right;width-=this.padding.left;width-=this.padding.right;height-=this.margin.top;height-=this.margin.bottom;height-=this.padding.top;height-=this.padding.bottom;var da=DIV({'class':className+'-dialogarea'});da.style.width=width+"px";da.style.height=height+"px";da.style.overflow="auto";da.style.textAlign="left";da.style.marginLeft=this.margin.left+"px";da.style.marginRight=this.margin.right+"px";da.style.marginTop=this.margin.top+"px";da.style.marginBottom=this.margin.bottom+"px";da.style.paddingLeft=this.padding.left+"px";da.style.paddingRight=this.padding.right+"px";da.style.paddingTop=this.padding.top+"px";da.style.paddingBottom=this.padding.bottom+"px";da.style.borderStyle=(this.showTitle&&this.showButtons)?"solid":"none";da.style.borderLeftWidth=((this.showTitle&&this.showButtons)?"1":"0")+"px";da.style.borderRightWidth=((this.showTitle&&this.showButtons)?"1":"0")+"px";da.style.borderTopWidth="0px";da.style.borderBottomWidth="0px";this.createDialogArea(da);div.appendChild(da);this.dialogArea=da;if(this.showButtons){var bb=DIV({'class':className+'-buttonbar'});bb.style.height="25px";bb.style.width=(parseInt(div.style.width)-2)+"px";bb.style.borderStyle="solid";bb.style.borderTopWidth="1px";bb.style.borderBottomWidth="1px";bb.style.borderLeftWidth="1px";bb.style.borderRightWidth="1px";bb.style.textAlign="right";bb.style.overflow="hidden";this.createButtonBar(bb);div.appendChild(bb);this.buttonBar=bb;}
return wrapper;};$prototype.onKeyPressed=function(event){var key=event.key().code;if(key==13){this.onOk();}else if(key==27){this.onCancel();}};namespace("userSmarts.wt.dialogs");userSmarts.wt.dialogs.DialogWizard=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{title:"Wizard",name:"",width:300,height:200});setdefault(this,properties);userSmarts.wt.dialogs.Dialog.call(this,properties);this.pages=[];this.currentPage=-1;this.lastPage=-1;};userSmarts.wt.dialogs.DialogWizard.inheritsFrom(userSmarts.wt.dialogs.Dialog);userSmarts.wt.dialogs.DialogWizard.prototype.addPage=function(dialog){if(dialog instanceof userSmarts.wt.dialogs.Dialog){this.pages.push(dialog);if(this.currentPage<0){this.currentPage=0;this.isFirstPage=true;}}};userSmarts.wt.dialogs.DialogWizard.prototype.addPages=function(){};userSmarts.wt.dialogs.DialogWizard.prototype.getNextButton=function(){return this.nextButton;};userSmarts.wt.dialogs.DialogWizard.prototype.getPreviousButton=function(){return this.prevButton;};userSmarts.wt.dialogs.DialogWizard.prototype.getFinishButton=function(){return this.finishButton;};userSmarts.wt.dialogs.DialogWizard.prototype.finishPressed=function(){this.okPressed();};userSmarts.wt.dialogs.DialogWizard.prototype.createDialogArea=function(parent){this.renderDialogArea();};userSmarts.wt.dialogs.DialogWizard.prototype.renderDialogArea=function(){var clb=this.getCancelButton();var bbar=this.getButtonBar();var prb=BUTTON(null,"Previous");prb.onclick=bind(this.prevPage,this);this.prevButton=prb;var nxb=BUTTON(null,"Next");nxb.onclick=bind(this.nextPage,this);this.nextButton=nxb;var fnb=BUTTON(null,"Finish");fnb.onclick=bind(this.finishPressed,this);this.finishButton=fnb;if(this.isFirstPage&&this.isLastPage){replaceChildNodes(bbar,[clb,fnb]);}else if(this.isFirstPage){replaceChildNodes(bbar,[clb,nxb]);}else if(this.isLastPage){replaceChildNodes(bbar,[clb,prb,fnb]);}else{if(this.canFinish){replaceChildNodes(bbar,[clb,prb,nxb,fnb]);}else{replaceChildNodes(bbar,[clb,prb,nxb]);}}
var page=this.pages[this.currentPage];page.paint();this.setSize(page.width,page.height);var parent=this.titleBar.parentNode;parent.replaceChild(page.titleBar,this.titleBar);this.titleBar=page.titleBar;replaceChildNodes(this.dialogArea,page.dialogArea.childNodes);};userSmarts.wt.dialogs.DialogWizard.prototype.nextPage=function(){this.lastPage=this.currentPage;if(this.currentPage<this.pages.length){this.currentPage++;if(this.currentPage==this.pages.length-1){this.isLastPage=true;}else{this.isLastPage=false;}}
this.onPageChange();this.renderDialogArea();};userSmarts.wt.dialogs.DialogWizard.prototype.prevPage=function(){this.lastPage=this.currentPage;if(this.currentPage>0){this.currentPage--;if(this.currentPage==this.pages.length-1){this.isFirstPage=true;}else{this.isFirstPage=false;}}
this.onPageChange();this.renderDialogArea();};userSmarts.wt.dialogs.DialogWizard.prototype.onPageChange=function(){};namespace("userSmarts.wt.dialogs");$namespace.MessageDialog=Class.create(userSmarts.wt.dialogs.Dialog);$prototype.initialize=function(superClass){superClass.call(this,arguments);};$prototype.open=function(){throw new Error("Must use 'openError', 'openWarning', 'openInformation', or "+"'openConfirm' when opening a MessageDialog!");};$prototype.close=function(){return false;};$prototype.okPressed=function(){};$prototype.cancelPressed=function(){};$namespace.MessageDialog.openError=function(title,msg){alert("Error: "+title+"\n\n"+msg);};$namespace.MessageDialog.openWarning=function(title,msg){alert("Warning: "+title+"\n\n"+msg);};$namespace.MessageDialog.openInformation=function(title,msg){alert(title+"\n\n"+msg);};$namespace.MessageDialog.openConfirm=function(title,msg){return confirm(msg);};$namespace.PromptDialog=Class.create(userSmarts.wt.dialogs.Dialog);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{title:"Enter a value",value:"",enableKeys:true,useTables:false,modal:false});};$prototype.createDialogArea=function(parent){parent.appendChild(document.createTextNode(this.description));parent.appendChild(BR());var props={size:50,parent:this,validationFunc:"validate",binding:new BeanPropertyBinding2(this,'value')};var field=new userSmarts.wt.forms.Field2(props);parent.appendChild(field.paint());this.field=field;};$prototype.focus=function(){this.field.focus();};$prototype.getValue=function(){return this.value;};$prototype.validate=function(value){if(value&&value.length>0){return null;}
return"Must specify a value";};$prototype.okPressed=function(){if(this.deferred){this.deferred.callback(this.getValue());this.deferred=null;}};$prototype.cancelPressed=function(){if(this.deferred){this.value=null;this.deferred.callback(null);this.deferred=null;}};$namespace.ConfirmDialog=Class.create(userSmarts.wt.dialogs.Dialog);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{title:"Yes or No",enableKeys:true,useTables:false,modal:false});};$prototype.createButtonBar=function(){var yesBtn=BUTTON(null,"Yes");connect(yesBtn,'onclick',this,this.onOk);this.okButton=yesBtn;parent.appendChild(yesBtn);var noBtn=BUTTON(null,"No");connect(noBtn,'onclick',this,this.onCancel);parent.appendChild(noBtn);var cancelBtn=BUTTON(null,"Cancel");connect(cancelBtn,'onclick',this,this.onAbort);this.cancelButton=cancelBtn;parent.appendChild(cancelBtn);};$prototype.onAbort=function(){if(this.deferred){this.deferred.callback(null);this.deferred=null;}
this.close();};namespace("userSmarts.wt.dialogs");userSmarts.wt.dialogs.ConfigureTableDialog=function(properties){if(isPrototype(arguments))return;properties=properties||{};setdefault(properties,{title:"Configure Table Columns",description:"Check or uncheck each column to change visibility:",modal:false,width:200,height:200});userSmarts.wt.dialogs.Dialog.call(this,properties);};userSmarts.wt.dialogs.ConfigureTableDialog.inheritsFrom(userSmarts.wt.dialogs.Dialog);userSmarts.wt.dialogs.ConfigureTableDialog.prototype.createDialogArea=function(parent){parent.appendChild(document.createTextNode(this.description));parent.appendChild(BR());var columns=this.model.getColumns();var box;var colName;for(var i=0;i<columns.length;i++){colName=this.model.getColumnLabel(columns[i],null);box=INPUT({type:'checkbox',name:colName});box.column=i;box.checked=box.defaultChecked=!(columns[i].visible===false);connect(box,'onclick',this,this.onColumnChange);parent.appendChild(box);parent.appendChild(document.createTextNode(" "+colName));parent.appendChild(BR());}
this.modifiedColumns=[];};userSmarts.wt.dialogs.ConfigureTableDialog.prototype.onColumnChange=function(event){var box=event.src();this.modifiedColumns[box.column]=box.checked;};userSmarts.wt.dialogs.ConfigureTableDialog.prototype.okPressed=function(){for(var k in this.modifiedColumns){if(this.modifiedColumns[k]===true){this.model.showColumn(k*1);}else if(this.modifiedColumns[k]===false){this.model.hideColumn(k*1);}}
this.model.setProperty("modified",true);userSmarts.wt.dialogs.Dialog.prototype.okPressed.call(this);};namespace("userSmarts.wt.dialogs");$namespace.MenuBar=Class.create(userSmarts.wt.dialogs.Dialog);$prototype.initialize=function(superClass,properties){var height=15;var items=(properties&&properties.items)?properties.items:[];var num=0.0;for(var n=0;n<items.length;++n){if(items[n]instanceof userSmarts.wt.action.HorizontalSeparator){num+=0.5;}else if(items[n]instanceof userSmarts.wt.action.ContributionItem){num+=1;}}
height+=Math.floor(num*21);properties=setdefault(properties,{'class':"menubar",id:"menubar-menu",width:250,height:height,title:"",description:""});properties.modal=false;properties.useTables=false;properties.enableDrag=false;properties.enableKeys=false;properties.showTitle=false;properties.showButtons=false;properties.border={style:"solid",top:1,left:1,right:1,bottom:1},properties.padding={top:3,left:0,right:0,bottom:0};superClass.call(this,properties);};$prototype.createDialogArea=function(parent){this.listener=connect(parent,"onclick",this,this.onCancel);var item;var node;var items=this.items;for(var i=0;i<items.length;i++){item=items[i];if(item instanceof userSmarts.wt.action.ContributionItem){item.update();parent.appendChild(item.getNode());}}};$prototype.close=function(){disconnect(this.listener);userSmarts.wt.dialogs.Dialog.prototype.close.call(this);};userSmarts.wt.dialogs.ToolbarMenu=function(properties){if(isPrototype(arguments))return;properties=properties||{};setdefault(properties,{title:"",modal:false,width:150,height:250});userSmarts.wt.dialogs.Dialog.call(this,properties);};userSmarts.wt.dialogs.ToolbarMenu.inheritsFrom(userSmarts.wt.dialogs.Dialog);$prototype.createDialogArea=function(parent){this.titleBar.style.display="none";this.getButtonBar().style.display="none";parent.style.padding="none";var div=DIV();div.style.width="100%";div.style.border="1px solid #555555";div.style.backgroundColor="#FFFFCC";div.style.font="12px small Arial";this.listeners=[];if(this.toolbarManager){var item;var node;var icon;var text;var items=this.toolbarManager.getItems();for(var i=0;i<items.length;i++){item=items[i];if(item instanceof userSmarts.wt.action.Action&&!(item instanceof userSmarts.wt.action.OpenToolbarSelectorAction)){icon=IMG({src:item.getImage()});text=" ";if(typeof(item.getText)=='function'){text+=(item.getText()||"Item");}else{text+="Item";}
node=DIV({'class':'toolbar-menu-item'},icon,text);node.index=i;if(i==0){node.style.borderTop="none";}
this.listeners.push(connect(node,"onclick",this,this.executeItem));div.appendChild(node);}}}
parent.appendChild(div);};$prototype.executeItem=function(event){var node=event.src();var itemIndex=node.index;this.onOk();this.toolbarManager.getItems()[itemIndex].execute();};$prototype.close=function(){for(var i=0;i<this.listeners.length;++i){disconnect(this.listeners[i]);this.listeners[i]=null;}
userSmarts.wt.dialogs.Dialog.prototype.close.call(this);};namespace("userSmarts.wt.dialogs");$namespace.SelectColumnDialog=Class.create(userSmarts.wt.dialogs.Dialog);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{title:"Select List Column",modal:false,width:200,height:125,description:"Choose which column to select from the list below:"});userSmarts.wt.dialogs.Dialog.call(this,properties);};$prototype.createDialogArea=function(parent){parent.appendChild(document.createTextNode(this.description));parent.appendChild(BR());var dt={uri:{namespaceURI:'http://www.usersmarts.com/rcp/wt/list',prefix:'list',localPart:'columns'},facets:{enumeration:[]}};var model=this.model||(this.list?this.list.model:null);if(model){var option;var columns=this.model.getColumns();for(var i=0;i<columns.length;++i){if(columns[i].visible!=false){option={label:columns[i].label||columns[i].name,value:columns[i]};if(columns[i].name==model.getSortElement()){option.selected=true;this.column=columns[i];}
dt.facets.enumeration.push(option);}}}else{dt.facets.enumeration.push({label:"No columns",value:null});}
if(!this.column){this.column=dt.facets.enumeration[0].value;}
var props={size:1,parent:null,binding:new BeanPropertyBinding(this,'column'),optionModel:new userSmarts.wt.forms.DefaultOptionModel({datatype:dt})};var select=new userSmarts.wt.forms.Select(props);parent.appendChild(select.paint());};$prototype.getSelectedColumn=function(){return this.column;};$prototype.okPressed=function(){if(this.deferred){this.deferred.callback(this.getSelectedColumn());this.deferred=null;}};$prototype.cancelPressed=function(){if(this.deferred){this.deferred.callback(null);this.deferred=null;}};namespace("userSmarts.wt.dialogs");$namespace.SelectionDialog=Class.create(userSmarts.wt.dialogs.Dialog);$prototype.initialize=function(superClass,properties){var height=100;if(properties&&properties.displaySize){height+=(properties.displaySize*12);}else{height+=12;}
properties=setdefault(properties,{title:"Select Item",modal:false,useTables:false,enableKeys:true,width:250,height:height,displaySize:1,description:"Choose an item from the list below:"});superClass.call(this,properties);};$prototype.createDialogArea=function(parent){parent.appendChild(document.createTextNode(this.description));parent.appendChild(BR());var dt=this.dataType;if(!dt){dt={uri:{namespaceURI:'http://www.usersmarts.com/rcp/wt/dialog',prefix:'dialog',localPart:'choices'},facets:{enumeration:[]}};}
if(!this.selected){for(var c=0;c<dt.facets.enumeration.length;++c){if(dt.facets.enumeration[c].selected){this.selected=dt.facets.enumeration[c].value;break;}}}
var props={size:this.displaySize||1,parent:null,style:{width:(this.width-25)},binding:new BeanPropertyBinding(this,'selected'),optionModel:new userSmarts.wt.forms.DefaultOptionModel({datatype:dt})};var select=new userSmarts.wt.forms.Select(props);parent.appendChild(select.paint());this.select=select;};$prototype.focus=function(){this.select.focus();};$prototype.getSelected=function(){return this.selected;};$prototype.setOptions=function(dataType){if(typeof(dataType.push)=="function"){this.dataType={uri:{namespaceURI:'http://www.usersmarts.com/rcp/wt/dialog',prefix:'dialog',localPart:'choices'},facets:{enumeration:[]}};var option;for(var c=0;c<dataType.length;++c){option={label:dataType[c],value:dataType[c]};if(c==0){option.selected=true;this.option=option;}
this.dataType.facets.enumeration.push(option);}}else if(dataType.uri&&dataType.facets&&dataType.facets.enumeration){this.dataType=dataType;}};$prototype.okPressed=function(){if(this.deferred){this.deferred.callback(this.getSelected());this.deferred=null;}};$prototype.cancelPressed=function(){if(this.deferred){this.selected=null;this.deferred.callback(null);this.deferred=null;}};namespace("userSmarts.wt.dialogs");$namespace.HelpDialog=Class.create($namespace.Dialog);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{title:"Help",modal:false,useTables:false,width:600,height:500,src:"help.html"});superClass.call(this,properties);};$prototype.createDialogArea=function(parent){var frame=document.createElement("IFRAME");frame.src=this.src;frame.width=parseInt(parent.style.width)-4;frame.height=parseInt(parent.style.height)-4;parent.appendChild(frame);};$prototype.createButtonBar=function(parent){var okBtn=BUTTON(null,"Close");connect(okBtn,'onclick',this,this.onOk);this.okButton=okBtn;parent.appendChild(okBtn);};namespace("userSmarts.wt.dialogs");$namespace.CDialog=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=properties||{};var defaultWidth=properties.width||200;var defaultHeight=properties.height||150;var defaultTop=0;var defaultLeft=0;if(!properties.top&&!properties.left){var cx=getWindowWidth()/2;var cy=getWindowHeight()/2;var ox=(properties.width|defaultWidth)/2;var oy=(properties.height|defaultHeight)/2;defaultTop=cy-oy;defaultLeft=cx-ox;}
if(properties.padding){this.dialogPadding=properties.padding;properties.padding={left:0,right:0,top:0,bottom:0};}else{this.dialogPadding={top:2,left:2,right:2,bottom:2};}
if(properties.margin){this.dialogMargins=properties.margin;properties.margin={left:0,right:0,top:0,bottom:0};}else{this.dialogMargins={left:0,right:0,top:0,bottom:0};}
var preDefaultShow=properties.showButtons;var preDefaultShowTitle=properties.showTitle;if(properties.disableDrag===true||properties.disableDrag===false){properties.enableDrag=!properties.disableDrag;}
properties=setdefault(properties,{'class':'cdialog',modal:false,showButtons:true,showTitle:true,buttonsToUse:0,enableKeys:false,enableDrag:false,showClose:false,enableResize:false,title:"",border:{style:"solid",top:1,bottom:1,left:1,right:1},buttonListeners:[]});if(preDefaultShow===false){properties.showButtons=false;}
if(preDefaultShowTitle===false){properties.showTitle=false;}
superClass.call(this,properties);this.opened=false;this.setPosition(defaultLeft,defaultTop);this.setSize(defaultWidth,defaultHeight);this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));};$namespace.CDialog.OK_CANCEL=0;$namespace.CDialog.OK=1;$namespace.CDialog.CANCEL=2;$namespace.CDialog.YES_NO_CANCEL=3;$prototype.initNode=function(){if(this.showTitle){this.createTitleBar();}
this.dialogArea=new userSmarts.wt.widgets.Composite({'class':this['class']+'-dialogarea',parent:this,updateOnBoundsChange:true,border:{style:"solid",top:0,bottom:0,left:0,right:0},margin:this.dialogMargins,padding:this.dialogPadding,layoutData:{width:"100%",height:"*"}});if(this.showButtons){this.createButtonBar();}
this.createDialogArea(this.dialogArea);if(this.enableResize){var tempC=new userSmarts.wt.widgets.Composite({parent:this,layoutData:{width:"100%",height:3},_layout:new userSmarts.wt.layout.RowLayout({type:"horizontal"})});var temp1=new userSmarts.wt.widgets.Control({parent:tempC,layoutData:{width:"*",height:"100%"}});var temp=new userSmarts.wt.widgets.Control({parent:tempC,layoutData:{width:3,height:"100%"}});temp.getNode().style.backgroundColor="#506D8F";var dragger=new userSmarts.wt.dialogs.CDialogResizeHandler({dialog:this,cursor:"se-resize",updateOnStop:true});dragger.init(temp.getNode());this.resizeDragger=dragger;}
if(this.enableKeys){this.keyListener=connect(this.node,"onkeydown",this,this.onKeyPressed);}
this.getNode().style.zIndex=9999;};$prototype.open=function(){this.deferred=new Deferred();this.update();this.setVisibility(false);$("display").appendChild(this.getNode());this.setVisibility(true);this.focus();this.opened=true;return this.deferred;};$prototype.close=function(){if(this.dragHandler){this.dragHandler.dispose();this.dragHandler=null;}
if(this.resizeDragger){this.resizeDragger.stop();this.resizeDragger.dispose();this.resizeDragger=null;}
if(this.keyListener){disconnect(this.keyListener);this.keyListener=null;}
if(this.closeListener){disconnect(this.closeListener);this.closeListener=null;}
for(var i=0;i<this.buttonListeners.length;++i){disconnect(this.buttonListeners[i]);this.buttonListeners[i]=null;}
this.buttonListeners=[];this.setVisibility(false);try{$("display").removeChild(this.getNode());}catch(e){}
this.node=null;this.opened=false;this.dispose();};$prototype.isOpen=function(){return this.opened===true;};$prototype.okPressed=function(){if(this.deferred){this.deferred.callback(true);this.deferred=null;}};$prototype.cancelPressed=function(){if(this.deferred){this.deferred.callback(null);this.deferred=null;}};$prototype.yesPressed=function(){if(this.deferred){this.deferred.callback(true);this.deferred=null;}};$prototype.noPressed=function(){if(this.deferred){this.deferred.callback(false);this.deferred=null;}};$prototype.onOk=function(){this.okPressed();this.close();};$prototype.onCancel=function(){this.cancelPressed();this.close();};$prototype.onYes=function(){this.yesPressed();this.close();};$prototype.onNo=function(){this.noPressed();this.close();};$prototype.focus=function(){};$prototype.getTitleBar=function(){return this.titleBar;};$prototype.getDialogArea=function(){return this.dialogArea;};$prototype.getButtonBar=function(){return this.buttonBar;};$prototype.getOKButton=function(){return this.okButton;};$prototype.getCancelButton=function(){return this.cancelButton;};$prototype.createTitleBar=function(){this.titleBar=new userSmarts.wt.widgets.Composite({'class':this['class']+'-titlearea',parent:this,updateOnBoundsChange:true,border:{style:"solid",top:0,bottom:0,left:0,right:0},margin:{top:0,left:0,right:0,bottom:0},padding:{top:2,left:2,right:2,bottom:3},layoutData:{width:"100%",height:24}});this.titleBar.setLayout(new userSmarts.wt.layout.RowLayout({type:"horizontal"}));var icon;if(this.image){var theme=userSmarts.runtime.Platform.getTheme();if(theme){icon=theme.getImage(this.image,null);icon.style.width="16px";icon.style.height="16px";}}
if(icon){var iconControl=new userSmarts.wt.widgets.Control({parent:this.titleBar,'class':"dialog-icon",layoutData:{width:19,height:16},margin:{top:0,left:1,right:2,bottom:0}});iconControl.getNode().appendChild(icon);}
var titleControl=new userSmarts.wt.widgets.Control({parent:this.titleBar,layoutData:{width:"*",height:"100%"}});titleControl.getNode().appendChild(document.createTextNode(this.title));if(this.showClose){var closer;var theme=userSmarts.runtime.Platform.getTheme();if(theme){closer=theme.getImage("image.close",null);}
if(closer){closer.style.cursor="pointer";var closerControl=new userSmarts.wt.widgets.Control({parent:this.titleBar,layoutData:{width:16,height:16},margin:{top:0,left:2,right:0,bottom:0}});closerControl.getNode().appendChild(closer);}
this.closeListener=connect(closer,"onclick",this,this.onCancel);}
if(this.enableDrag){this.dragHandler=new userSmarts.util.DragHandler();this.dragHandler.init(this.node,this.titleBar.getNode());}};$prototype.createButtonBar=function(){this.buttonBar=new userSmarts.wt.widgets.Control({'class':this['class']+'-buttonbar',parent:this,updateOnBoundsChange:true,border:{style:"solid",top:0,bottom:0,left:0,right:0},margin:{top:0,left:0,right:0,bottom:0},padding:{top:0,left:0,right:0,bottom:0},layoutData:{width:"100%",height:25}});var node=this.buttonBar.getNode();if(this.buttonsToUse==userSmarts.wt.dialogs.CDialog.YES_NO_CANCEL){var yesBtn=BUTTON(null,"Yes");yesBtn.style.width="75px";this.buttonListeners.push(connect(yesBtn,'onclick',this,this.onYes));node.appendChild(yesBtn);var noBtn=BUTTON(null,"No");noBtn.style.width="75px";this.buttonListeners.push(connect(noBtn,'onclick',this,this.onNo));node.appendChild(noBtn);}else if(this.buttonsToUse==userSmarts.wt.dialogs.CDialog.OK_CANCEL||this.buttonsToUse==userSmarts.wt.dialogs.CDialog.OK){var okBtn=BUTTON(null,"OK");okBtn.style.width="75px";this.buttonListeners.push(connect(okBtn,'onclick',this,this.onOk));this.okButton=okBtn;node.appendChild(okBtn);}
if(this.buttonsToUse==userSmarts.wt.dialogs.CDialog.OK_CANCEL||this.buttonsToUse==userSmarts.wt.dialogs.CDialog.CANCEL||this.buttonsToUse==userSmarts.wt.dialogs.CDialog.YES_NO_CANCEL){var cancelBtn=BUTTON(null,"Cancel");cancelBtn.style.width="75px";this.buttonListeners.push(connect(cancelBtn,'onclick',this,this.onCancel));this.cancelButton=cancelBtn;node.appendChild(cancelBtn);}};$prototype.createDialogArea=function(composite){composite.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));var control=new userSmarts.wt.widgets.Control({parent:composite,updateOnBoundsChange:true,layoutData:{width:"100%",height:"100%"}});if(this.description){control.getNode().innerHTML=this.description.replace(/\n/,"<BR/>");}};$prototype.onKeyPressed=function(event){var key=event.key().code;if(key==13){this.onOk();}else if(key==27){this.onCancel();}};$prototype.setPosition=function(x,y){this.setLocation(x,y);};$prototype.update=function(){userSmarts.wt.widgets.Composite.prototype.update.call(this);this.focus();};namespace("userSmarts.wt.dialogs");$namespace.CDialogResizeHandler=Class.create();$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{lockX:false,lockY:false,cursor:"se-resize",updateOnStop:false});setdefault(this,properties);this.move=null;this.down=null;this.offset=null;this.target=null;this.listener=null;this.listeners=[];};$prototype.connect=function(listener,listenerFunc){if(listenerFunc){this.listeners.push(connect(this,"modified",listener,listenerFunc));}else{this.listeners.push(connect(this,"modified",listener));}};$prototype.init=function(elem,hook){this.target=elem;var el=(hook)?hook:elem;if(el){el.style.cursor=this.cursor;this.listener=connect(el,'onmousedown',this,this.start);}
if(this.isDisposed){this.listeners=[];this.isDisposed=false;}};$prototype.dispose=function(){if(this.listener){disconnect(this.listener);this.listener=null;}
for(var l=0;l<this.listeners.length;++l){disconnect(this.listeners[l]);this.listeners[l]=null;}
this.listeners=null;this.isDisposed=true;this.target=null;this.dialog=null;};$prototype.start=function(e){e.stop();if(!this.target)return;if(this.move)return;var pos=elementPosition(this.target);this.offset=this.diff(e.mouse().page,pos);this.move=connect(document,'onmousemove',this,this.drag);this.down=connect(document,'onmouseup',this,this.stop);if(this.updateOnStop){this.changeContentsOpacity(50);}};$prototype.drag=function(e){e.stop();if(this.target&&this.move){var pos=this.diff(e.mouse().page,this.offset);this.update(pos);}else{this.stop();}};$prototype.stop=function(e){if(this.updateOnStop){var dialog=this.dialog;var width=parseInt(dialog.getNode().style.width);var height=parseInt(dialog.getNode().style.height);this.changeContentsOpacity(100);if(dialog.border.style=="none"){var dnode=dialog.getNode();dnode.style.borderLeftStyle="none";dnode.style.borderRightStyle="none";dnode.style.borderTopStyle="none";dnode.style.borderBottomStyle="none";}
dialog.setSize(width,height);dialog.update();}
disconnect(this.move);this.move=null;disconnect(this.down);this.down=null;};$prototype.diff=function(lhs,rhs){return{x:lhs.x-rhs.x,y:lhs.y-rhs.y};};$prototype.update=function(pos){if(!this.target){this.stop();return;}
try{var pc=this.target.parentNode;var tc=this.target;var dialog=this.dialog
var width=dialog.getSize().width;var height=dialog.getSize().height;var targetLeft=parseInt(pc.style.left)+
parseInt(tc.style.left);var targetTop=parseInt(pc.style.top)+
parseInt(tc.style.top);var dc=dialog.getNode();var ox=targetLeft+parseInt(dc.style.left);var oy=targetTop+parseInt(dc.style.top);var dx=(pos.x-ox);dx=Math.max(200-width,dx);var dy=(pos.y-oy);dy=Math.max(150-height,dy);if(!this.lockX)width+=dx;if(!this.lockY)height+=dy;if(this.updateOnStop){var dnode=dialog.getNode();if(dialog.border.style=="none"){dnode.style.borderLeftStyle="solid";dnode.style.borderRightStyle="solid";dnode.style.borderTopStyle="solid";dnode.style.borderBottomStyle="solid";}
dnode.style.width=width+"px";dnode.style.height=height+"px";}else{dialog.setSize(width,height);dialog.update();}}catch(e){this.stop();getLogger().logError("Error resizing dialog, cause: "+e);}};$prototype.changeContentsOpacity=function(opacity){var children=this.dialog.getChildren();for(var i=0;i<children.length;++i){children[i].getNode().style.opacity=opacity/100;children[i].getNode().style.filter="alpha(opacity="+opacity+")";}};namespace("userSmarts.wt.dialogs");$namespace.SliderDialog=Class.create(userSmarts.wt.dialogs.CDialog);$prototype.initialize=function(superClass,properties){this.sliderPadding=properties.padding||{top:3,left:0,right:0,bottom:0};this.sliderMargins=properties.margin;properties.showButtons=false;properties.enableKeys=true;properties.showClose=true;properties.padding={top:0,left:0,right:0,bottom:0};properties.margin={top:0,left:0,right:0,bottom:0};properties.value=properties.value||0.5;properties.min=properties.min||0;properties.max=properties.max||1;properties.orientation=properties.orientation||"horizontal";superClass.call(this,properties);};$prototype.createDialogArea=function(composite){composite.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));var slider=new userSmarts.wt.widgets.CSlider({parent:composite,value:this.value,type:this.orientation,padding:this.sliderPadding,layoutData:{width:"100%",height:"100%"}});};namespace("userSmarts.wt.dialogs");$namespace.CalendarDialog=Class.create(userSmarts.wt.dialogs.CDialog);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{title:"Calendar",showButtons:false,showClose:true,date:new Date()});superClass.call(this,properties);};$prototype.createDialogArea=function(composite){composite.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));this.calendar=new userSmarts.wt.widgets.Calendar({parent:composite,margin:{top:2,left:2,right:0,bottom:0},day:this.date.getDate(),month:this.date.getMonth(),year:this.date.getFullYear()});if(this.autoClose){this.selectedListener=connect(this.calendar,"selected",this,this.onOk);}
var xoff=0+this.padding.left+this.border.left+this.margin.left;var yoff=0+this.padding.top+this.border.top+this.margin.top;this.calendar.setLocation(xoff,yoff);};$prototype.onCancel=function(){this.okPressed();this.close();};$prototype.okPressed=function(){if(this.deferred){this.deferred.callback(this.calendar.getDate());this.deferred=null;this.calendar.dispose();}};$prototype.close=function(){if(this.selectedListener){disconnect(this.selectedListener);this.selectedListener=null;}
userSmarts.wt.dialogs.CDialog.prototype.close.call(this);};namespace("userSmarts.wt.dialogs");$namespace.ColorDialog=Class.create(userSmarts.wt.dialogs.CDialog);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{title:"Select a Color",width:175,height:175,showButtons:true,showClose:true});superClass.call(this,properties);};$prototype.createDialogArea=function(composite){composite.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));this.palette=new userSmarts.wt.widgets.ColorPalette({parent:composite});};$prototype.getColor=function(){return this.palette.getSelected();};$prototype.okPressed=function(){if(this.deferred){this.deferred.callback(this.getColor());this.deferred=null;}};$prototype.cancelPressed=function(){if(this.deferred){this.deferred.callback(null);this.deferred=null;}};$prototype.onColorSelected=function(){this.onOk();};namespace("userSmarts.wt.dialogs");$namespace.TableCreatorDialog=Class.create(userSmarts.wt.dialogs.CDialog);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{title:"Define Table",width:150,height:125,numRows:3,numCols:3,borderWidth:1});superClass.call(this,properties);};$prototype.createDialogArea=function(composite){composite.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));new userSmarts.wt.forms.FieldComposite({parent:composite,labelWidth:85,showLabel:true,title:"Rows",validator:this,validationFunc:"validate",format:new IntegerFormat({defaultValue:1}),binding:new BeanPropertyBinding2(this,'numRows')});new userSmarts.wt.forms.FieldComposite({parent:composite,labelWidth:85,showLabel:true,title:"Cols",validator:this,validationFunc:"validate",format:new IntegerFormat({defaultValue:1}),binding:new BeanPropertyBinding2(this,'numCols')});new userSmarts.wt.forms.FieldComposite({parent:composite,labelWidth:85,showLabel:true,title:"Border (px)",validator:this,validationFunc:"validate",format:new IntegerFormat({defaultValue:1}),binding:new BeanPropertyBinding2(this,'borderWidth')});};$prototype.validate=function(value){if(isNaN(value)){return"Must be a valid number";}else if((value*1)>0){return"Must be be positive";}
return null;};$prototype.okPressed=function(){if(this.deferred){this.deferred.callback(this.getTable());this.deferred=null;}};$prototype.getTable=function(){var table="<table border=\""+this.borderWidth+"\"><tbody>";for(var r=0;r<this.numRows;++r){table+="<tr>";for(var c=0;c<this.numCols;++c){table+="<td></td>";}
table+="</tr>";}
table+="</tbody></table>";return table;};$namespace.TableCreatorPopup=Class.create(userSmarts.wt.dialogs.CDialog);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{showTitle:false,showButtons:false,enableDrag:false,enableKeys:false,enableResize:false,width:115,height:115,borderWidth:1,numCols:3,numRows:3});superClass.call(this,properties);};$prototype.createDialogArea=function(composite){composite.setLayout(new userSmarts.wt.layout.GridLayout({columns:5}));var node=composite.getNode();connect(node,"onclick",this,this.handleSelection);var ctrl=new userSmarts.wt.widgets.Control({parent:composite,layoutData:{width:"100%",height:"100%"}});var left=0;var top=0;for(var i=0;i<25;++i){var col=(i%5);var row=Math.floor(i/5);left=(col*20)+((col+1)*2);top=(row*20)+((row+1)*2);var div=DIV();div.style.position="absolute";div.style.top=top+"px";div.style.left=left+"px";div.style.width="19px";div.style.height="19px";div.style.border="1px solid #999999";div.rowIndex=row+1
div.colIndex=col+1;ctrl.getNode().appendChild(div);}};$prototype.handleSelection=function(event){var target=event.target();this.numRows=target.rowIndex||3;this.numCols=target.colIndex||3;this.onOk();};$prototype.updateSelection=function(event){var target=event.target();var source=event.src();var i=0;};$prototype.okPressed=function(){if(this.deferred){this.deferred.callback(this.getTable());this.deferred=null;}};$prototype.getTable=function(){var colWidth=(100/(this.numCols||1))+"%";;var table="<table width=\"99%\" cellspacing=\"0\" cellpadding=\"0\" "+"border=\""+this.borderWidth+"\"><tbody>";for(var r=0;r<this.numRows;++r){table+="<tr>";for(var c=0;c<this.numCols;++c){table+="<td width=\""+colWidth+"\"></td>";}
table+="</tr>";}
table+="</tbody></table>";return table;};namespace("userSmarts.wt.dialogs");$namespace.PageControlDialog=Class.create(userSmarts.wt.dialogs.CDialog);$prototype.initialize=function(superClass,properties){properties=properties||{};properties.showClose=true;properties.enableDrag=false;properties.showButtons=false;properties.enableResize=false;properties.width=232;properties.height=50;properties.title="Edit Paging";superClass.call(this,properties);};$prototype.createDialogArea=function(composite){composite.setLayout(new userSmarts.wt.layout.HorizontalRowLayout());this.pageControl=new userSmarts.wt.widgets.TablePageControl({parent:composite,table:this.table,minimum:true,showLabel:false});};$prototype.refresh=function(){this.pageControl.update();};namespace("userSmarts.wt.layout");namespace("userSmarts.wt.layout");namespace("userSmarts.wt.layout");$namespace.RowLayout=Class.create(userSmarts.wt.widgets.Layout);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{spacing:0,type:userSmarts.wt.widgets.Layout.VERTICAL});superClass.call(this,properties);};$namespace.RowLayout.prototype.NumberPattern=/(\d*)(.*)/;$prototype.getLayoutData=function(control){var rowData=control.getLayoutData();if(rowData&&!rowData.units){rowData.units={};this.parseRowData(rowData,"width");this.parseRowData(rowData,"height");}
return rowData;};$prototype.computeSize=function(control,maxWidth,maxHeight,flushCache){var wHint=5;var hHint=4;var data=this.getLayoutData(control);if(data){if(data.units.width=="%"){wHint=(data.width/100.0)*maxWidth;}else if(data.units.width=="*"){wHint="*";}else{wHint=data.width;}
if(data.units.height=="%"){hHint=(data.height/100.0)*maxHeight;}else if(data.units.height=="*"){hHint="*";}else{hHint=data.height;}}
return{x:wHint,y:hHint};};$prototype.parseRowData=function(rowData,fieldName){var value=rowData[fieldName];if(!value){return;}
if(typeof value=="number"){if(!rowData.units[fieldName]){rowData.units[fieldName]="px";}
return;}
var match=this.NumberPattern.exec(rowData[fieldName]);if(match){rowData[fieldName]=match[1]*1;rowData.units[fieldName]=match[2]||"px";}else if(value=="*"){rowData[fieldName]=100;rowData.units[fieldName]="*";}};$prototype.layout=function(composite,flushCache){var size=composite.getSize();if(this.type==userSmarts.wt.widgets.Layout.VERTICAL){this.layoutVertical(composite,size.height,flushCache);}else{this.layoutHorizontal(composite,size.width,flushCache);}};$prototype.layoutVertical=function(composite,height,flushCache){var children=composite.getChildren();var count=children.length;var childWidth=0;var childHeight=0;var maxHeight=0;var marginWidth=composite.margin.left;var offsetTop=0;var marginHeight=composite.margin.top;var spacing=this.spacing;var totalSpace=spacing*(count-1);var rect=composite.getClientArea();if(userSmarts.util.Browser.isIE){if(composite.border.style!="none"){rect.width-=(composite.border.left+composite.border.right);rect.height-=(composite.border.top+composite.border.bottom);}}
var clientX=rect.x;var clientY=rect.y;var clientWidth=rect.width;var clientHeight=rect.height-totalSpace;var availableHeight=clientHeight;for(var i=0;i<count;++i){var ld=this.getLayoutData(children[i]);if(ld.units&&ld.units.height=="px"){availableHeight-=ld.height;}}
var totalHeight=0;var sizes=[];var nwild=0;for(var i=0;i<count;i++){var child=children[i];var size=this.computeSize(child,clientWidth,availableHeight,flushCache);sizes.push(size);if(size.y=="*"){nwild++;}else{totalHeight+=(spacing+size.y);}}
var wildHeight;if(clientHeight>totalHeight){wildHeight=(clientHeight-totalHeight)/nwild;}else{wildHeight=0;}
if(nwild>0){for(var i=0;i<count;++i){if(sizes[i].y=="*"){sizes[i].y=wildHeight;}}}
var maxX=0;var x=composite.padding.left;var y=composite.padding.top;for(var i=0;i<count;i++){var child=children[i];var childX=Math.floor(x);var childY=Math.floor(y);var size=sizes[i];childWidth=Math.floor(clientWidth);childHeight=(isNaN(size.y))?clientHeight:Math.floor(size.y);try{child.setBounds(childX,childY,childWidth,childHeight);}catch(e){}
y+=spacing+childHeight;maxX=Math.max(maxX,x);}};$prototype.layoutHorizontal=function(composite,width,flushCache){var children=composite.getChildren();var count=children.length;var childWidth=0;var childHeight=0;var maxHeight=0;var rect=composite.getClientArea();var clientX=rect.x;var clientY=rect.y;if(userSmarts.util.Browser.isIE){if(composite.border.style!="none"){rect.width-=(composite.border.left+composite.border.right);rect.height-=(composite.border.top+composite.border.bottom);}}
var offsetLeft=composite.padding.left;var marginWidth=0;var offsetTop=composite.padding.top;var marginHeight=0;var spacing=this.spacing;var totalSpace=spacing*(count-1);var clientWidth=rect.width-totalSpace;var clientHeight=rect.height;var availableWidth=clientWidth;for(var i=0;i<count;++i){var ld=this.getLayoutData(children[i]);if(ld.units&&ld.units.width=="px"){availableWidth-=ld.width;}}
var totalWidth=0;var sizes=[];var nwild=0;for(var i=0;i<count;i++){var child=children[i];var size=this.computeSize(child,availableWidth,clientHeight,flushCache);sizes.push(size);if(size.x=="*"){nwild++;}else{totalWidth+=(spacing+size.x);}}
var wildWidth;if(clientWidth>totalWidth){wildWidth=(clientWidth-totalWidth)/nwild;}else{wildWidth=0;}
if(nwild>0){for(var i=0;i<count;++i){if(sizes[i].x=="*"){sizes[i].x=wildWidth;}}}
var maxX=0,x=offsetLeft+marginWidth,y=offsetTop+marginHeight;for(var i=0;i<count;i++){var child=children[i];var childX=x;var childY=y;var size=sizes[i];childWidth=size.x;childHeight=(isNaN(size.y))?clientHeight:Math.min(clientHeight,size.y);try{child.setBounds(childX,childY,childWidth,childHeight);}catch(e){}
x+=spacing+childWidth;maxX=Math.max(maxX,x);}
maxX=Math.max(clientX+offsetLeft+marginWidth,maxX-spacing);};$namespace.HorizontalRowLayout=Class.create(userSmarts.wt.layout.RowLayout);$prototype.initialize=function(superClass,properties){properties=properties||{};properties.type=userSmarts.wt.widgets.Layout.HORIZONTAL;superClass.call(this,properties);};$namespace.VerticalRowLayout=Class.create(userSmarts.wt.layout.RowLayout);$prototype.initialize=function(superClass,properties){properties=properties||{};properties.type=userSmarts.wt.widgets.Layout.VERTICAL;superClass.call(this,properties);};$namespace.WrappingRowLayout=Class.create(userSmarts.wt.layout.HorizontalRowLayout);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);this.maxHeight=this.maxHeight||50;};$prototype.layoutHorizontal=function(composite,width,flushCache){var children=composite.getChildren();var count=children.length;var childWidth=0;var childHeight=0;var maxHeight=0;var rect=composite.getClientArea();var clientX=rect.x;var clientY=rect.y;if(userSmarts.util.Browser.isIE){if(composite.border.style!="none"){rect.width-=(composite.border.left+composite.border.right);rect.height-=(composite.border.top+composite.border.bottom);}}
var offsetLeft=composite.padding.left;var offsetTop=composite.padding.top;var spacing=this.spacing;var totalSpace=spacing*(count-1);var clientWidth=rect.width-totalSpace;var clientHeight=Math.min(rect.height,this.maxHeight);var availableWidth=clientWidth;for(var i=0;i<count;++i){var ld=this.getLayoutData(children[i]);if(ld.units&&ld.units.width=="px"){availableWidth-=ld.width;}}
var totalWidth=0,sizes=[],nwild=0;for(var i=0;i<count;i++){var child=children[i];var size=this.computeSize(child,availableWidth,clientHeight,flushCache);sizes.push(size);if(size.x=="*")nwild++;else totalWidth+=(spacing+size.x);}
var wildWidth=(clientWidth>totalWidth)?(clientWidth-totalWidth)/nwild:0;if(nwild>0){for(var i=0;i<count;++i){if(sizes[i].x=="*"){sizes[i].x=wildWidth;}}}
var x=offsetLeft,y=offsetTop;for(var i=0;i<count;i++){var child=children[i],childX=x,childY=y,size=sizes[i];childWidth=size.x;childHeight=(isNaN(size.y))?clientHeight:Math.min(clientHeight,size.y);if(rect.width>0&&childWidth+childX>rect.width){childX=x=0;childY=y=(y+childHeight+6);}
try{child.setBounds(childX,childY,childWidth,childHeight);}catch(e){}
x+=spacing+childWidth;}};namespace("userSmarts.wt.layout");userSmarts.wt.layout.StackLayout=function(properties){if(isPrototype(arguments)){return;}
userSmarts.wt.widgets.Layout.call(this,properties);this.marginWidth=0;this.marginHeight=0;this.topControl=null;};userSmarts.wt.layout.StackLayout.inheritsFrom(userSmarts.wt.widgets.Layout);userSmarts.wt.layout.StackLayout.prototype.layout=function(composite,flushCache){var children=composite.getChildren();var rect=composite.getClientArea();rect.x+=this.marginWidth;rect.y+=this.marginHeight;rect.width-=2*this.marginWidth;rect.height-=2*this.marginHeight;for(var i=0;i<children.length;++i){if(children[i]==this.topControl){children[i].setBounds(0,0,rect.width,rect.height);children[i].setVisibility(true);}else{children[i].setVisibility(false);}}};namespace("userSmarts.wt.layout");$namespace.PerspectiveBarLayout=Class.create(userSmarts.wt.layout.RowLayout);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{spacing:0,maxChildWidth:175});superClass.call(this,properties);this.type=userSmarts.wt.widgets.Layout.HORIZONTAL;};$prototype.layout=function(composite,flushCache){var size=composite.getSize();this.layoutHorizontal(composite,size.width,flushCache);};$prototype.layoutHorizontal=function(composite,width,flushCache){var children=composite.getChildren();var count=children.length;var childWidth=0;var childHeight=0;var maxHeight=0;var rect=composite.getClientArea();if(userSmarts.util.Browser.isIE){if(composite.border.style!="none"){rect.width-=(composite.border.left+composite.border.right);rect.height-=(composite.border.top+composite.border.bottom);}
rect.height+=composite.padding.top+composite.padding.bottom;rect.height+=composite.margin.top+composite.margin.bottom;}
var clientX=rect.x;var clientY=rect.y;var offsetLeft=0;var marginWidth=0;var offsetTop=0;var marginHeight=0;var spacing=this.spacing;var totalSpace=spacing*(count-1);var clientWidth=rect.width-totalSpace;var clientHeight=rect.height;var totalWidth=0;var sizes=[];var nwild=0;for(var i=0;i<count;i++){var child=children[i];var size=this.computeSize(child,clientWidth,clientHeight,flushCache);sizes.push(size);if(size.x=="*"){nwild++;}else{totalWidth+=(spacing+size.x);}}
var wildWidth;if(clientWidth>totalWidth){wildWidth=Math.min(this.maxChildWidth,(clientWidth-totalWidth)/nwild);}else{wildWidth=0;}
if(nwild>0){for(var i=0;i<count;++i){if(sizes[i].x=="*"){sizes[i].x=wildWidth;}}}
var maxX=0,x=offsetLeft+marginWidth,y=offsetTop+marginHeight;for(var i=0;i<count;i++){var child=children[i];var childX=x;var childY=y;var size=sizes[i];childWidth=size.x;childHeight=(isNaN(size.y))?clientHeight:Math.min(clientHeight,size.y);try{child.setBounds(childX,childY,childWidth,childHeight);}catch(e){}
x+=spacing+childWidth;maxX=Math.max(maxX,x);}
maxX=Math.max(clientX+offsetLeft+marginWidth,maxX-spacing);};namespace("userSmarts.wt.layout");$namespace.GridLayout=Class.create(userSmarts.wt.widgets.Layout);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{columns:3});superClass.call(this,properties);};$prototype.getLayoutData=function(control){var rowData=control.getLayoutData();if(rowData&&!rowData.units){rowData.units={};this.parseRowData(rowData,"width");this.parseRowData(rowData,"height");}
return rowData;};$prototype.parseRowData=function(rowData,fieldName){var value=rowData[fieldName];if(!value){return;}
if(typeof value=="number"){if(!rowData.units[fieldName]){rowData.units[fieldName]="px";}
return;}
var match=this.NumberPattern.exec(rowData[fieldName]);if(match){rowData[fieldName]=match[1]*1;rowData.units[fieldName]=match[2]||"px";}else if(value=="*"){rowData[fieldName]=100;rowData.units[fieldName]="*";}};$prototype.layout=function(composite,flushCache){var children=composite.getChildren();var count=children.length;var rows=count/this.columns;var columns=this.columns;var rect=composite.getClientArea();var clientX=rect.x;var clientY=rect.y;var clientWidth=rect.width;var clientHeight=rect.height;var childWidth=clientWidth/columns;var childHeight=clientHeight/rows;var top=0;var left=0;var row=0;var col=0;for(var i=0;i<count;i++){row=Math.floor(i/columns);col=i%columns;top=row*childHeight;left=col*childWidth;var child=children[i];try{child.setBounds(left,top,childWidth,childHeight);}catch(e){}}};namespace("userSmarts.wt.layout");$namespace.ToolbarLayout=Class.create($namespace.RowLayout);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{spacing:0});superClass.call(this,properties);};$prototype.layout=function(composite,flushCache){var size=composite.getSize();var width=size.width
var children=composite.getChildren();var count=children.length;var childWidth=0;var childHeight=0;var maxHeight=0;var rect=composite.getClientArea();if(rect.width<5&&rect.height<5)return;if(userSmarts.util.Browser.isIE){if(composite.border.style!="none"){rect.width-=(composite.border.left+composite.border.right);rect.height-=(composite.border.top+composite.border.bottom);}}
var clientX=rect.x;var clientY=rect.y;var offsetLeft=0;var marginWidth=0;var offsetTop=0;var marginHeight=0;var spacing=this.spacing;var totalSpace=spacing*(count-1);var clientWidth=rect.width-totalSpace;var clientHeight=rect.height;var totalWidth=0;var sizes=[];var nwild=0;for(var i=0;i<count;i++){var child=children[i];var size=this.computeSize(child,clientWidth,clientHeight,flushCache);sizes.push(size);if(size.x=="*"){nwild++;}else{totalWidth+=(spacing+size.x);}}
var wildWidth;if(clientWidth>totalWidth){wildWidth=Math.min(this.maxChildWidth,(clientWidth-totalWidth)/nwild);}else{wildWidth=-1;}
if(nwild>0||wildWidth<0){for(var i=0;i<count;++i){if(wildWidth<0){sizes[i].x=18;}else if(sizes[i].x=="*"){sizes[i].x=wildWidth;}}}
if(sizes.length<=0)return;var x=clientWidth-sizes[sizes.length-1].x;var y=0;for(var i=sizes.length-1;i>=0;--i){var child=children[i];var size=sizes[i];try{child.setBounds(x,y,size.x,size.y);}catch(e){}
if(i>0){x-=(spacing+sizes[i-1].x);}}};namespace("userSmarts.wt.forms");namespace("userSmarts.wt.forms");userSmarts.wt.forms.version=0.2;userSmarts.wt.forms.namespace="http://www.usersmarts.com/form#";namespace("userSmarts.wt.forms");$namespace.Label=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'form-input-field-label',value:""});superClass.call(this,properties);};$prototype.initNode=function(){if(this.value){this.node.appendChild(document.createTextNode(this.value));}};$prototype.getValue=function(){return this.value;};$prototype.setValue=function(label){this.value=label;replaceChildNodes(this.node,label);};namespace("userSmarts.wt.forms");$namespace.Field=Class.create(Bean);$prototype.initialize=function(superClass,properties){setdefault(properties,{size:25,disabled:false,format:new StringFormat(),validationFunc:"validate"});Bean.call(this,properties);};$prototype.paint=function(){this.input=INPUT();this.input.id=this.name||"";this.input.type="text";this.input.size=this.size||25;if(this.disabled)this.input.disabled=true;this.changeListener=connect(this.input,"onchange",this,this.onInputChange);if(this.binding){this.input.value=this.binding.getValue();}else{this.input.value=(this.value||"");}
if(this.binding){this.bindingListener=connect(this.binding,"*",this,this.onBindingChange);}
this.layout=SPAN({'class':'form-input-field'});if(this.showLabel){this.layout.appendChild(LABEL({"for":this.name},this.title));}
this.layout.appendChild(this.input);return this.layout;};$prototype.onInputChange=function(event){var value=this.input.value;if(this.format&&typeof(this.format.parseObject)=="function"){value=this.format.parseObject(value);}
var err=null;if(this.parent){err=this.parent[this.validationFunc](value);}
if(!err){if(this.binding){this.binding.setValue(value);}}else{this.input.value=this.format.format(this.binding.getValue());alert("Illegal Argument: \n"+err);}};$prototype.onBindingChange=function(event){var value=this.binding.getValue();if(this.format&&typeof(this.format.parseObject)=="function"){this.input.value=this.format.format(value);}};$prototype.focus=function(){if(this.input){this.input.focus();if(this.input.value){this.input.select();}}};$prototype.getValue=function(){var value=this.input.value;if(this.format&&typeof(this.format.parseObject)=="function"){value=this.format.parseObject(value);}
return value;};$prototype.setValue=function(value){var err=null;if(this.parent){err=this.parent[this.validationFunc](value);}
if(!err){this.binding.setValue(value);this.input.value=this.format.format(value);}else{alert("Illegal Argument: \n"+err);}};$prototype.dispose=function(){disconnect(this.changeListener);if(this.bindingListener){disconnect(this.bindingListener);}
this.input=null;this.format=null;this.binding.dispose();delete this.binding;delete this.parent;Bean.prototype.dispose.call(this);};namespace("userSmarts.wt.forms");$namespace.FieldControl=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){if(properties&&properties.size){properties.fieldSize=properties.size;properties.size=null;}
properties=setdefault(properties,{'class':"form-input-field",fieldSize:25,disabled:false,format:new StringFormat(),validationFunc:"validate"});superClass.call(this,properties);};$prototype.initNode=function(){var node=this.node;this.input=INPUT();this.input.id=this.name||"";this.input.type="text";this.input.size=this.fieldSize||25;if(this.binding){if(this.format&&typeof(this.format.format)=="function"){this.input.value=this.format.format(this.binding.getValue());}else{this.input.value=this.binding.getValue();}}else{if(this.format&&typeof(this.format.format)=="function"){this.input.value=this.format.format(this.value||"");}else{this.input.value=(this.value||"");}}
if(this.disabled)this.input.disabled=true;this.changeListener=connect(this.input,"onchange",this,this.onInputChange);if(this.binding){this.bindingListener=connect(this.binding,"*",this,this.onBindingChange);}
if(this.showLabel&&this.title){if(this.title.indexOf(":")<this.title.length-2){this.title+=": "}
node.appendChild(DIV({'class':'form-input-field-label'},this.title));}
node.appendChild(this.input);};$prototype.setSize=function(width,height){userSmarts.wt.widgets.Control.prototype.setSize.call(this,width,height);var nodeWidth=parseInt(this.node.style.width)||0;var w=(Math.max(nodeWidth,11)-10);this.input.style.width=w+"px";};$prototype.setBinding=function(binding){this.binding=binding;var value=binding.getValue();if(this.format&&typeof(this.format.format)=="function"){this.input.value=this.format.format(value||"");}else{this.input.value=(value||"");}};$prototype.onInputChange=function(event){var value=this.input.value;if(this.format&&typeof(this.format.parseObject)=="function"){value=this.format.parseObject(value);}
var err=null;if(this.validator){err=this.validator[this.validationFunc](value);}
if(!err){if(this.binding){this.binding.setValue(value);}}else{if(this.format&&typeof(this.format.format)=="function"){this.input.value=this.format.format(this.binding.getValue());}else{this.input.value=this.binding.getValue();}
getLogger().logError("Illegal Argument",err);}};$prototype.onBindingChange=function(event){var value=this.binding.getValue();if(this.format&&typeof(this.format.format)=="function"){this.input.value=this.format.format(value);}};$prototype.focus=function(){if(this.input){this.input.focus();if(this.input.value){this.input.select();}}};$prototype.getValue=function(){var value=this.input.value;if(this.format&&typeof(this.format.parseObject)=="function"){value=this.format.parseObject(value);}
return value;};$prototype.setValue=function(value,validate){var err=null;if(this.validator&&(validate!==false)){err=this.validator[this.validationFunc](value);}
if(!err){this.binding.setValue(value);if(this.format&&typeof(this.format.format)=="function"){this.input.value=this.format.format(value);}else{this.input.value=value;}}else{alert("Illegal Argument: \n"+err);}};$prototype.dispose=function(){disconnect(this.changeListener);if(this.bindingListener){disconnect(this.bindingListener);}
this.input=null;this.format=null;if(this.binding){this.binding.dispose();delete this.binding;}
if(this.validator){delete this.validator;}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};namespace("userSmarts.wt.forms");$namespace.FieldComposite=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{showLabelOnTop:false});superClass.call(this,properties);};$prototype.initNode=function(){var type="horizontal";if(this.showLabelOnTop){type="vertical";}
this.setLayout(new userSmarts.wt.layout.RowLayout({type:type}));if((this.showLabel||this.showLabelOnTop)&&this.title){if(this.title.indexOf(":")<this.title.length-2){this.title+=": "}
var layout={width:"*",height:"*"};var padding={top:0,left:0,right:0,bottom:0};if(this.showLabelOnTop){this.layoutData.height=50;layout.width="100%";layout.height=20;}else{if(!this.labelWidth){this.labelWidth=determineLabelWidth(this.title,"form-input-field-label");}
layout.width=this.labelWidth;layout.height="100%";padding.top=3;}
var labelControl=new userSmarts.wt.forms.Label({parent:this,'class':"form-input-field-label",padding:padding,layoutData:layout,value:this.title});}
this.fieldControl=new userSmarts.wt.forms.FieldControl({parent:this,layoutData:{width:"*",height:"*"},value:this.value||null,binding:this.binding||null,format:this.format||null,validator:this.validator||null,validationFunc:this.validationFunc||null,disabled:this.disabled||false,showLabel:false});this.update();};$prototype.focus=function(){this.fieldControl.focus();};$prototype.setBinding=function(binding){this.fieldControl.setBinding(binding);};$prototype.getValue=function(){return this.fieldControl.getValue();};$prototype.setValue=function(value,validate){this.fieldControl.setValue(value,validate);};$namespace.RoundedFieldComposite=Class.create(userSmarts.wt.widgets.RoundedComposite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'form-field',updateOnBoundsChange:true,layoutData:{width:"100%",height:37},padding:{top:0,left:5,right:5,bottom:0}});superClass.call(this,properties);};$prototype.initNode=function(){userSmarts.wt.widgets.RoundedComposite.prototype.initNode.call(this);var field=new userSmarts.wt.forms.FieldComposite({title:this.title,showLabel:this.showLabel,showLabelOnTop:this.showLabelOnTop,labelWidth:this.labelWidth,validator:this.validator,validationFunc:this.validationFunc,value:this.value,binding:this.binding,format:this.format,disabled:this.disabled});this.add(field);this.field=field;};$prototype.focus=function(){this.field.focus();};$prototype.getValue=function(){return this.field.getValue();}
$prototype.setValue=function(value){this.field.setValue(value);};namespace("userSmarts.wt.forms");userSmarts.wt.forms.DefaultOptionModel=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{options:[]});Bean.call(this,properties);if(this.datatype&&this.datatype.facets&&this.datatype.facets.enumeration){this.buildFromDatatype(this.datatype);}};userSmarts.wt.forms.DefaultOptionModel.inheritsFrom(Bean);userSmarts.wt.forms.DefaultOptionModel.prototype.getLabel=function(index){return this.options[index].label||"";};userSmarts.wt.forms.DefaultOptionModel.prototype.getValue=function(index){return this.options[index].value||"";};userSmarts.wt.forms.DefaultOptionModel.prototype.getDisabled=function(index){return this.options[index].disabled===true||this.options[index].disabled=="true";};userSmarts.wt.forms.DefaultOptionModel.prototype.isSelected=function(index){return this.options[index].selected===true||this.options[index].selected=="true";};userSmarts.wt.forms.DefaultOptionModel.prototype.setSelected=function(index,value){if(typeof(value)!="boolean"){value=true;}
return this.options[index].selected==value;};$prototype.getOptions=function(){return this.options;};userSmarts.wt.forms.DefaultOptionModel.prototype.getOptionCount=function(){return this.options.length;};userSmarts.wt.forms.DefaultOptionModel.prototype.addOption=function(value,label,selected){var option={value:value,label:label,selected:(selected===true)};this.options.push(option);return option;};userSmarts.wt.forms.DefaultOptionModel.prototype.buildFromDatatype=function(datatype){var enumeration=datatype.facets.enumeration;for(var i=0;i<enumeration.length;++i){var item=enumeration[i];if(typeof(item)=='string'){this.addOption(item,item,false);}else if(typeof(item)=='object'){var value=item.value;var label=item.label;var selected=(this.selectedOption==value)||item.selected;this.addOption(value,label,selected);}}};namespace("userSmarts.wt.forms");$namespace.Select=Class.create(Bean);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{atts:{},size:''});superClass.call(this,properties);if(!this.optionModel){this.optionModel=new userSmarts.wt.forms.DefaultOptionModel({datatype:this.datatype});}};$prototype.paint=function(context){var options=[];var model=this.optionModel;var hasSelection=false;for(var i=0;i<model.getOptionCount();++i){var atts={value:model.getValue(i),'class':'form-option-'+model.getLabel(i).replace(/\s+/g,'_')};if(model.getDisabled(i)){atts.disabled="disabled";}
if(model.isSelected(i)||model.getValue(i)==this.value||(this.binding&&this.binding.getValue()==model.getValue(i))){hasSelection=true;atts.selected="selected";}
options.push(OPTION(atts,model.getLabel(i)));}
if(!hasSelection){if(options.length>0){options[0].selected="selected";if(this.binding){this.binding.setValue(options[0].value);}}}
this.select=SELECT();this.select.id=this.name;this.select.name=this.name;this.select.size=this.size;if(this.style&&this.style.width){this.select.style.width=parseInt(this.style.width)+"px";}
if(this.style&&this.style.height){this.select.style.height=parseInt(this.style.height)+"px";}
for(var i=0;i<options.length;++i){this.select.appendChild(options[i]);}
this.changeListener=connect(this.select,'onchange',this,this.onInputChange);this.layout=SPAN({'class':'form-select-field'});if(this.showLabel){this.layout.appendChild(LABEL({"for":this.name},this.title));}
this.layout.appendChild(this.select);return this.layout;};$prototype.repaint=function(){};$prototype.onInputChange=function(event){var selectedIndex=this.select.selectedIndex;var value=this.optionModel.getValue(selectedIndex);if(this.binding){this.binding.setValue(value);}
if(this.parent){this.parent.validate();}};$prototype.focus=function(){if(this.select){this.select.focus();}};$prototype.dispose=function(){if(this.changeListener){disconnect(this.changeListener);this.changeListener=null;}
Bean.prototype.dispose.call(this);};namespace("userSmarts.wt.forms");$namespace.SelectControl=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){if(properties&&properties.size){properties.selectSize=properties.size;properties.size=null;}
properties=setdefault(properties,{'class':'form-select-field',atts:{},selectSize:'',validationFunc:"validate"});if(!properties.optionModel&&properties.datatype){properties.optionModel=new userSmarts.wt.forms.DefaultOptionModel({datatype:properties.datatype});}
superClass.call(this,properties);};$prototype.initNode=function(){var node=this.node;var hasSelection=false;var options=this.options;if(!options){options=[];var model=this.optionModel;if(model){for(var i=0;i<model.getOptionCount();++i){var atts={value:model.getValue(i),'class':'form-option-'+model.getLabel(i).replace(/\s+/g,'_')};if(model.getDisabled(i))atts.disabled="disabled";if(model.isSelected(i)||model.getValue(i)==this.value||(this.binding&&this.binding.getValue()==model.getValue(i))){hasSelection=true;atts.selected="selected";}
options.push(OPTION(atts,model.getLabel(i)));}}}
if(!hasSelection){if(options.length>0){options[0].selected="selected";if(this.binding){this.binding.setValue(options[0].value);}}}
this.select=SELECT();this.select.id=this.name;this.select.name=this.name;this.select.size=this.selectSize;if(this.style&&this.style.width){this.select.style.width=parseInt(this.style.width)+"px";}
if(this.style&&this.style.height){this.select.style.height=parseInt(this.style.height)+"px";}
for(var i=0;i<options.length;++i){this.select.appendChild(options[i]);}
this.changeListener=connect(this.select,'onchange',this,this.onInputChange);if(this.showLabel&&this.title){if(this.title.indexOf(":")<this.title.length-2){this.title+=": "}
node.appendChild(DIV({'class':'form-input-field-label'},this.title));}
node.appendChild(this.select);return this.layout;};$prototype.getSelect=function(){return this.select;};$prototype.setSize=function(width,height){userSmarts.wt.widgets.Control.prototype.setSize.call(this,width,height);var offset=(userSmarts.util.Browser.isIE?9:6);this.select.style.width=((parseInt(this.node.style.width)||(offset+1))-offset)+"px";};$prototype.onInputChange=function(event){var value=this.getSelectedValue();if(this.binding){this.binding.setValue(value);}
if(this.validator){this.validator[this.validationFunc](value);}};$prototype.setValue=function(value){if(this.format&&typeof(this.format.format)=="function"){value=this.format.format(value);}
for(var i=0;i<this.select.options.length;++i){if(this.select.options[i].value==value){try{this.select.selectedIndex=i;}catch(e){}}}};$prototype.getValue=function(){return this.getSelectedValue();};$prototype.getSelectedValue=function(){var selectedIndex=this.select.selectedIndex;var value;if(this.optionModel){value=this.optionModel.getValue(selectedIndex);}else{value=this.select[selectedIndex].value}
if(this.format&&typeof(this.format.parseObject)=="function"){value=this.format.parseObject(value);}
return value;};$prototype.focus=function(){if(this.select){this.select.focus();}};$prototype.setOptions=function(newOptions){this.options=newOptions;var options=this.options||[];replaceChildNodes(this.select,options);};$prototype.dispose=function(){disconnect(this.changeListener);this.changeListener=null;if(this.binding){this.binding.dispose();this.binding=null;delete this.binding;}
if(this.validator){delete this.validator;}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};namespace("userSmarts.wt.forms");$namespace.SelectComposite=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{showLabelOnTop:false});superClass.call(this,properties);};$prototype.initNode=function(){var type="horizontal";if(this.showLabelOnTop){type="vertical";}
this.setLayout(new userSmarts.wt.layout.RowLayout({type:type}));if((this.showLabel||this.showLabelOnTop)&&this.title){if(this.title.indexOf(":")<this.title.length-2){this.title+=": "}
var layout={width:"*",height:"*"};var padding={top:0,left:0,right:0,bottom:0};if(this.showLabelOnTop){this.layoutData.height=50;layout.width="100%";layout.height=20;}else{if(!this.labelWidth){this.labelWidth=determineLabelWidth(this.title,"form-input-field-label");}
layout.width=this.labelWidth;layout.height="100%";padding.top=3;}
var labelControl=new userSmarts.wt.forms.Label({parent:this,'class':"form-input-field-label",padding:padding,layoutData:layout,value:this.title});}
this.selectControl=new userSmarts.wt.forms.SelectControl({parent:this,layoutData:{width:"*",height:"*"},value:this.value||null,binding:this.binding||null,format:this.format||null,validator:this.validator||null,validationFunc:this.validationFunc||null,disabled:this.disabled||false,options:this.options,datatype:this.datatype,optionModel:this.optionModel,showLabel:false});this.update();};$prototype.getSelect=function(){return this.selectControl.getSelect();};$prototype.focus=function(){this.selectControl.focus();};$prototype.getValue=function(){return this.selectControl.getValue();};$prototype.setValue=function(value){this.selectControl.setValue(value);};$prototype.setOptions=function(newOptions){this.selectControl.setOptions(newOptions);};namespace("userSmarts.wt.forms");$namespace.Text=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'form-input-field',value:"",showLabelOnTop:false});superClass.call(this,properties);};$prototype.initNode=function(){var type="horizontal";if(this.showLabelOnTop){type="vertical";}
this.setLayout(new userSmarts.wt.layout.RowLayout({type:type}));var padding={top:0,left:0,right:0,bottom:0};if((this.showLabel||this.showLabelOnTop)&&this.title){if(this.title.indexOf(":")<this.title.length-2){this.title+=": "}
var layout={width:"*",height:"*"};if(this.showLabelOnTop){this.layoutData.height=50;layout.width="100%";layout.height=20;}else{if(!this.labelWidth){this.labelWidth=determineLabelWidth(this.title,"form-input-field-label");}
layout.width=this.labelWidth;layout.height="100%";padding.top=3;}
var labelControl=new userSmarts.wt.forms.Label({parent:this,'class':"form-input-field-label",padding:padding,layoutData:layout,value:this.title});}
this.valueControl=new userSmarts.wt.forms.Label({parent:this,'class':"form-input-field-value",padding:padding,layoutData:{width:"*",height:"*"},value:this.value||""});this.update();};$prototype.getValue=function(){return this.valueControl.getValue();};$prototype.setValue=function(value){this.valueControl.setValue(value);};namespace("userSmarts.wt.forms");$namespace.TextArea=Class.create(Bean);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{rows:0,cols:0,wrap:'SOFT',multiplicity:false,format:new StringFormat(),validationFunc:"validate"});Bean.call(this,properties);};$prototype.paint=function(){var ta=document.createElement("TEXTAREA");ta.id=this.name;ta.name=this.name;ta.rows=this.rows;ta.cols=this.cols;ta['WRAP']=this.wrap;this.input=ta;if(this.disabled)this.input.disabled=true;this.changeListener=connect(this.input,'onchange',this,this.onInputChange);if(this.value){this.input.value=this.value;}else if(this.binding){this.input.value=this.binding.getValue();}else{this.input.value="";}
this.layout=SPAN({'class':'form-input-field'});if(this.name&&this.title){this.layout.appendChild(LABEL({"for":this.name},this.title));}
this.layout.appendChild(this.input);if(this.binding){this.bindingListener=connect(this.binding,"*",this,this.onBindingChange);}
return this.layout;};$prototype.onInputChange=function(event){var value=this.input.value;if(this.format&&typeof(this.format.parseObject)=="function"){value=this.format.parseObject(value);}
var err=null;if(this.parent){err=this.parent[this.validationFunc](value);}
if(!err){if(this.binding){this.binding.setValue(value);}}else{this.input.value=this.format.format(this.binding.getValue());alert("Illegal Argument: \n"+err);}};$prototype.onBindingChange=function(event){var value=this.binding.getValue();if(this.format&&typeof(this.format.parseObject)=="function"){this.input.value=this.format.format(value);}};$prototype.getValue=function(){var value=this.input.value;if(this.format&&typeof(this.format.parseObject)=="function"){value=this.format.parseObject(value);}
return value;};$prototype.setValue=function(value){var err=null;if(this.parent){err=this.parent[this.validationFunc](value);}
if(!err){this.binding.setValue(value);this.input.value=this.format.format(value);}else{alert("Illegal Argument: \n"+err);}};$prototype.dispose=function(){disconnect(this.changeListener);if(this.bindingListener){disconnect(this.bindingListener);}
this.input=null;this.format=null;this.binding.dispose();delete this.binding;delete this.parent;Bean.prototype.dispose.call(this);};$prototype.focus=function(){if(this.input){this.input.focus();if(this.input.value){this.input.select();}}};namespace("userSmarts.wt.forms");$namespace.TextAreaControl=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{'class':'form-input-field',wrap:'SOFT',multiplicity:false,format:new StringFormat(),validationFunc:"validate"});superClass.call(this,properties);};$prototype.initNode=function(){var node=this.node;var ta=document.createElement("TEXTAREA");ta.id=this.name;ta.name=this.name;ta['WRAP']=this.wrap;this.input=ta;if(this.disabled)this.input.disabled=true;this.changeListener=connect(this.input,'onchange',this,this.onInputChange);if(this.value){this.input.value=this.value;}else if(this.binding){this.input.value=this.binding.getValue();}else{this.input.value="";}
if(this.showLabel&&this.title){if(this.title.indexOf(":")<this.title.length-2){this.title+=": "}
node.appendChild(DIV({'class':this['class']+"-label"},this.title));}
node.appendChild(this.input);if(this.binding){this.bindingListener=connect(this.binding,"*",this,this.onBindingChange);}};$prototype.setSize=function(width,height){userSmarts.wt.widgets.Control.prototype.setSize.call(this,width,height);this.input.style.width=(Math.max(parseInt(this.node.style.width)||0,11)-10)+"px";if(!this.rows){this.input.style.height=(Math.max(parseInt(this.node.style.height)||0,21)-20)+"px";}else{this.input.rows=Coerce.toInteger(this.rows,3);}};$prototype.setBinding=function(binding){this.binding=binding;var value=binding.getValue();if(this.format&&typeof(this.format.format)=="function"){this.input.value=this.format.format(value||"");}else{this.input.value=(value||"");}};$prototype.onInputChange=function(event){var value=this.input.value;if(this.format&&typeof(this.format.parseObject)=="function"){value=this.format.parseObject(value);}
var err=null;if(this.validator){err=this.validator[this.validationFunc](value);}
if(!err){if(this.binding){this.binding.setValue(value);}}else{this.input.value=this.format.format(this.binding.getValue());alert("Illegal Argument: \n"+err);}};$prototype.onBindingChange=function(event){var value=this.binding.getValue();if(this.format&&typeof(this.format.parseObject)=="function"){this.input.value=this.format.format(value);}};$prototype.getValue=function(){var value=this.input.value;if(this.format&&typeof(this.format.parseObject)=="function"){value=this.format.parseObject(value);}
return value;};$prototype.setValue=function(value){var err=null;if(this.validator){err=this.validator[this.validationFunc](value);}
if(!err){if(this.binding){this.binding.setValue(value);}
if(this.format){value=this.format.format(value);}
this.input.value=value;}else{alert("Illegal Argument: \n"+err);}};$prototype.dispose=function(){disconnect(this.changeListener);if(this.bindingListener){disconnect(this.bindingListener);}
this.input=null;this.format=null;if(this.binding){this.binding.dispose();delete this.binding;}
if(this.validator){delete this.validator;}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};$prototype.focus=function(){if(this.input){this.input.focus();if(this.input.value){this.input.select();}}};namespace("userSmarts.wt.forms");$namespace.TextAreaComposite=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{showLabelOnTop:false});superClass.call(this,properties);};$prototype.initNode=function(){var type="horizontal";if(this.showLabelOnTop){type="vertical";}
this.setLayout(new userSmarts.wt.layout.RowLayout({type:type}));if((this.showLabel||this.showLabelOnTop)&&this.title){if(this.title.indexOf(":")<this.title.length-2){this.title+=": "}
var layout={width:"*",height:"*"};var padding={top:0,left:0,right:0,bottom:0};if(this.showLabelOnTop){layout.width="100%";layout.height=20;}else{if(!this.labelWidth){this.labelWidth=determineLabelWidth(this.title,"form-input-field-label");}
layout.width=this.labelWidth;layout.height="100%";padding.top=3;}
var labelControl=new userSmarts.wt.forms.Label({parent:this,'class':"form-input-field-label",padding:padding,layoutData:layout,value:this.title});}
this.textAreaControl=new userSmarts.wt.forms.TextAreaControl({parent:this,layoutData:{width:"*",height:"*"},value:this.value||null,binding:this.binding||null,format:this.format||null,validator:this.validator||null,validationFunc:this.validationFunc||null,disabled:this.disabled||false,showLabel:false});this.update();};$prototype.setBinding=function(binding){this.textAreaControl.setBinding(binding);};$prototype.focus=function(){this.textAreaControl.focus();};$prototype.getValue=function(){return this.textAreaControl.getValue();};$prototype.setValue=function(value,validate){this.textAreaControl.setValue(value,validate);};namespace("userSmarts.wt.forms");$namespace.RadioControl=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{atts:{},size:''});superClass.call(this,properties);if(!this.optionModel&&this.datatype){this.optionModel=new userSmarts.wt.forms.DefaultOptionModel({datatype:this.datatype});}};$prototype.initNode=function(){var model=this.optionModel;var input;if(model){for(var i=0;i<model.getOptionCount();++i){input=INPUT({type:'radio',name:this.name});input.index=i;input.value=model.getValue(i);connect(input,"onclick",this,this.onInputChange);if(model.isSelected(i)||model.getValue(i)==this.value||(this.binding&&this.binding.getValue()==model.getValue(i))){input.checked=true;}
if(model.getDisabled(i)){input.disabled=true;}
this.node.appendChild(input);this.node.appendChild(document.createTextNode(" "+model.getLabel(i)));this.node.appendChild(BR());}}};$prototype.onInputChange=function(event){var input=event.src();var index=input.index;var value=this.optionModel.getValue(index);if(this.validator){this.validator[this.validationFunc](value);}
this.optionModel.setSelected(index,input.checked);if(this.binding){if(input.checked){this.addValueToBinding(value);}else{this.removeValueFromBinding(value);}}};$prototype.removeValueFromBinding=function(value){if(this.binding){var values=this.binding.getValue()||[];for(var i=0;i<values.length;++i){if(values[i]==value){values.splice(i,1);break;}}
this.binding.setValue(values);}};$prototype.addValueToBinding=function(value){if(this.binding){var values=this.binding.getValue()||[];var found=false;for(var i=0;i<values.length;++i){if(values[i]==value){found=true;break;}}
if(!found){values.push(value);}
this.binding.setValue(values);}};