﻿/* Version Update: 5 August 2009 */
var octoImageUrl = "http://localhost:2010/App_Themes/Default/images/octoshape.png";
var octoPluginUrl = "http://www.octoshape.com/plugin/get.asp?variant=mediacorp";

var silverlightImageUrl = "http://localhost:2010/App_Themes/Default/images/silverlight.png";
var silverlightPluginUrl = "http://www.microsoft.com/silverlight/get-started/install/default.aspx";

window.addEvent("resize", function() {
    if ($defined(mc)) {
        mc.resize();
    }
});

var domIsReady = false;
window.addEvent("domready", function() {
    domIsReady = true;
});

function GetAddressInfo() {
    var hostname = "";
    var address = "";

    try {
        var sock = new java.net.Socket();
        sock.bind(new java.net.InetSocketAddress("0.0.0.0", 0));
        sock.connect(new java.net.InetSocketAddress(document.domain, (!document.location.port) ? 80 : document.location.port));
        hostname = sock.getLocalAddress().getHostName();
        address = sock.getLocalAddress().getHostAddress();
    }
    catch (e) {
    }

    return { hostname: hostname, address: address };
}

function GetVariable(name) {
    return window[name];
}

function GetWindowHeight() {
    return window.getSize().y;
}

function GetWindowWidth() {
    return window.getSize().x;
}

function HideObjects(id) {
    $$("embed").each(function(item, index) {
        if (item.id != id) {
            item.style.visibility = "hidden";
        }
    });

    $$("object").each(function(item, index) {
        if (item.id != id) {
            item.style.visibility = "hidden";
        }
    });
}

function ShowObjects(id) {
    $$("embed").each(function(item, index) {
        if (item.id != id) {
            item.style.visibility = "visible";
        }
    });

    $$("object").each(function(item, index) {
        if (item.id != id) {
            item.style.visibility = "visible";
        }
    });
}

var MediaCorp = new Class({
    Implements: [Options, Log],
    options: {
        installPrompt: false,
        octoRequired: false
    },
    initialize: function(options) {
        this.setOptions(options);

        this.name = "silverlight_player_mediacorp";
        this.frame = null;
        this.octo = new Octoshape();
        this.players = new Object();
        this.frameCenterPos = null;

        this.players.add = function(player, name, opt) {
            if ($type(player) == "string") {
                mc.players[player] = new WebPlayer(player, name, opt);
            }
            else {
                mc.players[player.id] = new WebPlayer(player, name, opt);
            }
        };

        this.players.remove = function(id) {
            delete mc.players[id];
        };

        window.addEvent("domready", function() {
            var MCFrame = new Element("div", {
                "id": "MCFrame",
                "class": "MCOpacFrame",
                "styles": {
                    "height": "0px",
                    "overflow": "hidden",
                    "position": "absolute",
                    "visibility": "hidden",
                    "width": "0px",
                    "z-index": "100"
                }
            });

            document.body.appendChild(MCFrame);

            MCFrame.position({
                relativeTo: document.body,
                position: "center",
                edge: "center"
            });

            mc.frameCenterPos = MCFrame.position({
                relativeTo: document.body,
                position: "center",
                edge: "center",
                returnPos: true
            });

            mc.frame = MCFrame;

            if (mc.options.installPrompt) {
                InstallationPrompt();
            }
        });

        window.addEvent("beforeunload", function() {
            if ($defined(mc)) {
                mc.stop();
            }
        });
    },
    debug: function(info) {
        this.log(info);
    },
    message: function(lang, id) {
        return MCSystemMessage(lang, id);
    },
    resize: function() {
        var i;

        for (i in this.players) {
            if ($type(this.players[i]) != "function") {
                if (this.players[i].resizeId) {
                    clearTimeout(this.players[i].resizeId);
                }

                this.players[i].resizeId = setTimeout("mc.players['" + i + "'].resize();", 10);
            }
        }
    },
    stop: function() {
        var i;

        try {
            for (i in this.players) {
                if ($type(this.players[i]) != "function") {
                    this.players[i].player.Content.Player.Stop();
                }
            }
        }
        catch (e) {
            alert(e);
        }

    }
});

var ScreenLink = new Class({
    initialize: function(playerId, screenName, link) {
        this.playerId = playerId;
        this.screenName = screenName;
        this.link = link;
    }
});

var Octoshape = new Class({
    initialize: function() {
        this.links = new Array();
        this.plugin = octoLowLevelGet();
    },
    clearLink: function(playerId, screenName) {
        this.links.each(function(item, index) {
            if (item.playerId == playerId && item.screenName == screenName) {
                item.link = "";
            }
        });
    },
    getLink: function(playerId, screenName) {
        var link = "";

        this.links.each(function(item, index) {
            if (item.playerId == playerId && item.screenName == screenName) {
                link = item.link;
            }
        });

        return link;
    },
    getPlugin: function(playerId) {
        mc.players[playerId].player.Content.Player.ShowGetOctoshapePluginImage();
    },
    manageLink: function(playerId, screenName, link) {
        var found = false;

        this.links.filter(function(item, index) {
            if (item.playerId == playerId && item.screenName == screenName) {
                found = true;
                item.link = link;
            }
        });

        if (!found) {
            this.links[this.links.length] = new ScreenLink(playerId, screenName, link);
        }
    },
    ok: function() {
        return octoLowLevelCheck(this.plugin);
    },
    play: function(octolink, playerId, screenName) {
        if (octoLowLevelCheck(this.plugin)) {
            octoLowLevelReady(this.plugin,
			    function() { mc.octo.stream(octolink, playerId, screenName); },
			    function() { mc.octo.start(playerId); });
        }
        else {
            this.getPlugin(playerId);
        }
    },
    start: function(playerId) {
        if (!mc.players[playerId].octoStartup) {
            mc.players[playerId].octoStartup = true;
            mc.players[playerId].player.Content.Player.ShowMessage(mc.message(mc.players[playerId].player.Content.Player.LanguageCode, "OctoStartup"));
        }
        else {
            this.start(playerId).delay(1500);
        }
    },
    stream: function(octolink, playerId, screenName) {
        var link = "";

        if (this.ok()) {
            link = this.plugin.getLink(octolink, false);

            this.manageLink(playerId, screenName, link);
            mc.players[playerId].player.Content.Player.SetMediaLiveSource(link, screenName);
        }
    }
});

var Omniture = new Class({
    initialize: function(p) {
        this.player = p;
        this.videoStart = true;
    },
    close: function(title, itemId, position) {
        try {
            if (s && title.trim() != "" && itemId.trim() != "" && this.videoStart == true) {
                this.videoStart = false;

                var l_prop6 = s.prop6;
                var l_prop7 = s.prop7;
                var l_prop8 = s.prop8;
                var l_prop10 = s.prop10;
                var l_eVar10 = s.eVar10;
                var l_events = s.events;
                var l_hier1 = s.hier1;
                var l_pageName = s.pageName;

                s.prop6 = title;
                s.prop7 = itemId;
                s.prop8 = "";
                s.prop10 = title;
                s.eVar10 = title;
                s.events = "event8";
                s.hier1 = "";
                s.pageName = "";

                if (s.Media) {
                    s.Media.trackVars = "prop1,prop2,prop3,prop4,prop5,prop6,prop7,prop10,eVar10,events";
                    s.Media.trackEvents = "event8";
                    s.Media.stop(title, position);
                    s.Media.close(title);
                }

                s.prop6 = l_prop6;
                s.prop7 = l_prop7;
                s.prop8 = l_prop8;
                s.prop10 = l_prop10;
                s.eVar10 = l_eVar10;
                s.events = l_events;
                s.hier1 = l_hier1;
                s.pageName = l_pageName;
            }
        }
        catch (e) {
        }
    },
    open: function(title, itemId, duration) {
        this.videoStart = false;
    },
    play: function(title, itemId, duration, position) {
        try {
            if (s && title.trim() != "" && itemId.trim() != "") {
                var l_prop6 = s.prop6;
                var l_prop7 = s.prop7;
                var l_prop8 = s.prop8;
                var l_prop10 = s.prop10;
                var l_eVar10 = s.eVar10;
                var l_events = s.events;
                var l_hier1 = s.hier1;
                var l_pageName = s.pageName;

                if (this.videoStart == false) {
                    this.videoStart = true;

                    s.prop6 = title;
                    s.prop7 = itemId;
                    s.prop8 = "";
                    s.prop10 = title;
                    s.eVar10 = title;
                    s.events = "event7";
                    s.hier1 = "";
                    s.pageName = "";

                    if (s.Media) {
                        s.Media.trackVars = "prop1,prop2,prop3,prop4,prop5,prop6,prop7,prop10,eVar10,events";
                        s.Media.trackEvents = "event7";
                        s.Media.open(title, duration, this.player.name);
                        s.Media.play(title, position);
                    }
                }
                else {
                    s.prop6 = title;
                    s.prop7 = itemId;
                    s.prop8 = "";
                    s.prop10 = title;
                    s.eVar10 = title;
                    s.events = "";
                    s.hier1 = "";
                    s.pageName = "";

                    if (s.Media) {
                        s.Media.trackVars = "prop1,prop2,prop3,prop4,prop5,prop6,prop7,prop10,eVar10,events";
                        s.Media.trackEvents = "";
                        s.Media.play(title, position);
                    }
                }

                s.prop6 = l_prop6;
                s.prop7 = l_prop7;
                s.prop8 = l_prop8;
                s.prop10 = l_prop10;
                s.eVar10 = l_eVar10;
                s.events = l_events;
                s.hier1 = l_hier1;
                s.pageName = l_pageName;
            }
        }
        catch (e) {
        }
    },
    stop: function(title, itemId, position) {
        try {
            if (s && title.trim() != "" && itemId.trim() != "" && this.videoStart == true) {
                var l_prop6 = s.prop6;
                var l_prop7 = s.prop7;
                var l_prop8 = s.prop8;
                var l_prop10 = s.prop10;
                var l_eVar10 = s.eVar10;
                var l_events = s.events;
                var l_hier1 = s.hier1;
                var l_pageName = s.pageName;

                s.prop6 = title;
                s.prop7 = itemId;
                s.prop8 = "";
                s.prop10 = title;
                s.eVar10 = title;
                s.events = "";
                s.hier1 = "";
                s.pageName = "";

                if (s.Media) {
                    s.Media.trackVars = "prop1,prop2,prop3,prop4,prop5,prop6,prop7,prop10,eVar10,events";
                    s.Media.trackEvents = "";
                    s.Media.stop(title, position);
                }

                s.prop6 = l_prop6;
                s.prop7 = l_prop7;
                s.prop8 = l_prop8;
                s.prop10 = l_prop10;
                s.eVar10 = l_eVar10;
                s.events = l_events;
                s.hier1 = l_hier1;
                s.pageName = l_pageName;
            }
        }
        catch (e) {
        }
    }
});

var WebPlayer = new Class({
    Implements: Options,
    options: {
        alertError: false
    },
    initialize: function(p, n, options) {
        this.setOptions(options);

        if (n) {
            if (n.trim() == "") {
                n = mc.name;
            }
        }
        else {
            n = mc.name;
        }

        this.name = n;

        if ($type(p) == "string") {
            p = $(p);
        }

        this.player = p;
        this.octoStartup = false;
        this.omni = new Omniture(this);
        this.resizeId = null;

        try {
            if (this.player && this.player.parentNode) {
                this.parent = $(this.player.parentNode.id);

                if (this.parent && this.parent.parentNode) {
                    this.ancestor = $(this.parent.parentNode.id);

                    if (this.ancestor) {
                        this.ancestor.setStyles({
                            height: this.player.Content.Player.ScreenHeight,
                            width: this.player.Content.Player.ScreenWidth
                        });
                    }

                    this.parent.setStyles({
                        position: "absolute",
                        height: this.player.Content.Player.ScreenHeight,
                        width: this.player.Content.Player.ScreenWidth
                    });

                    this.parent.setProperties({
                        height: this.player.Content.Player.ScreenHeight,
                        width: this.player.Content.Player.ScreenWidth
                    });
                }

                this.resize();

                if (!this.player.Content.Player.EnableFullScreen && this.player.Content.Player.InitFullScreenOnLoad) {
                    this.player.Content.Player.SetFullScreen(true);
                }

                if (this.player.Content.Player.OnLoadFunction.trim() != "") {
                    setTimeout(this.player.Content.Player.OnLoadFunction, 3000);
                }
            }
        }
        catch (e) { }
    },
    addSimple: function(websiteId, moduleId, menuId, itemId, title, description, thumbnail, source, keywords) {
        var newMedia = null;

        try {
            newMedia = this.player.Content.services.createObject("Media");

            if (newMedia) {
                newMedia.WebsiteID = websiteId;
                newMedia.ModuleID = moduleId;
                newMedia.MenuID = menuId;
                newMedia.ItemID = itemId;
                newMedia.Title = title;
                newMedia.Description = description;
                newMedia.Thumbnail = thumbnail;
                newMedia.SourceLow = source;
                newMedia.SourceAverage = source;
                newMedia.SourceHigh = source;
                newMedia.Keywords = keywords;
            }
        }
        catch (e) {
            newMedia = null;
        }

        if ($defined(newMedia)) {
            this.player.Content.Player.Playlist.Medias.Add(newMedia);
        }
    },
    addAdvance: function(websiteId, moduleId, menuId, parentItemId, itemId, title, description, thumbnail, sourceLow, sourceAverage, sourceHigh, startDate, endDate, languageCode, keywords, markerId, drm) {
        var newMedia = null;

        try {
            newMedia = this.player.Content.services.createObject("Media");

            if (newMedia) {
                newMedia.WebsiteID = websiteId;
                newMedia.ModuleID = moduleId;
                newMedia.MenuID = menuId;
                newMedia.ParentItemID = parentItemId;
                newMedia.ItemID = itemId;
                newMedia.Title = title;
                newMedia.Description = description;
                newMedia.Thumbnail = thumbnail;
                newMedia.SourceLow = sourceLow;
                newMedia.SourceAverage = sourceAverage;
                newMedia.SourceHigh = sourceHigh;
                newMedia.LanguageCode = languageCode;
                newMedia.Keywords = keywords;
                newMedia.MarkerID = markerId;
                newMedia.DRM = drm;

                if ($defined(startDate)) {
                    newMedia.StartDate = startDate;
                }

                if ($defined(endDate)) {
                    newMedia.EndDate = endDate;
                }
            }
        }
        catch (e) {
            newMedia = null;
        }

        if ($defined(newMedia)) {
            this.player.Content.Player.Playlist.Medias.Add(newMedia);
        }
    },
    resize: function() {
        var playerHeight;
        var playerWidth;

        var pos;
        var ua = window.navigator.userAgent;

        var htmlHeight = $$("html")[0].getComputedSize().totalHeight;
        var formHeight = 0;

        if ($$("form").length > 0) {
            formHeight = $$("form")[0].getComputedSize().totalHeight;

            if (htmlHeight < formHeight) {
                htmlHeight = formHeight;
            }
        }

        if (this.player.Content.Player.EnableFullScreen) {
            playerHeight = this.player.Content.Player.ScreenHeight;
            playerWidth = this.player.Content.Player.ScreenWidth;

            if (this.player.style.height.toInt() != playerHeight) {
                this.player.Content.Player.ScreenHeight = playerHeight;
            }

            if (this.player.style.width.toInt() != playerWidth) {
                this.player.Content.Player.ScreenWidth = playerWidth;
            }

            if (this.parent && this.ancestor) {
                this.parent.position({
                    relativeTo: this.ancestor,
                    position: "upperLeft",
                    edge: "upperLeft"
                });
            }
        }
        else {
            if (this.parent) {
                if (this.player.Content.Player.IsFullPage) {
                    playerHeight = window.getSize().y;
                    if (playerHeight < this.player.Content.Player.FullPageMinHeight) {
                        playerHeight = this.player.Content.Player.FullPageMinHeight;
                    }

                    playerWidth = window.getSize().x;
                    if (playerWidth < this.player.Content.Player.FullPageMinWidth) {
                        playerWidth = this.player.Content.Player.FullPageMinWidth;
                    }

                    if (mc.frame) {
                        mc.frame.position({
                            relativeTo: document.body,
                            position: "center",
                            edge: "center"
                        });

                        mc.frame.setStyles({
                            "visibility": "visible"
                        });

                        mc.frame.morph({
                            "top": 0,
                            "left": 0,
                            "width": $$("html")[0].getComputedSize().totalWidth,
                            "height": htmlHeight
                        });
                    }

                    this.parent.setStyles({
                        zIndex: "200"
                    });

                    pos = this.parent.position({
                        relativeTo: document.body,
                        position: "upperLeft",
                        edge: "upperLeft",
                        returnPos: true
                    });

                    HideObjects(this.player.id);
                }
                else {
                    playerHeight = this.player.Content.Player.PIPScreenHeight;
                    playerWidth = this.player.Content.Player.PIPScreenWidth;

                    if (mc.frame) {
                        mc.frame.morph({
                            "top": mc.frameCenterPos.top,
                            "left": mc.frameCenterPos.left,
                            "width": 0,
                            "height": 0
                        });
                    }

                    this.parent.setStyles({ zIndex: "0" });

                    if (this.ancestor) {
                        pos = this.parent.position({
                            relativeTo: this.ancestor,
                            position: "upperLeft",
                            edge: "upperLeft",
                            returnPos: true
                        });
                    }

                    ShowObjects(this.player.id);
                }

                if (ua.indexOf("MSIE") >= 0) {
                    this.parent.setStyles({
                        top: pos.top,
                        left: pos.left,
                        height: playerHeight,
                        width: playerWidth
                    });

                    this.player.style.height = String(playerHeight) + "px";
                    this.player.style.width = String(playerWidth) + "px";

                    this.player.setAttribute("height", String(playerHeight));
                    this.player.setAttribute("width", String(playerWidth));
                }
                else {
                    this.parent.morph({
                        top: pos.top,
                        left: pos.left,
                        height: playerHeight,
                        width: playerWidth
                    });

                    this.player.morph({
                        height: playerHeight,
                        width: playerWidth
                    });
                }
            }
        }
    },
    resizeAncestor: function() {
        if (this.ancestor) {
            this.ancestor.setStyles({
                height: this.player.Content.Player.ScreenHeight,
                width: this.player.Content.Player.ScreenWidth
            });
        }
    }
});

function InstallationPrompt() {
    var MCSilverlightPrompt = false;
    var MCOctoPrompt = false;

    var htmlHeight = $$("html")[0].getComputedSize().totalHeight;
    var formHeight = 0;

    if ($$("form").length > 0) {
        formHeight = $$("form")[0].getComputedSize().totalHeight;

        if (htmlHeight < formHeight) {
            htmlHeight = formHeight;
        }
    }
    
    var MCInstallFrame = new Element("div", {
        "id": "MCInstallFrame",
        "styles": {
            "height": "0px",
            "overflow": "hidden",
            "position": "absolute",
            "text-align": "center",
            "vertical-align": "middle",
            "visibility": "hidden",
            "width": "0px",
            "z-index": "160"
        }
    });

    var MCInstallBox = new Element("div", {
        "id": "MCInstallBox",
        "styles": {
            "margin-left": "auto",
            "margin-right": "auto",
            "text-align": "center",
            "vertical-align": "middle",
            "width": "250px",
            "z-index": "160"
        }
    });

    if (mc.options.installPrompt && !Silverlight.isInstalled("2.0.31005.0")) {
        MCSilverlightPrompt = true;

        var MCSilverlightBox = new Element("div", {
            "id": "MCSilverlightBox",
            "styles": {
                "float": "left",
                "margin-left": "10px",
                "margin-right": "10px",
                "text-align": "center",
                "vertical-align": "middle",
                "width": "225px"
            }
        });

        var MCSilverlightLogoBox = new Element("div", {
            "id": "MCSilverlightLogoBox",
            "styles": {
                "margin-left": "auto",
                "margin-right": "auto",
                "text-align": "center",
                "vertical-align": "middle",
                "width": "225px"
            }
        });

        var MCSilverlightLink = new Element("a", {
            "href": silverlightPluginUrl,
            "target": "_blank"
        });

        var MCSilverlightLogo = new Element("img", {
            "id": "MCSilverlightLogo",
            "src": silverlightImageUrl,
            "styles": {
                "border-width": "0px"
            }
        });

        var MCSilverlightTextBox = new Element("div", {
            "id": "MCSilverlightTextBox",
            "styles": {
                "color": "#FFFFFF",
                "font-family": "Arial",
                "font-size": "8pt",
                "margin-left": "auto",
                "margin-right": "auto",
                "text-align": "center",
                "vertical-align": "middle",
                "width": "225px"
            }
        });

        MCSilverlightTextBox.set("html", "Microsoft Silverlight is the most powerful cross-browser, cross-platform, and cross-device plug-in empowering you to experience next generation of high quality media and rich interactive applications on the Web.<br />For more information, visit<br /><a href=\"http://www.silverlight.net\" target=\"_blank\">http://www.silverlight.net</a>");
        
        MCSilverlightLink.appendChild(MCSilverlightLogo);
        MCSilverlightLogoBox.appendChild(MCSilverlightLink);
        MCSilverlightBox.appendChild(MCSilverlightLogoBox);
        MCSilverlightBox.appendChild(MCSilverlightTextBox);
        MCInstallBox.appendChild(MCSilverlightBox);
    }

    if (mc.options.octoRequired && mc.options.installPrompt && !mc.octo.ok()) {
        MCOctoPrompt = true;

        var MCOctoBox = new Element("div", {
            "id": "MCOctoBox",
            "styles": {
                "float": "left",
                "margin-left": "10px",
                "margin-right": "10px",
                "text-align": "center",
                "vertical-align": "middle",
                "width": "225px"
            }
        });

        var MCOctoLogoBox = new Element("div", {
            "id": "MCOctoLogoBox",
            "styles": {
                "margin-left": "auto",
                "margin-right": "auto",
                "text-align": "center",
                "vertical-align": "middle",
                "width": "225px"
            }
        });

        var MCOctoLink = new Element("a", {
            "href": octoPluginUrl,
            "target": "_blank"
        });

        var MCOctoLogo = new Element("img", {
            "id": "MCOctoLogo",
            "src": octoImageUrl,
            "styles": {
                "border-width": "0px"
            }
        });

        var MCOctoTextBox = new Element("div", {
            "id": "MCOctoTextBox",
            "styles": {
                "color": "#FFFFFF",
                "font-family": "Arial",
                "font-size": "8pt",
                "margin-left": "auto",
                "margin-right": "auto",
                "text-align": "center",
                "vertical-align": "middle",
                "width": "225px"
            }
        });

        MCOctoTextBox.set("html", "Octoshape is a plug-in that allows you to enjoy faster, non-buffering, high quality live streaming powered by grid technology (peer-to-peer).<br />For more information, visit<br /><a href=\"http://www.octoshape.com\" target=\"_blank\">http://www.octoshape.com</a>");

        MCOctoLink.appendChild(MCOctoLogo);
        MCOctoLogoBox.appendChild(MCOctoLink);
        MCOctoBox.appendChild(MCOctoLogoBox);
        MCOctoBox.appendChild(MCOctoTextBox);
        MCInstallBox.appendChild(MCOctoBox);
    }

    MCInstallFrame.appendChild(MCInstallBox);
    document.body.appendChild(MCInstallFrame);

    if (MCSilverlightPrompt || MCOctoPrompt) {
        HideObjects("");

        mc.frame.position({
            relativeTo: document.body,
            position: "center",
            edge: "center"
        });

        MCInstallFrame.position({
            relativeTo: document.body,
            position: "center",
            edge: "center"
        });

        mc.frame.setStyles({
            "visibility": "visible"
        });

        MCInstallFrame.setStyles({
            "visibility": "visible"
        });

        if (MCSilverlightPrompt && MCOctoPrompt) {
            MCInstallBox.setStyles({
                "width": "500px"
            });
        }

        MCInstallBox.setStyles({
            "margin-top": (window.getSize().y / 2) - (MCInstallBox.getSize().y / 2)
        });

        mc.frame.morph({
            "top": 0,
            "left": 0,
            "width": $$("html")[0].getComputedSize().totalWidth,
            "height": htmlHeight
        });

        MCInstallFrame.morph({
            "top": 0,
            "left": 0,
            "width": window.getSize().x,
            "height": window.getSize().y
        });
    }
}

function CreateSilverlight(sourceXap, parentElement, pluginId, w, h, installPrompt, bgColor, windowless, frame, initParams) {
     if (domIsReady) {
        Silverlight.createObject(
            sourceXap,
            parentElement,
            pluginId,
            {
                width: w,
                height: h,
                inplaceInstallPrompt: installPrompt,
                background: bgColor,
                isWindowless: windowless,
                framerate: frame,
                version: "2.0.31005.0"
            },
            {
                onError: function(sender, args) {
                },
                onLoad: function(sender) {
                    if (mc.options.octoRequired && mc.options.installPrompt && !mc.octo.ok()) {
                        HideObjects("");
                    }
                    else {
                        mc.players.add(pluginId);
                    }
                }
            },
            initParams + ",IpAddress=" + GetAddressInfo().address,
            pluginId);
    }
    else {
        window.addEvent("domready", function() {
            CreateSilverlight(sourceXap, parentElement, pluginId, w, h, installPrompt, bgColor, windowless, frame, initParams);
        });
    }
}

//Silverlight.onRequiredVersionAvailable = function() {
//    
//};

//Silverlight.onRestartRequired = function() {
//    
//};

//Silverlight.onUpgradeRequired = function() {
//    
//};

//Silverlight.onInstallRequired = function() {
//    
//};

//var mc = new MediaCorp({
//    installPrompt: true,
//    octoRequired: true
//});
