
var myListener = new Object();
/**
 * Initialisation
 */
myListener.onInit = function() {
};
/**
 * onClick event on the video
 */
myListener.onClick = function() {
    var total = document.getElementById("info_click").innerHTML;
    document.getElementById("info_click").innerHTML = Number(total)+1;
};
/**
 * onKeyUp event on the video
 */
myListener.onKeyUp = function(pKey) {
    document.getElementById("info_key").innerHTML = pKey;
};
/**
 * onComplete event
 */
myListener.onFinished = function() {
    stop(); 
    // play(); // boucle loop
};
/**
 * Update
 */
myListener.onUpdate = function() {
    document.getElementById("info_playing").innerHTML = this.isPlaying;
    document.getElementById("info_url").innerHTML = this.url;
    document.getElementById("info_volume").innerHTML = this.volume;
    document.getElementById("info_position").innerHTML = this.position;
    document.getElementById("info_duration").innerHTML = this.duration;
    document.getElementById("info_buffer").innerHTML = this.bufferLength + "/" + this.bufferTime;
    document.getElementById("info_bytes").innerHTML = this.bytesLoaded + "/" + this.bytesTotal + " (" + this.bytesPercent + "%)";
    var isPlaying = (this.isPlaying == "true");
    document.getElementById("playerplay").style.display = (isPlaying)?"none":"block";
    document.getElementById("playerpause").style.display = (isPlaying)?"block":"none";
    var timelineWidth = 160;
    var sliderWidth = 40;
    var sliderPositionMin = 40;
    var sliderPositionMax = sliderPositionMin + timelineWidth - sliderWidth;
    var sliderPosition = sliderPositionMin + Math.round((timelineWidth - sliderWidth) * this.position / this.duration);
    if (sliderPosition < sliderPositionMin) {
        sliderPosition = sliderPositionMin;
    }
    if (sliderPosition > sliderPositionMax) {
        sliderPosition = sliderPositionMax;
    }
    document.getElementById("playerslider").style.left = sliderPosition+"px";
};
function getFlashObject() {
    return document.getElementById("myFlash");
}
function play() {
    if (myListener.position == 0) {
        getFlashObject().SetVariable("method:setUrl", "http://pa.quai13.com/jeveuxvoir/img/upload/php7mHXLi.flv");
    }
    getFlashObject().SetVariable("method:play", "");
}
function pause() {
    getFlashObject().SetVariable("method:pause", "");
}
function stop() {
    getFlashObject().SetVariable("method:stop", "");
}
function setWidth() {
    var width = document.getElementById("inputWidth").value;
    getFlashObject().width = width+"px";
}
function setHeight() {
    var height = document.getElementById("inputHeight").value;
    getFlashObject().height = height+"px";
}
function setPosition() {
    var position = document.getElementById("inputPosition").value;
    getFlashObject().SetVariable("method:setPosition", position);
}
function setVolume() {
    var volume = document.getElementById("inputVolume").value;
    getFlashObject().SetVariable("method:setVolume", volume);
}
function loadImage() {
    var url = document.getElementById("inputImage").value;
    var depth = document.getElementById("inputImageDepth").value;
    var verticalAlign = document.getElementById("inputImageVertical").value;
    var horizontalAlign = document.getElementById("inputImageHorizontal").value;
    getFlashObject().SetVariable("method:loadMovieOnTop", url+"|"+depth+"|"+verticalAlign+"|"+horizontalAlign);
}
function unloadImage() {
    var depth = document.getElementById("inputUnloadDepth").value;
    getFlashObject().SetVariable("method:unloadMovieOnTop", depth);
}

