﻿/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace("MXA.Website.Kaldenbroeck");

MXA.Website.Kaldenbroeck.Template = function (element) {

    MXA.Website.Kaldenbroeck.Template.initializeBase(this, [element]);
    this._datasource = null;
    this.addCssClass('Template');
    this._title = null;
    this._slogan = null;

    this._contentContainer = document.createElement('div');
    this._contentContainer.className = 'tarContent';
    element.appendChild(this._contentContainer);
}

MXA.Website.Kaldenbroeck.Template.prototype =
{

    initialize: function () {
        MXA.Website.Kaldenbroeck.Template.callBaseMethod(this, 'initialize');
    },

    setSize: function () {

    },

    get_title: function () {
        return this._title;
    },

    set_title: function (value) {
        this._title = value;
    },

    get_slogan: function () {
        return this._slogan;
    },

    set_slogan: function (value) {
        this._slogan = value;
    },

    dispose: function () {
        MXA.Website.Kaldenbroeck.Template.callBaseMethod(this, 'dispose');
    },

    set_datasource: function (value) {
        this._datasource = value;
    },

    databind: function () {
        if (this._datasource.title != null) {
            this._title.innerHTML = this._datasource.title;
        }
        else {
            this._title.innerHTML = '';
        }
        if (this._datasource.slogan != null) {
            this._slogan.innerHTML = this._datasource.slogan;
        }
        else {
            this._slogan.innerHTML = '';
        }
        Cufon.replace([this._title, this._slogan]);

    },

    getMaxWidth: function () {
        return 0;

    },

    hide: function () {
        $(this._element).removeClass('active');
    },

    show: function () {
        if ($(this._element).hasClass('active') == false) {
            $(this._element).addClass('active');
        }
    },

    clear: function () {

    },

    raiseEvent: function (eventName, eventArgs) {

        var handler = this.get_events().getHandler(eventName);
        if (handler) {
            handler(this, eventArgs);
        }

    },

    deactivate: function (callback) {
        $(this._element).stop(true).animate({ opacity: 0 }, 100, callback);
    },

    activate: function (callback) {
        $(this._element).stop(true).css({ opacity: 0 }).animate({ opacity: 1 }, 600, callback);
    },

    getHeight: function () {
        return this._element.scrollHeight;
    }
}



MXA.Website.Kaldenbroeck.Template.registerClass('MXA.Website.Kaldenbroeck.Template', Sys.UI.Control);
