
/*
FILE CONCAT ADD FILE
PATH: /ft/resources/client/modules/markets/sectorsAndIndustries/SectorsPerformanceAndSummary.js
*/
var SectorsPerformanceAndSummary = function() {
}

SectorsPerformanceAndSummary.prototype.BUFFER_URL = '/ft/resources/buffer/sectorsAndIndustries/performanceSummary.asp'

SectorsPerformanceAndSummary.prototype.init = function() {
    this.industryLinks = WSDOM.Element.parseSelector('a.performanceSummaryLink');
    this.tableHolder = WSDOM.Element.parseSelector('div.tableHolder ', 'wsod', 'first');

    WSDOM.Events.add(this.industryLinks, 'click', this.initBuffer, this);
}

SectorsPerformanceAndSummary.prototype.initBuffer = function(e, el) {
    if (WSDOM.Element.hasClass(el, 'active')) { return; }

    WSDOM.Element.removeClass(this.industryLinks, 'active');
    WSDOM.Element.addClass(el, 'active');

    var view = el.getAttribute('view'),
        cb = this.getContentBuffer();
        
    this.loadingOverlay = new LoadingOverlay(this.tableHolder);
    this.loadingOverlay.showLoading();
    
    var conn = cb.load({
        debug: true,
        url: this.BUFFER_URL,
        method: "post",
        contentType: "text/html",
        context: this,
        data: {
            view: view			
        },
        onload: this.bufferReturn
     });
}

SectorsPerformanceAndSummary.prototype.bufferReturn = function(cb) {
    var oResults = new Serializer().deserialize(cb.getResult());
    var sHTML = oResults.html;
		
    this.loadingOverlay.hideLoading();
    WSDOM.Element.removeChildNodes(this.tableHolder);
    WSDOM.Element.setHTML(this.tableHolder, sHTML);    
}

SectorsPerformanceAndSummary.prototype.getContentBuffer = function() {
    var cb = new ContentBuffer();

    this.getContentBuffer = function() {
        return cb;
    }

    return this.getContentBuffer();
}

