﻿// Behavior for displaying date in local date/time format
// Associated with control that is rendered as a span
Type.registerNamespace("CustomControls");

CustomControls.DateLabelBehavior = function(element)
{
    CustomControls.DateLabelBehavior.initializeBase(this, [element]);
    this._dateTime = null;
    this._format = null;
}
// Create protytype.
CustomControls.DateLabelBehavior.prototype = 
{
    set_DateTime: function(dateTime)
    {
        this._dateTime = dateTime;
    },

    get_DateTime: function()
    {
        return this._dateTime;
    },

    set_Format: function(format)
    {
        this._format = format;
    },

    get_Format: function()
    {
        return this._format;
    },

    initialize : function()
    { 
        CustomControls.DateLabelBehavior.callBaseMethod(this, 'initialize'); 
        if (this._format != null)
        {
            this.get_element().innerHTML = this._dateTime.format(this._format);            
        }
    }, 

    dispose : function()
    { 
        $clearHandlers(this.get_element()) ; 
        CustomControls.DateLabelBehavior.callBaseMethod(this, 'dispose') ; 
    } 

} // End of prototype definition.

// This is an extension of a control rather than a behavior
CustomControls.DateLabelBehavior.registerClass('CustomControls.DateLabelBehavior', Sys.UI.Control);

