/*
 * @require jade/ArrayUtils.js
 */
jade.compat.Object=function(b,a){this.children=[];
this.connectedSlots={};if(a){this.name=a}else{this.name=this.createName()}if(b){b.insertChild(this)
}};jade.compat.Object.objCounter=0;jade.compat.Object.prototype.parent=null;jade.compat.Object.prototype.children=null;
jade.compat.Object.prototype.name=null;jade.compat.Object.prototype.connectedSlots=null;
jade.compat.Object.prototype.busyCounter=0;jade.compat.Object.prototype.getChildren=function(){return this.children.slice(0)
};jade.compat.Object.prototype.getParent=function(){return this.parent};jade.compat.Object.prototype.setParent=function(b){var a;
a=this.parent;if(a==b){return}if(a){a.removeChild(this)}this.parent=b;if(b){b.insertChild(this)
}};jade.compat.Object.prototype.insertChild=function(a){if(a.parent!=this){a.setParent(this)
}else{if(!jade.ArrayUtils.inArray(this.children,a)){this.children.push(a);this.sendSignal("insertChild",a)
}}};jade.compat.Object.prototype.removeChild=function(b){var a;a=b.getParent();if(!a||a!==this){return false
}if(jade.ArrayUtils.remove(this.children,b)){b.parent=null;this.sendSignal("removeChild",b)
}return true};jade.compat.Object.prototype.clear=function(){var b,a;for(b=0,a=this.children.length;
b<a;b++){this.children[b].parent=null;this.sendSignal("removeChild",this.children[b])
}this.children=[]};jade.compat.Object.prototype.isChild=function(a){return jade.ArrayUtils.inArray(this.children,a)
};jade.compat.Object.prototype.sendSignal=function(f,e){var d,c,a,b,h,g;d=this.connectedSlots[f];
if(d===undefined){return true}b=arguments;b[0]=this;d=d.slice();h=true;for(c=0,a=d.length;
c<a;c++){g=d[c];if(g[0].apply(g[1],b)===false){h=false}}return h};jade.compat.Object.prototype.sendQuery=function(g,d,a){var e,c,h,f,b,j;
e=this.connectedSlots[g];if(e===undefined){return d}f=arguments;f[0]=this;b=true;
for(c=0,h=e.length;c<h;c++){j=e[c];f[1]=j[0].apply(j[1],f)}return f[1]};jade.compat.Object.prototype.connect=function(d,e,b,c){var a;
if(!e){throw new Error("Invalid slot")}if(c!==undefined&&c&&this.isConnected(d,e,b)){return
}if(b===undefined){b=window}a=this.connectedSlots[d];if(a===undefined){a=[];this.connectedSlots[d]=a
}a.push([e,b])};jade.compat.Object.prototype.disconnect=function(d,e,c){var b,a;if(c===undefined){c=window
}b=this.connectedSlots[d];if(b===undefined){return}for(a=b.length-1;a>=0;a--){if(!e||(b[a][0]==e&&b[a][1]==c)){b.splice(a,1)
}}};jade.compat.Object.prototype.isConnected=function(d,e,c){var b,a;b=this.connectedSlots[d];
if(e===undefined){return b&&!!b.length}if(c===undefined){c=window}if(b===undefined){return false
}for(a=b.length-1;a>=0;a--){if(b[a][0]==e&&b[a][1]==c){return true}}return false};
jade.compat.Object.prototype.getName=function(){return this.name};jade.compat.Object.prototype.createName=function(){return"jade.compat.Object-"+(jade.compat.Object.objCounter++)
};jade.compat.Object.prototype.bringChildToFront=function(a){if(jade.ArrayUtils.remove(this.children,a)){this.children.push(a)
}};jade.compat.Object.prototype.sendChildToBack=function(a){if(jade.ArrayUtils.remove(this.children,a)){this.children.splice(0,0,a)
}};jade.compat.Object.prototype.sendToBack=function(){if(this.isAtBack()){return false
}if(this.parent){this.parent.sendChildToBack(this)}return true};jade.compat.Object.prototype.isAtFront=function(){var a;
a=this.getParent().getChildren();if(a.length==1){return true}return jade.ArrayUtils.isLast(a,this)
};jade.compat.Object.prototype.isAtBack=function(){var a;a=this.getParent().getChildren();
if(a.length==1){return true}return jade.ArrayUtils.isFirst(a,this)};jade.compat.Object.prototype.bringToFront=function(){if(this.isAtFront()){return false
}if(this.parent){this.parent.bringChildToFront(this)}return true};jade.compat.Object.prototype.busy=function(){this.busyCounter++;
if(this.busyCounter==1){this.sendSignal("busy")}};jade.compat.Object.prototype.ready=function(){if(!this.busyCounter){throw new Error("Object is not busy")
}this.busyCounter--;if(!this.busyCounter){this.sendSignal("ready")}};jade.compat.Object.prototype.isBusy=function(){return this.busyCounter!=0
};jade.compat.Object.prototype.isReady=function(){return this.busyCounter==0};jade.compat.Object.prototype.setName=function(a){this.name=a
};jade.compat.Object.prototype.getName=function(a){return this.name};
