﻿Type.registerNamespace('CorvusCMS.UI');

CorvusCMS.UI.GalleryItem = function(element) {

    CorvusCMS.UI.GalleryItem.initializeBase(this, [element]);

    this._item = null;
    this._itemType = null;
    this._width = 327;
    this._height = 224;


}

CorvusCMS.UI.GalleryItem.prototype = {

    initialize: function() {
        CorvusCMS.UI.GalleryItem.callBaseMethod(this, 'initialize');

        if (!this.get_item())
            throw new Error("Item not set.");

        this._itemType = this.get_item().ItemType;

    },

    dispose: function() {

        CorvusCMS.UI.GalleryItem.callBaseMethod(this, 'dispose');


    },

    get_item: function() {
        return this._item;
    },

    set_item: function(value) {
        if (this._item !== value) {
            this._item = value;
        }
    },

    get_itemType: function() {
        return this._itemType;
    },

    get_width: function() {
        return this._width;
    },

    set_width: function(value) {
        if (this._width !== value) {
            this._width = value;
        }
    },

    get_height: function() {
        return this._height;
    },

    set_height: function(value) {
        if (this._height !== value) {
            this._height = value;
        }
    },

    render: function() {
        throw new Error("Not implemented.");
    }


}

CorvusCMS.UI.GalleryItem.renderControl = function(item, element, width, height) {

    var ctrl = null;

    if (item.ItemType == "Video") {
        ctrl = $create(CorvusCMS.UI.Video,
                    { "item": item,
                        "width": width,
                        "height": height
                    }, null, null, element);
       element.style.width = width + "px";
       element.style.height = height + "px";
    }
    if (item.ItemType == "Image") {
        ctrl = $create(CorvusCMS.UI.Image,
                    { "item": item
                    }, null, null, element);
       element.style.width =item.Width + "px";
       element.style.height = item.Height + "px";
    }

    ctrl.render();
    
    return ctrl;
}

CorvusCMS.UI.GalleryItem.registerClass("CorvusCMS.UI.GalleryItem", Sys.UI.Control, Sys.IDisposable);



if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();