﻿function DragObj(){
    this.elStartLeft = 11;
    this.cursorStartX = 12;
    this.elNode = 13;
    this.zIndex = 14;
    
}

var Player = Class.create();
Player.prototype = {       
    initialize: function(){
        this.strPlaybackURI;
        this.view;
        this.preContentSpot = "";
        this.postContentSpot = "";
        this.dragging = false;
    },
    makeObject:function(){
        this.idI = -1;
        this.isFullScreen = false;
        this.dragObj = new DragObj();
        
        this.wmpId = wmpobject.create("playerWindow","100%","100%");
        
        wmpobject.addParam(this.wmpId, "autostart", "true");
        wmpobject.addParam(this.wmpId, "mute", "false");
        wmpobject.addParam(this.wmpId, "volume", "50");
        wmpobject.addParam(this.wmpId, "windowlessVideo", "false");
        wmpobject.addParam(this.wmpId,"stretchToFit","true");
        wmpobject.addParam(this.wmpId,"enableContextMenu","false");
        
        if(contentFormat == "wmv")
        {
            wmpobject.addListener(this.wmpId,"all",this.listener);
            wmpobject.addPositionListener(this.wmpId, this.updateProgress);
            wmpobject.addParam(this.wmpId,"uiMode","none");
        }
        else
        {
            wmpobject.addParam(this.wmpId, "allowFullScreen", "true");
            //toolbox_settings.MP3PlayerUri = "soundplayer.swf";
            toolbox_settings.FLAPlayerUri = toolBoxURI + "resources/MultiPlayer.swf";
            toolbox_settings.FLAControllerFullUri = "flvplayerskin.swf";
            toolbox_settings.FLAControllerNoneUri = "nothing.swf";
        }
    },
    makePlayList:function()
    {
        if(this.preContentSpot != "")
        {
            if(contentFormat == "wmv")
                wmpobject.adduri(this.wmpId,this.preContentSpot,"",false,true,true, this.onNotifyStart, this.onNotifyDone);
            else
            {
                var extraParamsPre = new Object();
                extraParamsPre["src"] = this.preContentSpot;
                extraParamsPre["mode"] = "overlay";
                extraParamsPre["frameColor"] = "000000";
                extraParamsPre["eventlistener"] = "oPlayer.multiPlayerEventListener";
                extraParamsPre["controls"] = "disabled";
                wmpobject.adduri(this.wmpId, this.preContentSpot, "", true, true, true, null, null, extraParamsPre);
            }
        }
        
        if(contentFormat == "wmv")
            wmpobject.adduri(this.wmpId,this.strPlaybackURI,"",true,true,true, this.onNotifyStart, this.onNotifyDone);
		else
		{
		    var extraParamsMain = new Object();
            extraParamsMain["src"] = this.strPlaybackURI;
            extraParamsMain["mode"] = "overlay";
            extraParamsMain["frameColor"] = "000000";
            extraParamsMain["eventlistener"] = "oPlayer.multiPlayerEventListener";
            wmpobject.adduri(this.wmpId, this.strPlaybackURI, null, true, true, true, null, null, extraParamsMain);
		}
		
		if(this.postContentSpot != "")
        {
            if(contentFormat == "wmv")
                wmpobject.adduri(this.wmpId,this.postContentSpot,"",false,true,true, this.onNotifyStart, this.onNotifyDone);
            else
            {
                var extraParamsPost = new Object();
                    extraParamsPost["src"] = this.postContentSpot;
                    extraParamsPost["mode"] = "overlay";
                    extraParamsPost["frameColor"] = "000000";
                    extraParamsPost["eventlistener"] = "oPlayer.multiPlayerEventListener";
					extraParamsPost["controls"] = "disabled";
                    wmpobject.adduri(this.wmpId, this.postContentSpot, "", true, true, true, null, null, extraParamsPost);
            }
        }
    },
    play:function()
    {
        wmpobject.play(this.wmpId);
    },
	onNotifyStart:function(obj)
	{
		if(obj.isFlash || obj.isAudio){
			$("playerControls").style.display = 'none';
		} else {
			$("playerControls").style.display = '';
		}
	},
	onNotifyDone:function(obj)
	{
		
	},
    setSpotUrls:function()
    {
        if($("preContentSpot").innerHTML != "")
        {
            var str = this.getSpotUrl($("preContentSpot"));
            if(this.isMediaUrl(str))
                this.preContentSpot = str;
        }
        if($("postContentSpot").innerHTML != "")
        {
            var str = this.getSpotUrl($("postContentSpot"));
            if(this.isMediaUrl(str))
                this.postContentSpot = str;
        }
    },
    getSpotUrl:function(obj)
    {
        var all = obj.innerHTML;
        var url = all;
        if(all.indexOf('</scr') > -1)
        {
            var i = all.indexOf('</scr');
            if(i > -1)
                url = all.substr(i+9);
        }
        url = url.split(" ").join("");
        url = url.split("\n").join("");
        url = url.split("\r").join("");
        return url;
    },
    isMediaUrl:function(str)
    {
        var ret = false;
        if(str.indexOf(".wmv") > -1 || str.indexOf(".flv") > -1)
        {
            ret = true;
        }
        return ret
    },
    listener: function(id,wmp,eventName, args){
        try{
        eventName = eventName.toLowerCase();
        if(eventName == "buffering"){
            oPlayer.buff(args[0]);
        }
        if (eventName == "click"){
            if(args[0] == 1) { //Left mouse button
               if(args[0] == 1) { //Left mouse button
                    if(wmpobject.getWmp(oPlayer.wmpId).playState == 1){
                        wmpobject.getWmp(oPlayer.wmpId).controls.play();   
                    }
                    else{
                        oPlayer.stop();
                    }
                }        
            }        
        }
        if (eventName == "doubleclick"){
            if(args[0] == 1) { //Left mouse button
                oPlayer.stop();                
            }        
        }
        if (eventName == "playstatechange") 
        {
            oPlayer.playStateChange();
        }
        if (eventName == "openstatechange") 
        {
            ///oPlayer.openStateChange();
        }    
        if (eventName == "positionchange") 
        {
            //oPlayer.positionChange();
        }    
        if (eventName == "statuschange") 
        {
            oPlayer.statusChange();
        } 
        if (eventName == "error") 
        {
            alert("A media-error has occured");
        }
        if (eventName == "mediaerror") 
        {
            alert("A media-error has occured");
        }
        }catch(e){}   
    },
    updateBP:function(){
        $("activity").innerHTML = "Buffering: "+ wmpobject.getWmp(oPlayer.wmpId).network.bufferingProgress +" % complete";
    },
    buff:function(Start){
        if(Start == true){
            var thisObj = this;
		    this.idI = setInterval(function() {thisObj.updateBP()}, 100);
        }
        else{            
            clearInterval(this.idI);
            this.updateBP();
            this.idI = -1;
        }   
    },
    dragGo: function(event) {
        try{
          var x;

          if (window.event) {
            x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
          } else {
            x = event.clientX + window.scrollX;
          }
          
          var moveTo = (oPlayer.dragObj.elStartLeft + x - oPlayer.dragObj.cursorStartX) + parseInt($("mediaProgressIndikator").style.width);
          
          if (moveTo > 0) {
            if (moveTo > 187) {
                moveTo = 187;
            }
          } else {
            moveTo = 0;
          } 
          
          moveTo -= parseInt($("mediaProgressIndikator").style.width);

          oPlayer.dragObj.elNode.style.left = moveTo + "px";

          if (window.event) {
            window.event.cancelBubble = true;
            window.event.returnValue = false;
          } else {
            event.preventDefault();
          }
        }catch (e) {}  
    },
    dragStart: function(event, id) {
        //try{
            if (oPlayer.idI == -1 && wmpobject.getWmp(oPlayer.wmpId).openState == 13) 
            {
                oPlayer.dragging = true;
                var el;
                var x;

                if (id)
                    oPlayer.dragObj.elNode = document.getElementById(id);
                else {
                    if (window.event)
                    oPlayer.dragObj.elNode = window.event.srcElement;
                    
                    if (event.target)
                    oPlayer.dragObj.elNode = event.target;

                    if (oPlayer.dragObj.elNode.nodeType == 3)
                    oPlayer.dragObj.elNode = oPlayer.dragObj.elNode.parentNode;
                }

                // Get cursor position with respect to the page.
                if (window.event) {
                    x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
                } else {
                    x = event.clientX + window.scrollX;
                }

                oPlayer.dragObj.cursorStartX = x;
                oPlayer.dragObj.elStartLeft  = parseInt(oPlayer.dragObj.elNode.style.left, 10);

                if (isNaN(oPlayer.dragObj.elStartLeft)) oPlayer.dragObj.elStartLeft = 0;

                // Update element's z-index.
                oPlayer.dragObj.elNode.style.zIndex = ++oPlayer.dragObj.zIndex;

                // Capture mousemove and mouseup events on the page.
                if (document.attachEvent) {
                    document.attachEvent("onmousemove", oPlayer.dragGo);
                    document.attachEvent("onmouseup", oPlayer.dragStop);
                    window.event.cancelBubble = true;
                    window.event.returnValue = false;
                } else {
                    document.addEventListener("mousemove", oPlayer.dragGo, true);
                    document.addEventListener("mouseup", oPlayer.dragStop, true);
                    event.preventDefault();
                }                
            }
        //}catch(e){}
    },
    dragStop: function(event) {
        try
        {
            if (document.detachEvent) {
                document.detachEvent("onmousemove", oPlayer.dragGo);
                document.detachEvent("onmouseup", oPlayer.dragStop);
            } else {
                document.removeEventListener("mousemove", oPlayer.dragGo,   true);
                document.removeEventListener("mouseup", oPlayer.dragStop, true);
            }
            oPlayer.dragging = false;
            if (!oPlayer.setCurrentPosition((parseInt(oPlayer.dragObj.elNode.style.left)+parseInt($("mediaProgressIndikator").style.width))/208)) 
            {
                oPlayer.positionChange(0,0);            
            }
            
        }catch(e){}
    },
    error: function(){
        //alert("Error, error!!")
    },
    toggleFullscreen: function(){       
        try{
        if(this.isFullScreen){
            this.smallScreen();
        }
        else{
            this.fullScreen();
        }
        }
        catch(e){}
    },
    fullScreen:function(){
    if((client.is_ie && contentFormat == "wmv") || contentFormat == "pdf"){
            if(this.view == "portal"){
                $("middle").style.height = "705px";
                $("bottom").style.display = "none";
                $("miniChannelLeftArea").style.display = "none";
                $("miniChannelRightArea").style.height = "693px";
                $("miniChannelRightArea").style.paddingTop = "12px";
                $("miniChannelRightArea").style.width = "691px";
                $("miniChannelRightArea").style.paddingLeft = "83px";
                $("miniChannelRightArea").style.paddingRight = "81px";
                $("miniChannelRightArea").style.backgroundImage = "url(" + $("channel").style.backgroundImage + ")";
                $("activity").style.width = "625px";
                $("playerWindow").style.height = "518px"; 
                $("playerWindow").style.width = "691px";
                $("playerControls").style.height = "25px";
                $("playerControls").style.paddingTop = "0px";
                $("playerControls").style.paddingLeft = "0px";
                $("playerControls").style.backgroundImage = "url(img/playerBig_bg2.jpg)";
                $("onlyPadding").style.display = "block";
                    $("btnMute").style.marginRight = "0px";
                    $("btnMute").style.width = "53px";
                    $("btnMute").style.height = "25px";
                    $("btnMute").style.backgroundImage = "url(img/playercontrols/btnMute_big.png)";
                    $("btnUnMute").style.marginRight = "0px";
                    $("btnUnMute").style.width = "53px";
                    $("btnUnMute").style.height = "25px";
                    $("btnUnMute").style.backgroundImage = "url(img/playercontrols/btnUnMute_big.png)";
                    $("btnPlay").style.marginRight = "39px";
                    $("btnPlay").style.width = "53px";
                    $("btnPlay").style.height = "25px";
                    $("btnPlay").style.backgroundImage = "url(img/playercontrols/btnPlay_big.png)";
                    $("btnPaus").style.marginRight = "39px";
                    $("btnPaus").style.height = "25px";   
                    $("btnPaus").style.width = "53px";
                    $("btnPaus").style.backgroundImage = "url(img/playercontrols/btnPaus_big.png)";
                    $("mediaProgressBar").style.marginRight = "82px";
                    $("mediaProgressBar").style.marginTop = "9px";
                    $("mediaTimeLeft").style.marginTop = "6px"
                    $("btnFullScreen").style.display = "none";
                    $("btnSmallScreen").style.display = "block";
                    $("channelBanner2").style.display = "block";
                this.originalBanner = $("bannerAreaMiniChannel").innerHTML;
                $("bannerAreaMiniChannel").innerHTML = $("bannerAreaRight").innerHTML;
                this.isFullScreen = true;     
            }
            else if(this.view == "channel"){
                //$("menuBar").style.display = "none";
                $("clipInfoArea").style.display = "none";
                $("channel_leftArea").style.display = "none";
                //$("bannerAreaRight").style.top = "95px"
                //$("channel_container").style.top = "95px";
                $("channel_container").style.paddingLeft = "83px"
                $("channel_container").style.width = "772px"
                $("channel_container").style.paddingBottom = "0px"
                $("channel_container").style.height = "685px"
                $("publ_rightArea").style.marginTop = "-8px";
                $("publ_rightArea").style.width = "691px";
                $("activity").style.width = "625px";
                $("playerWindow").style.height = "518px"; 
                $("playerWindow").style.width = "691px";
                $("playerControls").style.backgroundImage = "url(img/playerBig_bg2.jpg)";
                $("channelBanner2").style.marginTop = "14px";
                $("channelBanner2").style.marginLeft = "96px"; 
                $("onlyPadding").style.display = "block";
                $("mediaProgressBar").style.marginLeft = "39px";
                $("mediaTimeLeft").style.paddingLeft = "57px";
                //$("mediaTimeLeft").style.backgroundImage = "url(img/playerBig_bg_2.gif)";
                $("btnFullScreen").style.display = "none";
                $("btnSmallScreen").style.display = "block";
                this.isFullScreen = true;
                browserWindow.setTheEnd(); 
                
                browserWindow.positionBanners(); 
            }
        }
        else{ 
           try{
	            wmpobject.setFullscreen(oPlayer.wmpId);
            }catch(e){}
        }
    },
    smallScreen:function(){
        if(this.view == "portal"){
             $("middle").style.height = "350px";
                $("bottom").style.display = "block";
                $("miniChannelLeftArea").style.display = "block";
                $("miniChannelRightArea").style.height = "351px";
                $("miniChannelRightArea").style.paddingTop = "0px";
                $("miniChannelRightArea").style.width = "400px";
                $("miniChannelRightArea").style.paddingLeft = "0px";
                $("miniChannelRightArea").style.paddingRight = "20px";
                $("miniChannelRightArea").style.backgroundImage = "none";
                $("activity").style.width = "375px";
                $("playerWindow").style.height = "300px"; 
                $("playerWindow").style.width = "400px";
                $("playerControls").style.height = "17px";
                $("playerControls").style.paddingTop = "6px";
                $("playerControls").style.paddingLeft = "6px";
                $("playerControls").style.backgroundImage = "url(img/playerSmall_bg.jpg)";
                $("onlyPadding").style.display = "none";
                $("btnMute").style.marginRight = "6px";
                $("btnMute").style.width = "13px";
                $("btnMute").style.height = "13px";
                $("btnMute").style.backgroundImage = "url(img/playercontrols/btnMute_small.gif)";
                $("btnUnMute").style.marginRight = "6px";
                $("btnUnMute").style.width = "13px";
                $("btnUnMute").style.height = "13px";
                $("btnUnMute").style.backgroundImage = "url(img/playercontrols/btnUnMute_small.gif)";
                $("btnPlay").style.marginRight = "6px";
                $("btnPlay").style.width = "13px";
                $("btnPlay").style.height = "13px";
                $("btnPlay").style.backgroundImage = "url(img/playercontrols/btnPlay_small.gif)";
                $("btnPaus").style.marginRight = "6px";
                $("btnPaus").style.height = "13px";   
                $("btnPaus").style.width = "13px";
                $("btnPaus").style.backgroundImage = "url(img/playercontrols/btnPaus_small.gif)";
                $("mediaProgressBar").style.marginRight = "9px";
                $("mediaProgressBar").style.marginTop = "3px";
                $("mediaTimeLeft").style.marginTop = "0px"
                $("btnFullScreen").style.display = "block";
                $("btnSmallScreen").style.display = "none";
                $("channelBanner2").style.display = "none";
                $("bannerAreaMiniChannel").innerHTML = this.originalBanner;
                this.isFullScreen = false;
        }
        else if(this.view == "channel"){
            //$("menuBar").style.display = "block";
            $("clipInfoArea").style.display = "block";
            $("channel_leftArea").style.display = "block";
            //$("bannerAreaRight").style.top = "121px"
            //$("channel_container").style.top = "121px";
            $("channel_container").style.paddingLeft = "18px";
            $("channel_container").style.width = "837px";
            $("channel_container").style.paddingBottom = "20px";
            $("channel_container").style.height = "auto";
            $("publ_rightArea").style.marginTop = "0px";
            $("publ_rightArea").style.width = "500px";
            $("activity").style.width = "475px";
            $("playerWindow").style.height = "375px"; 
            $("playerWindow").style.width = "500px";
            $("playerControls").style.backgroundImage = "url(img/playerBig_bg.jpg)";
            $("channelBanner2").style.marginTop = "20px";
            $("channelBanner2").style.marginLeft = "0px"; 
            $("onlyPadding").style.display = "none";
            $("mediaProgressBar").style.marginLeft = "25px";
            $("mediaTimeLeft").style.paddingLeft = "0px";
            $("btnFullScreen").style.display = "block";
            $("btnSmallScreen").style.display = "none";
            this.isFullScreen = false;
            browserWindow.setTheEnd(); 
            browserWindow.positionBanners(); 
        }
    },
    playPause: function() {
        wmpobject.togglePlay(oPlayer.wmpId);
    },
    playStateChange: function() {
        try {
            if (wmpobject.getWmp(oPlayer.wmpId).playState == 3) {
                $("btnPlay").style.display = 'none';
                $("btnPaus").style.display = 'block';
            } 
            else {
                $("btnPlay").style.display = 'block';
                $("btnPaus").style.display = 'none';
            }
        }
        catch (e) {}
    },
    setCurrentPosition: function(iPercent) {
        return wmpobject.setPosition(oPlayer.wmpId,iPercent);
    }, 
    statusChange: function(){
        try{
            if(this.idI == -1){
                $("activity").innerHTML = wmpobject.getWmp(oPlayer.wmpId).status;
            }
        } 
        catch (e) {}   
    },
    startPlayBack: function(strPlaybackURI){ //TODO: Kolla om den här behövs
        try {
        var thisPlayer = wmpobject.getWmp(oPlayer.wmpId);
        thisPlayer.Url = strPlaybackURI;
        if(thisPlayer.controls){
		    if (thisPlayer.controls.isAvailable('Play')){
			    thisPlayer.controls.play();
		    }
	    }
	    } 
        catch (e) {}   
    },
    close: function() {
        try{
            wmpobject.getWmp(oPlayer.wmpId).controls.stop();
            wmpobject.getWmp(oPlayer.wmpId).close();
        } 
        catch (e){}
    },
    stop: function (){
        try{
            if(contentFormat == "wmv")
                wmpobject.getWmp(oPlayer.wmpId).controls.stop();
            else
            {
                var fvp = this.getFvpObj();
                if (fvp) 
                    fvp.FVPStop();
            }
        } 
        catch (e){}
    },
    toggleMute: function(){
        try {
            if (wmpobject.getWmp(oPlayer.wmpId).settings.mute) {
                wmpobject.getWmp(oPlayer.wmpId).settings.mute = false;
                $("btnUnMute").style.display = 'none';
                $("btnMute").style.display = 'block';        
            } 
            else {
                wmpobject.getWmp(oPlayer.wmpId).settings.mute = true;
                $("btnMute").style.display = 'none';   
                $("btnUnMute").style.display = 'block';         
            }
        } 
        catch (e){}        
    },
    updateProgress: function(oPosition){
        try{
            //alert(oPlayer.dragging);
            if (oPlayer.dragging) return;
            var iDuration = oPosition.duration;
            var iCurrentPosition = oPosition.position;

            var strDuration = oPosition.durationString;
            var strCurrentPosition = oPosition.positionString;
        
            $("mediaTimeLeft").innerHTML = strCurrentPosition + "/" + strDuration;
            $("mediaProgressIndikator").style.width = Math.floor((iCurrentPosition/iDuration)*208) + "px"; //Should be mediaProgressBar.style.width
            $("mediaProgressSlider").style.left = "1px"; 
        }
        catch(e)
        {
        }
    },
    multiPlayerEventListenerTimer: 0,
    multiPlayerEventListener: function(type, data) {
        if (type == "metadata") {
            if (data.height && data.width) {
                var dimObj = {};
                dimObj.width = data.width;
                dimObj.height = data.height;
                oPlayer.adjustPlayerHeight(dimObj);
            }
        } else
            if (type == "start") {
            clearTimeout(oPlayer.multiPlayerEventListenerTimer);
        } else{
            oPlayer.multiPlayerEventListenerTimer = setTimeout(function() {
                if (!wmpobject.playNext(oPlayer.wmpId)) oPlayer.stop();
            }, 2000);
        }
    },
    adjustPlayerHeight: function(dimObj)
    {
        var mediaDim = dimObj || {width:14,height:9};
        
        var h = Math.round(mediaDim.height * $("playerWindow").getWidth() / mediaDim.width);

        if (h != $("playerWindow").getHeight()) 
            $("playerWindow").morph('height:' + h + 'px');
        
    },
    adjustStyle: function() {
        
        if(contentFormat == "flv"){
            if($("playerTop")){
                var playerWrapper = $("playerTop").up();
                
                if(playerWrapper && playerWrapper.hasClassName("externalControls"))
                    playerWrapper.removeClassName("externalControls");
            }
            this.adjustPlayerHeight();
        }
    },
    getFvpObj: function() {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return window.flashPlayerObj;
        }
        else {
            return document.flashPlayerObj;
        }
    },
    getWmpObj: function() {
        try {
            return wmpobject.getWmp(this.wmpId);
        }
        catch (e) {
            return false;
        }
    }
}
oPlayer = new Player();

function startPlayback(strPlaybackURI) {
    oPlayer.strPlaybackURI = strPlaybackURI;
	switch (contentFormat){
		case "wmv":
		    verify.setupTest("wmp", "mms", "none");
			verify.checkSystem(verifyResult);
		break;
		case "flv":
			verifyResult(true);
		break;
		case "mp3":
			verifyResult(true);
		break;
		case "pdf":
            $("playerWindow").innerHTML = '<iframe src="' + strPlaybackURI + '#navpanes=0&toolbar=0&view=Fit" href="' + strPlaybackURI + '" width="100%" style="position:relative;height:100%;" ></iframe><a title="Download" target="download" href="' + strPlaybackURI + '" style="color:white;">Click to download file</a>';
		   $("playerControls").style.display = "none";
		   $("linkBg").style.display = "block"		
		   break;
		default:
			alert("startPlayback, no playback for format: " + contentFormat);
	}
	
}

function verifyResult(ok,arActions){
    if (ok){
        oPlayer.setSpotUrls();
        oPlayer.makeObject();
        oPlayer.adjustStyle();
        oPlayer.makePlayList();
        oPlayer.play();
        
    }
    else{
        actions.buildActionsMenu();
        printAction(actions.arActionsMenu[0]);
        $("playerWindow").style.display = "none";
        $("report").style.display = "block";               
    }
}

function printAction(index) {
    document.getElementById('report').innerHTML = "";
    
    // Build a menu of Actions
    if (actions.arActionsMenu.length != 1) {
        document.getElementById('report').innerHTML = actions.getActionText("actionslist").title + "<br>";
        for (var x = 0; x < actions.arActionsMenu.length; x++) {
            if (actions.arActionsMenu[x] != index) {
                document.getElementById('report').innerHTML += "<a href='javascript:printAction(" + actions.arActionsMenu[x] + ");'>" + (x+1) + " - " + actions.getActionText(actions.arActions[actions.arActionsMenu[x]][2]).title + "</a>";    
            } else {
                document.getElementById('report').innerHTML += (x+1) + " - " + actions.getActionText(actions.arActions[actions.arActionsMenu[x]][2]).title;                    
            }
            if (x != (actions.arActionsMenu.length-1)) {
                document.getElementById('report').innerHTML += " | ";
            }
        }
        document.getElementById('report').innerHTML += "<br>";
    }
    
    //Show selected Action.
    document.getElementById('report').innerHTML += "<b>" + actions.getActionText(actions.arActions[index][2]).title + "</b><br><br>";
    
    //Show a related text, and extra action information.
    switch (actions.arActions[index][3]) {
        case "software":
            document.getElementById('report').innerHTML += actions.getActionText(actions.arActions[index][2]).text + "<br><br>" + actions.getActionText(actions.arActions[index][3]).text + "<br><a href='" + actions.arActions[index][4] + "' target='_blank'>" + actions.getActionText(actions.arActions[index][3]).title + "</a>";
            break;
        
        case "script":
            document.getElementById('report').innerHTML += actions.getActionText(actions.arActions[index][2]).text + "<br><br>" + actions.getActionText(actions.arActions[index][3]).text + "<br><a href='javascript:" + actions.arActions[index][4] + "();'>" + actions.getActionText(actions.arActions[index][3]).title + "</a>";
            break;
        
        case "message":
            document.getElementById('report').innerHTML += actions.getActionText(actions.arActions[index][2]).text;
            break;
    }
}