﻿
function EmbedPlayer(Divid, Vidid, width, height) {
    var playerType = "Flash";
    var playerSpeed = "HD";
    var Apple = {};
    Apple.UA = navigator.userAgent;
    Apple.Device = false;
    Apple.Types = ["iPhone", "iPod", "iPad"];
    for (var d = 0; d < Apple.Types.length; d++) {
        var atype = Apple.Types[d];
        Apple[atype] = !!Apple.UA.match(new RegExp(atype, "i"));
        Apple.Device = Apple.Device || Apple[atype];
    }
    if (Apple.Device) {
        playerType = "Quicktime";
        if (Apple.iPhone) {
            playerSpeed = "Low";
        }
        if (Apple.iPad) {
            playerSpeed = "High";
        }
    }
    Vio.Media.LoadP(Vidid, function () {
        Vio.OnReady(function () {
            target = new Vio.Player.NewTarget(document.getElementById(Divid));
            // Step 4: Set the options for the target
            target.Options.player = { fullscreen_enabled: true };
            target.Options.embedPlayer.mediaId = Vidid;
            target.Options.embedPlayer.playerId = '18a30c2b-9c88-41dc-9e4e-9e491a1c25e3';
            target.Options.embedPlayer.playerFormat = playerType;
            target.Options.embedPlayer.playerQuality = playerSpeed;
            target.Options.embedPlayer.playerWidth = width;
            target.Options.embedPlayer.playerHeight = height;

            // Step 5: Set the location of each element we're using
            target.PlayerElement = document.getElementById(Divid);

            // Step 6: Fire the events that render the pieces
            Vio.Event.Trigger("RenderPlayer", target);
        });
    });
}
