var NewsTabSection=new JS.Class({include:JS.State,extend:{Story:new JS.Class({initialize:function(B,A){this._section=B;this._element=Ojay(A);var C=this._element.method("descendants");this._headline=C("h3").node.innerHTML.stripTags();this._image=C("img")},select:function(A){if(A){this._section.getStories().forEach({select:false})}this.getElement()[A?"show":"hide"]();this.getImageContainer()[A?"addClass":"removeClass"]("selected")},getElement:function(){return this._element},getHeadline:function(){return this._headline},getImage:function(){if(this._dupImage){return this._dupImage}var B=this._image.node,A=Number(B.width),C=Number(B.height);var D=100/A;return this._dupImage=Ojay(Ojay.HTML.img({src:B.src,width:D*A,height:D*C,title:B.title}))},getImageContainer:function(){return this._imageContainer||null},extend:{STORY_SELECTOR:".picture-story",extract:function(A,B){return Ojay(A).descendants(this.STORY_SELECTOR).map(function(C){return new this(B,C)},this)}}}),Controller:new JS.Class({initialize:function(A){this._section=A;A.getStories().forEach(function(C,B){C.getImage().on("click")._(A).setStory(B+1)},this);this._elements={}},getHTML:function(){if(this._elements._container){return this._elements._container}var A=this._elements._container=Ojay(Ojay.HTML.div());this._section.getStories().forEach(function(C){var B=C._imageContainer=Ojay(Ojay.HTML.div({className:"img"}));var D=Ojay(Ojay.HTML.div());D.insert(C.getImage().node);B.insert(D.node);A.insert(B.node)});A.addClass("news-photos");return this._elements._container=A}})},initialize:function(A){this._selector=A;this.setState("CREATED")},getInitialState:function(){return{story:1}},changeState:function(A){if(A.story!==undefined){this._handleSetStory(A.story)}},getStories:function(){return this._stories||null},getController:function(){return this._controller||null},states:{CREATED:{setup:function(){this._container=Ojay(this._selector);if(!this._container.node){return this}this._stories=this.klass.Story.extract(this._container,this);this._controller=new this.klass.Controller(this);this._container.insert(this._controller.getHTML().node,"top");this.setState("READY");var A=this.getInitialState();this._handleSetStory(A.story);return this}},READY:{setStory:function(A){A=Number(A);if(A==this._currentStory||A<1||A>this._stories.length){return }this.changeState({story:A});return this},_handleSetStory:function(A){this._stories[A-1].select(true)}},SWITCHING:{}}})