Type.registerNamespace('ControlLibrary');

ControlLibrary.NewsTicker = function()
{
    //Fields      
    this.webServiceReference;
    this.controlNameHeadline;    
    this.controlNameBody;    
    this.controlTextHeadline;    
    this.controlTextBody;    
    this.currentNewsDate = null;
}

ControlLibrary.NewsTicker.prototype = {
    //Methods    

    ChangeContent: function() {
        this.webServiceReference.GetNewsLine(this.currentNewsDate, this.OnChangeContentFinish, this.OnChangeContentError, this);

    },


    OnChangeContentError: function(result, context, methodName) {
        alert("Error!");
    },

    OnChangeContentFinish: function(result, context, methodName) {
        context.SetCurrentRecord(result[0].format("MM/dd/yyyy HH:mm:ss"));
        context.controlTextHeadline = result[1];
        context.controlTextBody = result[2];
        //context.controlTextBody = result[2] + "<img src='/Resources/Images/chocBar.jpg'/>"

        if ($get(context.controlNameHeadline) != null) {
        
            $get(context.controlNameHeadline).innerHTML = context.controlTextHeadline;
            $get(context.controlNameBody).innerHTML = context.controlTextBody;
        }

    },



    SetCurrentRecord: function(variable) {
        this.currentNewsDate = variable;
    },

    WireReferences: function(webReference, headlineControl, bodyControl) {
        this.webServiceReference = webReference;
        this.controlNameHeadline = headlineControl;
        this.controlNameBody = bodyControl;
    }

}

ControlLibrary.NewsTicker.registerClass('ControlLibrary.NewsTicker');

//====================================================================
// New Addition of the Class to handle the large content of the body.

//ControlLibrary.BodyBuilder = function() {
//    //Fields      
//    this.webServiceReference;
//    //this.controlNameHeadline;
//    this.controlNameBody;
//    this.controlTextHeadline;
//    this.controlTextBody;
//    this.currentNewsDate = null;
//}

//ControlLibrary.BodyBuilder.prototype = {
//    //Methods    

//    ChangeContent: function() {
//        this.webServiceReference.GetNewsLine(this.currentNewsDate, this.OnChangeContentFinish, this.OnChangeContentError, this);

//    },


//    OnChangeContentError: function(result, context, methodName) {
//        alert("Error!");
//    },

//    OnChangeContentFinish: function(result, context, methodName) {
//        context.SetCurrentRecord(result[0].format("MM/dd/yyyy HH:mm:ss"));
//        context.controlTextHeadline = result[1];
//        context.controlTextBody = result[2];
//        //context.controlTextBody = result[2] + "<img src='/Resources/Images/chocBar.jpg'/>"

//        if ($get(context.controlNameHeadline) != null) {

//            $get(context.controlNameHeadline).innerHTML = context.controlTextHeadline;
//            $get(context.controlNameBody).innerHTML = context.controlTextBody;
//        } 

//    },
//    SetCurrentRecord: function(variable) {
//        this.currentNewsDate = variable;
//    },

//     WireReferences: function(webReference, headlineControl, bodyControl) {
//    //WireReferences: function(webReference, bodyControl) {
//        this.webServiceReference = webReference;
//        this.controlNameHeadline = headlineControl;
//        this.controlNameBody = bodyControl;
//    }
//}
//ControlLibrary.BodyBuilder.registerClass('ControlLibrary.BodyBuilder');
// End of the new Addition of the Class.
//=======================================================================






ControlLibrary.PageManager = function()
{
    this.pageUri;
    this.subSectionText;
    this.subSectionName;
    this.documentPageText;    
    this.documentPageName;    
    this.webServiceReference;
}

ControlLibrary.PageManager.prototype = {

    LoadPageData : function(uri)
    {
        this.pageUri = uri;
        this.webServiceReference.GetRequestedPage(this.pageUri,this.OnLoadPageFinish,this.OnLoadPageError, this);             
    },
    
    OnLoadPageFinish : function(result, context, methodName)
    {
        context.documentPageText = result[0];
        context.subSectionText = result[1];
        
        if (context != null)
        {
            $get(context.documentPageName).innerHTML = context.documentPageText;
            $get(context.subSectionName).innerHTML = context.subSectionText;
        }
    },
    
    OnLoadPageError : function(result, context, methodName)
    {
        alert("Error");
    },
        
    WireReferences : function(webReference, pageContentPaneName, subSectionPaneName)
    {
        this.documentPageName = pageContentPaneName;
        this.subSectionName = subSectionPaneName;
        this.webServiceReference = webReference;        
    }
            
    
}
ControlLibrary.PageManager.registerClass('ControlLibrary.PageManager');