/**
 * @author Erick
 */

var player = null; 


function playerReady(player) { 

	player = window.document[player.id];
	//alert(player.id+': OK');
	player.sendEvent('PLAY');
}

function deletePlayer(theWrapper, thePlaceholder, thePlayerId) { 
        swfobject.removeSWF(thePlayerId);
        var tmp=document.getElementById(theWrapper);
        if (tmp) { tmp.innerHTML = "<div id=" + thePlaceholder + "></div>"; }
}


function createPlayer(thePlaceholder, thePlayerId, theFile, theWidth, theHeight) {
        var flashvars = {
                myFile:theFile
        }
        var params = {
                allowscriptaccess:"always"
        }
        var attributes = {
                id:thePlayerId,  
                name:thePlayerId,
				quality:"high",
				allowfullscreen:"true"
				
        }
        swfobject.embedSWF("./video/2/FLV_player.swf?myFile="+theFile, thePlaceholder, theWidth, theHeight, "9.0.115", false, flashvars, params, attributes);
}


function initPlayer(theFile) { 
        deletePlayer('flashParentNode', 'flash', 'mainPlayer');
        createPlayer('flash', 'mainPlayer', theFile, 720, 405);
}

// nouvelle fonctions pilotage player JW

function createPlayerJW(thePlaceholder, thePlayerId, theFile, theWidth, theHeight) {
        var flashvars = {
                file:theFile,
				height:405,
				width:720,
				stretching:"exactfit",
				skin:"/videoJW/swift.swf",
				dock:true
        }
        var params = {
                allowscriptaccess:"always"
        }
        var attributes = {
                id:thePlayerId,  
                name:thePlayerId,
				quality:"high",
				allowfullscreen:"true"
				
        }
        swfobject.embedSWF("./videoJW/player.swf?file="+theFile, thePlaceholder, theWidth, theHeight, "9.0.115", false, flashvars, params, attributes);
}

function initPlayerJW(theFile, alt, id_video ) { 
        deletePlayer('flashParentNode', 'flash', 'mainPlayer');
        createPlayerJW('flash', 'mainPlayer', theFile, 720, 405);
		alt = alt.replace(/\\'/g,"&#39;");
		content('videoText', alt);
		setEvent('videoAdminBtn', 'onclick', "edit('videoEdit', " + id_video + ")");
}
function launchMovie(pathFLV){
	debug('--> launchMovie('+pathFLV+')');
	deletePlayer('flashParentNode', 'flash', 'mainPlayer');  
	createPlayerJW('flash', 'mainPlayer', pathFLV, 720, 440); 
}

