﻿/*	copyright www.laRouteDuNet.fr 2008

    automate d'initialisation des flowplayers

	ATTENTION:  nécessite prototype.js, prototypeplus.js flashembed.min.js
*/
if(typeof Prototype == 'undefined')
  throw("controlflowplayer.js requires prototype.js library");

if(!Control) var Control = {};

Control.AutoFlowPlayer = Class.create();
//lecteur FlowPlayer
Control.AutoFlowPlayer.prototype = {
    initialize: function() {
        Event.observe(window, 'load', this.load.bind(this), false);
    },
    load: function() {
        //la page est chargée
        var elms=document.getElementsByTagAndClassName('A','flowplayer');
        for (var x=0,length=elms.length;x<length;x++) {
            var imgSrc=null;
            try {
                var img=elms[x].childNodes[0];
                if (img.nodeName=='IMG')
                    imgSrc=img.src;
            } catch (e) {}
            flashembed(elms[x],
		        /* 
			        first argument supplies standard Flash parameters. See full list:
			        http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701
		        */
		        {
		            debug:false,
			        src:'FlowPlayerDark.swf',
			        width: 400, 
			        height: (400*9/16)+50
		        },
        		
		        /*
			        second argument is Flowplayer specific configuration. See full list:
			        http://flowplayer.org/player/configuration.html
		        */
		        {config: {   
			        autoPlay: false,
			        autoBuffering: true,
			        controlBarBackgroundColor:'0x2e8860',
			        initialScale: 'noscale',
			        videoFile: elms[x].href,
			        splashImageFile: imgSrc
		        }} 
            );
        }
    }
}
var AutoFlowPlayer=new Control.AutoFlowPlayer();