jade.require("jade.ArrayUtils");jade.Object=function(D,C){this.children=[];this.connectedSlots={};
if(C){this.name=C}else{this.name=this.createName()}if(D){D.insertChild(this)}};jade.Object.objCounter=0;
jade.Object.prototype.parent=null;jade.Object.prototype.children=null;jade.Object.prototype.name=null;
jade.Object.prototype.connectedSlots=null;jade.Object.prototype.busyCounter=0;jade.Object.prototype.getChildren=function(){return this.children.slice()
};jade.Object.prototype.getParent=function(){return this.parent};jade.Object.prototype.setParent=function(D){var C;
C=this.parent;if(C==D){return }if(C){C.removeChild(this)}this.parent=D;if(D){D.insertChild(this)
}};jade.Object.prototype.insertChild=function(B){if(B.parent!=this){B.setParent(this)
}else{if(!jade.ArrayUtils.inArray(this.children,B)){this.children.push(B);this.sendSignal("insertChild",B)
}}};jade.Object.prototype.removeChild=function(D){var C;C=D.getParent();if(!C||C!==this){return false
}if(jade.ArrayUtils.remove(this.children,D)){D.parent=null;this.sendSignal("removeChild",D)
}return true};jade.Object.prototype.clear=function(){var D,C;for(D=0,C=this.children.length;
D<C;D++){this.children[D].parent=null;this.sendSignal("removeChild",this.children[D])
}this.children=[]};jade.Object.prototype.isChild=function(B){return jade.ArrayUtils.inArray(this.children,B)
};jade.Object.prototype.sendSignal=function(L,M){var N,O,I,P,J,K;N=this.connectedSlots[L];
if(N===undefined){return true}P=arguments;P[0]=this;N=N.slice();J=true;for(O=0,I=N.length;
O<I;O++){K=N[O];if(K[0].apply(K[1],P)===false){J=false}}return J};jade.Object.prototype.sendQuery=function(P,J,M){var R,K,O,Q,L,N;
R=this.connectedSlots[P];if(R===undefined){return J}Q=arguments;Q[0]=this;L=true;
for(K=0,O=R.length;K<O;K++){N=R[K];Q[1]=N[0].apply(N[1],Q)}return Q[1]};jade.Object.prototype.connect=function(H,G,J,I){var F;
if(!G){throw new Error("Invalid slot")}if(I!==undefined&&I&&this.isConnected(H,G,J)){return 
}if(J===undefined){J=window}F=this.connectedSlots[H];if(F===undefined){F=[];this.connectedSlots[H]=F
}F.push([G,J])};jade.Object.prototype.disconnect=function(H,G,I){var J,F;if(I===undefined){I=window
}J=this.connectedSlots[H];if(J===undefined){return }for(F=J.length-1;F>=0;F--){if(J[F][0]==G&&J[F][1]==I){J.splice(F,1)
}}};jade.Object.prototype.isConnected=function(H,G,I){var J,F;J=this.connectedSlots[H];
if(G===undefined){return J&&!!J.length}if(I===undefined){I=window}if(J===undefined){return false
}for(F=J.length-1;F>=0;F--){if(J[F][0]==G&&J[F][1]==I){return true}}return false};
jade.Object.prototype.getName=function(){return this.name};jade.Object.prototype.createName=function(){return"jade.Object-"+(jade.Object.objCounter++)
};jade.Object.prototype.bringChildToFront=function(B){if(jade.ArrayUtils.remove(this.children,B)){this.children.push(B)
}};jade.Object.prototype.sendChildToBack=function(B){if(jade.ArrayUtils.remove(this.children,B)){this.children.splice(0,0,B)
}};jade.Object.prototype.sendToBack=function(){if(this.isAtBack()){return false}if(this.parent){this.parent.sendChildToBack(this)
}return true};jade.Object.prototype.isAtFront=function(){var B;B=this.getParent().getChildren();
if(B.length==1){return true}return jade.ArrayUtils.isLast(B,this)};jade.Object.prototype.isAtBack=function(){var B;
B=this.getParent().getChildren();if(B.length==1){return true}return jade.ArrayUtils.isFirst(B,this)
};jade.Object.prototype.bringToFront=function(){if(this.isAtFront()){return false
}if(this.parent){this.parent.bringChildToFront(this)}return true};jade.Object.prototype.busy=function(){this.busyCounter++;
if(this.busyCounter==1){this.sendSignal("busy")}};jade.Object.prototype.ready=function(){if(!this.busyCounter){throw new Error("Object is not busy")
}this.busyCounter--;if(!this.busyCounter){this.sendSignal("ready")}};jade.Object.prototype.isBusy=function(){return this.busyCounter!=0
};jade.Object.prototype.isReady=function(){return this.busyCounter==0};jade.Object.prototype.setName=function(B){this.name=B
};jade.Object.prototype.getName=function(B){return this.name};