define(["backbone"],function(b){var a=b.Router.extend({title:"",view:null,validationModel:null,subcontrollers:null,attached:null,initialize:function(c){b.Router.prototype.initialize.apply(this,arguments);this.subcontrollers=new Array();},subController:function(h,g,l,j,d,f,i,c){if(!j){j=[];}var e=_.bind(function(m){this.listenTo(g,"controller:attach",function(p){if(f===true){this.stopListening(g);}p.setParent(m);var o=$(h);switch(d){case a.attachMode.Defer:o.html(p.$el.html());o.css("display","none");break;case a.attachMode.Append:var n=p.$el.html();o.append(n);if(c&&c.length>0){o=$(c);}break;default:o.html(p.$el.html());break;}p.setElement(o);});},this);var k=_.bind(function(){this.listenTo(this,"controller:attach",function(m){this.attached=true;if(f!==false){this.stopListening(this);}e(m);g[l].apply(g,j);});},this);this.subcontrollers.push(g);if(this.attached===true||i===false){e(this.view);g[l].apply(g,j);}else{k();}},close:function(e){for(var c=0;c<this.subcontrollers.length;++c){var d=this.subcontrollers[c];if(d){d.close();}}this.off();this.stopListening();if(this.view){this.view.close(e);}delete this;}},{attachMode:{SetContents:0,Append:1,Defer:2}});return a;});