﻿/// <reference path="VideoScripts.js" />
function createPlayer(theFile, videoId, theImg, autostart, icons) 
{
    // The videoId parameter is only used to set the id of the
    // currently playing video. For a playlist with a collection of videos
    // this parameter should be zero.
    CURRENT_VIDEO_ID = videoId;
    
    var params = 
    {  
        allowfullscreen: "true", 
        allowscriptaccess: "always", 
        menu: "true" 
    }; 
        
    var flashvars = 
    {
        frontcolor: "0xBE6021", 
        screencolor: "0xeeeeee",
        autostart: autostart,  
        width: "640", 
        height: "500",
        bufferlength: "10",   
        usefullscreen: "true",
        repeat: "list",  
        shuffle: "false",  
        showdownload: "false", 
        file: theFile,
        javascriptid: "videoContent", 
        enablejs: "true",
        showIcons: icons,
        abouttxt:'PrepLogic Media Player',
        aboutlnk:'http://www.preplogic.com', 
        image: theImg 
    };
    var attributes = 
    { 
        id: "videoContent"
    };
    
    // Stop the player if it is already running
    // canHaveHTML is false if videoContent is a <div>, true when it is an object
    var videoContent = $get("videoContent");
    if (!videoContent.canHaveHTML)
    {
        sendEvent("videoContent", "stop");
    }
    
    // recreate the videoContent element
    videoContent = null;
    var videoContentContainer = $get("videoContentContainer");
    videoContentContainer.innerHTML = '<div id="videoContent"><div id="noFlashMessage" style="width: 640; height: 500;"> <h2 style="color: red; font-weight: bold; font-size: 14px">You don&quot;t have the latest version of Macromedia Flash Player</h2><p style="font-weight: normal; font-size: 12px">In order to watch the videos on this site, you need to install the latest version of Flash Player by clicking on the image below:</p><a href="http://www.adobe.com/go/getflashplayer" target="_blank"><img style="border: 0px;" alt="Get Adobe Flash Player" src="images/get_adobe_flash_player.png"/></a></div></div>'
 
    // embed the player    
    swfobject.embedSWF(
        "mediaplayer.swf", "videoContent", 
        "640", "500", "9.0.115","expressInstall.swf", 
        flashvars, params, attributes);
}

var directSend = 0;
function sendEvent(swf,typ,prm) 
{
    if (typ == "playitem")
        directSend = prm; 
        
    try
    {
        var host = document.getElementById(swf);
        if (host != null)
            host.sendEvent(typ, prm);
    }
    catch(e){ }
};

function sendVCplayitem(prm)
{
    var host = document.getElementById("videoContent");
    host.sendEvent('playitem', prm);
}

function getUpdate(typ,pr1,pr2,swf) 
{
    if(typ == "item" && swf == "videoContent") 
    {
        var obj = document.getElementById("playListIndex");
        if (pr1 == directSend)
        {
            directSend = 0;
        }
        else
        {
            obj.value = pr1;
            setTocSelectionIndex(pr1);
        }
    }
    
    if(typ == 'state')
    {
        // drop out of fullscreen
        if(pr1 == 3)
        {
          this.window.focus();
        }
    }
}

function thisMovie(swf) 
{
  if(navigator.appName.indexOf("Microsoft") != -1) 
  {
    return window[swf];
  } 
  else 
  {
    return document[swf];
  }
}
