﻿var texteReplay;	
var idVideo;
var titreVideo;

function getFlowPlayer(urlVideo, urlImage, id, titre) {


     //Variables qui pourront être utilisées par d'autres fonctions
	    idVideo = id;
		titreVideo = titre;
	 //Traitement nécessaire des & et ' pour affichage adéquat avec le plugin content
		titreEmbed = titre.replace(/&/g, "%26#39;");
		titreEmbed = titreEmbed.replace(/\'/g, "%26#39;");
		
		
	    if(langue == "fr")
		{
		   texteReplay = "Revoir";
		   lienVideoUnique = "http://www.montrealjazzfest.com/multimedia-fr/video.aspx?id=";
		}
		else 
		{
		    texteReplay = "Play again";
		    lienVideoUnique = "http://www.montrealjazzfest.com/multimedia-en/video.aspx?id=";
		}	

        var keys = {           
            'montrealjazzfest.com' : '#@c7164e915005f588587',           
            'montrealjazzfest.ca' : '#@59514508af77159145c'
        };
		
		var leDomain = (location.host).replace("www.","");
		  				
		flowplayer("player", {src: '/js/flowplayer/flowplayer.commercial-3.1.5.swf', wmode: 'transparent'}, { 
		
        key: keys[leDomain] || '',	  
       

        play: {

            // label text; by default there is no text 
            label: null,

            // label text at end of video clip 
            replayLabel: texteReplay
        },


        //Ce qui est commun à tous les clips           
        clip: {
            autoPlay: true,
            url: urlVideo
        },


        //Liste des clips, on peut overwriter les propriétés décrites dans clip
        playlist: [
        //Le premier clip est l'image du vidéo 
                       {url: urlImage, scaling: 'fit' },
        //Le deuxième clip est le vidéo lui-même
                       {url: urlVideo,
                       autoPlay: false,
                       onStart: function() {
                           //alert("on compte click "+ idVideo);      
                           compteurVideo.clickVideo(idVideo);
                       }
                   }

            ],

        canvas: {
            // configure background properties 
            background: '#000000',

            // remove default canvas gradient 
            backgroundGradient: 'none'

        },
        
         /*
            relative path to the logo. this can a JPG, PNG or SWF file.
            NOTE: the logo can only be changed in commercial versions
        */
//       logo: {

//            // default logo and its position
//            url: 'logo_bell.swf',
//            top: 15,
//            right: 25,
//            opacity: 0.3,

//            // for SWF-based logos you can supply a relative size (to make the logo larger in fullscreen)
//            width: '25%',
//            height: '25%',

//            // if set to false, then the logo is also shown in non-fullscreen mode
//            fullscreenOnly: false,

//            // time to display logo (in seconds). 0 = show forever
//            displayTime: 20,

//            /*
//	            if displayTime > 0 then this specifies the time it will take for
//	            the logo to fade out. this happens internally by changing the opacity
//	            property from its initial value to full transparency.
//	            value is given in milliseconds.
//            */
//            fadeSpeed: 0

//            // for commercial versions you can specify where the user is redirected when the logo is clicked
//            //linkUrl: 'http://flowplayer.org'
//        },


        plugins: {
            controls: {
                backgroundGradient: [0.6, 0.3, 0, 0, 0],
                tooltipColor: '#5F747C',
                sliderColor: '#000000',
                volumeSliderColor: '#000000',
                tooltipTextColor: '#ffffff',
                backgroundColor: '#575757',
                borderRadius: '0px',
                bufferColor:'#232323',
                bufferGradient: 'low',
                timeColor: '#ffffff',
                timeBgColor: '#555555',
                progressColor: '#6a7275',
                buttonOverColor: '#728B94',
                buttonColor: '#6a7275',
                volumeSliderGradient: 'none',
                progressGradient: 'low',                
                durationColor: '#ffffff',
                sliderGradient: 'none',
                height: 24,
                opacity: 1.0,
                playlist: false
            }, 
            
			content: {

                // location of the plugin
                url: 'flowplayer.content-3.2.0.swf',

                // display properties
                top: 5,		            

                // styling properties
                border: "2px solid #ffffff",
                borderRadius: 5,		            
                display:"block",
                backgroundGradient: [0.1, 0.2, 0.5],
	            
                // "inline" styling 
                style: {
                    '.titre' : {
                        fontSize: 12,
                        fontFamily: 'Arial,verdana,helvetica',
                        color:'#ffffff',
                        fontWeight:'bold'                        
                    }
                    
                },

               closeButton: true,
	          		           
              html: '<p class="titre"><a href="'+lienVideoUnique+idVideo+'" target="_blank" ><img src="http://www.montrealjazzfest.com/images/multimedia/mtlJazzTv_petit_2.png" align="left" vspace="0" hspace="0"/>' + titreEmbed + '</a></p>'
                
                
       		            
            }//fin de content
       },//fin plugins
       
       //Pour éviter que le texte du content s'affiche dans le player de notre site. Il n'affichera que pour l'embed.
      onLoad: function() {
		   this.getPlugin('content').hide(); 
	   }


    }); //fin de flowplayer 	


} //fin getFlowPlayer()		
		
		

