﻿//*********************** Universal Media Player Enums ***************************
var UmpIntelAffiliateId = "139766";

var UmpObjectId = {
    "EMBEDDED": "mod-ump-embedded-object",
    "MODAL": "mod-ump-modal-object"
};

var UmpSize = {
    "Small": "Small",
    "Medium": "Medium",
    "Large": "Large"
};

var UmpSizeDimensions = new Array();
UmpSizeDimensions["Small"] = { "Width": 320, "Height": 378 };
UmpSizeDimensions["Medium"] = { "Width": 480, "Height": 472 };
UmpSizeDimensions["Large"] = { "Width": 640, "Height": 564 };

var UmpHtmlCarouselSizeDimensions = new Array();
UmpHtmlCarouselSizeDimensions["Small"] = { "Width": 320, "Height": 398 };
UmpHtmlCarouselSizeDimensions["Medium"] = { "Width": 480, "Height": 472 };
UmpHtmlCarouselSizeDimensions["Large"] = { "Width": 640, "Height": 635 };

var UmpEmbeddedHtmlCarouselSizeDimensions = new Array();
UmpHtmlCarouselSizeDimensions["Small"] = { "Width": 320, "Height": 460 };
UmpHtmlCarouselSizeDimensions["Medium"] = { "Width": 480, "Height": 550 };
UmpHtmlCarouselSizeDimensions["Large"] = { "Width": 640, "Height": 635 };


var UmpCarouselHeight = 160;
var UmpContentInfoHeight = 35;

var UmpSizeCarouselButtonClass = new Array();
UmpSizeCarouselButtonClass['Small'] = 'mod-ump-small';
UmpSizeCarouselButtonClass['Medium'] = 'mod-ump-medium';
UmpSizeCarouselButtonClass['Large'] = 'mod-ump-large';

var UmpSizeId = new Array();
UmpSizeId["Small"] = 311908;
UmpSizeId["Medium"] = 311822;
UmpSizeId["Large"] = 311504;  //341316;

var UmpSubscriber = {
    "EMBEDDED": "mod-ump-embedded-subscriber",
    "MODAL": "mod-ump-modal-subscriber"
};

var UmpSwfContainer = {
    "EMBEDDED": "mod-ump-embedded-player-div",
    "MODAL": "mod-ump-modal-player-div"
};

var UmpEvent = {
    "LOAD": 0,
    "MEDIA_CHANGE": 1,
    "PLAY": 2,
    "PAUSE": 3,
    "MEDIA_END": 4,
    "CAROUSEL_DISPLAY_STATE_CHANGE": 5,
    "NEW_MEDIA": 6,
    "REGISTER_ELEMENT": 7,
    "MEDIA_PERCENT_COMPLETE": 8
};

var UmpCarouselDirection = {
    "FORWARD": true,
    "BACKWARD": false
};

var UmpComponentDisplayState = {
    "ON": "on",
    "OFF": "off"
};

var UmpPlayState = {
    "ON": "on",
    "OFF": "off"
};

var UmpAssetType = {
    "AUDIO": "audio",
    "VIDEO": "video",
    "IMAGE": "image"
};

var UmpAssetProperty = {
    "ASSET_TYPE": "ump-asset-type",
    "ASSET_URL": "ump-asset-url",
    "ASSET_TITLE": "ump-asset-title",
    "ASSET_DESCRIPTION": "ump-asset-description",
    "ASSET_THUMBNAIL": "ump-asset-thumbnail",
    "ASSET_PREVIEW": "ump-asset-preview",
    "PAGE_URL": "ump-page-url",
    "SHARE_URL": "ump-share-url",
    "RELATED_MEDIA": "ump-related-media",
    "LINK_DESCRIPTION": "ump-link-description",
    "LINK_URL": "ump-link-url"
};

var UmpComponentName = {
    "VIDEO_PLAYER_CONTAINER": "cont_videoFull",
    "VIDEO_PLAYER": "video_640_360",
    "VIDEO_PLAYER_TITLE": "text_title",
    "VIDEO_PLAYER_DESCRIPTION": "text_description",
    "VIDEO_PLAYER_PLAY_BUTTON": "playButton",
    "VIDEO_PLAYER_PAUSE_BUTTON": "pauseButton",
    "AUDIO_PLAYER_CONTAINER": "cont_audioFull",
    "AUDIO_PLAYER": "audio_component",
    "AUDIO_PLAYER_TITLE": "text_titleAudio",
    "AUDIO_PLAYER_DESCRIPTION": "text_descriptionAudio",
    "AUDIO_PLAYER_PLAY_BUTTON": "button_audioPlay",
    "AUDIO_PLAYER_PAUSE_BUTTON": "button_audioPause",
    "IMAGE_VIEWER_CONTAINER": "cont_imageFull",
    "IMAGE_VIEWER": "comp_imageLoader",
    "CAROUSEL_CONTAINER": "cont_listFull",
    "CAROUSEL": "Advanced List",
    "END_FRAME_CONTAINER": "cont_endframe",
    "EMBED_CODE": "input_embedCode",
    "LEARN_MORE_BUTTON": "button_learnMoreFull",
    "DIGG_BUTTON": "button_digg",
    "DELICIOUS_BUTTON": "button_delicious",
    "FACEBOOK_BUTTON": "button_facebook",
    "LIVE_BUTTON": "button_live",
    "TWITTER_BUTTON": "button_twitter"
};

var UmpKaProperty = {
    "MEDIA_URL": "mediaURL",
    "CONTENT_URL": "contentURL",
    "TEXT": "text",
    "ACTIONS": "actions",
    "CLICK": "click",
    "ENCLOSURE": "enclosure"
};

var UmpKaCommand = {
    "TOGGLE_PLAY": "togglePlay",
    "TOGGLE_VISIBLE": "toggleVisible",
    "PAGE_ITEMS": "pageItems"
};

var UmpEmbedCodes = new Array();
UmpEmbedCodes[UmpComponentName.AUDIO_PLAYER] = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="480" height="270" id="kickWidget_139766_314477" ><param name="movie" value="http://serve.a-widget.com/service/getWidgetSwf.kickAction"></param><param name="FlashVars" value="affiliateSiteId=139766&amp;widgetId=314477&amp;width=480&amp;height=270&amp;revision=294&amp;playOnLoad=0&amp;autoPlay=0&amp;kaShare=1&amp;clickTag=http://www.intel.com&amp;mediaURL=place_holder" ></param><param name="wmode" value="transparent" ></param><param name="allowFullScreen" value="true" ></param><param name="allowScriptAccess" value="always" ></param><embed src="http://serve.a-widget.com/service/getWidgetSwf.kickAction" name="kickWidget_139766_314477" width="480" height="270" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowScriptAccess="always" allowFullScreen="true" FlashVars="affiliateSiteId=139766&amp;widgetId=314477&amp;width=480&amp;height=270&amp;revision=294&amp;playOnLoad=0&amp;autoPlay=0&amp;kaShare=1&amp;clickTag=http://www.intel.com&amp;mediaURL=place_holder"></embed></object>';
UmpEmbedCodes[UmpComponentName.VIDEO_PLAYER] = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="480" height="270" id="kickWidget_139766_314466" ><param name="movie" value="http://serve.a-widget.com/service/getWidgetSwf.kickAction"></param><param name="FlashVars" value="affiliateSiteId=139766&amp;widgetId=314466&amp;width=480&amp;height=270&amp;revision=294&amp;playOnLoad=0&amp;autoPlay=0&amp;kaShare=1&amp;clickTag=http://www.intel.com&amp;mediaURL=place_holder" ></param><param name="wmode" value="transparent" ></param><param name="allowFullScreen" value="true" ></param><param name="allowScriptAccess" value="always" ></param><embed src="http://serve.a-widget.com/service/getWidgetSwf.kickAction" name="kickWidget_139766_314466" width="480" height="270" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowScriptAccess="always" allowFullScreen="true" FlashVars="affiliateSiteId=139766&amp;widgetId=314466&amp;width=480&amp;height=270&amp;revision=294&amp;playOnLoad=0&amp;autoPlay=0&amp;kaShare=1&amp;clickTag=http://www.intel.com&amp;mediaURL=place_holder"></embed></object>';

var activeUniversalMediaPlayer = null;
function UmpMediaPercentCompleteEventHandler() {
    if (activeUniversalMediaPlayer != null) {
        activeUniversalMediaPlayer.UmpMediaPercentCompleteEventHandler();
    }
}

//*********************** Universal Media Player JavaScript Controls ***************************
function UniversalMediaPlayer() {
    this.OnLoad = null;
    this.OnPlay = null;
    this.OnPause = null;
    this.OnMediaChange = null;
    this.OnMediaPercentComplete = null;
    this.OnMediaEnd = null;
    this.OnCarouselDisplayStateChange = null;
    this.OnNewMedia = null;
    this.OnRegisterElement = null;

    this.m_Ump = null;
    this.m_WidgetId = null;
    this.m_CurrentAssetPlayer = UmpComponentName.VIDEO_PLAYER;

    this.m_DefaultPageURL = 'http://www.intel.com';
    this.m_FeedRoomDefaultShareURL = 'http://www.intel.com/experience';
};

UniversalMediaPlayer.prototype.Initialize = function(id) {
    this.m_Ump = navigator.appName.indexOf("Microsoft") != -1 ? window[id] : document[id];
    this.m_WidgetId = id;
};

UniversalMediaPlayer.prototype.RegisterElements = function(elementClass) {
    var pageElements = document.getElementsByTagName('*');
    for (index = 0; index < pageElements.length; index++) {
        var pageElement = pageElements[index];
        if (pageElement.className.indexOf(elementClass) > -1) {
            this.RegisterElement(pageElement);
        }
    }
};

UniversalMediaPlayer.prototype.RegisterElement = function(element) {
    AddHandler(element, 'click', CreateDelegate(this, this.SubscriberClickHandler));
    this.FireEvent(UmpEvent.REGISTER_ELEMENT);
};

UniversalMediaPlayer.prototype.SetMedia = function(type, mediaURL, pageURL, title, description, relatedMedia, playState) {
    this.m_Ump.runCommand([UmpComponentName.END_FRAME_CONTAINER, UmpKaCommand.TOGGLE_VISIBLE, false, UmpComponentDisplayState.OFF]);
    this.m_Ump.runCommand([UmpComponentName.AUDIO_PLAYER_CONTAINER, UmpKaCommand.TOGGLE_VISIBLE, false, UmpComponentDisplayState.OFF]);
    try {this.m_Ump.runCommand([UmpComponentName.AUDIO_PLAYER, UmpKaCommand.TOGGLE_PLAY, false, UmpPlayState.OFF]);}catch(e){}
    this.m_Ump.runCommand([UmpComponentName.VIDEO_PLAYER_CONTAINER, UmpKaCommand.TOGGLE_VISIBLE, false, UmpComponentDisplayState.OFF]);
    this.m_Ump.runCommand([UmpComponentName.VIDEO_PLAYER, UmpKaCommand.TOGGLE_PLAY, false, UmpPlayState.OFF]);
    this.m_Ump.runCommand([UmpComponentName.IMAGE_VIEWER_CONTAINER, UmpKaCommand.TOGGLE_VISIBLE, false, UmpComponentDisplayState.OFF]);
    try {this.m_Ump.setComponentProperty(this.m_CurrentAssetPlayer, UmpKaProperty.MEDIA_URL, '');} catch (e) { }

    this.FireEvent(UmpEvent.NEW_MEDIA);

//    if (relatedMedia != '' && relatedMedia != null) {
//        this.m_Ump.setComponentProperty(UmpComponentName.CAROUSEL, UmpKaProperty.MEDIA_URL, relatedMedia);
//    }

    switch (type) {
        case UmpAssetType.AUDIO:
            this.m_CurrentAssetPlayer = UmpComponentName.AUDIO_PLAYER;
            this.m_Ump.runCommand([UmpComponentName.AUDIO_PLAYER_CONTAINER, UmpKaCommand.TOGGLE_VISIBLE, false, UmpComponentDisplayState.ON]);
            this.m_Ump.setComponentProperty(UmpComponentName.AUDIO_PLAYER_TITLE, UmpKaProperty.TEXT, title);
            this.m_Ump.setComponentProperty(UmpComponentName.AUDIO_PLAYER_DESCRIPTION, UmpKaProperty.TEXT, description);
            this.m_Ump.setComponentProperty(UmpComponentName.AUDIO_PLAYER, UmpKaProperty.MEDIA_URL, mediaURL);
            this.m_Ump.runCommand([UmpComponentName.AUDIO_PLAYER, UmpKaCommand.TOGGLE_PLAY, false, playState]);
            break;
        case UmpAssetType.VIDEO:
            this.m_CurrentAssetPlayer = UmpComponentName.VIDEO_PLAYER;
            this.m_Ump.runCommand([UmpComponentName.VIDEO_PLAYER_CONTAINER, UmpKaCommand.TOGGLE_VISIBLE, false, UmpComponentDisplayState.ON]);
            this.m_Ump.setComponentProperty(UmpComponentName.VIDEO_PLAYER_TITLE, UmpKaProperty.TEXT, title);
            this.m_Ump.setComponentProperty(UmpComponentName.VIDEO_PLAYER_DESCRIPTION, UmpKaProperty.TEXT, description);
            this.m_Ump.setComponentProperty(UmpComponentName.VIDEO_PLAYER, UmpKaProperty.MEDIA_URL, mediaURL);
            try { this.m_Ump.runCommand([UmpComponentName.VIDEO_PLAYER, UmpKaCommand.TOGGLE_PLAY, false, playState]); } catch (e) { }
            break;
        case UmpAssetType.IMAGE:
            this.m_CurrentAssetPlayer = UmpComponentName.IMAGE_VIEWER;
            this.m_Ump.runCommand([UmpComponentName.IMAGE_VIEWER_CONTAINER, UmpKaCommand.TOGGLE_VISIBLE, false, UmpComponentDisplayState.ON]);
            this.m_Ump.setComponentProperty(UmpComponentName.IMAGE_VIEWER, UmpKaProperty.CONTENT_URL, mediaURL);
            break;
    }
};

UniversalMediaPlayer.prototype.SetEmbedCode = function(mediaURL, pageURL) {
    if (this.m_CurrentAssetPlayer == UmpComponentName.IMAGE_VIEWER) { return; }

    var newPageURL = pageURL != '' ? pageURL : this.m_DefaultPageURL;
    var pageURLRegex = new RegExp(this.m_DefaultPageURL, 'g');

    var embedCode = UmpEmbedCodes[this.m_CurrentAssetPlayer];
    embedCode = embedCode.replace(/place_holder/g, mediaURL);
    embedCode = embedCode.replace(pageURLRegex, newPageURL);

    this.m_Ump.setComponentProperty(UmpComponentName.EMBED_CODE, UmpKaProperty.TEXT, embedCode);
};

UniversalMediaPlayer.prototype.GetProperty = function(component, property, isSelectedItem) {
    var property = this.m_Ump.getComponentProperty(component, property, isSelectedItem);
    return property;
};

UniversalMediaPlayer.prototype.SetPageURL = function(pageURL) {
    var newPageURL = pageURL != '' ? pageURL : this.m_DefaultPageURL;
    this.m_Ump.setComponentProperty(UmpComponentName.LEARN_MORE_BUTTON, UmpKaProperty.ACTIONS, { 'click': [newPageURL] });
};

UniversalMediaPlayer.prototype.SetShareURL = function(type, pageURL) {
    var newPageURL = pageURL != '' ? pageURL : this.m_DefaultPageURL;

    switch (type) {
        case UmpAssetType.AUDIO:
            this.m_Ump.setComponentProperty(UmpComponentName.DELICIOUS_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://delicious.com/save?v=5&noui&jump=close&url=" + newPageURL + "&title=#{text_titleAudio.text}"] });
            this.m_Ump.setComponentProperty(UmpComponentName.DIGG_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://digg.com/submit?url=" + newPageURL + "&amp;title=#{text_titleAudio.text}"] });
            this.m_Ump.setComponentProperty(UmpComponentName.FACEBOOK_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://www.facebook.com/sharer.php?u=" + newPageURL + "&t=#{text_titleAudio.text}"] });
            this.m_Ump.setComponentProperty(UmpComponentName.LIVE_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://spaces.live.com/BlogIt.aspx?Title=#{text_titleAudio.text}&description=#{text_descriptionAudio.text}%3Cbr\/%3E%3Ca%20href=%22" + newPageURL + "%22%3E" + newPageURL + "%3C\/a%3E"] });
            this.m_Ump.setComponentProperty(UmpComponentName.TWITTER_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://twitter.com/home?status=Check%20this%20audio%20clip%20out%20--%20#{text_titleAudio.text}%20" + newPageURL] });
            break;
        case UmpAssetType.VIDEO:
            this.m_Ump.setComponentProperty(UmpComponentName.DELICIOUS_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://delicious.com/save?v=5&noui&jump=close&url=" + newPageURL + "&title=#{text_title.text}"] });
            this.m_Ump.setComponentProperty(UmpComponentName.DIGG_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://digg.com/submit?url=" + newPageURL + "&amp;title=#{text_title.text}"] });
            this.m_Ump.setComponentProperty(UmpComponentName.FACEBOOK_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://www.facebook.com/sharer.php?u=" + newPageURL + "&t=#{text_title.text}"] });
            this.m_Ump.setComponentProperty(UmpComponentName.LIVE_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://spaces.live.com/BlogIt.aspx?Title=#{text_title.text}&amp;&description=#{text_description.text}%3Cbr\/%3E%3Ca%20href=%22" + newPageURL + "%22%3E" + newPageURL + "%3C\/a%3E"] });
            this.m_Ump.setComponentProperty(UmpComponentName.TWITTER_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://twitter.com/home?status=Check%20this%20video%20out%20--%20#{text_title.text}%20" + newPageURL] });
            break;
        case UmpAssetType.IMAGE:
            this.m_Ump.setComponentProperty(UmpComponentName.DELICIOUS_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://delicious.com/save?v=5&noui&jump=close&url=" + newPageURL + "&title=Check%20this%20image%20out%20--%20"] });
            this.m_Ump.setComponentProperty(UmpComponentName.DIGG_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://digg.com/submit?url=" + newPageURL] });
            this.m_Ump.setComponentProperty(UmpComponentName.FACEBOOK_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://www.facebook.com/sharer.php?u=" + newPageURL] });
            this.m_Ump.setComponentProperty(UmpComponentName.LIVE_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://spaces.live.com/BlogIt.aspx?Title=Image from Intel.com&description=%3Cimg%20src=%22" + newPageURL + "%22%3E%3C\/img%3E"] });
            this.m_Ump.setComponentProperty(UmpComponentName.TWITTER_BUTTON, UmpKaProperty.ACTIONS, { "click": ["http://twitter.com/home?status=Check%20this%20image%20out%20--%20" + newPageURL] });
            break;
    }
};

UniversalMediaPlayer.prototype.Play = function(mediaURL) {
    this.m_Ump.runCommand([this.m_CurrentAssetPlayer, UmpKaCommand.TOGGLE_PLAY, false, UmpPlayState.ON]);
    this.FireEvent(UmpEvent.PLAY);
};

UniversalMediaPlayer.prototype.Pause = function(mediaURL) {
    if (this.m_CurrentAssetPlayer == UmpComponentName.IMAGE_VIEWER) {
        return;
    }

    this.m_Ump.runCommand([this.m_CurrentAssetPlayer, UmpKaCommand.TOGGLE_PLAY, false, UmpPlayState.OFF]);
    this.FireEvent(UmpEvent.PAUSE);
};

UniversalMediaPlayer.prototype.MoveCarousel = function(direction) {
    this.m_Ump.runCommand([UmpComponentName.CAROUSEL, UmpKaCommand.PAGE_ITEMS, false, direction, false]);
};

UniversalMediaPlayer.prototype.DisplayCarousel = function(state) {
    this.m_Ump.runCommand([UmpComponentName.CAROUSEL_CONTAINER, UmpKaCommand.TOGGLE_VISIBLE, false, state]);
    this.FireEvent(UmpEvent.CAROUSEL_DISPLAY_STATE_CHANGE);
};

UniversalMediaPlayer.prototype.DisplayContentInfo = function(state) {
    switch (this.m_CurrentAssetPlayer) {
        case UmpComponentName.AUDIO_PLAYER:
            this.m_Ump.runCommand([UmpComponentName.AUDIO_PLAYER_TITLE, UmpKaCommand.TOGGLE_VISIBLE, false, state]);
            this.m_Ump.runCommand([UmpComponentName.AUDIO_PLAYER_DESCRIPTION, UmpKaCommand.TOGGLE_VISIBLE, false, state]);
            break;
        case UmpComponentName.VIDEO_PLAYER:
            this.m_Ump.runCommand([UmpComponentName.VIDEO_PLAYER_TITLE, UmpKaCommand.TOGGLE_VISIBLE, false, state]);
            this.m_Ump.runCommand([UmpComponentName.VIDEO_PLAYER_DESCRIPTION, UmpKaCommand.TOGGLE_VISIBLE, false, state]);
            break;
    }
};

UniversalMediaPlayer.prototype.CalculatePlayerHeight = function(displayCarousel, displayContentInfo, size) {
    var height = UmpSizeDimensions[size].Height;
    if (!displayCarousel && !displayContentInfo) {
        height = height - UmpCarouselHeight - UmpContentInfoHeight;
    }
    else if (!displayCarousel) {
        height = height - UmpCarouselHeight;
    }

    return height;
};

UniversalMediaPlayer.prototype.CalculatePlayerHeightWithHtmlCarousel = function(displayCarousel, displayContentInfo, size) {
    var height = UmpHtmlCarouselSizeDimensions[size].Height;
    if (!displayCarousel && !displayContentInfo) {
        height = height - UmpCarouselHeight - UmpContentInfoHeight;
    }
    else if (!displayCarousel) {
        height = height - UmpCarouselHeight;
    }

    return height;
};

UniversalMediaPlayer.prototype.ShowModalUmp = function() { };

UniversalMediaPlayer.prototype.HideModalUmp = function() { };

UniversalMediaPlayer.prototype.SubscriberClickHandler = function(e) {};

UniversalMediaPlayer.prototype.FindTopNode = function(element, tagName) {
    if (element.tagName.indexOf(tagName) > -1) {
        return element;
    }
    else {
        return this.FindTopNode(element.parentNode, tagName);
    }
};

UniversalMediaPlayer.prototype.GetElementInfo = function(element) {
    var asset = new UniversalMediaPlayerAsset();
    asset.Type = element.getAttribute(UmpAssetProperty.ASSET_TYPE);
    asset.URL = element.getAttribute(UmpAssetProperty.ASSET_URL);
    asset.Thumbnail = element.getAttribute(UmpAssetProperty.ASSET_THUMBNAIL);
    asset.Preview = element.getAttribute(UmpAssetProperty.ASSET_PREVIEW);
    asset.ShareURL = element.getAttribute(UmpAssetProperty.SHARE_URL);
    asset.PageURL = element.getAttribute(UmpAssetProperty.PAGE_URL);
    asset.Title = element.getAttribute(UmpAssetProperty.ASSET_TITLE);
    asset.Description = element.getAttribute(UmpAssetProperty.ASSET_DESCRIPTION);
    asset.RelatedMedia = element.getAttribute(UmpAssetProperty.RELATED_MEDIA);
    asset.LinkDescription = element.getAttribute(UmpAssetProperty.LINK_DESCRIPTION);
    asset.Link = element.getAttribute(UmpAssetProperty.LINK_URL);

    asset.PlayState = UmpPlayState.OFF;
    if (element.className.indexOf(UmpSubscriber.MODAL) > -1) {
        asset.PlayState = UmpPlayState.ON;
    }

    return asset;
};

UniversalMediaPlayer.prototype.DisplayAsset = function(asset) {
    this.SetEmbedCode(asset.URL, asset.PageURL);
    this.SetPageURL(asset.PageURL);

    if (asset.ShareURL != '' && asset.ShareURL != undefined && asset.ShareURL != null) {
        this.SetShareURL(asset.Type, asset.ShareURL);
    }
    else {
        if (asset.URL.toLowerCase().indexOf('rtmp', 0) > -1) {
            this.SetShareURL(asset.Type, this.m_FeedRoomDefaultShareURL);
        }
        else {
            this.SetShareURL(asset.Type, asset.URL);
        }
    }

    this.SetMedia(asset.Type, asset.URL, asset.PageURL, asset.Title, asset.Description, asset.RelatedMedia, asset.PlayState);
}

UniversalMediaPlayer.prototype.OnPlayerClick = function(clickedSWF, clickedComponent) {
    if (clickedSWF == this.m_WidgetId) {
        switch (clickedComponent) {
            case UmpComponentName.VIDEO_PLAYER_PLAY_BUTTON:
            case UmpComponentName.AUDIO_PLAYER_PLAY_BUTTON:
                this.FireEvent(UmpEvent.PLAY);
                break;
            case UmpComponentName.VIDEO_PLAYER_PAUSE_BUTTON:
            case UmpComponentName.AUDIO_PLAYER_PAUSE_BUTTON:
                this.FireEvent(UmpEvent.PAUSE);
                break;
        }
    }
};

UniversalMediaPlayer.prototype.OnPlayerLoad = function(loadedSWF) {
    this.FireEvent(UmpEvent.LOAD);
};

UniversalMediaPlayer.prototype.OnPlayerEvent = function(componentName, event) {
    switch (event.data) {
        case UmpKaProperty.MEDIA_URL:
            this.FireEvent(UmpEvent.MEDIA_CHANGE);
            break;
    }
};

UniversalMediaPlayer.prototype.FireEvent = function(event) {
    switch (event) {
        case UmpEvent.LOAD:
            if (this.OnLoad != null) { this.OnLoad(); }
            break;
        case UmpEvent.MEDIA_CHANGE:
            if (this.OnMediaChange != null) { this.OnMediaChange(); }
            break;
        case UmpEvent.PLAY:
            if (this.OnPlay != null) { this.OnPlay(); }
            break;
        case UmpEvent.PAUSE:
            if (this.OnPause != null) { this.OnPause(); }
            break;
        case UmpEvent.MEDIA_PERCENT_COMPLETE:
            if (this.OnMediaPercentComplete != null) { this.OnMediaPercentComplete(); }
            break;
        case UmpEvent.MEDIA_END:
            if (this.OnMediaEnd != null) { this.OnMediaEnd(); }
            break;
        case UmpEvent.CAROUSEL_DISPLAY_STATE_CHANGE:
            if (this.OnCarouselDisplayStateChange != null) { this.OnCarouselDisplayStateChange(); }
            break;
        case UmpEvent.NEW_MEDIA:
            if (this.OnNewMedia != null) { this.OnNewMedia(); }
            break;
        case UmpEvent.REGISTER_ELEMENT:
            if (this.OnRegisterElement != null) { this.OnRegisterElement(); }
            break;
    }
};


//*********************************************************************************
//*********************** UMP Asset Info  ***************************
function UniversalMediaPlayerAsset(assetType, assetURL, assetThumbnail, assetPreview, assetTitle, assetDescription, shareURL, pageURL, relatedMedia, playState, linkDescription, linkURL) {
    this.Type = assetType;
    this.URL = assetURL;
    this.Thumbnail = assetThumbnail;
    this.Preview = assetPreview;
    this.ShareURL = shareURL;
    this.PageURL = pageURL;
    this.Title = assetTitle;
    this.Description = assetDescription;
    this.RelatedMedia = relatedMedia;
    this.LinkDescription = linkDescription;
    this.Link = linkURL;
    this.PlayState = playState;
}
