 function renderVideo( videoFile, videoDiv ) {
         var vFile = videoFile;
         var vDiv  = videoDiv;
         // alert("After conversion: File: " + vFile + " Div: " + vDiv);
         // var dummyPlaceHolder = "PlaceHolder";
         var so = new SWFObject("/mediaplayer/player.swf", vDiv, "400", "280", "9", "#ffffff");
         // so.addVariable('plugins', 'captions-1,flow-1');
         // so.addVariable('captions.file', '/USCIS/E-Verify/Videos/everify_employee_cc.xml');

         so.addVariable("file", vFile);
         so.addParam("menu", "true");
         so.addParam("allowFullScreen", "true");
         so.addParam("wmode", "window");
         so.write(vDiv);
 }

// **
// ** method: deletePlayer - this method
// ** removes the flash object by its id
// ** and creates/recreates a place holder for the video

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

// **
// ** method: renderVideo - this method is responsible for instantiating
// ** all the required parameters and config values for the video player
// ** and then rendering the player as well.
 function renderVideo( videoFile, videoDiv, autostart ) {
         var vFile = videoFile;
         var vDiv  = videoDiv;

         var flashvars = {
                showstop: "true",
                showicons: "true",
                showdigits: "true",
                autostart: autostart,
                file: vFile
        }
        var params = {
                menu: "true",
                allowFullScreen: "true",
                wmode: "transparent",
                swliveconnect: "true",
                allowscriptaccess: "always"
        }
        var attributes = {
                id: "embedPlayer",
                name: "embedPlayer"
        }

        // create player in div that is specified
        swfobject.embedSWF("/mediaplayer/player.swf", vDiv, "400", "320", "9.0.115", false, flashvars, params, attributes);
 }

// **
// ** method: initPlayer - this method is essentially the contructor/main for this javascript file
// ** It firsts deletes the area for the video and recreates it with the new video loaded.
function initPlayer( videoFile, videoDiv, autoPlay ) {
        deletePlayer('emVideo', videoDiv, 'embedPlayer');
        renderVideo( videoFile, videoDiv, autoPlay );
}

