/* Class for video */
var media_video = $.inherit(Module, {
    __constructor: function(elem) {
        this.__base(elem);
        this.comptype = "media.video";
        this.fromTab = 'Media';
        this.isResizing = true;
        this.keepAspectRatio = false;
        this.file = '';
    },

    initialize: function() {
        this.file = $('div', this.container).html();
        this.loadMovie();
    },

    loadModuleCallback: function(data) {
        var _this = this;
        var _data = data;

        // Add a loading message
        this.container.html("Loading...");

        // Add a draghandle
        this.addDragHandle(data);

        this.container.html(data.html);

        this.file = $('div', this.container).html();

        // Load the movie using the url from the module div
        this.loadMovie();
    },

    loadMovie: function() {
        // Insert the object and embed tags required to show the video
        var fullSwfPath = '/adm/mediamanager/videoplayer/video.swf?videoUrl=' + this.file;
        fullSwfPath = fullSwfPath.replace(' ', '%20');

        var html = '<object id="video' + this.id + '" width="100%" height="100%"><param name="movie" value="' + fullSwfPath + '"></param><param name="quality" value="high"></param><embed class="media.video" type="application/x-shockwave-flash" src="' + fullSwfPath + '" width="100%" height="100%"></embed></object>';

        $('div', this.container).html(html);
    },

    saveModule: function() {
        return '<div>' + this.file + '</div>';
    } 
});

