DRHorton.community = DRHorton.community || {};
DRHorton.community.content = DRHorton.community.content || {};


DRHorton.community.content.Content = function(jqObj){
    this.jqObj = jqObj;
    this.type = "PAGE";
    if(typeof this.jqObj != "undefined")
        this.init();
};

DRHorton.community.content.Content.inherits(DRHorton.events.EventDispatcher);

    
DRHorton.community.content.Content.methods({
    
    init : function(){
        this.jqObj.hide();
        this.render();
    },
    
    render : function(){
        var _this = this;
        this.jqObj.find("[data-community-element-type]").each(function(){
            _this.transformElement($(this));            
        });
    },
    
    transformElement : function(element){
        var _this = this;
        switch(element.attr("data-community-element-type").toLowerCase()){
            case "community-simple-slideshow":
                var slideshow = new DRHorton.community.elements.SimpleSlideShow(element);
                slideshow.addEventListener(DRHorton.community.elements.SimpleSlideShow.CREATION_COMPLETE, function() { _this.onRenderComplete(); } )
                break;
        }
    },
    
    
    onRenderComplete : function(){
        this.dispatchEvent(new DRHorton.events.Event(DRHorton.community.content.Content.CREATION_COMPLETE));
        this.jqObj.show();
    }
    
    
});


DRHorton.community.content.Content.CREATION_COMPLETE = "DRHorton.community.content.Content.CREATION_COMPLETE";
