/**
 * The Shadowbox Flash video player class.
 *
 * This file is part of Shadowbox.
 *
 * Shadowbox is an online media viewer application that supports all of the
 * web's most popular media publishing formats. Shadowbox is written entirely
 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website
 * authors can showcase a wide assortment of media in all major browsers without
 * navigating users away from the linking page.
 *
 * You should have received a license with this distribution explaining the terms
 * under which Shadowbox may be used. If you did not, you may obtain a copy of the
 * license at http://shadowbox-js.com/LICENSE
 *
 * @author      Michael J. I. Jackson <michael@mjijackson.com>
 * @copyright   2007-2009 Michael J. I. Jackson
 * @version     SVN: $Id: shadowbox-flv.js 26 2009-04-29 05:17:01Z mjijackson.com $
 *
 *
 * Added flowplayer support by Codesign Oy, Marko Niskanen
 * 
 */

(function(S){

    var U = S.util,
        controller_height = 20; // height of JW FLV player controller

    /**
     * Constructor. This class is used to display Flash videos with the JW
     * FLV player.
     *
     * @param   Object      obj     The content object
     * @public
     */
    S.flv = function(obj){
        this.obj = obj;

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

        // height/width default to 300 pixels
        this.height = obj.height ? parseInt(obj.height, 10) : 300;
        if(S.options.showMovieControls == true)
            this.height += controller_height;
        this.width = obj.width ? parseInt(obj.width, 10) : 300;
    }

    S.flv.prototype = {

        /**
         * Appends this movie to the document.
         *
         * @param   HTMLElement     body    The body element
         * @param   String          id      The content id
         * @param   Object          dims    The current Shadowbox dimensions
         * @return  void
         * @public
         */
        append: function(body, id, dims){
            this.id = id;

            // append temporary content element to replace
            var tmp = document.createElement('div');
            tmp.id = id;
            body.appendChild(tmp);


            var h = dims.resize_h, // use resized dimensions
                w = dims.resize_w;
            tmp.innerHTML = '<a  href="" style="outline:none; display:block;width:'+w+'px;height:'+h+'px" id="flowplayercontainer"> </a>';


            var giaplayer = {
                    canvas: { 
                        // customize player background, i.e. the canvas 
                        backgroundColor: "#ffffff" 
                      }, 
                    clip: { 
/*                        url: this.obj.content,*/
                        autoPlay: true/* ,
                        scaling: "fit" */
                    }, 

                    // our playlist 
                    playlist: [ 
                        { 
                            url: '/css/webinars/intro.flv', 
                            title: 'Welcome', 
                            scaling: "fit",
                            captionUrl: '/css/webinars/introtext.xml',
                            showCaptions: true
                        },     
                        { 
                            url: this.obj.content,
                            title: 'Webinar video' 
                        } 
                    ], 
                    plugins: {
                        controls: {
                            url: '/swf/flowplayer.controls-3.1.3.swf', 
                            left: 0, 
                            bottom: 0, 
                            opacity: 1.00,
                            background: '#FFFFFF',
                            backgroundGradient: 'none', 
                            timeColor: '#ffffff', 
                            all: false,
                            play: true, 
                            time: true, 
                            scrubber: true,
                            mute: true,
                            volume: true,
                            fullscreen: true,
                            scrubberHeightRatio: 0.4,
                            volumeSliderGradient: 'medium',
                            sliderGradient: 'medium',
                            backgroundColor: '#666666', 
                            bufferColor: '#444444', 
                            progressColor: '#999999',             
                            buttonColor: '#888888', 
                            buttonOverColor: '#ff0000', 
                            tooltipColor: '#cc0000', 
                            height: 30, 
                            tooltips:  { 
                                buttons: true, 
                                pause: 'Pause playing', 
                                fullscreen: 'Enter fullscreen mode', 
                                volume: '% - Volume' 
                            } 
                        },
                        
                        captions: { 
                            url: '/swf/flowplayer.captions-3.1.4.swf', 
                            
                            // pointer to a content plugin (see below) 
                            captionTarget: 'content',
                            button: null

                        }, 
                        
                        // configure a content plugin to look good for our purpose 
                        content: { 
                            url:'/swf/flowplayer.content-3.1.0.swf', 
                            top: 10, 
                            width: '80%', 
                            height: 50, 
                            backgroundColor: 'transparent', 
                            backgroundGradient: 'none', 
                            borderRadius: 0, 
                            border: 0, 
                            
                            style: { 
                                'body': { 
                                fontSize: '15', 
                                fontStyle: 'Bold', 
                                fontFamily: 'Arial Black', 
                                textAlign: 'center', 
                                color: '#555555' 
                                } 
                            } 
                        }
                        
                    }
                };
                
                flowplayer("flowplayercontainer", "/swf/flowplayer-3.1.3.swf", giaplayer);
                var obj = document.getElementById("flowplayercontainer_api");
                if (obj) obj.style.outline='none';



        },

        /**
         * Removes this movie from the document.
         *
         * @return  void
         * @public
         */
        remove: function(){
            var el = document.getElementById(this.id);
            if(el){
                S.lib.remove(el);
            }
        }

    };

})(Shadowbox);

