// File name: courselab.js
// Created: 06.08.2007 (2.3)
// Copyright (c) WebSoft, 2007. All rights reserved.
var g_isMSIE = false;
var g_isFireFox = false;
var g_isOpera = false;
var g_nFirst = 1;
var g_sMSXMLProgID;
var g_sMSXMLHTTPProgID;
var g_oBoardFrame;
var g_bPreloadImages;
var g_oDoc;
var g_oModule;
var g_oSlides;
var g_oMasters;
var g_oGroups;
var g_oMethods;
var g_oParams;
var g_oMaster;
var g_oMasterFrame;
var g_oSlide;
var g_oSlideFrame;
var g_sSlideFrameId = "";
var g_sReturnFrameId = null;
var g_arVars = new Array();
var g_arSlideVars = new Array();
var g_pEvtHandlers = null;
var g_pTimeActions = null;
var g_nTimeoutId = null;
var g_nSlideBeginTime;
var g_nSlideEndTime;
var g_nSlideCurrentTime;
var g_nPauseBeginTime;
var g_nFrameBeginTime;
var g_bPause = false;
var g_bDragOn;
var g_nOffsetX;
var g_nOffsetY;
var g_oDragObject;
var g_oDragTarget;
var g_oDHTMLDragTarget;
// SCO
var g_oDocSCO;
var g_oSCO;
var g_bStrictOrder = false;
var g_bPreloadImages = false;
var g_bNormalize = false;
var g_oImages = null;
var g_bPreloadingImages = false;
var g_bSoundEnabled = true;
var g_bSoundOn = false;
var g_sSoundId = null;
var g_bWMSoundOn = false;
var g_bSWSoundOn = false;
var g_bDebug = false;
var g_sComponent = "Компонент ";
var g_sIsNotInstalled = " не установлен.";
var g_sLoadingImages = "Идёт загрузка изображений";
var g_sSkip = "Пропустить";
var g_vPropertyValue = null;
// EvtHandler
function EvtHandler(sEvt, sType, sTargetId)
{
this.sEvt = sEvt;
this.sType = sType;
this.sTargetId = sTargetId;
this.pNext = null;
}
// TIMEACTIONS
// TimeActionAlpha constructor
function TimeActionAlpha(sTargetId, nBeginTime, nEndTime, nStartAlpha, nEndAlpha)
{
this.sType = "alpha";
this.sTargetId = sTargetId;
this.nBeginTime = parseInt(nBeginTime);
this.nEndTime = parseInt(nEndTime);
this.nStartAlpha = parseInt(nStartAlpha);
this.nEndAlpha = parseInt(nEndAlpha);
this.bComplete = false;
this.pNext = null;
this.TimeAction = TimeActionAlpha_TimeAction;
this.TravelThroughTime = TimeActionAlpha_TravelThroughTime;
this.GetNearTime = TimeActionAlpha_GetNearTime;
}
// TimeActionAlpha_TimeAction
function TimeActionAlpha_TimeAction(nCurrentTime)
{
var oTarget = document.getElementById(this.sTargetId);
if (oTarget == null)
this.bComplete = true;
else
{
if (nCurrentTime >= this.nBeginTime)
{
if (nCurrentTime < this.nEndTime)
{
var nTotalTime = this.nEndTime - this.nBeginTime;
var nElapsed = nCurrentTime - this.nBeginTime;
var nAlpha = this.nStartAlpha + (this.nEndAlpha - this.nStartAlpha) * (nElapsed / nTotalTime);
oTarget.style.opacity = parseFloat(nAlpha)/100;
}
else
{
oTarget.style.opacity = parseFloat(this.nEndAlpha)/100;
this.bComplete = true;
}
}
}
return true;
}
// TimeActionAlpha_TravelThroughTime
function TimeActionAlpha_TravelThroughTime(nDistance)
{
this.nBeginTime += nDistance;
this.nEndTime += nDistance;
}
// TimeActionAlpha_GetNearTime
function TimeActionAlpha_GetNearTime(nNow)
{
if (nNow < this.nBeginTime)
return this.nBeginTime - nNow;
else
return 0;
}
// CreateTimeActionAlpha
function CreateTimeActionAlpha(sTargetId, nBeginTime, nDuration, nStartAlpha, nEndAlpha)
{
if (nBeginTime == null)
{
var dtCurrent = new Date();
nBeginTime = dtCurrent.valueOf();
}
var oTimeActionAlpha = new TimeActionAlpha(sTargetId, parseInt(nBeginTime), parseInt(nBeginTime) + parseFloat(nDuration), nStartAlpha, nEndAlpha);
oTimeActionAlpha.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionAlpha;
if (g_nTimeoutId == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
// TimeActionMove constructor
function TimeActionMove(sTargetId, nBeginTime, nEndTime, nStartX, nStartY, nEndX, nEndY)
{
this.sType = "move";
this.sTargetId = sTargetId;
this.nBeginTime = parseInt(nBeginTime);
this.nEndTime = parseInt(nEndTime);
this.nStartX = parseInt(nStartX);
this.nStartY = parseInt(nStartY);
this.nEndX = parseInt(nEndX);
this.nEndY = parseInt(nEndY);
this.bComplete = false;
this.pNext = null;
this.TimeAction = TimeActionMove_TimeAction;
this.TravelThroughTime = TimeActionMove_TravelThroughTime;
this.GetNearTime = TimeActionMove_GetNearTime;
}
// TimeActionMove_TimeAction
function TimeActionMove_TimeAction(nCurrentTime)
{
var oTarget = document.getElementById(this.sTargetId);
if (oTarget == null)
this.bComplete = true;
else
{
if (nCurrentTime >= this.nBeginTime)
{
if (nCurrentTime < this.nEndTime)
{
var nTotalTime = this.nEndTime - this.nBeginTime;
var nElapsed = nCurrentTime - this.nBeginTime;
var nPosX = this.nStartX + (this.nEndX - this.nStartX) * (nElapsed / nTotalTime);
var nPosY = this.nStartY + (this.nEndY - this.nStartY) * (nElapsed / nTotalTime);
oTarget.style.left = nPosX + "px";
oTarget.style.top = nPosY + "px";
}
else
{
oTarget.style.left = this.nEndX + "px";
oTarget.style.top = this.nEndY + "px";
this.bComplete = true;
}
}
}
return true;
}
// TimeActionMove_TravelThroughTime
function TimeActionMove_TravelThroughTime(nDistance)
{
this.nBeginTime += nDistance;
this.nEndTime += nDistance;
}
// TimeActionMove_GetNearTime
function TimeActionMove_GetNearTime(nNow)
{
if (nNow < this.nBeginTime)
return this.nBeginTime - nNow;
else
return 0;
}
// CreateTimeActionMove
function CreateTimeActionMove(sTargetId, nBeginTime, nDuration, nStartX, nStartY, nEndX, nEndY)
{
if (nBeginTime == null)
{
var dtCurrent = new Date();
nBeginTime = dtCurrent.valueOf();
}
var oTimeActionMove = new TimeActionMove(sTargetId, parseInt(nBeginTime), parseInt(nBeginTime) + parseFloat(nDuration),
nStartX, nStartY, nEndX, nEndY);
oTimeActionMove.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionMove;
if (g_nTimeoutId == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
// TimeActionCancelMove constructor
function TimeActionCancelMove(sTargetId, bAll, nTime)
{
this.sType = "cancelmove";
this.sTargetId = sTargetId;
this.bAll = bAll;
this.nTime = parseInt(nTime);
this.bComplete = false;
this.pNext = null;
this.TimeAction = TimeActionCancelMove_TimeAction;
this.TravelThroughTime = TimeActionCancelMove_TravelThroughTime;
this.GetNearTime = TimeActionCancelMove_GetNearTime;
}
// TimeActionCancelMove_TimeAction
function TimeActionCancelMove_TimeAction(nCurrentTime)
{
var oTarget = document.getElementById(this.sTargetId);
if (oTarget == null)
this.bComplete = true;
else
{
if (nCurrentTime >= this.nTime)
{
for (var oTimeAction = g_pTimeActions; oTimeAction != null; oTimeAction = oTimeAction.pNext)
{
if (oTimeAction.sType == "move")
{
if (this.bAll == true || oTimeAction.sTargetId == this.sTargetId)
oTimeAction.bComplete = true;
}
}
this.bComplete = true;
}
}
return true;
}
// TimeActionCancelMove_TravelThroughTime
function TimeActionCancelMove_TravelThroughTime(nDistance)
{
this.nTime += nDistance;
}
// TimeActionCancelMove_GetNearTime
function TimeActionCancelMove_GetNearTime(nNow)
{
return this.nTime - nNow;
}
// CreateTimeActionCancelMove
function CreateTimeActionCancelMove(sTargetId, nTime)
{
if (nTime == null)
{
var dtCurrent = new Date();
nTime = dtCurrent.valueOf();
}
var oTimeActionCancelMove = new TimeActionCancelMove(sTargetId, parseInt(nTime));
oTimeActionCancelMove.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionCancelMove;
if (g_nTimeoutId == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
// TimeActionRotate constructor
function TimeActionRotate(sTargetId, nBeginTime, nEndTime, nStartAngle, nEndAngle, x, y, w, h)
{
this.sType = "rotate";
this.sTargetId = sTargetId;
this.nBeginTime = parseInt(nBeginTime);
this.nEndTime = parseInt(nEndTime);
this.nStartAngle = parseInt(nStartAngle);
this.nEndAngle = parseInt(nEndAngle);
this.x = parseInt(x);
this.y = parseInt(y);
this.w = parseInt(w);
this.h = parseInt(h);
this.bComplete = false;
this.pNext = null;
this.TimeAction = TimeActionRotate_TimeAction;
this.TravelThroughTime = TimeActionRotate_TravelThroughTime;
this.GetNearTime = TimeActionRotate_GetNearTime;
}
// TimeActionRotate_TimeAction
function TimeActionRotate_TimeAction(nCurrentTime)
{
var oTarget = document.getElementById(this.sTargetId);
if (oTarget == null)
this.bComplete = true;
else
{
if (nCurrentTime >= this.nBeginTime)
{
if (nCurrentTime < this.nEndTime)
{
var x = this.x;//!!!!!!
var y = this.y;//!!!!!!
var w = this.w;//!!!!!!
var h = this.h;//!!!!!!
var nTotalTime = this.nEndTime - this.nBeginTime;
var nElapsed = nCurrentTime - this.nBeginTime;
var nRotation = this.nStartAngle + (this.nEndAngle - this.nStartAngle) * (nElapsed / nTotalTime);
var flRad = parseFloat(nRotation) * (2 * Math.PI) / 360;
var flCos = Math.cos(flRad);
var flSin = Math.sin(flRad);
var M11 = flCos;
var M12 = -flSin;
var M21 = flSin;
var M22 = flCos;
var flAbsSin = (flSin >= 0 ? flSin : -flSin);
var flAbsCos = (flCos >= 0 ? flCos : -flCos);
var cx = parseInt(w) / 2;
var cy = parseInt(h) / 2;
var offsetx = -cx*flAbsCos - cy*flAbsSin + cx;
var offsety = -cx*flAbsSin - cy*flAbsCos + cy;
x = parseFloat(x) + parseFloat(offsetx);
y = parseFloat(y) + parseFloat(offsety);
if (oTarget.filters.length == 0)
oTarget.style.filter = "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand')";
var oFilter;
try
{
oFilter = oTarget.filters.item("DXImageTransform.Microsoft.Matrix");
}
catch (e)
{
oTarget.style.filter += " progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand')";
oFilter = oTarget.filters.item("DXImageTransform.Microsoft.Matrix");
}
oFilter.M11 = M11;
oFilter.M12 = M12;
oFilter.M21 = M21;
oFilter.M22 = M22;
oTarget.style.left = x;
oTarget.style.top = y;
}
else
{
var x = this.x;//!!!!!!
var y = this.y;//!!!!!!
var w = this.w;//!!!!!!
var h = this.h;//!!!!!!
var nRotation = this.nEndAngle;
var flRad = parseFloat(nRotation) * (2 * Math.PI) / 360;
var flCos = Math.cos(flRad);
var flSin = Math.sin(flRad);
var M11 = flCos;
var M12 = -flSin;
var M21 = flSin;
var M22 = flCos;
var flAbsSin = (flSin >= 0 ? flSin : -flSin);
var flAbsCos = (flCos >= 0 ? flCos : -flCos);
var cx = parseInt(w) / 2;
var cy = parseInt(h) / 2;
var offsetx = -cx*flAbsCos - cy*flAbsSin + cx;
var offsety = -cx*flAbsSin - cy*flAbsCos + cy;
x = parseFloat(x) + parseFloat(offsetx);
y = parseFloat(y) + parseFloat(offsety);
if (oTarget.filters.length == 0)
oTarget.style.filter = "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand')";
var oFilter = oTarget.filters.item("DXImageTransform.Microsoft.Matrix")
oFilter.M11 = M11;
oFilter.M12 = M12;
oFilter.M21 = M21;
oFilter.M22 = M22;
oTarget.style.left = x;
oTarget.style.top = y;
this.bComplete = true;
}
}
}
return true;
}
// TimeActionRotate_TravelThroughTime
function TimeActionRotate_TravelThroughTime(nDistance)
{
this.nBeginTime += nDistance;
this.nEndTime += nDistance;
}
// TimeActionRotate_GetNearTime
function TimeActionRotate_GetNearTime(nNow)
{
if (nNow < this.nBeginTime)
return this.nBeginTime - nNow;
else
return 0;
}
// CreateTimeActionRotate
function CreateTimeActionRotate(sTargetId, nBeginTime, nDuration, nStartAngle, nEndAngle)
{
if (nBeginTime == null)
{
var dtCurrent = new Date();
nBeginTime = dtCurrent.valueOf();
}
var oTimeActionRotate = new TimeActionRotate(sTargetId, parseInt(nBeginTime), parseInt(nBeginTime) + parseFloat(nDuration), nStartAngle, nEndAngle);
oTimeActionRotate.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionRotate;
if (g_nTimeoutId == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
// TimeActionCancelRotate constructor
function TimeActionCancelRotate(sTargetId, bAll, nTime)
{
this.sType = "cancelrotate";
this.sTargetId = sTargetId;
this.bAll = bAll;
this.nTime = parseInt(nTime);
this.bComplete = false;
this.pNext = null;
this.TimeAction = TimeActionCancelRotate_TimeAction;
this.TravelThroughTime = TimeActionCancelRotate_TravelThroughTime;
this.GetNearTime = TimeActionCancelRotate_GetNearTime;
}
// TimeActionCancelRotate_TimeAction
function TimeActionCancelRotate_TimeAction(nCurrentTime)
{
var oTarget = document.getElementById(this.sTargetId);
if (oTarget == null)
this.bComplete = true;
else
{
if (nCurrentTime >= this.nTime)
{
for (var oTimeAction = g_pTimeActions; oTimeAction != null; oTimeAction = oTimeAction.pNext)
{
if (oTimeAction.sType == "rotate")
{
if (this.bAll == true || oTimeAction.sTargetId == this.sTargetId)
oTimeAction.bComplete = true;
}
}
this.bComplete = true;
}
}
return true;
}
// TimeActionCancelRotate_TravelThroughTime
function TimeActionCancelRotate_TravelThroughTime(nDistance)
{
this.nTime += nDistance;
}
// TimeActionCancelRotate_GetNearTime
function TimeActionCancelRotate_GetNearTime(nNow)
{
return this.nBeginTime - nNow;
}
// CreateTimeActionCancelRotate
function CreateTimeActionCancelRotate(sTargetId, nTime)
{
if (nTime == null)
{
var dtCurrent = new Date();
nTime = dtCurrent.valueOf();
}
var oTimeActionCancelRotate = new TimeActionCancelRotate(sTargetId, parseInt(nTime));
oTimeActionCancelRotate.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionCancelRotate;
if (g_nTimeoutId == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
// TimeActionSize constructor
function TimeActionSize(sTargetId, nBeginTime, nEndTime, nStartW, nStartH, nEndW, nEndH)
{
this.sType = "size";
this.sTargetId = sTargetId;
this.nBeginTime = parseInt(nBeginTime);
this.nEndTime = parseInt(nEndTime);
this.nStartW = parseInt(nStartW);
this.nStartH = parseInt(nStartH);
this.nEndW = parseInt(nEndW);
this.nEndH = parseInt(nEndH);
this.bComplete = false;
this.pNext = null;
this.TimeAction = TimeActionSize_TimeAction;
this.TravelThroughTime = TimeActionSize_TravelThroughTime;
this.GetNearTime = TimeActionSize_GetNearTime;
}
// TimeActionSize_TimeAction
function TimeActionSize_TimeAction(nCurrentTime)
{
var oTarget = document.getElementById(this.sTargetId);
if (oTarget == null)
{
this.bComplete = true;
}
else
{
if (nCurrentTime < this.nEndTime)
{
var nTotalTime = this.nEndTime - this.nBeginTime;
var nElapsed = nCurrentTime - this.nBeginTime;
var nSizeW = this.nStartW + (this.nEndW - this.nStartW) * (nElapsed / nTotalTime);
var nSizeH = this.nStartH + (this.nEndH - this.nStartH) * (nElapsed / nTotalTime);
oTarget.style.width = nSizeW + "px";
oTarget.style.height = nSizeH + "px";
}
else
{
oTarget.style.width = this.nEndW + "px";
oTarget.style.height = this.nEndH + "px";
this.bComplete = true;
}
}
return true;
}
// TimeActionSize_TravelThroughTime
function TimeActionSize_TravelThroughTime(nDistance)
{
this.nBeginTime += nDistance;
this.nEndTime += nDistance;
}
// TimeActionSize_GetNearTime
function TimeActionSize_GetNearTime(nNow)
{
if (nNow < this.nBeginTime)
return this.nBeginTime - nNow;
else
return 0;
}
// CreateTimeActionSize
function CreateTimeActionSize(sTargetId, nBeginTime, nDuration, nStartW, nStartH, nEndW, nEndH)
{
if (nBeginTime == null)
{
var dtCurrent = new Date();
nBeginTime = dtCurrent.valueOf();
}
var oTimeActionSize = new TimeActionSize(sTargetId, parseInt(nBeginTime), parseInt(nBeginTime) + parseFloat(nDuration),
nStartW, nStartH, nEndW, nEndH);
oTimeActionSize.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionSize;
//if (g_nTimeoutId == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
// TimeActionDisplay constructor
function TimeActionDisplay(sTargetId, nTime, bDisplay, nTransition, nDuration)
{
this.sType = "display";
this.sTargetId = sTargetId;
this.nTime = parseInt(nTime);
this.bDisplay = bDisplay;
this.nTransition = nTransition;
this.nDuration = nDuration;
this.bComplete = false;
this.pNext = null;
this.TimeAction = TimeActionDisplay_TimeAction;
this.TravelThroughTime = TimeActionDisplay_TravelThroughTime;
this.GetNearTime = TimeActionDisplay_GetNearTime;
}
// TimeActionDisplay_TimeAction
function TimeActionDisplay_TimeAction(nCurrentTime)
{
if (nCurrentTime >= this.nTime)
{
if (this.bDisplay == true)
ShowObject(this.sTargetId, this.nTransition, this.nDuration);
else
HideObject(this.sTargetId, this.nTransition, this.nDuration);
this.bComplete = true;
}
return true;
}
// TimeActionDisplay_TravelThroughTime
function TimeActionDisplay_TravelThroughTime(nDistance)
{
this.nTime += nDistance;
}
// TimeActionDisplay_GetNearTime
function TimeActionDisplay_GetNearTime(nNow)
{
return this.nTime - nNow;
}
// TimeActionAction constructor
function TimeActionAction(nTime, oActions, nIndex)
{
this.sType = "action";
this.nTime = parseInt(nTime);
this.oActions = oActions;
this.nIndex = nIndex;
this.bComplete = false;
this.pNext = null;
this.TimeAction = TimeActionAction_TimeAction;
this.TravelThroughTime = TimeActionAction_TravelThroughTime;
this.GetNearTime = TimeActionAction_GetNearTime;
}
// TimeActionAction_TimeAction
function TimeActionAction_TimeAction(nCurrentTime)
{
if (nCurrentTime >= this.nTime)
{
var oActions = this.oActions;
var nIndex = this.nIndex;
this.bComplete = true;
for (var j = nIndex; j < oActions.length; j++)
{
var bContinue = ProcessAction(oActions, j);//!!!!!!!!!
if (!bContinue)
break;
}
}
return true;
}
// TimeActionAction_TravelThroughTime
function TimeActionAction_TravelThroughTime(nDistance)
{
this.nTime += nDistance;
}
// TimeActionAction_GetNearTime
function TimeActionAction_GetNearTime(nNow)
{
return this.nTime - nNow;
}
// TimeActionNextFrame constructor
function TimeActionNextFrame(nTime)
{
this.sType = "nextframe";
this.nTime = parseInt(nTime);
this.bComplete = false;
this.pNext = null;
this.TimeAction = TimeActionNextFrame_TimeAction;
this.TravelThroughTime = TimeActionNextFrame_TravelThroughTime;
this.GetNearTime = TimeActionNextFrame_GetNearTime;
}
// TimeActionNextFrame_TimeAction
function TimeActionNextFrame_TimeAction(nCurrentTime)
{
if (nCurrentTime >= this.nTime)
{
this.bComplete = true;
if (g_oSlideFrame != null)
{
// Handle frame oncomplete event
var oOnComplete = g_oSlideFrame.selectSingleNode("oncomplete");
if (oOnComplete != null)
ProcessActions(oOnComplete, false);
}
NextFrame();
return false;//!!!
}
return true;
}
// TimeActionNextFrame_TravelThroughTime
function TimeActionNextFrame_TravelThroughTime(nDistance)
{
this.nTime += nDistance;
}
// TimeActionNextFrame_GetNearTime
function TimeActionNextFrame_GetNearTime(nNow)
{
return this.nTime - nNow;
}
// TimeActionDestroy constructor
function TimeActionDestroy(sTargetId, nTime)
{
this.sType = "destroy";
this.sTargetId = sTargetId;
this.nTime = parseInt(nTime);
this.bComplete = false;
this.pNext = null;
this.TimeAction = TimeActionDestroy_TimeAction;
this.TravelThroughTime = TimeActionDestroy_TravelThroughTime;
this.GetNearTime = TimeActionDestroy_GetNearTime;
}
// TimeActionDestroy_TimeAction
function TimeActionDestroy_TimeAction(nCurrentTime)
{
if (nCurrentTime >= this.nTime)
{
var oTarget = document.getElementById(this.sTargetId);
if (oTarget != null)
oTarget.parentNode.removeChild(oTarget);
this.bComplete = true;
}
return true;
}
// TimeActionDestroy_TravelThroughTime
function TimeActionDestroy_TravelThroughTime(nDistance)
{
this.nTime += nDistance;
}
// TimeActionDestroy_GetNearTime
function TimeActionDestroy_GetNearTime(nNow)
{
return this.nTime - nNow;
}
// TimeActionMethod constructor
function TimeActionMethod(sTargetType, sMethodName, nTime, oArg)
{
this.sType = "method";
this.sTargetType = sTargetType;
this.sMethodName = sMethodName;
this.nTime = parseInt(nTime);
this.oArg = oArg;
this.pNext = null;
this.TimeAction = TimeActionMethod_TimeAction;
this.TravelThroughTime = TimeActionMethod_TravelThroughTime;
this.GetNearTime = TimeActionMethod_GetNearTime;
}
// TimeActionMethod_TimeAction
function TimeActionMethod_TimeAction(nCurrentTime)
{
if (nCurrentTime >= this.nTime)
{
this.bComplete = true;
CallMethod(this.sTargetType, this.sMethodName, this.oArg);
}
return true;
}
// TimeActionMethod_TravelThroughTime
function TimeActionMethod_TravelThroughTime(nDistance)
{
this.nTime += nDistance;
}
// TimeActionMethod_GetNearTime
function TimeActionMethod_GetNearTime(nNow)
{
return this.nTime - nNow;
}
// CreateTimeActionMethod
function CreateTimeActionMethod(sObjectType, sObjectMethod, nBeginTime, nTimeDistance, oArg)
{
if (nBeginTime == null)
{
var dtCurrent = new Date();
nBeginTime = dtCurrent.valueOf();
}
var oTimeActionMethod = new TimeActionMethod(sObjectType, sObjectMethod, parseInt(nBeginTime) + parseInt(nTimeDistance), oArg);
oTimeActionMethod.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionMethod;
if (g_pTimeActions != null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
// GetResolution
function GetResolution()
{
var bHiResEvtHandler = false;
for (var oEvtHandler = g_pEvtHandlers; oEvtHandler != null; oEvtHandler = oEvtHandler.pNext)
{
if (oEvtHandler.sEvt == "EVENT_TIMER")
{
bHiResEvtHandler = true;
break;
}
}
var nNearTime = 10000;
if (bHiResEvtHandler)
nNearTime = 100;
var dtNow = new Date;
var nNow = dtNow.valueOf();
for (var oTimeAction = g_pTimeActions; oTimeAction != null; oTimeAction = oTimeAction.pNext)
{
var nTimeActionNearTime = oTimeAction.GetNearTime(nNow);
if (nTimeActionNearTime < nNearTime)
nNearTime = nTimeActionNearTime;
}
return nNearTime >= 0 ? nNearTime : 0;
}
// TimerFunction
function TimerFunction()
{
clearTimeout(g_nTimeoutId);
g_nTimeoutId = null;
if (g_bPause == false)
{
var dtCurrent = new Date();
g_nSlideCurrentTime = dtCurrent.valueOf();
//PrintTimeline();
HandleEvt("EVENT_TIMER", null);
//var oTimer = document.getElementById("Timer");
//oTimer.innerHTML = dtCurrent.toLocaleTimeString();
var pListFirst = null;
for (var oTimeAction = g_pTimeActions; oTimeAction != null; oTimeAction = oTimeAction.pNext)
{
var oElement = new Object;
oElement.pTimeAction = oTimeAction;
oElement.pNext = pListFirst;
pListFirst = oElement;
}
for (var oElement = pListFirst; oElement != null; oElement = oElement.pNext)
{
var oTimeAction = oElement.pTimeAction;
var bContinue = oTimeAction.TimeAction(g_nSlideCurrentTime);
if (bContinue == false)
break;
}
// // Remove 'complete' time actions
// oTimeAction = g_pTimeActions;
// g_pTimeActions = null;
//
// while (oTimeAction != null)
// {
// var pNext = oTimeAction.pNext;
// if (oTimeAction.bComplete != true)
// {
// oTimeAction.pNext = g_pTimeActions;
// g_pTimeActions = oTimeAction;
// }
// oTimeAction = pNext;
// }
var oTimeAction = g_pTimeActions;
var oLastTimeAction = g_pTimeActions;
var oFirstTimeAction = null;
while (oTimeAction != null)
{
if (oTimeAction.bComplete == true)
oLastTimeAction.pNext = oTimeAction.pNext;
else
{
oLastTimeAction = oTimeAction;
if (oFirstTimeAction == null)
oFirstTimeAction = oTimeAction;
}
oTimeAction = oTimeAction.pNext;
}
g_pTimeActions = oFirstTimeAction;
if (g_pTimeActions != null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
//PrintTimeline();
}
}
// AttachMSIETransition
function AttachMSIETransition(oTarget, nTransition, nDuration)
{
if (oTarget.filters.length == 0)
oTarget.style.filter = "progid:DXImageTransform.Microsoft.RevealTrans(transition="+ nTransition +",duration="+ nDuration +")";
else
{
var oFilter;
try
{
oFilter = oTarget.filters("DXImageTransform.Microsoft.RevealTrans");
}
catch (e)
{
oTarget.style.filter += " progid:DXImageTransform.Microsoft.RevealTrans(transition="+ nTransition +",duration="+ nDuration +")";
oFilter = oTarget.filters("DXImageTransform.Microsoft.RevealTrans");
}
oFilter.Transition = nTransition;
oFilter.Duration = parseFloat(nDuration);
}
}
// AttachFireFoxTranIn
function AttachFireFoxTranIn(sTargetId, nX, nY, nW, nH, nNow, nTransition, nDuration)
{
try
{
var s = "";
var sTransitionDivId = sTargetId + "_tranin";
switch (nTransition)
{
case "12":
{
// dissolve
var oTimeActionAlpha = new TimeActionAlpha(sTargetId,
nNow, nNow + 1000 * parseFloat(nDuration), 0, 100);
oTimeActionAlpha.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionAlpha;
break;
}
case "4":
{
// down side up
s += "
";
s += "
";
var oTimeActionSize = new TimeActionSize(sTransitionDivId,
nNow, nNow + 1000 * parseFloat(nDuration), nW, nH, nW, 0);
oTimeActionSize.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionSize;
break;
}
case "5":
{
// up side down
s += "
";
s += "
";
var oTimeActionSize = new TimeActionSize(sTransitionDivId,
nNow, nNow + 1000 * parseFloat(nDuration), nW, nH, nW, 0);
oTimeActionSize.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionSize;
var oTimeActionMove = new TimeActionMove(sTransitionDivId,
nNow, nNow + 1000 * parseFloat(nDuration),
nX, nY, nX, parseInt(nY) + parseInt(nH));
oTimeActionMove.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionMove;
break;
}
case "19":
case "20":
case "6":
{
// left side right
s += "
";
s += "
";
var oTimeActionSize = new TimeActionSize(sTransitionDivId,
nNow, nNow + 1000 * parseFloat(nDuration), nW, nH, 0, nH);
oTimeActionSize.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionSize;
var oTimeActionMove = new TimeActionMove(sTransitionDivId,
nNow, nNow + 1000 * parseFloat(nDuration),
parseInt(nX), nY, parseInt(nX) + parseInt(nW), nY);
oTimeActionMove.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionMove;
break;
}
case "7":
{
// right side left
s += "
";
s += "
";
var oTimeActionSize = new TimeActionSize(sTransitionDivId,
nNow, nNow + 1000 * parseFloat(nDuration), nW, nH, 0, nH);
oTimeActionSize.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionSize;
break;
}
default:
{
// up side down
s += "
";
s += "
";
var oTimeActionSize = new TimeActionSize(sTransitionDivId,
nNow, nNow + 1000 * parseFloat(nDuration), nW, nH, nW, 0);
oTimeActionSize.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionSize;
var oTimeActionMove = new TimeActionMove(sTransitionDivId,
nNow, nNow + 1000 * parseFloat(nDuration),
nX, nY, nX, parseInt(nY) + parseInt(nH));
oTimeActionMove.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionMove;
break;
}
}
if (nTransition != "12")
{
var oTimeActionDestroy = new TimeActionDestroy(sTransitionDivId,
nNow + 1000 * parseFloat(nDuration));
oTimeActionDestroy.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionDestroy;
}
}
catch (e)
{
alert("minierror: " + e + " " +
sTargetId+" "+nX+" "+nY+" "+nW+" "+nH+" "+nNow+" "+nTransition+" "+nDuration);
}
return s;
}
// AttachFireFoxTranOut
function AttachFireFoxTranOut(sTargetId, nX, nY, nW, nH, nNow, nTransition, nDuration)
{
var s = "";
var sTransitionDivId = sTargetId +"_tranout";
s += "
";
s += "
";
var oHideAction = new TimeActionDisplay(sTargetId,
nNow + 1000 * parseFloat(nDuration), false, 0, 0);
oHideAction.pNext = g_pTimeActions;
g_pTimeActions = oHideAction;
var oTimeActionSize = new TimeActionSize(sTransitionDivId,
nNow, nNow + 1000 * parseFloat(nDuration), 0, nH, nW, nH);
oTimeActionSize.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionSize;
var oTimeActionDestroy = new TimeActionDestroy(sTransitionDivId,
nNow + 1000 * parseFloat(nDuration) + 100);
oTimeActionDestroy.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionDestroy;
return s;
}
// PrintTimeline
function PrintTimeline()
{
if (g_bDebug == true)
{
var dtCurrent = new Date();
var oTimerSpan = document.getElementById("Timer");
if (oTimerSpan == null)
{
var s = "";
s += "Timer:";
s += "";
if (g_isMSIE)
document.body.insertAdjacentHTML("beforeEnd", s);
else if (g_isFireFox)
document.body.innerHTML += s;
oTimerSpan = document.getElementById("Timer");
}
var s = "";
s += dtCurrent.getHours() + ":" + dtCurrent.getMinutes() + ":" + dtCurrent.getSeconds();
s += " ";
s += dtCurrent.valueOf();
s += " ";
var dtNow = new Date;
var nNow = dtNow.valueOf();
for (var oTimeAction = g_pTimeActions; oTimeAction != null; oTimeAction = oTimeAction.pNext)
{
s += oTimeAction.sType;
var nTimeActionNearTime = oTimeAction.GetNearTime(nNow);
var dt = nTimeActionNearTime;
s += " ";
s += dt.toString();
s += " ";
}
oTimerSpan.innerHTML = s;
}
}
// Pause
function Pause()
{
if (g_bPause == false)
{
g_bPause = true;
var dtCurrent = new Date();
g_nPauseBeginTime = dtCurrent.valueOf();
if (g_nTimeoutId != null)
{
clearTimeout(g_nTimeoutId);
g_nTimeoutId = null;
}
}
}
// Resume
function Resume()
{
if (g_bPause == true)
{
g_bPause = false;
var dtCurrent = new Date();
var nPauseEndTime = dtCurrent.valueOf();
var nPauseDuration = nPauseEndTime - g_nPauseBeginTime;
//if (nPauseEndTime < g_nPauseBeginTime)
// alert(nPauseEndTime - g_nPauseBeginTime);
g_nSlideBeginTime += nPauseDuration;
g_nSlideEndTime += nPauseDuration;
g_nFrameBeginTime += nPauseDuration;
if (g_pTimeActions != null)
{
for (var oTimeAction = g_pTimeActions; oTimeAction != null; oTimeAction = oTimeAction.pNext)
oTimeAction.TravelThroughTime(nPauseDuration);
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
}
}
// CallConstructors
function CallConstructors(oObjects)
{
try
{
for (var i = 0; i < oObjects.length; i++)
{
var oObject = oObjects[i];
var sType = oObject.getAttribute("type");
if (sType != null)
{
var sTargetId = oObject.getAttribute("id");
var oArg = new Object;
oArg.pid = sTargetId;
CallMethod(sType, "Constructor", oArg);
}
}
}
catch (e)
{
alert("CallConstructors: "+ e.description);
}
}
// CallMethod
function CallMethod(sType, sMethod, oArg)
{
var oMethod = g_oMethods.selectSingleNode("method[@type=\""+ sType +"\" and @name=\""+ sMethod +"\"]");
if (oMethod != null)
{
var sText = oMethod.text;
//alert(sText);
var nBegin = sText.indexOf("{");
var nEnd = sText.lastIndexOf("}");
var sBody = sText.substring(nBegin + 1, nEnd);
try
{
var oFunction = new Function("argobj", sBody);
oFunction(oArg);
}
catch (e)
{
alert("CallMethod: "+ sType +" "+ sMethod +" "+ e.description);
}
}
}
// FireEvent
function FireEvent(sTargetId, sResponseType)
{
var oResponse = g_oSlides.selectSingleNode("slide/frame/object[@id='"+ sTargetId +"']/RESPONSE[@type='"+ sResponseType +"']");
if (oResponse == null)
oResponse = g_oMasters.selectSingleNode("slide/frame/object[@id='"+ sTargetId +"']/RESPONSE[@type='"+ sResponseType +"']");
if (oResponse != null)
{
ProcessActions(oResponse, false);
}
// else
// {
// alert("FireEvent ?TargetId:"+ sTargetId +" ?TypeId:"+ sResponseType);
// }
}
// OpenMaster
function OpenMaster(oNewMaster)
{
g_oMaster = oNewMaster;
g_oMasterFrame = g_oMaster.selectSingleNode("frame["+g_nFirst+"]");
//g_oBoardFrame.innerHTML = "";
// Create objects
var sTotal = "";
var oObjects = g_oMasterFrame.selectNodes("object");
for (var i = 0; i < oObjects.length; i++)
{
var oObject = oObjects[i];
sTotal += OpenObject(oObject, false);
}
g_oBoardFrame.innerHTML = sTotal;
// Call constructors
CallConstructors(oObjects);
}
// OpenSlide
function OpenSlide(oNewSlide, sFrameId, bPreloaded)
{
g_arSlideVars = new Array();
g_oSlide = oNewSlide;
document.title = g_oSlide.getAttribute("name");
if (g_bPreloadImages && g_isMSIE)
{
if (typeof(bPreloaded) == "undefined")
{
if (g_oSlideFrame != null)
{
CloseFrame(g_oSlideFrame, false);
g_oSlideFrame = null;
}
else
{
g_oBoardFrame.innerHTML = "";
}
g_sSlideFrameId = sFrameId;
var s = "";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";//row 1
s += "
";
s += "";
s += g_sLoadingImages+" ... ";
s += "";
s += "
";
s += "
";
s += "
";//row 2
s += "
";
s += "";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";
s += "
";
BoardAppendHTML(s);
setTimeout(PreloadImages, 0);
return false;
}
}
try
{
SCOAddSlideToVisits(oNewSlide);
var sSlideId = "";
if (g_oSlide != null)
sSlideId = g_oSlide.getAttribute("id");
SCOApplyRules();
g_sLmsCmiLocation = sSlideId;
g_sLmsCmiExit = "suspend";
g_sLmsCmiSuspendData = g_oSCO.xml;
LMSSaveState();
}
catch (e)
{
}
var dtCurrent = new Date();
g_nSlideBeginTime = dtCurrent.valueOf();
g_nSlideCurrentTime = dtCurrent.valueOf();
g_nSlideEndTime = dtCurrent.valueOf();
{ // Open master
var sMasterId = g_oSlide.getAttribute("masterid");
var bOpenMaster = true;
if (g_oMaster != null)
{
if (g_oMaster.getAttribute("id") == sMasterId)
bOpenMaster = false;
}
if (bOpenMaster == true)
{
var oNewMaster = g_oMasters.selectSingleNode("slide[@id='"+sMasterId+"']");
OpenMaster(oNewMaster);
}
}
var oNewFrame = sFrameId == null ?
g_oSlide.selectSingleNode("frame["+g_nFirst+"]") :
g_oSlide.selectSingleNode("frame[@id='"+sFrameId+"']");
var oFrames = g_oSlide.selectNodes("frame");
for (var i = 0; i < oFrames.length; i++)
{
var oFrame = oFrames[i];
var sDuration = oFrame.getAttribute("dur");
if (sDuration != null)
g_nSlideEndTime += parseInt(sDuration);
}
OpenFrame(oNewFrame, false, true);
HandleEvt("EVENT_SLIDE_OPENED", null);
// Handle slide oncomplete event
var oOnComplete = g_oSlide.selectSingleNode("oncomplete");
if (oOnComplete != null)
ProcessActions(oOnComplete, false);
if (g_oSlideFrame == null)
return;
var sDuration = g_oSlideFrame.getAttribute("dur");
if (sDuration == "0")
{
var oNextFrame = g_oSlideFrame.nextSibling;
while (oNextFrame != null && oNextFrame.nodeType != 1)
oNextFrame = oNextFrame.nextSibling;
if (oNextFrame == null)
HandleEvt("EVENT_SLIDE_COMPLETE", null);
}
}
// OpenFrame
function OpenFrame(oNewFrame, bKeepPreviousFrame)
{
// Remove previous frame time actions
g_pTimeActions = null;
g_bPause = false;
if (g_bSoundOn)
StopSound();
if (g_oSlideFrame != null)
CloseFrame(g_oSlideFrame, bKeepPreviousFrame);
g_oSlideFrame = oNewFrame;
var dtBegin = new Date;
g_nFrameBeginTime = dtBegin.valueOf();
{
g_nSlideCurrentTime = g_nFrameBeginTime;
g_nSlideBeginTime = g_nFrameBeginTime;
g_nSlideEndTime = g_nFrameBeginTime;
var oFrames = g_oSlide.selectNodes("frame");
for (var i = 0; i < oFrames.length; i++)
{
var oFrame = oFrames[i];
var sDuration = oFrame.getAttribute("dur");
if (sDuration != null)
g_nSlideEndTime += parseInt(sDuration);
}
var oPreviousFrame = g_oSlideFrame;
for (;;)
{
oPreviousFrame = oPreviousFrame.previousSibling;
if (oPreviousFrame == null)
break;
if (oPreviousFrame.nodeType == 1 && oPreviousFrame.nodeName == "frame")
{
var sDuration = oPreviousFrame.getAttribute("dur");
if (sDuration != null)
{
var nPreviousFrameDur = parseInt(sDuration);
g_nSlideBeginTime -= nPreviousFrameDur;
g_nSlideEndTime -= nPreviousFrameDur;
}
}
}
}
// Handle slide onload event
var oOnLoad = g_oSlide.selectSingleNode("onload");
if (oOnLoad != null)
ProcessActions(oOnLoad, false);
// Handle frame onload event
var oOnLoad = g_oSlideFrame.selectSingleNode("onload");
if (oOnLoad != null)
{
ProcessActions(oOnLoad, false);
}
// Create elements
var sTotal = "";
var oObjects = g_oSlideFrame.selectNodes("object");
for (var i = 0; i < oObjects.length; i++)
{
var oObject = oObjects[i];
sTotal += OpenObject(oObject, false);
}
BoardAppendHTML(sTotal);
//alert(g_oBoardFrame.innerHTML);
// Call constructors
CallConstructors(oObjects);
// Play transitions
if (g_isMSIE)
{
for (var i = 0; i < oObjects.length; i++)
{
var oObject = oObjects[i];
var nTransition = oObject.getAttribute("tranin");
if (nTransition != null)
{
var sDisplay = oObject.getAttribute("display");
if (sDisplay != "none")
{
var nBegin = oObject.getAttribute("begin");
if (nBegin == 0)
{
var sId = oObject.getAttribute("id");
var oElement = document.getElementById(sId);
var nDuration = oObject.getAttribute("durin");
AttachMSIETransition(oElement, nTransition, nDuration);
oElement.style.visibility = "hidden";
oElement.filters("DXImageTransform.Microsoft.RevealTrans").Apply();
oElement.style.visibility = "visible";
oElement.filters("DXImageTransform.Microsoft.RevealTrans").Play();
}
}
}
}
}
else if (g_isFireFox)
{
var sTransitions = "";
for (var i = 0; i < oObjects.length; i++)
{
var oObject = oObjects[i];
var sDisplay = oObject.getAttribute("display");
var nBegin = oObject.getAttribute("begin");
var nTransition = oObject.getAttribute("tranin");
if (nTransition != null && nBegin == 0 && sDisplay != "none")
{
var sTargetId = oObject.getAttribute("id");
var x = oObject.getAttribute("x");
var y = oObject.getAttribute("y");
var w = oObject.getAttribute("w");
var h = oObject.getAttribute("h");
var nDuration = oObject.getAttribute("durin");
var s = AttachFireFoxTranIn(sTargetId, x, y, w, h, g_nFrameBeginTime, nTransition, nDuration);
sTransitions += s;
}
}
BoardAppendHTML(sTransitions);
}
// Handle objects onload events
for (var i = 0; i < oObjects.length; i++)
{
var oObject = oObjects[i];
var sOnLoad = oObject.getAttribute("onload");
if (sOnLoad != null)
processEvent(sOnLoad);
}
// Handle objects oncomplete events
for (var i = 0; i < oObjects.length; i++)
{
var oObject = oObjects[i];
var sOnComplete = oObject.getAttribute("oncomplete");
if (sOnComplete != null)
processEvent(sOnComplete);
}
// Start delays
var oTimeActions = g_oSlideFrame.selectNodes("timeline/timeaction");
for (var i = 0; i < oTimeActions.length; i++)
{
var oTimeAction = oTimeActions[i];
var sType = oTimeAction.getAttribute("type");
switch (sType)
{
case "display":
{
var nBegin = oTimeAction.getAttribute("begin");
var sTargetId = oTimeAction.getAttribute("targetid");
var oTimeActionDisplay = new TimeActionDisplay(sTargetId,
dtBegin.valueOf() + parseInt(nBegin), true, 1, 0);
oTimeActionDisplay.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionDisplay;
break;
}
case "hide":
{
var nBegin = oTimeAction.getAttribute("begin");
var sTargetId = oTimeAction.getAttribute("targetid");
var oTimeActionDisplay = new TimeActionDisplay(sTargetId,
dtBegin.valueOf() + parseInt(nBegin), false, 1, 0);
oTimeActionDisplay.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionDisplay;
break;
}
case "actionbox":
{
var nBegin = oTimeAction.getAttribute("begin");
var sTargetId = oTimeAction.getAttribute("targetid");
var oResponse = g_oSlideFrame.selectSingleNode("actionboxes/actionbox[@id='"+ sTargetId +"']/RESPONSE[@name='"+ sTargetId +"_1']");
if (oResponse != null)
{
var oActions = oResponse.selectNodes("ACTION");
var oTimeActionAction = new TimeActionAction(
dtBegin.valueOf() + parseInt(nBegin), oActions, 0);
oTimeActionAction.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionAction;
}
break;
}
}
}
//var sFrameDisplay = g_oSlideFrame.getAttribute("display");
//if (sFrameDisplay == "time")
{
var nFrameInfinite = g_oSlideFrame.getAttribute("infinite");
if (nFrameInfinite == "0")
{
var nFrameDur = g_oSlideFrame.getAttribute("dur");
var oTimeAction = new TimeActionNextFrame(dtBegin.valueOf() + parseInt(nFrameDur));
oTimeAction.pNext = g_pTimeActions;
g_pTimeActions = oTimeAction;
}
}
// Create mouse pointers
var oMousePointers = g_oSlideFrame.selectSingleNode("mousepointers");
if (oMousePointers != null)
{
var nStartX = oMousePointers.getAttribute("x");
var nStartY = oMousePointers.getAttribute("y");
var nTime = dtBegin.valueOf();
var sPrevArrowFile = null;
var sPrevArrowId = null;
var sPrevClickFile = null;
var sPrevClickId = null;
var sArrowFile = null;
var sArrowId = null;
var sClickFile = null;
var sClickId = null;
var sDefArrowFile = "images/cursor_arrow.gif";
var sDefArrowId = null;
var sDefClickFile = "images/cursor_click.gif";
var sDefClickId = null;
oMousePointers = oMousePointers.selectNodes("mousepointer");
for (var i = 0; i < oMousePointers.length; i++)
{
var oMousePointer = oMousePointers[i];
var nEndX = oMousePointer.getAttribute("x");
var nEndY = oMousePointer.getAttribute("y");
var nBegin = oMousePointer.getAttribute("begin");
var nDur = oMousePointer.getAttribute("dur");
var bClick = oMousePointer.getAttribute("click");
sArrowFile = oMousePointer.getAttribute("arrowfile");
if (sArrowFile == null)
{
if (sDefArrowId == null)
{
sDefArrowId ="IMG_ARROW";
var s = "";
BoardAppendHTML(s);
}
sArrowId = sDefArrowId;
sArrowFile = sDefArrowFile;
}
else if (sArrowFile == sPrevArrowFile)
{
sArrowId = sPrevArrowId;
}
else
{
sArrowId = "IMG_ARROW" + i;
var s = "";
BoardAppendHTML(s);
}
if (sArrowId != sPrevArrowId)
{
// Hide arrow
var oTimeActionDisplay = new TimeActionDisplay(sPrevArrowId,
dtBegin.valueOf() + parseInt(nBegin), false, false);
oTimeActionDisplay.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionDisplay;
// Display arrow
var oTimeActionDisplay = new TimeActionDisplay(sArrowId,
dtBegin.valueOf() + parseInt(nBegin), true, false);
oTimeActionDisplay.pNext = g_pTimeActions;
g_pTimeActions = oTimeActionDisplay;
sPrevArrowFile = sArrowFile;
sPrevArrowId = sArrowId;
}
nTime = dtBegin.valueOf() + parseInt(nBegin);
// Move arrow
var oTimeAction = new TimeActionMove(sArrowId,
nTime, nTime + parseInt(nDur), nStartX, nStartY, nEndX, nEndY);
oTimeAction.pNext = g_pTimeActions;
g_pTimeActions = oTimeAction;
nStartX = nEndX;
nStartY = nEndY;
nTime += parseInt(nDur);
if (bClick != null)
{
sClickFile = oMousePointer.getAttribute("clickfile");
if (sClickFile == null)
{
if (sDefClickId == null)
{
sDefClickId ="IMG_CLICK";
var s = "";
BoardAppendHTML(s);
}
sClickId = sDefClickId;
sClickFile = sDefClickFile;
}
else if (sClickFile == sPrevClickFile)
{
sClickId = sPrevClickId;
}
else
{
sClickId = "IMG_CLICK" + i;
var s = "";
BoardAppendHTML(s);
}
//---
// Move click
var oMoveClickAction = new TimeActionMove(sClickId,
nTime, nTime, nEndX, nEndY, nEndX, nEndY);
oMoveClickAction.pNext = g_pTimeActions;
g_pTimeActions = oMoveClickAction;
nTime += 500;
// Hide arrow
var oHideArrowAction = new TimeActionDisplay(sArrowId,
nTime, false, false);
oHideArrowAction.pNext = g_pTimeActions;
g_pTimeActions = oHideArrowAction;
// Display click
var oDisplayClickAction = new TimeActionDisplay(sClickId,
nTime, true, false);
oDisplayClickAction.pNext = g_pTimeActions;
g_pTimeActions = oDisplayClickAction;
nTime += 200;
// Hide click
var oHideClickAction = new TimeActionDisplay(sClickId,
nTime, false, false);
oHideClickAction.pNext = g_pTimeActions;
g_pTimeActions = oHideClickAction;
sPrevClickFile = sClickFile;
sPrevClickId = sClickId;
// Display arrow
var oDisplayArrowAction = new TimeActionDisplay(sArrowId,
nTime, true, false);
oDisplayArrowAction.pNext = g_pTimeActions;
g_pTimeActions = oDisplayArrowAction;
}
}
/*if (bClick != null)
{
// Display arrow
var oDisplayArrowAction = new TimeActionDisplay(sArrowId,
nTime, true, false);
oDisplayArrowAction.pNext = g_pTimeActions;
g_pTimeActions = oDisplayArrowAction;
}*/
}
// Play sounds
var sSoundSrc = null;
var sSoundId = null;
for (var i = 0; i < oObjects.length; i++)
{
var oObject = oObjects[i];
var sDisplay = oObject.getAttribute("display");
if (sDisplay != "none")
{
var nBegin = oObject.getAttribute("begin");
if (nBegin == "0")
{
sSoundSrc = oObject.getAttribute("soundsrc");
if (sSoundSrc != null)
{
var sPlay = oObject.getAttribute("play");
if (sPlay == "1")
{
sSoundId = oObject.getAttribute("id");
break;
}
sSoundSrc = null;
}
}
}
}
if (sSoundSrc != null)
PlaySound(sSoundSrc, sSoundId);
if (g_pTimeActions != null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
HandleEvt("EVENT_FRAME_OPENED", null);
}
// OpenObject
function OpenObject(oObject, bForceDisplay)
{
var sId = oObject.getAttribute("id");
var x = oObject.getAttribute("x");
var y = oObject.getAttribute("y");
var w = oObject.getAttribute("w");
var h = oObject.getAttribute("h");
var nAlpha = oObject.getAttribute("alpha");
var nRotation = oObject.getAttribute("rotation");
var nTransition = oObject.getAttribute("tranin");
var sDisplay = oObject.getAttribute("display");
var nBegin = oObject.getAttribute("begin");
var nZIndex = oObject.getAttribute("zIndex");
var nDraggable = oObject.getAttribute("draggable");
var sNoDiv = oObject.getAttribute("nodiv");
//alert(sId + " " + nZIndex + " " + bForceDisplay);
//alert(oObject.xml);
var oData = oObject.selectSingleNode("data");
if (oData == null)
{
if (g_isMSIE)
oData = oObject.selectSingleNode("iedata");
else if (g_isFireFox)
oData = oObject.selectSingleNode("firefoxdata");
}
var sText = oData.text;
for (;;)
{
var nPatternBegin = sText.indexOf("variable=\"");
if (nPatternBegin == -1)
break;
var nNameBegin = nPatternBegin + 10;
var nNameEnd = sText.indexOf("\"", nNameBegin);
if (nNameEnd == -1)
break;
var nPatternEnd = nNameEnd + 1;
var sName = sText.substr(nNameBegin, nNameEnd - nNameBegin);
var sValue = IsSlideVar(sName) ? g_arSlideVars[sName] : g_arVars[sName];
var sBefore = sText.substr(0, nPatternBegin);
var sAfter = sText.substr(nPatternEnd);
sText = sBefore + sValue + sAfter;
}
var s = "";
if (sNoDiv != "yes")
{
s += "
= 0 ? flSin : -flSin);
var flAbsCos = (flCos >= 0 ? flCos : -flCos);
var cx = parseInt(w) / 2;
var cy = parseInt(h) / 2;
var offsetx = -cx*flAbsCos - cy*flAbsSin + cx;
var offsety = -cx*flAbsSin - cy*flAbsCos + cy;
x = parseFloat(x) + parseFloat(offsetx);
y = parseFloat(y) + parseFloat(offsety);
s += " filter:progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand'";
s += ",M11="+M11+",M12="+M12+",M21="+M21+",M22="+M22;
s += ");";
}
}
if (nAlpha != null)
{
s += "filter:alpha(opacity="+ nAlpha +");";
s += "-moz-opacity:."+ nAlpha +";";
s += "opacity:."+ nAlpha +";";
}
s += "position:absolute;left:"+ x +"px;top:"+ y +"px;width:"+ w +"px;height:"+ h +"px;";
s += "z-index:"+ nZIndex +";";
// if (nTransition != null)
// {
// var nDuration = oObject.getAttribute("durin");
// if (g_isMSIE)
// s += "filter:revealTrans(transition="+ nTransition +",duration="+ nDuration +");";
// }
if ((sDisplay == "none" || nBegin != "0") && !bForceDisplay)
s += "display:none;";
else
{
if (g_isFireFox)
{
if (nTransition == "12")
s += "opacity:0.0;";
}
}
s += "\"";
if (nDraggable != null)
{
s += " onmousedown=\"DragBegin(this, event);\"";
s += " onmouseup=\"DragEnd(this, event);\"";
s += " onmousemove=\"DragMove(this, event);\"";
}
s += ">";
}
else
{
// Styles
var sStyles = "";
sStyles += "position:absolute;";
sStyles += "z-index:"+ nZIndex +";";
if ((sDisplay == "none" || nBegin != "0") && !bForceDisplay)
sStyles += "display:none;";
var sPattern = /\[!STYLES\]/g;
sText = sText.replace(sPattern, sStyles);
// Attrs
var sAttrs = "";
sAttrs += "id=\""+ sId +"\"";
sPattern = /\[!ATTRS\]/g;
sText = sText.replace(sPattern, sAttrs);
}
s += sText;
if (sNoDiv != "yes")
{
s += "
";
}
return s;
}
// GetObjectById
function GetObjectById(sObjectId)
{
var oObject = g_oSlideFrame.selectSingleNode("object[@id='"+ sObjectId +"']");
if (oObject != null)
return oObject;
oObject = g_oSlide.selectSingleNode("frame/object[@id='"+ sObjectId +"']");
if (oObject != null)
return oObject;
oObject = g_oSlides.selectSingleNode("slide/frame/object[@id='"+ sObjectId +"']");
if (oObject != null)
return oObject;
var oObject = g_oMasterFrame.selectSingleNode("object[@id='"+ sObjectId +"']");
if (oObject != null)
return oObject;
oObject = g_oMaster.selectSingleNode("frame/object[@id='"+ sObjectId +"']");
if (oObject != null)
return oObject;
oObject = g_oMasters.selectSingleNode("master/frame/object[@id='"+ sObjectId +"']");
if (oObject != null)
return oObject;
return null;
}
// GetResponseById
function GetResponseById(sResponseId)
{
var oResponse = g_oSlideFrame.selectSingleNode("object/RESPONSE[@name='"+ sResponseId +"']");
if (oResponse != null)
return oResponse;
oResponse = g_oSlide.selectSingleNode("frame/object/RESPONSE[@name='"+ sResponseId +"']");
if (oResponse != null)
return oResponse;
oResponse = g_oSlides.selectSingleNode("slide/frame/object/RESPONSE[@name='"+ sResponseId +"']");
if (oResponse != null)
return oResponse;
var oResponse = g_oMasterFrame.selectSingleNode("object/RESPONSE[@name='"+ sResponseId +"']");
if (oResponse != null)
return oResponse;
oResponse = g_oMaster.selectSingleNode("frame/object/RESPONSE[@name='"+ sResponseId +"']");
if (oResponse != null)
return oResponse;
oResponse = g_oMasters.selectSingleNode("master/frame/object/RESPONSE[@name='"+ sResponseId +"']");
if (oResponse != null)
return oResponse;
return null;
}
// ShowObject
function ShowObject(sTargetId, nTransition, nDuration)
{
{
var oObject = GetObjectById(sTargetId);
if (oObject != null)
{
var sTextId = oObject.getAttribute("textid");
if (sTextId != null && sTextId != sTargetId)
{
ShowObject(sTextId, nTransition, nDuration)
}
}
}
try
{
var oTarget = document.getElementById(sTargetId);
if (oTarget != null)
{
if (oTarget.style.display != "inline" && oTarget.style.display != "block")
{
if (g_isMSIE)
{
oTarget.style.display = "inline";
}
else if (g_isFireFox)
{
if (nTransition)
{
var oObject = GetObjectById(sTargetId);
if (oObject != null)
{
if (nTransition == 1)
{
nTransition = oObject.getAttribute("tranin");
nDuration = oObject.getAttribute("durin");
}
else
{
nTransition -= 2;
nDuration /= 1000;
}
if (nTransition == "12")
{
oTarget.style.opacity = 0;
}
}
}
oTarget.style.display = "block";
}
if (nTransition)
{
var oObject = GetObjectById(sTargetId);
if (oObject != null)
{
if (nTransition == 1)
{
nTransition = oObject.getAttribute("tranin");
nDuration = oObject.getAttribute("durin");
}
else
{
nTransition -= 2;
nDuration /= 1000;
}
if (nTransition != null)
{
if (g_isMSIE)
{
AttachMSIETransition(oTarget, nTransition, nDuration);
oTarget.style.visibility = "hidden";
oTarget.filters("DXImageTransform.Microsoft.RevealTrans").Apply();
oTarget.style.visibility = "visible";
oTarget.filters("DXImageTransform.Microsoft.RevealTrans").Play();
}
else if (g_isFireFox)
{
var x = oObject.getAttribute("x");
var y = oObject.getAttribute("y");
var w = oObject.getAttribute("w");
var h = oObject.getAttribute("h");
var dtNow = new Date;
var nNow = dtNow.valueOf();
var s = AttachFireFoxTranIn(sTargetId, x, y, w, h, nNow, nTransition, nDuration);
BoardAppendHTML(s);
}
}
}
}
}
}
else
{
var oObject = GetObjectById(sTargetId);
if (oObject != null)
{
var s = OpenObject(oObject, true);
BoardAppendHTML(s);
if (nTransition)
{
if (nTransition == 1)
{
nTransition = oObject.getAttribute("tranin");
nDuration = oObject.getAttribute("durin");
}
else
{
nTransition -= 2;
nDuration /= 1000;
}
if (nTransition != null && nDuration != null)
{
var dtNow = new Date;
var nNow = dtNow.valueOf();
if (g_isMSIE)
{
var oTarget = document.getElementById(sTargetId);
AttachMSIETransition(oTarget, nTransition, nDuration);
oTarget.style.visibility = "hidden";
oTarget.filters("DXImageTransform.Microsoft.RevealTrans").Apply();
oTarget.style.visibility = "visible";
oTarget.filters("DXImageTransform.Microsoft.RevealTrans").Play();
}
else
{
//oTarget.style.display = "none";//!!!!
var x = oObject.getAttribute("x");
var y = oObject.getAttribute("y");
var w = oObject.getAttribute("w");
var h = oObject.getAttribute("h");
//alert(sTargetId+" "+ x+" "+ y+" "+ w+" "+ h+" "+ nNow+" "+ nTransition+" "+ nDuration);
var s = AttachFireFoxTranIn(sTargetId, x, y, w, h, nNow, nTransition, nDuration);
BoardAppendHTML(s);
}
}
}
// Handle object onload event
var sOnLoad = oObject.getAttribute("onload");
if (sOnLoad != null)
processEvent(sOnLoad);
// Handle object oncomplete event
var sOnComplete = oObject.getAttribute("oncomplete");
if (sOnComplete != null)
processEvent(sOnComplete);
}
else
{
var oGroup = g_oGroups.selectSingleNode("group[@id=\""+sTargetId+"\"]");
if (oGroup != null)
{
var oRefs = oGroup.selectNodes("ref");
for (var k = 0; k < oRefs.length; k++)
{
var oRef = oRefs[k];
var sObjectId = oRef.getAttribute("id");
ShowObject(sObjectId, nTransition, nDuration);
}
}
}
}
// Sound
var oObject = GetObjectById(sTargetId);
if (oObject != null)
{
var sSoundSrc = oObject.getAttribute("soundsrc");
if (sSoundSrc != null)
{
var sPlay = oObject.getAttribute("play");
if (sPlay == "1")
{
var sSoundId = oObject.getAttribute("id");
PlaySound(sSoundSrc, sSoundId);
}
}
}
if (g_isFireFox)
{
if (g_pTimeActions != null && g_nTimeoutId == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
}
catch (e)
{
alert("ShowObject:" + e.description);
}
}
// HideObject
function HideObject(sTargetId, nTransition, nDuration)
{
{
var oObject = GetObjectById(sTargetId);
if (oObject != null)
{
var sTextId = oObject.getAttribute("textid");
if (sTextId != null && sTextId != sTargetId)
{
HideObject(sTextId, nTransition, nDuration)
}
}
}
try
{
var oTarget = document.getElementById(sTargetId);
if (oTarget != null)
{
if (oTarget.style.display != "none")
{
if (g_bSoundOn == true && g_sSoundId != null)
{
if (g_sSoundId == sTargetId)
StopSound();
}
if (nTransition)
{
if (nTransition == 1)
{
var oObject = GetObjectById(sTargetId);
if (oObject != null)
{
var nTransition = oObject.getAttribute("tranout");
if (nTransition != null)
{
nTransition = oObject.getAttribute("tranout");
nDuration = oObject.getAttribute("durout");
}
}
}
else
{
nTransition -= 2;
nDuration /= 1000;
}
if (nTransition != null && nDuration != null)
{
var dtNow = new Date;
var nNow = dtNow.valueOf();
if (g_isMSIE)
{
AttachMSIETransition(oTarget, nTransition, nDuration);
oTarget.style.visibility = "visible";
oTarget.filters("DXImageTransform.Microsoft.RevealTrans").Apply();
oTarget.style.visibility = "hidden";
oTarget.filters("DXImageTransform.Microsoft.RevealTrans").Play();
var oHideAction = new TimeActionDisplay(sTargetId,
nNow + 1000 * parseFloat(nDuration), false, false);
oHideAction.pNext = g_pTimeActions;
g_pTimeActions = oHideAction;
}
else
{
//oTarget.style.display = "none";//!!!!
var x = oObject.getAttribute("x");
var y = oObject.getAttribute("y");
var w = oObject.getAttribute("w");
var h = oObject.getAttribute("h");
//alert(sTargetId+" "+ x+" "+ y+" "+ w+" "+ h+" "+ nNow+" "+ nTransition+" "+ nDuration);
var s = AttachFireFoxTranOut(sTargetId, x, y, w, h, nNow, nTransition, nDuration);
BoardAppendHTML(s);
}
}
else
{
oTarget.style.display = "none";
}
}
else
{
oTarget.style.display = "none";
}
}
if (g_pTimeActions != null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
else
{
var oGroup = g_oGroups.selectSingleNode("group[@id=\""+sTargetId+"\"]");
if (oGroup != null)
{
var oRefs = oGroup.selectNodes("ref");
for (var k = 0; k < oRefs.length; k++)
{
var oRef = oRefs[k];
var sObjectId = oRef.getAttribute("id");
HideObject(sObjectId, nTransition, nDuration);
}
}
}
}
catch (e)
{
alert("HideObject:" + e.description);
}
}
// GetIEComponent
function GetIEComponent(sActiveXClsID)
{
var bFound = document.body.isComponentInstalled("{" + sActiveXClsID + "}", "ComponentID");
return bFound;
}
// GetIEActiveX
function GetIEActiveX(sActiveXProgID)
{
try
{
var oTestObject = new ActiveXObject(sActiveXProgID);
return true
}
catch (e)
{
return false
}
}
// FindFireFoxPlugIn
function FindFireFoxPlugIn()
{
var arPlugins = navigator.plugins;
for (var i = 0; i < arPlugins.length; i++)
{
var sDescription = " " + arPlugins[i].description;
var sName = " " + arPlugins[i].name;
//alert(sDescription + "|" + sName);
var bAllFound = true;
for (j = 0; j < arguments.length; j++)
{
if (sDescription.indexOf(" " + arguments[j]) == -1 &&
sName.indexOf(" " + arguments[j]) == -1)
{
bAllFound = false;
break;
}
}
if (bAllFound)
return true;
}
return false;
}
// ProcessRuntimeChecks
function ProcessRuntimeChecks()
{
if (g_isMSIE)
{
document.body.addBehavior("#default#clientCaps");
}
var oRuntimeChecks = g_oModule.selectSingleNode("runtimechecks");
if (oRuntimeChecks != null)
{
oRuntimeChecks = oRuntimeChecks.selectNodes("runtimecheck");
for (var i = 0; i < oRuntimeChecks.length; i++)
{
var oRuntimeCheck = oRuntimeChecks[i];
var sId = oRuntimeCheck.getAttribute("id");
switch (sId)
{
case "MSMP":
{
var sComponent = "Microsoft Windows Media Player";
var bFound;
if (g_isMSIE)
bFound = GetIEComponent("22D6F312-B0F6-11D0-94AB-0080C74C7E95");
else if (g_isFireFox)
bFound = FindFireFoxPlugIn("Windows", "Media", "Player", "Plug-in");
if (!bFound)
alert(g_sComponent + sComponent + g_sIsNotInstalled);
break;
}
case "MMFP":
{
var sComponent = "Macromedia Flash";
var bFound;
if (g_isMSIE)
bFound = GetIEActiveX("ShockwaveFlash.ShockwaveFlash.1");
else if (g_isFireFox)
bFound = FindFireFoxPlugIn("Shockwave", "Flash");
if (!bFound)
alert(g_sComponent + sComponent + g_sIsNotInstalled);
break;
}
case "MMSW":
{
var sComponent = "Macromedia Shockwave";
var bFound;
if (g_isMSIE)
bFound = GetIEActiveX("SWCtl.SWCtl.8.5");
else if (g_isFireFox)
bFound = FindFireFoxPlugIn("Shockwave", "Director");
if (!bFound)
alert(g_sComponent + sComponent + g_sIsNotInstalled);
break;
}
case "APQT":
{
var sComponent = "Apple QuickTime";
var bFound;
if (g_isMSIE)
bFound = GetIEActiveX("QuickTime.QuickTime");
else if (g_isFireFox)
bFound = FindFireFoxPlugIn("QuickTime");
if (!bFound)
alert(g_sComponent + sComponent + g_sIsNotInstalled);
break;
}
}
}
}
}
// WMPlaySound
function WMPlaySound(sSoundSrc)
{
var oPlayer = document.getElementById("WMPlayer");
if (oPlayer == null)
{
InsertWMPlayer();
oPlayer = document.getElementById("WMPlayer");
}
if (oPlayer != null)
{
g_bWMSoundOn = true;
oPlayer.URL = sSoundSrc;
oPlayer.controls.play();
}
}
// WMStopSound
function WMStopSound()
{
if (g_bWMSoundOn)
{
g_bWMSoundOn = false;
var oPlayer = document.getElementById("WMPlayer");
if (oPlayer != null)
oPlayer.URL = "";
}
}
// SWPlaySound
function SWPlaySound(sSoundSrc)
{
var oPlayer = document.getElementById("SWPlayer");
if (oPlayer == null)
{
InsertSWPlayer();
oPlayer = document.getElementById("SWPlayer");
}
if (oPlayer != null)
{
g_bSWSoundOn = true;
oPlayer.object.Movie = sSoundSrc;
oPlayer.object.Play();
}
}
// SWStopSound
function SWStopSound()
{
if (g_bSWSoundOn)
{
g_bSWSoundOn = false;
var oPlayer = document.getElementById("SWPlayer");
if (oPlayer != null)
{
oPlayer.object.Stop();
oPlayer.object.Movie = "";
}
}
}
// PlaySound
function PlaySound(sSoundSrc, sSoundId)
{
if (g_bSoundEnabled)
{
g_bSoundOn = true;
g_sSoundId = sSoundId;
if (sSoundSrc.indexOf('.swf') != -1)
SWPlaySound(sSoundSrc);
else
WMPlaySound(sSoundSrc);
}
}
// StopSound
function StopSound()
{
if (g_bSoundOn)
{
g_bSoundOn = false;
g_sSoundId = null;
WMStopSound();
SWStopSound();
}
}
// EnableSound
function EnableSound(bEnable)
{
if (bEnable)
{
g_bSoundEnabled = true;
}
else
{
g_bSoundEnabled = false;
StopSound();
}
}
// CloseFrame
function CloseFrame(oFrame, bKeepPreviousFrame)
{
// // Remove frame objects
// var oObjects = oFrame.selectNodes("object");
// for (var i = 0; i < oObjects.length; i++)
// {
// var oObject = oObjects[i];
// var sId = oObject.getAttribute("id");
//
// var oElement = document.getElementById(sId);
// if (oElement != null)
// oElement.parentNode.removeChild(oElement);
//
// oElement = document.getElementById(sId + "_transition");
// if (oElement != null)
// oElement.parentNode.removeChild(oElement);
// }
var oNextFrame = g_oSlideFrame.nextSibling;
while (oNextFrame != null && oNextFrame.nodeType != 1)
oNextFrame = oNextFrame.nextSibling;
var oMasterObjects = null;
if (g_oMasterFrame != null)
oMasterObjects = g_oMasterFrame.selectNodes("object");
var oElements = g_oBoardFrame.childNodes;
for (var i = 0; i < oElements.length; i++)
{
var oElement = oElements[i];
var sElementId = oElement.getAttribute("id");
var bMaster = false;
if (oMasterObjects != null)
{
for (var j = 0; j < oMasterObjects.length; j++)
{
var oObject = oMasterObjects[j];
if (oObject.getAttribute("id") == sElementId)
{
bMaster = true;
break;
}
}
}
if (!bMaster)
{
var bRemove = true;
if (bKeepPreviousFrame)
{
if (oNextFrame != null)
{
var oObject = g_oSlide.selectSingleNode("frame/object[@id='"+ sElementId +"']");
if (oObject != null)
{
var sDisplay = oObject.getAttribute("display");
if (sDisplay == "slide")
bRemove = false;
}
}
}
if (bRemove)
{
g_oBoardFrame.removeChild(oElement);
//oElement.parentNode.removeChild(oElement);
//alert(g_oBoardFrame.innerHTML)
i -= 1;
}
}
}
}
// PreviousSlide
function PreviousSlide()
{
try
{
var oPreviousSlide = g_oSlide.previousSibling;
while (oPreviousSlide != null && oPreviousSlide.nodeType != 1)
oPreviousSlide = oPreviousSlide.previousSibling;
if (oPreviousSlide != null)
OpenSlide(oPreviousSlide, null);
}
catch (e)
{
alert("PreviousSlide:" + e.description);
}
}
// NextSlide
function NextSlide()
{
try
{
var oNextSlide = g_oSlide.nextSibling;
while (oNextSlide != null && oNextSlide.nodeType != 1)
oNextSlide = oNextSlide.nextSibling;
if (oNextSlide != null)
{
OpenSlide(oNextSlide, null);
}
}
catch (e)
{
alert("NextSlide:" + e.description);
}
}
// PreviousFrame
function PreviousFrame()
{
try
{
var oPreviousFrame = g_oSlideFrame.previousSibling;
while (oPreviousFrame != null && oPreviousFrame.nodeType != 1)
oPreviousFrame = oPreviousFrame.previousSibling;
if (oPreviousFrame != null)
{
var dtCurrent = new Date();
g_nSlideCurrentTime = dtCurrent.valueOf();
var nCurrentFrameElapsed = parseInt(g_nSlideCurrentTime - g_nFrameBeginTime);
var nPreviousFrameDur = parseInt(oPreviousFrame.getAttribute("dur"));
g_nSlideBeginTime += (nPreviousFrameDur + nCurrentFrameElapsed);
g_nSlideCurrentTime += (nPreviousFrameDur + nCurrentFrameElapsed);
g_nSlideEndTime += (nPreviousFrameDur + nCurrentFrameElapsed);
OpenFrame(oPreviousFrame, false);
}
}
catch (e)
{
alert("PreviousFrame:" + e.description);
}
}
// NextFrame
function NextFrame()
{
if (g_oSlideFrame == null)
return;
try
{
var oNextFrame = g_oSlideFrame.nextSibling;
while (oNextFrame != null && oNextFrame.nodeType != 1)
oNextFrame = oNextFrame.nextSibling;
if (oNextFrame != null)
{
var dtCurrent = new Date();
g_nSlideCurrentTime = dtCurrent.valueOf();
var nCurrentFrameElapsed = parseInt(g_nSlideCurrentTime - g_nFrameBeginTime);
var nCurrentFrameDur = parseInt(g_oSlideFrame.getAttribute("dur"));
g_nSlideBeginTime -= (nCurrentFrameDur - nCurrentFrameElapsed);
g_nSlideCurrentTime -= (nCurrentFrameDur - nCurrentFrameElapsed);
g_nSlideEndTime -= (nCurrentFrameDur - nCurrentFrameElapsed);
OpenFrame(oNextFrame, true);
}
else
{
HandleEvt("EVENT_SLIDE_COMPLETE", null);
var sAdvance = g_oSlide.getAttribute("advance");
if (sAdvance == "immediate")
NextSlide();
}
}
catch (e)
{
alert("NextFrame:" + e.description);
}
}
// processEvent
function processEvent(sResponseId)
{
var oResponse = GetResponseById(sResponseId);
if (oResponse != null)
{
if (g_isMSIE && window.event != null)
window.event.cancelBubble = true;
ProcessActions(oResponse, false);
}
else
{
alert("?Response: " + sResponseId);
}
}
// processEventLR
function processEventLR(sLeftResponseId, sRightResponseId, oEvt)
{
var oEvent = g_isMSIE ? window.event : oEvt;
if (oEvent != null)
{
var sResponseId = null;
if((g_isMSIE && oEvent.button == 1 ) || (!g_isMSIE && oEvent.button == 0))
{
if (sLeftResponseId != null)
{
sResponseId = sLeftResponseId;
}
} else {
if(oEvent.button == 2)
{
if (sRightResponseId != null)
{
sResponseId = sRightResponseId;
}
}
}
/* if (sLeftResponseId != null)
{
if ((g_isMSIE && oEvent.button == 1) || (!g_isMSIE && oEvent.button == 0))
{
sResponseId = sLeftResponseId;
}
}
else
{
if (sRightResponseId != null && oEvent.button == 2)
{
sResponseId = sRightResponseId;
}
}
*/
if (sResponseId != null)
{
var oResponse = GetResponseById(sResponseId);
if (oResponse != null)
{
if (g_isMSIE)
{
oEvent.cancelBubble = true;
}
else
{
oEvent.stopPropagation();
}
ProcessActions(oResponse, false);
}
else
{
alert("?Response: " + sResponseId);
}
}
}
}
// IsSlideVar
function IsSlideVar(sName)
{
var bSlideScope = false;
for (var sTest in g_arSlideVars)
{
if (sTest == sName)
{
bSlideScope = true;
break;
}
}
return bSlideScope;
}
// ProcessActions
function ProcessActions(oEvent, bSequentially)
{
var oActions = oEvent.selectNodes("ACTION");
for (var i = 0; i < oActions.length; i++)
{
var bContinue = ProcessAction(oActions, i, bSequentially);
if (!bContinue)
break;
}
if (g_pTimeActions != null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
// ACTIONS
// ActionDisplay
function ActionDisplay(eltChild, dtBegin)
{
var sTargetId = eltChild.getAttribute("pid");
var sDisplay = eltChild.getAttribute("display");
var nTransition = eltChild.getAttribute("transition");
var nDuration = eltChild.getAttribute("dur");
if (sDisplay != "none")
ShowObject(sTargetId, nTransition, nDuration);
else
HideObject(sTargetId, nTransition, nDuration);
HandleEvt("EVENT_DISPLAY_STATE_CHANGED", null);
return true;
}
// ActionMsgBox
function ActionMsgBox(eltChild, dtBegin)
{
var sValue = eltChild.getAttribute("value");
try
{
sValue = ReplacePropertiesInStr(sValue, true);
sValue = ReplaceVariablesInStr(sValue, true);
}
catch(e) {}
sValue = eval(sValue);
alert(sValue);
return true;
}
// ActionVariable
function ActionVariable(eltChild, dtBegin)
{
var sName = eltChild.getAttribute("name");
var sValue = eltChild.getAttribute("value");
var sGlobal = eltChild.getAttribute("global");
try
{
sValue = ReplacePropertiesInStr(sValue, true);
sValue = ReplaceVariablesInStr(sValue, true);
}
catch(e) {}
sValue = eval(sValue);
if (sGlobal == "1")
g_arVars[sName] = sValue;
else
g_arSlideVars[sName] = sValue;
return true;
}
// ReplaceMacrosInStr
function ReplaceMacrosInStr(sString)
{
var reLeft = new RegExp(/\{\{/);
var reRight = new RegExp(/\}\}/);
var sResult = sString;
if(reLeft.test(sString) && reRight.test(sString))
{
var iStart = 0;
var iEnd = 0;
var iTmp = 0;
var sBuffer = sString;
var sTestStr = "";
sResult = "";
while(reLeft.test(sBuffer))
{
iStart = sBuffer.search(reLeft);
if(iStart>0)
{
sResult += sBuffer.substring(0,iStart);
sBuffer = sBuffer.substr(iStart);
iStart = 0;
}
iEnd = sBuffer.search(reRight);
if(iEnd==-1)
{
sResult += "{{";
sBuffer = sBuffer.substr(2);
continue;
}
sTestStr = sBuffer.substring(iStart+2,iEnd);
sValue = ReplacePropertiesInStr(sTestStr);
if(sValue!=sTestStr)
{
sResult += sValue;
sBuffer = sBuffer.substr(iEnd+2);
continue;
}
sValue = ReplaceVariablesInStr(sTestStr);
if(sValue!=sTestStr)
{
sResult += sValue;
sBuffer = sBuffer.substr(iEnd+2);
continue;
}
sResult += "{{" + sTestStr + "}}";
sBuffer = sBuffer.substr(iEnd+2);
}
sResult += sBuffer;
}
return sResult;
}
// ReplaceVariablesInStr
function ReplaceVariablesInStr(sString, bEval)
{
if(bEval==null) var bEval = false;
var reLeft = new RegExp(/\#/);
var sResult = sString;
if(reLeft.test(sString))
{
var reRight = new RegExp(/\W/);
var sBuffer = sString;
var sTestStr = "";
var sValue = "";
var iStart = 0;
var iEnd = 0;
var bSlideVar = false;
sResult = "";
while(reLeft.test(sBuffer))
{
iStart = sBuffer.search(reLeft);
if(iStart>0)
{
sResult += sBuffer.substring(0,iStart);
sBuffer = sBuffer.substr(iStart);
iStart = 0;
}
sBuffer = sBuffer.substr(1);
iEnd = sBuffer.search(reRight);
sTestStr = iEnd==-1 ? sTestStr = sBuffer.substr(iStart) : sBuffer.substring(iStart,iEnd);
bSlideVar = IsSlideVar(sTestStr);
sValue = bSlideVar ? g_arSlideVars[sTestStr] : g_arVars[sTestStr];
if(sValue==null)
{
sResult = sResult + "#" + sTestStr;
}
else
{
if(bEval)
{
if(typeof sValue == "number")
{
sResult += sValue;
}
else
{
if(typeof sValue == "string")
{
sResult += "\""+sValue+"\"";
}
else
{
sResult = sResult + "#" + sTestStr;
}
}
}
else
{
sResult += sValue;
}
}
// sResult = sValue==null ? sResult + "#" + sTestStr : sResult + sValue;
sBuffer = iEnd==-1 ? "" : sBuffer.substr(iEnd);
}
sResult += sBuffer;
}
return sResult;
}
// ReplacePropertiesInStr
function ReplacePropertiesInStr(sString, bEval)
{
if(bEval==null) var bEval = false;
var reObjPtr = new RegExp(/\$/);
if(!reObjPtr.test(sString)) return sString;
var sBuffer = sString;
var reObjEnd = new RegExp(/\./);
var rePropEnd = new RegExp(/\W/);
var iObjStart = 0;
var iObjEnd = 0;
var iPropEnd = 0;
var iTmp = 0;
var sValue = "";
var sObjectId = "";
var sPropertyName = "";
var sPropertyValue = "";
while(reObjPtr.test(sBuffer))
{
iObjStart = sBuffer.search(reObjPtr);
if(iObjStart>0)
{
sValue += sBuffer.substring(0,iObjStart);
sBuffer = sBuffer.substr(iObjStart);
iObjStart = 0;
}
iObjEnd = sBuffer.search(reObjEnd);
if(iObjEnd==-1)
{
sValue += "$";
sBuffer = sBuffer.substr(1);
continue;
}
sObjectId = sBuffer.substring(iObjStart+1,iObjEnd);
if(GetObjectById(sObjectId)==null)
{
sValue += "$"+sObjectId+".";
sBuffer = sBuffer.substr(iObjEnd+1);
continue;
}
iTmp = sBuffer.substr(iObjEnd+1).search(rePropEnd);
iPropEnd = iTmp + iObjEnd + 1;
sProperty = iTmp==-1 ? sBuffer.substr(iObjEnd+1) : sBuffer.substring(iObjEnd+1,iPropEnd);
sPropertyValue = GetObjectProperty(sObjectId, sProperty);
if(sPropertyValue==null)
{
sValue = iTmp==-1 ? sValue + sBuffer : sValue + sBuffer.substring(0,iPropEnd);
}
else
{
if(bEval)
{
if(typeof sPropertyValue=="number")
{
sValue += sPropertyValue.toString();
}
else
{
if(typeof sPropertyValue=="string")
{
sValue += "\""+sPropertyValue+"\"";
}
else
{
sValue = iTmp==-1 ? sValue + sBuffer : sValue + sBuffer.substring(0,iPropEnd);
}
}
}
else
{
if(typeof sPropertyValue=="string" || typeof sPropertyValue=="number")
{
sValue += sPropertyValue.toString();
}
else
{
sValue = iTmp==-1 ? sValue + sBuffer : sValue + sBuffer.substring(0,iPropEnd);
}
}
}
sBuffer = iTmp==-1 ? "" : sBuffer.substr(iPropEnd);
}
if(sBuffer!="") sValue += sBuffer;
return sValue;
}
// GetObjectProperty
function GetObjectProperty(sObjectId, sProperty)
{
if(sObjectId==null || sProperty==null) return null;
var oObj = GetObjectById(sObjectId);
if(oObj==null) return null;
var vValue = oObj.getAttribute(sProperty);
if(vValue==null)
{
var sType = oObj.getAttribute("type");
if(sType==null) return null;
var oArgs = new Object;
oArgs.pid = sObjectId;
oArgs.property = sProperty;
CallMethod(sType, "GetProperty", oArgs);
vValue = g_vPropertyValue;
g_vPropertyValue = null;
}
return vValue;
}
// ActionIf
function ActionIf(eltChild, dtBegin)
{
var sIf = eltChild.getAttribute("if");
try
{
sIf = ReplacePropertiesInStr(sIf, true);
sIf = ReplaceVariablesInStr(sIf, true);
}
catch(e) {}
var sPattern = /(#)(\w+(\.\w*)?)/g;
var sEval = sIf.replace(sPattern, "(IsSlideVar(\"$2\")?g_arSlideVars:g_arVars)[\"$2\"]");
//alert(sEval);
var fConditionOk = eval(sEval);
if (fConditionOk)
{
ProcessActions(eltChild, false);
}
else
{
var oElse = eltChild.selectSingleNode("ACTION/ELSE");
if (oElse != null)
ProcessActions(oElse, false);
}
return true;
}
// ActionElse
function ActionElse(eltChild, dtBegin)
{
return true;
}
// ActionBeginAsync
function ActionBeginAsync(eltChild, dtBegin)
{
ProcessActions(eltChild, true);
return true;
}
// ActionWait
function ActionWait(eltChild, nIndex, oActions, dtBegin)
{
if (nIndex + 1 < oActions.length)
{
var nCheck = eltChild.getAttribute("check");
if (nCheck == 0)
{
var nMil = eltChild.getAttribute("mil");
var oTimeAction = new TimeActionAction(
dtBegin.valueOf() + parseInt(nMil), oActions, nIndex + 1);
oTimeAction.pNext = g_pTimeActions;
g_pTimeActions = oTimeAction;
}
}
return false;
}
// ActionMove
function ActionMove(eltChild, dtBegin)
{
var sTargetId = eltChild.getAttribute("pid");
var oTarget = document.getElementById(sTargetId);
if (oTarget != null)
{
var nStartX = parseInt(oTarget.style.left);
var nStartY = parseInt(oTarget.style.top);
var sEndX = eltChild.getAttribute("x");
var sEndY = eltChild.getAttribute("y");
try
{
sEndX = ReplacePropertiesInStr(sEndX);
sEndX = ReplaceVariablesInStr(sEndX);
sEndY = ReplacePropertiesInStr(sEndY);
sEndY = ReplaceVariablesInStr(sEndY);
}
catch(e) { return false; }
var nEndX = parseInt(sEndX,10);
var nEndY = parseInt(sEndY,10);
if(isNaN(nEndX) || isNaN(nEndY)) return false;
var sAdditive = eltChild.getAttribute("additive");
if (sAdditive == "sum")
{
nEndX += nStartX;
nEndY += nStartY;
}
var sDur = eltChild.getAttribute("dur");
var nBeginTime = dtBegin.valueOf();
//var nEndTime = nBeginTime + nDistance / parseInt(nSpeed) * 10;
var nEndTime = nBeginTime + parseFloat(sDur);// * 1000;
var oTimeAction = new TimeActionMove(sTargetId,
nBeginTime, nEndTime, nStartX, nStartY, nEndX, nEndY);
oTimeAction.pNext = g_pTimeActions;
g_pTimeActions = oTimeAction;
if (oTimeAction.pNext == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
return true;
}
// ActionCancelMove
function ActionCancelMove(eltChild, dtBegin)
{
var sTargetId = eltChild.getAttribute("pid");
var sAll = eltChild.getAttribute("all");
var bAll = (sAll == "1" ? true : false);
var oTarget = document.getElementById(sTargetId);
if (oTarget != null)
{
var nTime = dtBegin.valueOf();
var oTimeAction = new TimeActionCancelMove(sTargetId, bAll, nTime);
oTimeAction.pNext = g_pTimeActions;
g_pTimeActions = oTimeAction;
if (oTimeAction.pNext == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
return true;
}
// ActionGoto
function ActionGoto(eltChild, dtBegin)
{
var sOption = eltChild.getAttribute("option");
if (sOption != null)
{
//new
switch (sOption)
{
case "0":
{
var sFrameId = eltChild.getAttribute("pid");
var oNewFrame = g_oSlides.selectSingleNode("slide/frame[@id=\""+sFrameId+"\"]");
if (oNewFrame != null)
{
var oNewSlide = oNewFrame.parentNode;
if (oNewSlide.getAttribute("id") == g_oSlide.getAttribute("id"))
OpenFrame(oNewFrame, false);
else
OpenSlide(oNewSlide, sFrameId);
}
break;
}
case "1":
NextFrame();
break;
case "2":
PreviousFrame();
break;
case "3":
NextSlide();
break;
case "4":
PreviousSlide();
break;
}
}
else
{
//old
var sFrameId = eltChild.getAttribute("pid");
var oNewSlide = g_oSlides.selectSingleNode("slide[@id=\""+sFrameId+"\"]");
if (oNewSlide != null)
OpenSlide(oNewSlide, null);
else
{
var oNewFrame = g_oSlides.selectSingleNode("slide/frame[@id=\""+sFrameId+"\"]");
if (oNewFrame != null)
OpenFrame(oNewFrame, false);
}
}
return true;
}
// ActionMethod
function ActionMethod(eltChild, dtBegin)
{
var sTargetId = eltChild.getAttribute("pid");
var sMethod = eltChild.getAttribute("method");
var oObject = GetObjectById(sTargetId);
if (oObject != null)
{
var sType = oObject.getAttribute("type");
var oArg = new Object;
oArg.pid = sTargetId;
var oParamNodes = eltChild.selectNodes("param");
for (var i = 0; i < oParamNodes.length; i++)
{
var oParamNode = oParamNodes[i];
var sName = oParamNode.getAttribute("name");
var sValue = oParamNode.getAttribute("value");
oArg[sName] = sValue;
}
CallMethod(sType, sMethod, oArg);
}
return true;
}
// ActionCheckHit
function ActionCheckHit(eltChild, dtBegin)
{
var sTestId = eltChild.getAttribute("pid");
var sDragObjectId = g_oDragObject.getAttribute("id");
var fConditionOk = (sTestId == sDragObjectId ? true : false);
if (fConditionOk)
{
ProcessActions(eltChild, false);
}
else
{
var oElse = eltChild.selectSingleNode("ACTION/ELSE");
if (oElse != null)
ProcessActions(oElse, false);
}
return true;
}
// ActionJavaScript
function ActionJavaScript(eltChild, dtBegin)
{
var sText = eltChild.getAttribute("text");
eval(sText);
return true;
}
// ActionJump
function ActionJump(eltChild, dtBegin)
{
var sLink = eltChild.getAttribute("link");
try
{
sLink = ReplacePropertiesInStr(sLink);
sLink = ReplaceVariablesInStr(sLink);
}
catch(e) {}
window.open(sLink);
return true;
}
// ActionPrint
function ActionPrint()
{
try
{
window.print();
}
catch(e) {}
return true;
}
// ActionGosub
function ActionGosub(eltChild, dtBegin)
{
g_sReturnFrameId = g_oSlideFrame.getAttribute("id");
var sOption = eltChild.getAttribute("option");
if (sOption != null)
{
//new
switch (sOption)
{
case "0":
{
var sFrameId = eltChild.getAttribute("pid");
var oNewFrame = g_oSlides.selectSingleNode("slide/frame[@id=\""+sFrameId+"\"]");
if (oNewFrame != null)
{
var oNewSlide = oNewFrame.parentNode;
if (oNewSlide.getAttribute("id") == g_oSlide.getAttribute("id"))
OpenFrame(oNewFrame, false);
else
OpenSlide(oNewSlide, sFrameId);
}
break;
}
case "1":
NextFrame();
break;
case "2":
PreviousFrame();
break;
case "3":
NextSlide();
break;
case "4":
PreviousSlide();
break;
}
}
else
{
//old
var sFrameId = eltChild.getAttribute("pid");
var oNewSlide = g_oSlides.selectSingleNode("slide[@id=\""+sFrameId+"\"]");
if (oNewSlide != null)
OpenSlide(oNewSlide, null);
else
{
var oNewFrame = g_oSlides.selectSingleNode("slide/frame[@id=\""+sFrameId+"\"]");
if (oNewFrame != null)
OpenFrame(oNewFrame, false);
}
}
return true
}
// ActionReturn
function ActionReturn(eltChild, dtBegin)
{
if (g_sReturnFrameId != null)
{
var sFrameId = g_sReturnFrameId;
g_sReturnFrameId = null;
var oNewFrame = g_oSlides.selectSingleNode("slide/frame[@id=\""+sFrameId+"\"]");
if (oNewFrame != null)
{
var oNewSlide = oNewFrame.parentNode;
if (oNewSlide.getAttribute("id") == g_oSlide.getAttribute("id"))
OpenFrame(oNewFrame, false);
else
OpenSlide(oNewSlide, sFrameId);
}
}
return true
}
// ActionMediaPlay
function ActionMediaPlay(eltChild, dtBegin)
{
var sPlay = eltChild.getAttribute("play");
if (sPlay == "1")
{
var sSoundSrc = eltChild.getAttribute("src");
var sSoundId = null;
if (sSoundSrc == "")
{
var sTargetId = eltChild.getAttribute("pid");
var oObject = GetObjectById(sTargetId);
if (oObject != null)
{
sSoundSrc = oObject.getAttribute("soundsrc");
sSoundId = sTargetId;
}
}
if (sSoundSrc != null && sSoundSrc != "")
PlaySound(sSoundSrc, sSoundId);
}
else
{
if (g_bSoundOn)
{
StopSound();
}
}
return true;
}
// ActionRotate
function ActionRotate(eltChild, dtBegin)
{
var sTargetId = eltChild.getAttribute("pid");
var oTarget = document.getElementById(sTargetId);
if (oTarget != null)
{
//!!!var nStartAngle = parseInt(oTarget.style.left);
var nStartAngle = 0;
var nEndAngle = eltChild.getAttribute("angle");
try
{
nEndAngle = ReplacePropertiesInStr(nEndAngle);
nEndAngle = ReplaceVariablesInStr(nEndAngle);
}
catch(e) { return false; }
nEndAngle = parseInt(nEndAngle);
if (isNaN(nEndAngle))
nEndAngle = 0;
//var nSmooth = eltChild.getAttribute("smooth");
// if (parseInt(nSmooth) == 0)
// {
// oTarget.style.left = nEndX + "px";
// oTarget.style.top = nEndY + "px";
// }
// else
{
var nDur = eltChild.getAttribute("dur");
var x = oTarget.style.left;
var y = oTarget.style.top;
var w = oTarget.style.width;
var h = oTarget.style.height;
var nBeginTime = dtBegin.valueOf();
//var nEndTime = nBeginTime + nDistance / parseInt(nSpeed) * 10;
var nEndTime = nBeginTime + parseFloat(nDur);
var oTimeAction = new TimeActionRotate(sTargetId, nBeginTime, nEndTime, nStartAngle, nEndAngle, x, y, w, h);
oTimeAction.pNext = g_pTimeActions;
g_pTimeActions = oTimeAction;
if (oTimeAction.pNext == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
}
return true;
}
// ActionCancelRotate
function ActionCancelRotate(eltChild, dtBegin)
{
var sTargetId = eltChild.getAttribute("pid");
var sAll = eltChild.getAttribute("all");
var bAll = (sAll == "1" ? true : false);
var oTarget = document.getElementById(sTargetId);
if (oTarget != null)
{
var nTime = dtBegin.valueOf();
var oTimeAction = new TimeActionCancelRotate(sTargetId, bAll, nTime);
oTimeAction.pNext = g_pTimeActions;
g_pTimeActions = oTimeAction;
if (oTimeAction.pNext == null)
g_nTimeoutId = setTimeout(TimerFunction, GetResolution());
}
return true;
}
// ActionNavigation
function ActionNavigation(eltChild, dtBegin)
{
var sTargets = eltChild.getAttribute("targets");
var sAction = eltChild.getAttribute("action");
var oArg = new Object;
oArg.sTargets = sTargets;
oArg.sAction = sAction;
HandleEvt("EVENT_NAVIGATION", oArg);
return true;
}
// ActionSetScore
function ActionSetScore(eltChild, dtBegin)
{
var sObjectiveId = eltChild.getAttribute("pid");
var sSourceId = eltChild.getAttribute("oid");
var sAdditive = eltChild.getAttribute("additive");
var sScore = eltChild.getAttribute("score");
try
{
sSourceId = ReplacePropertiesInStr(sSourceId);
sSourceId = ReplaceVariablesInStr(sSourceId);
sScore = ReplacePropertiesInStr(sScore);
sScore = ReplaceVariablesInStr(sScore);
}
catch(e) { return false; }
var nScore = parseFloat(sScore);
if(isNaN(nScore)) return false;
SetObjectiveScore(sObjectiveId, sSourceId, sAdditive, sScore);
return true;
}
// ActionSetCompletionStatus
function ActionSetCompletionStatus(eltChild, dtBegin)
{
var sObjectiveId = eltChild.getAttribute("pid");
var sStatus = eltChild.getAttribute("status");
SetObjectiveCompletionStatus(sObjectiveId, sStatus);
return true;
}
// ActionSetSuccessStatus
function ActionSetSuccessStatus(eltChild, dtBegin)
{
var sObjectiveId = eltChild.getAttribute("pid");
var sStatus = eltChild.getAttribute("status");
SetObjectiveSuccessStatus(sObjectiveId, sStatus);
return true;
}
// ActionIfSuccessStatus
function ActionIfSuccessStatus(eltChild, dtBegin)
{
var sObjectiveId = eltChild.getAttribute("pid");
var sStatus = eltChild.getAttribute("status");
var sCurrentStatus = GetObjectiveSuccessStatus(sObjectiveId, sStatus);
if (sCurrentStatus == sStatus)
{
ProcessActions(eltChild, false);
}
else
{
var oElse = eltChild.selectSingleNode("ACTION/ELSE");
if (oElse != null)
ProcessActions(oElse, false);
}
return true;
}
// ActionFor
function ActionFor(eltChild, dtBegin)
{
var sFrom = eltChild.getAttribute("from");
var sTo = eltChild.getAttribute("to");
var sStep = eltChild.getAttribute("step");
try
{
sFrom = ReplacePropertiesInStr(sFrom);
sFrom = ReplaceVariablesInStr(sFrom);
sTo = ReplacePropertiesInStr(sTo);
sTo = ReplaceVariablesInStr(sTo);
sStep = ReplacePropertiesInStr(sStep);
sStep = ReplaceVariablesInStr(sStep);
}
catch(e) {}
var nFrom = parseInt(sFrom);
var nTo = parseInt(sTo);
var nStep = parseInt(sStep);
if(isNaN(nFrom) || isNaN(nTo) || isNaN(nStep)) return false;
for (var i = nFrom; i <= nTo; i += nStep)
ProcessActions(eltChild, false);
return true;
}
// ActionTimer
function ActionTimer(eltChild, dtBegin)
{
var oActions = eltChild.selectNodes("ACTION");
if (oActions.length > 0)
{
var nMil = eltChild.getAttribute("mil");
var oTimeAction = new TimeActionAction(
dtBegin.valueOf() + parseInt(nMil), oActions, 0);
oTimeAction.pNext = g_pTimeActions;
g_pTimeActions = oTimeAction;
}
return true;
}
// ProcessAction
function ProcessAction(oActions, nIndex, bSequentially)
{
var dtBegin = new Date;
var bContinue = true;
var oAction = oActions[nIndex];
var oChilds = oAction.childNodes;
for (var j = 0; j < oChilds.length; j++)
{
var eltChild = oChilds[j];
if (eltChild.nodeType == 1)
{
var sTagName = eltChild.tagName;
switch (sTagName)
{
case "DISPLAY":
bContinue = ActionDisplay(eltChild, dtBegin);
break;
case "MSGBOX":
bContinue = ActionMsgBox(eltChild, dtBegin);
break;
case "VARIABLE":
bContinue = ActionVariable(eltChild, dtBegin);
break;
case "IF":
bContinue = ActionIf(eltChild, dtBegin);
break;
case "ELSE":
bContinue = ActionElse(eltChild, dtBegin);
break;
case "BEGIN_ASYNC":
bContinue = ActionBeginAsync(eltChild, dtBegin);
break;
case "WAIT":
bContinue = ActionWait(eltChild, nIndex, oActions, dtBegin);
break;
case "MOVE":
bContinue = ActionMove(eltChild, dtBegin);
break;
case "CANCELMOVE":
bContinue = ActionCancelMove(eltChild, dtBegin);
break;
case "GOTO":
bContinue = ActionGoto(eltChild, dtBegin);
break;
case "METHOD":
bContinue = ActionMethod(eltChild, dtBegin);
break;
case "CHECKHIT":
bContinue = ActionCheckHit(eltChild, dtBegin);
break;
case "JAVASCRIPT":
bContinue = ActionJavaScript(eltChild, dtBegin);
break;
case "JUMP":
bContinue = ActionJump(eltChild, dtBegin);
break;
case "GOSUB":
bContinue = ActionGosub(eltChild, dtBegin);
break;
case "RETURN":
bContinue = ActionReturn(eltChild, dtBegin);
break;
case "MEDIAPLAY":
bContinue = ActionMediaPlay(eltChild, dtBegin);
break;
case "ROTATE":
bContinue = ActionRotate(eltChild, dtBegin);
break;
case "CANCELROTATE":
bContinue = ActionCancelRotate(eltChild, dtBegin);
break;
case "NAVIGATION":
bContinue = ActionNavigation(eltChild, dtBegin);
break;
case "SET_SCORE":
bContinue = ActionSetScore(eltChild, dtBegin);
break;
case "SET_COMPLETION_STATUS":
bContinue = ActionSetCompletionStatus(eltChild, dtBegin);
break;
case "SET_SUCCESS_STATUS":
bContinue = ActionSetSuccessStatus(eltChild, dtBegin);
break;
case "IF_SUCCESS_STATUS":
bContinue = ActionIfSuccessStatus(eltChild, dtBegin);
break;
case "FOR":
bContinue = ActionFor(eltChild, dtBegin);
break;
case "TIMER":
bContinue = ActionTimer(eltChild, dtBegin);
break;
case "PRINT":
bContinue = ActionPrint();
break;
default:
alert("?Action: " + sTagName);
}
}
if (!bContinue)
break;
}
return bContinue;
}
// CloseObject
function CloseObject(sTargetId)
{
var oTarget = document.getElementById(sTargetId);
if (oTarget != null)
{
oTarget.style.display = "none";
if (g_bSoundOn == true && g_sSoundId != null)
{
if (g_sSoundId == sTargetId)
StopSound();
}
}
}
// OpenSlideById
function OpenSlideById(sSlideId)
{
var oNewSlide = g_oSlides.selectSingleNode("slide[@id=\""+sSlideId+"\"]");
if (oNewSlide != null)
OpenSlide(oNewSlide, null);
}
// HandleEvt
function HandleEvt(sEvt, oArg)
{
// // Remove 'dead' event handlers
// var oEvtHandler = g_pEvtHandlers;
// g_pEvtHandlers = null;
//
// while (oEvtHandler != null)
// {
// var pNext = oEvtHandler.pNext;
//
// var oElement = document.getElementById(oEvtHandler.sTargetId);
// if (oElement != null)
// {
// oEvtHandler.pNext = g_pEvtHandlers;
// g_pEvtHandlers = oEvtHandler;
// }
//
// oEvtHandler = pNext;
// }
try
{
var oEvtHandler = g_pEvtHandlers;
var oFirstEvtHandler = null;
var oLastEvtHandler = oEvtHandler;
while (oEvtHandler != null)
{
var oElement = document.getElementById(oEvtHandler.sTargetId);
if (oElement == null)
oLastEvtHandler.pNext = oEvtHandler.pNext;
else
{
oLastEvtHandler = oEvtHandler;
if (oFirstEvtHandler == null)
oFirstEvtHandler = oEvtHandler;
}
oEvtHandler = oEvtHandler.pNext;
}
g_pEvtHandlers = oFirstEvtHandler;
// Call event handlers
oEvtHandler = g_pEvtHandlers;
while (oEvtHandler != null)
{
if (oEvtHandler.sEvt == sEvt)
{
var oMethod = g_oMethods.selectSingleNode("method[@type=\""+ oEvtHandler.sType +"\" and @name=\"HandleEvt\"]");
var sText = oMethod.text;
var nBegin = sText.indexOf("{");
var nEnd = sText.lastIndexOf("}");
var sBody = sText.substring(nBegin + 1, nEnd);
try
{
var oFunction = new Function("oEvtHandler, oArg", sBody);
oFunction(oEvtHandler, oArg);
}
catch (e)
{
alert("HandleEvt: " + e.description);
}
}
oEvtHandler = oEvtHandler.pNext;
}
}
catch (e)
{
alert("HandleEvt: " + e.description);
}
}
// CheckBrowserType
function CheckBrowserType()
{
var sUserAgent = navigator.userAgent.toLowerCase();
if (sUserAgent.indexOf("msie") != -1)
g_isMSIE = true;
else if (sUserAgent.indexOf("gecko")!=-1)
g_isFireFox = true;
if (sUserAgent.indexOf("opera")!=-1)
{
g_isOpera = true;
g_isFireFox = true;
}
}
// _Node_getXML
function _Node_getXML()
{
var objXMLSerializer = new XMLSerializer;
var strXML = objXMLSerializer.serializeToString(this);
return strXML;
}
// UpdateFireFoxDOM
function UpdateFireFoxDOM()
{
// selectNodes
if (document.implementation.hasFeature("XPath", "3.0"))
{
XMLDocument.prototype.selectNodes =
function (cXPathString, xNode)
{
if (!xNode)
xNode = this;
var oNSResolver = this.createNSResolver(this.documentElement)
var aItems = this.evaluate(cXPathString, xNode, oNSResolver,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
var aResult = [];
for (var i = 0; i < aItems.snapshotLength; i++)
aResult[i] = aItems.snapshotItem(i);
return aResult;
}
Element.prototype.selectNodes =
function (cXPathString)
{
if (this.ownerDocument.selectNodes)
return this.ownerDocument.selectNodes(cXPathString, this);
else
throw "For XML Elements Only";
}
}
// selectSingleNode
if (document.implementation.hasFeature("XPath", "3.0"))
{
// prototyping the XMLDocument
XMLDocument.prototype.selectSingleNode =
function (cXPathString, xNode)
{
if (!xNode)
xNode = this;
var xItems = this.selectNodes(cXPathString, xNode);
if (xItems.length > 0)
return xItems[0];
else
return null;
}
// prototyping the Element
Element.prototype.selectSingleNode =
function (cXPathString)
{
if (this.ownerDocument.selectSingleNode)
return this.ownerDocument.selectSingleNode(cXPathString, this);
else
throw "For XML Elements Only";
}
}
// loadXML
Document.prototype.loadXML =
function (sXML)
{
var objDOMParser = new DOMParser();
var objDoc = objDOMParser.parseFromString(sXML, "text/xml");
while (this.hasChildNodes())
this.removeChild(this.lastChild);
for (var i=0; i < objDoc.childNodes.length; i++)
{
var objImportedNode = this.importNode(objDoc.childNodes[i], true);
this.appendChild(objImportedNode);
}
}
Node.prototype.__defineGetter__("xml",
function()
{
var oXMLSerializer = new XMLSerializer;
var sXML = oXMLSerializer.serializeToString(this);
return sXML;
});
// text
Node.prototype.__defineGetter__("text",
function()
{
var sText = "";
var oText = this.firstChild;
while (oText != null)
{
if (oText.nodeType == 3 || oText.nodeType == 4)
sText += oText.nodeValue;
oText = oText.nextSibling;
}
return sText;
});
g_nFirst = 1;
}
// DetermineMSXMLProgID
function DetermineMSXMLProgID()
{
var oDoc;
var sProgID;
for (var i = 6; i >= 3; i--)
{
try
{
sProgID = "MSXML2.DOMDocument."+ i +".0";
oDoc = new ActiveXObject(sProgID);
}
catch (e)
{
}
if (oDoc != undefined)
{
g_sMSXMLProgID = sProgID;
g_nFirst = (i <= 3 ? 0 : 1);
break;
}
}
}
// DetermineMSXMLHTTPProgID
function DetermineMSXMLHTTPProgID()
{
var oDoc;
var sProgID;
for (var i = 6; i >= 3; i--)
{
try
{
sProgID = "MSXML2.XMLHTTP."+ i +".0";
oDoc = new ActiveXObject(sProgID);
}
catch (e)
{
}
if (oDoc != undefined)
{
g_sMSXMLHTTPProgID = sProgID;
break;
}
}
}
// CreateDOMDocument
function CreateDOMDocument()
{
var oDoc;
if (g_isMSIE)
{
oDoc = new ActiveXObject(g_sMSXMLProgID);
}
else if (g_isFireFox)
{
oDoc = document.implementation.createDocument("", "doc", null);
}
return oDoc;
}
// CreateXMLHTTP
function CreateXMLHTTP()
{
var oXmlHttp;
if (g_isMSIE)
{
oXmlHttp = new ActiveXObject(g_sMSXMLHTTPProgID);
}
else if (g_isFireFox)
{
//alert(window.XMLHttpRequest);
oXmlHttp = new XMLHttpRequest();
}
return oXmlHttp;
}
// LoadSplash
function LoadSplash()
{
var oDoc = CreateDOMDocument();
var bLoaded = false;
if (g_isMSIE)
{
oDoc.async = false;
bLoaded = oDoc.load("splash.xml");
}
else if (g_isFireFox)
{
var sWindowLocation = window.location;
sWindowLocation = sWindowLocation.toString();
sWindowLocation = sWindowLocation.toLowerCase()
if (sWindowLocation.indexOf("http:") != -1)
{
var oRequest = new XMLHttpRequest();
oRequest.open('GET', 'splash.xml', false);
oRequest.send(null);
if (oRequest.status == 200)
{
var sResponseText = oRequest.responseText;
var objDOMParser = new DOMParser();
var objDoc = objDOMParser.parseFromString(sResponseText, "text/xml");
oDoc = objDoc;
bLoaded = true;
}
}
else
{
oDoc.async = false;
bLoaded = oDoc.load("splash.xml");
}
}
if (bLoaded)
{
var oSplash = oDoc.selectSingleNode("splash");
var oSettings = oSplash.selectSingleNode("settings");
var oShowSplash = oSettings.selectSingleNode("showsplash");
var sShowSplash = oShowSplash.text;
if (sShowSplash == "yes")
{
var oData = oSplash.selectSingleNode("data");
var sData = oData.text;
g_oBoardFrame.innerHTML = sData;
return true;
}
}
return false;
}
// StartModule
function StartModule(sSlideId, sFrameId)
{
g_oDoc = CreateDOMDocument();
var bLoaded = false;
if (g_isMSIE)
{
g_oDoc.async = false;
bLoaded = g_oDoc.load("runtime.xml");
}
else if (g_isFireFox)
{
var sWindowLocation = window.location;
sWindowLocation = sWindowLocation.toString();
sWindowLocation = sWindowLocation.toLowerCase()
if (sWindowLocation.indexOf("http:") != -1)
{
var oRequest = new XMLHttpRequest();
oRequest.open('GET', 'runtime.xml', false);
oRequest.send(null);
if (oRequest.status == 200)
{
var sResponseText = oRequest.responseText;
var objDOMParser = new DOMParser();
var objDoc = objDOMParser.parseFromString(sResponseText, "text/xml");
g_oDoc = objDoc;
bLoaded = true;
}
}
else
{
g_oDoc.async = false;
bLoaded = g_oDoc.load("runtime.xml");
}
}
if (bLoaded)
{
g_oModule = g_oDoc.selectSingleNode("module");
g_oSlides = g_oModule.selectSingleNode("slides");
g_oMasters = g_oModule.selectSingleNode("masters");
g_oGroups = g_oModule.selectSingleNode("groups");
g_oMethods = g_oModule.selectSingleNode("methods");
g_oParams = g_oModule.selectSingleNode("params");
{
var oRuntime = g_oModule.selectSingleNode("runtime");
var sSeqSlides = oRuntime.getAttribute("seqslides");
g_bStrictOrder = sSeqSlides == "yes" ? true : false;
var sPreloadImages = oRuntime.getAttribute("preloadimages");
g_bPreloadImages = sPreloadImages == "yes" ? true : false;
var sNormalize = oRuntime.getAttribute("normalize");
g_bNormalize = sNormalize == "yes" ? true : false;
}
//InsertWMPlayer();
//InsertSWPlayer();
//CreateAnnals();
CreateSCO();
var bLoaded = LMSLoadState();
if (bLoaded)
{
if (g_sLmsCmiSuspendData != null &&
g_sLmsCmiSuspendData != "")
{
g_oDocSCO.loadXML(g_sLmsCmiSuspendData);
g_oSCO = g_oDocSCO.selectSingleNode("//SCO");
}
}
ProcessRuntimeChecks();
InitModule();
var oSlide = null;
if (sSlideId != null)
oSlide = g_oSlides.selectSingleNode("slide[@id='"+sSlideId+"']");
if (oSlide == null)
{
if (g_sLmsCmiLocation != "")
oSlide = g_oSlides.selectSingleNode("slide[@id='"+g_sLmsCmiLocation+"']");
}
if (oSlide == null)
oSlide = g_oSlides.selectSingleNode("slide["+g_nFirst+"]");
g_oSlide = oSlide;
OpenSlide(oSlide, sFrameId);
}
}
// ImageOnReadyStateChange
function ImageOnReadyStateChange()
{
if (g_bPreloadingImages)
{
var nTotalImages = g_oImages.length;
var nImagesLoaded = nTotalImages;
var bAllLoaded = true;
for (var i = nTotalImages - 1; i >= 0; i--)
{
if (g_oImages[i].readyState != "complete")
{
nImagesLoaded--;
bAllLoaded = false;
//break;
}
}
if (nTotalImages != 0)
{
var oSpan = document.getElementById("LoadingPercent");
if (oSpan != null)
{
var flRatio = parseInt(nImagesLoaded) / parseInt(nTotalImages);
var nPercent = parseInt(parseFloat(flRatio) * 100);
var s = nPercent + "%";
oSpan.innerText = s;
}
}
if (bAllLoaded == true)
{
g_bPreloadingImages = false;
var oDiv = document.getElementById("DivLoadingImages");
if (oDiv != null)
oDiv.parentNode.removeChild(oDiv);
OpenSlide(g_oSlide, g_sSlideFrameId, true);//!!!
}
else
{
//setTimeout("UpdatePreloadingPercent("+nTotalImages+","+nImagesLoaded+")", 100);
}
}
}
// CancelPreload
function CancelPreload()
{
g_bPreloadingImages = false;
var oDiv = document.getElementById("DivLoadingImages");
if (oDiv != null)
oDiv.parentNode.removeChild(oDiv);
OpenSlide(g_oSlide, g_sSlideFrameId, true);//!!!
}
// PreloadImages
function PreloadImages()
{
g_oImages = new Array();
g_bPreloadingImages = false;
var nImages = 0;
var oDiv = document.createElement("div");
var oFrames = g_oSlide.selectNodes("frame");
for (var j = 0; j < oFrames.length; j++)
{
var oFrame = oFrames[j];
var oObjects = oFrame.selectNodes("object");
for (var k = 0; k < oObjects.length; k++)
{
var oObject = oObjects[k];
var oData = oObject.selectSingleNode("data");
if (oData == null)
{
if (g_isMSIE)
oData = oObject.selectSingleNode("iedata");
else if (g_isFireFox)
oData = oObject.selectSingleNode("firefoxdata");
}
var sText = oData.text;
//oDiv.style.display = (g_isMSIE ? "inline" : "block");
oDiv.innerHTML = sText;
// Img src
var oImages = oDiv.getElementsByTagName("img");
for (var l = 0; l < oImages.length; l++)
{
var oImage = oImages[l];
var sSrc = oImage.src;
if (sSrc != "")
{
var bFound = false;
for (var m = 0; m < nImages; m++)
{
if (g_oImages[m].src == sSrc)
{
bFound = true;
break;
}
}
if (bFound != true)
{
g_oImages[nImages] = new Image();
g_oImages[nImages].onreadystatechange = ImageOnReadyStateChange;
g_oImages[nImages].src = sSrc;
nImages++;
}
}
}
// Td background
var oTds = oDiv.getElementsByTagName("td");
for (var l = 0; l < oTds.length; l++)
{
var oTd = oTds[l];
var sBackground = oTd.background;
if (sBackground != "")
{
var bFound = false;
for (var m = 0; m < nImages; m++)
{
if (g_oImages[m].src == sBackground)
{
bFound = true;
break;
}
}
if (bFound != true)
{
g_oImages[nImages] = new Image();
g_oImages[nImages].onreadystatechange = ImageOnReadyStateChange;
g_oImages[nImages].src = sBackground;
nImages++;
}
}
}
}
}
if (parseInt(nImages) > 0)
{
g_bPreloadingImages = true;
setTimeout(ImageOnReadyStateChange, 10);
}
else
{
g_bPreloadingImages = false;
var oDiv = document.getElementById("DivLoadingImages");
if (oDiv != null)
oDiv.parentNode.removeChild(oDiv);
OpenSlide(g_oSlide, g_sSlideFrameId, true);
}
}
// DragBegin
function DragBegin(oElement, oEvent)
{
g_bDragOn = true;
if (g_isMSIE)
{
oElement.setCapture(true);
}
else
{
if (window.Event)
{
window.captureEvents(Event.MOUSEMOVE);
window.captureEvents(Event.MOUSEOVER);
window.captureEvents(Event.MOUSEOUT);
// window.onmousedown = doItemMove;
// window.onmousemove = getItemXY;
// window.onmouseup = endItemMove;
}
}
g_nOffsetX = oEvent.clientX - parseInt(oElement.style.left);
g_nOffsetY = oEvent.clientY - parseInt(oElement.style.top);
}
// DragEnd
function DragEnd(oElement, oEvent)
{
if (g_bDragOn)
{
g_bDragOn = false;
g_oDragObject = oElement;
if (g_isMSIE)
{
oElement.releaseCapture();
}
else
{
if (window.Event)
{
window.releaseEvents(Event.MOUSEMOVE);
window.releaseEvents(Event.MOUSEOVER);
window.releaseEvents(Event.MOUSEOUT);
}
}
GetDropTarget(oEvent.clientX, oEvent.clientY, oElement.id);
HandleEvt("EVENT_DRAG_END", null);
if (g_oDragTarget != null)
{
var sTargetId = g_oDragTarget.getAttribute("id");
var oTarget = g_oSlides.selectSingleNode("slide/frame/object[@id='"+ sTargetId +"']");
if (oTarget != null)
{
var sResponseId = oTarget.getAttribute("ondrop");
if (sResponseId != null)
{
processEvent(sResponseId);
}
}
}
g_oDragObject = null;
g_oDragTarget = null;
g_oDHTMLDragTarget = null;
}
}
// DragMove
function DragMove(oElement, oEvent)
{
if (g_bDragOn)
{
oElement.style.left = oEvent.clientX - g_nOffsetX;
oElement.style.top = oEvent.clientY - g_nOffsetY;
}
}
// GetDropTarget
function GetDropTarget(x, y, id)
{
var oChildren = g_oBoardFrame.childNodes;
for (var i = oChildren.length - 1; i >= 0; i--)
{
var oChild = oChildren[i];
if (oChild.id != id)
{
var oStyle = oChild.style;
if (oStyle.display != "none")
{
if (parseInt(oStyle.left) <= x && parseInt(oStyle.left) + parseInt(oStyle.width) > x &&
parseInt(oStyle.top) <= y && parseInt(oStyle.top) + parseInt(oStyle.height) > y)
{
//alert(oChild.id + " " + oStyle.display);
g_oDragTarget = oChild;
g_oDHTMLDragTarget = GetChildOfDropTarget(g_oDragTarget, x, y, id);
//alert(g_oDHTMLDragTarget.id);
return;
}
}
}
}
}
// GetChildOfDropTarget
function GetChildOfDropTarget(oParent, x, y, id)
{
var oElement = oParent;
var oChildren = oParent.childNodes;
for (var i = oChildren.length - 1; i >= 0; i--)
{
var oChild = oChildren[i];
if (oChild.id != id)
{
var oStyle = oChild.style;
if ((typeof(oStyle) == "undefined") ||
(typeof(oStyle) != "undefined" && oStyle.display != "none"))
{
var offsetTop = oChild.offsetTop;
var offsetParent = oChild.offsetParent;
while (offsetParent != null)
{
offsetTop += offsetParent.offsetTop;
offsetParent = offsetParent.offsetParent;
}
var offsetLeft = oChild.offsetLeft;
offsetParent = oChild.offsetParent;
while (offsetParent != null)
{
offsetLeft += offsetParent.offsetLeft;
offsetParent = offsetParent.offsetParent;
}
if (parseInt(offsetLeft) <= x && parseInt(offsetLeft) + parseInt(oChild.offsetWidth) > x &&
parseInt(offsetTop) <= y && parseInt(offsetTop) + parseInt(oChild.offsetHeight) > y)
{
oElement = GetChildOfDropTarget(oChild, x, y, id);
break;
}
}
}
}
return oElement;
}
// BoardAppendHTML
function BoardAppendHTML(s)
{
if (g_isMSIE)
g_oBoardFrame.insertAdjacentHTML("beforeEnd", s);
else if (g_isFireFox)
g_oBoardFrame.innerHTML += s;
}
// DebugAppendHTML
function DebugAppendHTML(s)
{
var oDebugFrame = document.getElementById("boardDebug");
if (oDebugFrame)
{
if (g_isMSIE)
oDebugFrame.insertAdjacentHTML("beforeEnd", s);
else if (g_isFireFox)
oDebugFrame.innerHTML += s;
}
}
// InsertWMPlayer
function InsertWMPlayer()
{
if (g_isMSIE)
{
var s = "";
s += "";
g_oBoardFrame.insertAdjacentHTML("afterEnd", s);
}
else
{
//!!!!!!
}
}
// InsertSWPlayer
function InsertSWPlayer()
{
if (g_isMSIE)
{
var s = "";
s += "";
g_oBoardFrame.insertAdjacentHTML("afterEnd", s);
}
else
{
//!!!!!!
}
}
// CreateSCO
function CreateSCO()
{
oDoc = CreateDOMDocument();
var oSCO = oDoc.createElement("SCO");
if (g_isMSIE)
oDoc.appendChild(oSCO);
else if (g_isFireFox)
oDoc.documentElement.appendChild(oSCO);
var oVisits = oDoc.createElement("visits");
oSCO.appendChild(oVisits);
var oObjects = oDoc.createElement("objects");
oSCO.appendChild(oObjects);
var oObjectives = oDoc.createElement("objectives");
oSCO.appendChild(oObjectives);
var oInteractions = oDoc.createElement("interactions");
oSCO.appendChild(oInteractions);
// Create objectives
var oModuleObjectives = g_oModule.selectSingleNode("objectives");
if (oModuleObjectives != null)
{
oModuleObjectives = oModuleObjectives.selectNodes("objective");
for (var i = 0; i < oModuleObjectives.length; i++)
{
var oModuleObjective = oModuleObjectives[i];
var oObjective = oDoc.createElement("o");
oObjectives.appendChild(oObjective);
var s;
s = oModuleObjective.getAttribute("id");
oObjective.setAttribute("id", s);
s = oModuleObjective.getAttribute("name");
oObjective.setAttribute("desc", s);
s = oModuleObjective.getAttribute("module");
if (s == "yes")
oObjective.setAttribute("module", "yes");
s = oModuleObjective.getAttribute("cs");
if (s == null)
s = "n";
oObjective.setAttribute("cs", s);
s = oModuleObjective.getAttribute("ss");
if (s == null)
s = "u";
oObjective.setAttribute("ss", s);
s = oModuleObjective.getAttribute("scoremax");
oObjective.setAttribute("max", s);
s = oModuleObjective.getAttribute("scoremin");
oObjective.setAttribute("min", s);
oObjective.setAttribute("raw", "0");
oObjective.setAttribute("scaled", "0");
}
}
g_oDocSCO = oDoc;
g_oSCO = oSCO;
}
// SetObjectiveCompletionStatus
function SetObjectiveCompletionStatus(sObjectiveId, sStatus)
{
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjectiveId +"']");
if (oObjective != null)
{
if (oObjective.getAttribute("cs") != sStatus)
{
oObjective.setAttribute("cs", sStatus);
SCOApplyRules();
}
}
}
// SetObjectiveSuccessStatus
function SetObjectiveSuccessStatus(sObjectiveId, sStatus)
{
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjectiveId +"']");
if (oObjective != null)
{
if (oObjective.getAttribute("ss") != sStatus)
{
oObjective.setAttribute("ss", sStatus);
SCOApplyRules();
}
}
}
// GetObjectiveSuccessStatus
function GetObjectiveSuccessStatus(sObjectiveId)
{
var s = "";
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjectiveId +"']");
if (oObjective != null)
s = oObjective.getAttribute("ss");
return s;
}
// SetObjectiveScore
function SetObjectiveScore(sObjectiveId, sSourceId, sAdditive, sScore)
{
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjectiveId +"']");
if (oObjective != null)
{
SCOSetSourceScore(oObjective, sSourceId, sAdditive, sScore);
SCORollupObjectiveScore(oObjective);
SCOUpdateObjectiveScaled(oObjective);
SCOApplyObjectiveRules(oObjective);
}
}
// GetObjectiveSourceScore
function GetObjectiveSourceScore(sObjectiveId, sSourceId)
{
var sScore = "";
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjectiveId +"']");
if (oObjective != null)
{
var oSource = oObjective.selectSingleNode("s[@id='"+ sSourceId +"']");
if (oSource != null)
sScore = oSource.getAttribute("raw");
}
return sScore;
}
// GetObjectiveScore
function GetObjectiveScore(sObjectiveId)
{
var sScore = "";
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjectiveId +"']");
if (oObjective != null)
sScore = oObjective.getAttribute("raw");
return sScore;
}
// GetObjective
function GetObjective(sObjectiveId)
{
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjectiveId +"']");
return oObjective;
}
// SCOSetSourceScore
function SCOSetSourceScore(oObjective, sSourceId, sAdditive, sScore)
{
var bCreated = false;
var oSource = oObjective.selectSingleNode("s[@id='"+ sSourceId +"']");
if (oSource == null)
{
oSource = g_oDocSCO.createElement("s");
oObjective.appendChild(oSource);
oSource.setAttribute("id", sSourceId);
oSource.setAttribute("raw", "0");
bCreated = true;
}
switch (sAdditive)
{
case "sum":
var sOldScore = oSource.getAttribute("raw");
var sNewScore = parseInt(sOldScore) + parseInt(sScore);
oSource.setAttribute("raw", sNewScore);
break;
case "replace":
oSource.setAttribute("raw", sScore);
break;
}
return bCreated;
}
// SCOCheckCondition
function SCOCheckCondition(oCondition)
{
var bSuccess = false;
try
{
var sType = oCondition.getAttribute("type");
switch (sType)
{
case "group":
{
var oChildConditions = oCondition.selectNodes("condition");
for (var i = 0; i < oChildConditions.length; i++)
{
var oChildCondition = oChildConditions[i];
var bChildSuccess = SCOCheckCondition(oChildCondition);
if (i == 0)
bSuccess = bChildSuccess;
else
{
var sOp = oChildCondition.getAttribute("op");
switch (sOp)
{
case "and":
bSuccess = bSuccess && bChildSuccess;
break;
case "or":
bSuccess = bSuccess || bChildSuccess;
break;
case "andnot":
bSuccess = bSuccess && !bChildSuccess;
break;
case "ornot":
bSuccess = bSuccess || !bChildSuccess;
break;
}
}
}
break;
}
case "visited":
{
var sConditionVisits = oCondition.getAttribute("visits");
var nConditionVisitsLen = sConditionVisits.length;
if (nConditionVisitsLen > 0)
{
var sSCOVisits = "";
var oVisits = g_oSCO.selectSingleNode("visits");
if (g_isFireFox)
{
// var oText = oVisits.childNodes[1];
var oText = oVisits.childNodes[0];
if (oText != null)
sSCOVisits = oText.nodeValue;
}
else if (g_isMSIE)
{
sSCOVisits = oVisits.text;
}
var nSCOVisitsLen = sSCOVisits.length;
var bAllVisited = true;
for (var i = 0; i < nConditionVisitsLen; i += 2)
{
var sConditionVisit = sConditionVisits.substr(i, 2);
var bVisited = false;
for (var j = 0; j < nSCOVisitsLen; j += 2)
{
var sSCOVisit = sSCOVisits.substr(j, 2);
if (sSCOVisit == sConditionVisit)
{
bVisited = true;
break;
}
}
if (!bVisited)
{
bAllVisited = false;
break;
}
}
if (bAllVisited)
bSuccess = true;
}
break;
}
case "score":
{
var sObjective = oCondition.getAttribute("objective");
var sComp = oCondition.getAttribute("comp");
var sScore = oCondition.getAttribute("score");
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjective +"']");
if (oObjective != null)
{
var sObjectiveRaw = oObjective.getAttribute("raw");
switch (sComp)
{
case "lt":
if (parseInt(sObjectiveRaw) < parseInt(sScore))
bSuccess = true;
break;
case "gt":
if (parseInt(sObjectiveRaw) > parseInt(sScore))
bSuccess = true;
break;
case "eq":
if (parseInt(sObjectiveRaw) == parseInt(sScore))
bSuccess = true;
break;
case "le":
if (parseInt(sObjectiveRaw) <= parseInt(sScore))
bSuccess = true;
break;
case "ge":
if (parseInt(sObjectiveRaw) >= parseInt(sScore))
bSuccess = true;
break;
case "ne":
if (parseInt(sObjectiveRaw) != parseInt(sScore))
bSuccess = true;
break;
}
}
break;
}
case "success":
{
var sObjective = oCondition.getAttribute("objective");
var sSS = oCondition.getAttribute("ss");
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjective +"']");
if (oObjective != null)
{
var sObjectiveSS = oObjective.getAttribute("ss");
if (sSS == sObjectiveSS)
bSuccess = true;
}
break;
}
case "completion":
{
var sObjective = oCondition.getAttribute("objective");
var sCS = oCondition.getAttribute("cs");
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjective +"']");
if (oObjective != null)
{
var sObjectiveCS = oObjective.getAttribute("cs");
if (sCS == sObjectiveCS)
bSuccess = true;
}
break;
}
}
}
catch (e)
{
alert("SCOCheckCondition: " + e.description);
}
return bSuccess;
}
// SCOApplyRules
function SCOApplyRules()
{
try
{
if(g_oModule!=null)
{
var oRules = g_oModule.selectNodes("rules/rule");
for (var i = 0; i < oRules.length; i++)
{
var oRule = oRules[i];
var sObjective = oRule.getAttribute("objective");
var oObjective = g_oSCO.selectSingleNode("objectives/o[@id='"+ sObjective +"']");
if (oObjective != null)
{
var sSS = oRule.getAttribute("ss");
var sCS = oRule.getAttribute("cs");
var bCheck = false;
if (sSS != null)
{
if (oObjective.getAttribute("ss") != sSS)
bCheck = true;
}
if (sCS != null)
{
if (oObjective.getAttribute("cs") != sCS)
bCheck = true;
}
if (bCheck)
{
var bSuccess = false;
var oChildConditions = oRule.selectNodes("condition");
for (var j = 0; j < oChildConditions.length; j++)
{
var oChildCondition = oChildConditions[j];
var bChildSuccess = SCOCheckCondition(oChildCondition);
if (j == 0)
bSuccess = bChildSuccess;
else
{
var sOp = oChildCondition.getAttribute("op");
switch (sOp)
{
case "and":
bSuccess = bSuccess && bChildSuccess;
break;
case "or":
bSuccess = bSuccess || bChildSuccess;
break;
case "andnot":
bSuccess = bSuccess && !bChildSuccess;
break;
case "ornot":
bSuccess = bSuccess || !bChildSuccess;
break;
}
}
}
if (bSuccess == true)
{
//alert(sObjective + " ok ");
if (sSS != null)
oObjective.setAttribute("ss", sSS);
if (sCS != null)
oObjective.setAttribute("cs", sCS);
}
}
}
}
}
}
catch (e)
{
alert("SCOApplyRules: " + e.description);
}
// var oModuleObjective = g_oSCO.selectSingleNode("objectives/o[@module='yes']");
// if (oModuleObjective != null)
// {
// var sModuleObjectiveId = oModuleObjective.getAttribute("id");
// var sModuleSS = "p";
// var sModuleCS = "c";
//
// var oObjectives = g_oSCO.selectNodes("objectives/o");
// for (var i = 0; i < oObjectives.length; i++)
// {
// var oObjective = oObjectives[i];
// if (oObjective.getAttribute("id") != sModuleObjectiveId)
// {
// var sObjectiveSS = oObjective.getAttribute("ss");
// var sObjectiveCS = oObjective.getAttribute("cs");
//
// if (sObjectiveSS != "p")
// sModuleSS = "f";
//
// if (sObjectiveCS != "c")
// sModuleCS = "i";
// }
// }
//
// oModuleObjective.setAttribute("ss", sModuleSS);
// oModuleObjective.setAttribute("cs", sModuleCS);
// }
}
// SCOApplyObjectiveRules
function SCOApplyObjectiveRules(oObjective)
{
// !!!
// var sMax = oObjective.getAttribute("max");
// var sRaw = oObjective.getAttribute("raw");
//
// if (parseInt(sRaw) >= parseInt(sMax))
// oObjective.setAttribute("ss", "p");
// else
// oObjective.setAttribute("ss", "f");
SCOApplyRules();
}
// SCORollupSCOScore
function SCORollupSCOScore()
{
var oObjectives = g_oSCO.selectNodes("objectives/o");
for (var i = 0; i < oObjectives.length; i++)
{
var oObjective = oObjectives[i];
SCORollupObjectiveScore(oObjective);
SCOUpdateObjectiveScaled(oObjective);
}
}
// SCORollupObjectiveScore
function SCORollupObjectiveScore(oObjective)
{
var nObjectiveRaw = 0;
var oSources = oObjective.selectNodes("s");
for (var i = 0; i < oSources.length; i++)
{
var oSource = oSources[i];
var sSourceRaw = oSource.getAttribute("raw");
nObjectiveRaw = nObjectiveRaw + parseInt(sSourceRaw);
}
oObjective.setAttribute("raw", nObjectiveRaw);
}
// SCOUpdateObjectiveScaled
function SCOUpdateObjectiveScaled(oObjective)
{
var sMax = oObjective.getAttribute("max");
var sMin = oObjective.getAttribute("min");
var sRaw = oObjective.getAttribute("raw");
var sScaled = "0";
if ((parseInt(sMax) - parseInt(sMin)) != 0)
sScaled = (parseInt(sRaw) - parseInt(sMin)) / (parseInt(sMax) - parseInt(sMin));
oObjective.setAttribute("scaled", sScaled);
}
// SCOAddSlideToVisits
function SCOAddSlideToVisits(oSlide)
{
var bVisited = SCOIsSlideVisited(oSlide);
if (bVisited == false)
{
var oVisits = g_oSCO.selectSingleNode("visits");
var sSid = oSlide.getAttribute("sid");
while (sSid.length < 2)
sSid = "0" + sSid;
if (g_isFireFox)
{
var sText = "";
var oText = oVisits.childNodes[0];
// var oText = oVisits.childNodes[1];
if (oText != null)
{
sText = oText.nodeValue;
}
else
{
oText = document.createTextNode(sSid);
oVisits.appendChild(oText);
}
sText += sSid;
oText.nodeValue = sText;
}
else if (g_isMSIE)
{
var sText = oVisits.text;
sText += sSid;
oVisits.text = sText;
}
}
}
// SCOIsSlideVisited
function SCOIsSlideVisited(oSlide)
{
var sSid = oSlide.getAttribute("sid");
while (sSid.length < 2)
sSid = "0" + sSid;
var oVisits = g_oSCO.selectSingleNode("visits");
var sText = "";
if (g_isFireFox)
{
var oText = oVisits.childNodes[0];
// var oText = oVisits.childNodes[1];
if (oText != null)
sText = oText.nodeValue;
}
else if (g_isMSIE)
{
sText = oVisits.text;
}
var bVisited = false;
var nTextLen = sText.length;
for (var i = 0; i < nTextLen; i += 2)
{
var s = sText.substr(i, 2);
if (s == sSid)
{
bVisited = true;
break;
}
}
return bVisited;
}
// SCOSetObjectProp
function SCOSetObjectProp(sObjectId, sName, sValue)
{
var oObjects = g_oSCO.selectSingleNode("objects");
var bCreated = false;
var oObject = oObjects.selectSingleNode("o[@id='"+ sObjectId +"']");
if (oObject == null)
{
oObject = g_oDocSCO.createElement("o");
oObjects.appendChild(oObject);
oObject.setAttribute("id", sObjectId);
bCreated = true;
}
oObject.setAttribute(sName, sValue);
return bCreated;
}
// SCOGetObjectProp
function SCOGetObjectProp(sObjectId, sName)
{
var sValue = null;
var oObjects = g_oSCO.selectSingleNode("objects");
var oObject = oObjects.selectSingleNode("o[@id='"+ sObjectId +"']");
if (oObject != null)
sValue = oObject.getAttribute(sName);
return sValue;
}
// GetInteraction
function GetInteraction(sInteractionId)
{
var oInteraction = g_oSCO.selectSingleNode("interactions/i[@id='"+ sInteractionId +"']");
return oInteraction;
}
// SCOSetInteraction
function SCOSetInteraction(sInteractionId, sInteractionType, arObjectives, arCorrectResponses,
sWeighting, sLearnerResponse, sResult, sDescription, bJournaling)
{
var oInteractions = g_oSCO.selectSingleNode("interactions");
if (oInteractions == null)
{
oInteractions = g_oDocSCO.createElement("interactions");
g_oSCO.appendChild(oInteractions);
}
if (!bJournaling)
{
for (;;)
{
var oInteraction = oInteractions.selectSingleNode("i[@id='"+ sInteractionId +"']");
if (oInteraction == null)
break;
oInteraction.parentNode.removeChild(oInteraction);
}
}
var oInteraction = g_oDocSCO.createElement("i");
oInteractions.appendChild(oInteraction);
oInteraction.setAttribute("id", sInteractionId);
oInteraction.setAttribute("t", sInteractionType);
// Objectives
var oObjectives = g_oDocSCO.createElement("oo");
oInteraction.appendChild(oObjectives);
for (var i = 0; i < arObjectives.length; i++)
{
var sObjectiveId = arObjectives[i];
var oObjective = g_oDocSCO.createElement("o");
oObjectives.appendChild(oObjective);
oObjective.setAttribute("id", sObjectiveId);
}
// CorrectResponses
var oCorrectResponses = g_oDocSCO.createElement("rr");
oInteraction.appendChild(oCorrectResponses);
for (var i = 0; i < arCorrectResponses.length; i++)
{
var sCorrectResponse = arCorrectResponses[i];
var oCorrectResponse = g_oDocSCO.createElement("r");
oCorrectResponses.appendChild(oCorrectResponse);
oCorrectResponse.setAttribute("p", sCorrectResponse);
}
oInteraction.setAttribute("w", sWeighting);
oInteraction.setAttribute("l", sLearnerResponse);
oInteraction.setAttribute("r", sResult);
oInteraction.setAttribute("d", sDescription);
}
// TranslateFSCommand
function TranslateFSCommand(command, args)
{
var sp = args.split("&");
var a = new Object;
var sObjType = "agent_001";
var sObjMethod = "Listener";
for (var i = 0; i < sp.length; i++)
{
var vv = sp[i].split("=");
if (vv.length != 2)
continue;
switch (vv[0])
{
case "objID":
a.pid = vv[1];
break;
case "action":
a.action = vv[1];
break;
case "event":
a.ev = vv[1];
break;
case "objtype":
sObjType = vv[1];
break;
case "objmethod":
sObjMethod = vv[1];
break;
}
}
CallMethod(sObjType, sObjMethod, a);
return true;
}
// FindSlidesByText
function FindSlidesByText(sText)
{
/*var sPattern = /(&)/g
sText = sText.replace(sPattern, "&");
sPattern = /(')/g
sText = sText.replace(sPattern, "'");*/
var nodesSlides = g_oModule.selectNodes("slides/slide[contains(frame/object/data, '"+ sText +"')]");
/*for (var i = 0; i < nodesSlides.length; i++)
{
var nodeSlide = nodesSlides[i];
var sSlideId = nodeSlide.getAttribute("id");
}*/
return nodesSlides;
}
// Run
function Run(bPreloadImages)
{
g_oBoardFrame = document.getElementById("boardFrame");
//g_bPreloadImages = bPreloadImages;
g_bPreloadImages = true;//!!!
CheckBrowserType();
if (g_isFireFox && !g_isOpera)
{
UpdateFireFoxDOM();
}
else if (g_isMSIE)
{
DetermineMSXMLProgID();
DetermineMSXMLHTTPProgID();
}
LMSInitialize();
var sSlideId = null;
var sFrameId = null;
if (typeof(oHTA) != "undefined")
{
var sCmdLine = oHTA.commandLine;
if (sCmdLine)
{
if (sCmdLine.indexOf("slideid") != -1)
{
var s = sCmdLine.substr(sCmdLine.indexOf("slideid") + 8);
sSlideId = s.substring(s.indexOf('"', 0) + 1, s.indexOf('"', 1));
if (sCmdLine.indexOf("frameid") != -1)
{
var s = sCmdLine.substr(sCmdLine.indexOf("frameid") + 8);
sFrameId = s.substring(s.indexOf('"', 0) + 1, s.indexOf('"', 1));
}
}
}
}
if (sSlideId == null)
{
var bShowSplash = LoadSplash();
if (bShowSplash == false)
StartModule(sSlideId, sFrameId);
}
else
StartModule(sSlideId, sFrameId);
}
// BeforeUnload
function BeforeUnload()
{
var tags = document.getElementsByTagName("object");
for (var i = tags.length - 1; i >= 0; i--)
{
try
{
tags[i].parentNode.removeChild(tags[i]);
}
catch(e)
{
}
}
}
// Shutdown
function Shutdown()
{
try
{
if (g_oDocSCO != null)
{
var sSlideId = "";
if (g_oSlide != null)
sSlideId = g_oSlide.getAttribute("id");
SCOApplyRules();
g_sLmsCmiLocation = sSlideId;
g_sLmsCmiExit = "suspend";
g_sLmsCmiSuspendData = g_oSCO.xml;
LMSSaveState();
}
}
catch (e)
{
}
LMSShutdown();
}