
(function(){

    // shorthand
    var SB = Shadowbox;
    var SL = SB.lib;

    /**
     * Constructor. This class is used to display SWF movies.
     *
     * @param   {String}    id      The id to use for this content
     * @param   {Object}    obj     The content object
     * @public
     */
    Shadowbox.swf = function(id, obj){
        this.id = id;
        this.obj = obj;

        // SWF's are resizable
        this.resizable = true;

        // height defaults to 300 pixels
        this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;

        // width defaults to 300 pixels
        this.width = this.obj.width ? parseInt(this.obj.width, 10) : 300;
    };

    Shadowbox.swf.prototype = {

        /**
         * Returns an object containing the markup for this content, suitable
         * to pass to Shadowbox.lib.createHTML().
         *
         * @param   {Object}    dims    The current Shadowbox dimensions
         * @return  {Object}            The markup for this content item
         * @public
         */
        markup: function(dims){
            var bgcolor = SB.getOptions().flashBgColor;
            return {
                tag:        'object',
                id:         this.id,
                name:       this.id,
                type:       'application/x-shockwave-flash',
                data:       this.obj.content,
                children:   [
                    { tag: 'param', name: 'movie', value: this.obj.content },
                    { tag: 'param', name: 'bgcolor', value: bgcolor }
                ],
                height:     dims.resize_h, // use resized dimensions
                width:      dims.resize_w
            };
        },

        /**
         * Removes this SWF from the document.
         *
         * @return  void
         * @public
         */
        remove: function(){
            var el = SL.get(this.id);
            if(el) SL.remove(el);
        }

    };

})();
