function Controller(){function e(){c.toggleMenu(n.team,Alloy.Globals.animations.menu)}function t(){c.i("toggle favorite"),Alloy.Globals.loading.showHide("show");var e=Alloy.Globals.favourites.teams.slice(0);n.favouriteButton.active?(n.favouriteButton.backgroundImage="images/iconFavouriteOff.png",n.favouriteButton.active=!1,e=_.without(e,u.id)):(n.favouriteButton.backgroundImage="images/iconFavouriteOn.png",n.favouriteButton.active=!0,e.push(u.id)),c.setFaveTeams(e),Alloy.Globals.rebuildMenu()}function i(e){void 0!==e.source.clickArgs&&(Alloy.Globals.loading.showHide("show"),_.defer(function(){l(e.source.clickArgs)}))}function o(){c.toggleMenu(n.sectionOptions,v)}function l(e){var t=!1;(void 0===d||d.id!==e.id)&&(void 0!==d?(void 0!==d.cancelRefresh&&d.cancelRefresh(),n.detailWrapper.remove(d.getView()),d.destroy&&d.destroy(),d=null):t=!0,d=Alloy.createController(e.id,e.args),n.detailWrapper.add(d.getView()),n.sectionSelector.text="    "+e.label,n.team.cancelRefresh=d.cancelRefresh),t||o(),_.defer(function(){Alloy.Globals.loading.showHide("hide")})}function a(){_.contains(Alloy.Globals.favourites.teams,u.id)&&(n.favouriteButton.backgroundImage="images/iconFavouriteOn.png",n.favouriteButton.active=!0),n.team.args=u,n.title.text=u.name,_.each(g,function(e){n.sectionOptions.add(Alloy.createController("detailSelectorItem",e).getView())}),l(g[0])}require("alloy/controllers/BaseController").apply(this,Array.prototype.slice.call(arguments)),this.__controllerPath="team",arguments[0]?arguments[0].__parentSymbol:null,arguments[0]?arguments[0].$model:null,arguments[0]?arguments[0].__itemTemplate:null;var n=this,r={},s={};n.__views.team=Ti.UI.createView({backgroundColor:Alloy.CFG.colors.darkBlue,id:"team"}),n.__views.team&&n.addTopLevelView(n.__views.team),n.__views.detailWrapper=Ti.UI.createScrollView({top:88,backgroundColor:Alloy.CFG.colors.white,contentWidth:Ti.UI.FILL,id:"detailWrapper"}),n.__views.team.add(n.__views.detailWrapper),n.__views.sectionOptions=Ti.UI.createView({backgroundColor:Alloy.CFG.colors.darkGrey,layout:"vertical",height:123,top:-123,id:"sectionOptions"}),n.__views.team.add(n.__views.sectionOptions),i?n.__views.sectionOptions.addEventListener("click",i):s["$.__views.sectionOptions!click!sectionOptionClicked"]=!0,n.__views.titleBar=Ti.UI.createView({backgroundColor:Alloy.CFG.colors.darkBlue,height:40,top:0,id:"titleBar"}),n.__views.team.add(n.__views.titleBar),n.__views.menuButton=Ti.UI.createView({width:33,height:33,left:12,backgroundImage:"images/iconMenu.png",id:"menuButton"}),n.__views.titleBar.add(n.__views.menuButton),e?n.__views.menuButton.addEventListener("click",e):s["$.__views.menuButton!click!toggleMenu"]=!0,n.__views.title=Ti.UI.createLabel({font:{fontSize:20,fontFamily:Alloy.CFG.fonts.bold},color:Alloy.CFG.colors.white,id:"title"}),n.__views.titleBar.add(n.__views.title),n.__views.favouriteButton=Ti.UI.createView({width:33,height:33,right:12,backgroundImage:"images/iconFavouriteOff.png",id:"favouriteButton"}),n.__views.titleBar.add(n.__views.favouriteButton),t?n.__views.favouriteButton.addEventListener("click",t):s["$.__views.favouriteButton!click!toggleFavourite"]=!0,n.__views.sectionSelector=Ti.UI.createLabel({font:{fontSize:16,fontFamily:Alloy.CFG.fonts.bold},color:Alloy.CFG.colors.white,width:Ti.UI.FILL,height:48,top:40,backgroundColor:Alloy.CFG.colors.darkBlue,backgroundImage:"/images/bgDropDown.png",id:"sectionSelector"}),n.__views.team.add(n.__views.sectionSelector),o?n.__views.sectionSelector.addEventListener("click",o):s["$.__views.sectionSelector!click!toggleSectionMenu"]=!0,r.destroy=function(){},_.extend(n,n.__views);var c=require("helpers");require("feedSigner"),require("netConnect");var d,u=arguments[0]||{},v={open:Ti.UI.createAnimation({top:88,height:123,duration:300,curve:Ti.UI.ANIMATION_CURVE_EASE_IN_OUT}),close:Ti.UI.createAnimation({top:-123,height:123,duration:300,curve:Ti.UI.ANIMATION_CURVE_EASE_IN_OUT})},g=[{id:"newsItems",label:L("News_Title").toUpperCase(),args:{feedUrl:Alloy.CFG.feedUrls.newsArchiveTeam.replace("{{id}}",u.id)}},{id:"matchListTable",label:L("Matches_Title").toUpperCase(),args:{feedUrl:Alloy.CFG.feedUrls.matchesTeam.replace("{{id}}",u.id)}},{id:"teamSquad",label:L("Squad_Title").toUpperCase(),args:{id:u.id}}];a(),s["$.__views.sectionOptions!click!sectionOptionClicked"]&&n.__views.sectionOptions.addEventListener("click",i),s["$.__views.menuButton!click!toggleMenu"]&&n.__views.menuButton.addEventListener("click",e),s["$.__views.favouriteButton!click!toggleFavourite"]&&n.__views.favouriteButton.addEventListener("click",t),s["$.__views.sectionSelector!click!toggleSectionMenu"]&&n.__views.sectionSelector.addEventListener("click",o),_.extend(n,r)}var Alloy=require("alloy"),Backbone=Alloy.Backbone,_=Alloy._;module.exports=Controller;