jQuery(document).ready(function() {
    
});

/* HTML5 Video Player*/
var videoWidth;
var videoHeight;
var videoHolder;
var videoSrc1;
var videoSrc2;
var srcfallback;

function addVideo(myId, videoPath1, videoPath2, videoPath3, myPoster){
    $('#'+myId+' video' ).remove().parent().css('display','none');
    
    videoWidth = jQuery('#' + myId).width();
    videoHeight = jQuery('#' + myId).height();
    
    videoHolder = document.createElement('video');
    document.getElementById( myId ).appendChild(videoHolder);
    
    if( myPoster ){
        videoHolder.setAttribute('poster', myPoster);
    }
    videoHolder.setAttribute('width', videoWidth);
    videoHolder.setAttribute('height', videoHeight);
    //videoHolder.setAttribute('autoplay', 'true');
    videoHolder.setAttribute('controls', 'true');
    
    videoSrc1 =  document.createElement('source');
    videoSrc2 =  document.createElement('source');
    srcfallback =  document.createElement('div');
    
    videoSrc1.setAttribute('src', videoPath1);
    videoSrc1.setAttribute('type', 'video/mp4');
    videoSrc2.setAttribute('src', videoPath2);
    videoSrc2.setAttribute('type', 'video/ogg');
    srcfallback.setAttribute('id', 'swfFallback_'+myId );
    
    videoHolder.appendChild(videoSrc1);
    videoHolder.appendChild(videoSrc2);
    videoHolder.appendChild(srcfallback);
    
    flashvars = { flvSrc:'/cms/'+videoPath3, controls:'true', videoWidth:videoWidth, videoHeight:videoHeight, poster:myPoster};
    params = {wmode: "transparent"};                
    attributes = {};
    swfobject.embedSWF("upload/video/player.swf", 'swfFallback_'+myId, videoWidth, videoHeight, "9.0.0", "js/expressInstall.swf", flashvars, params, attributes);
}
