// JavaScript Document
var CHANGE_MIN_CHANGE = 1;
var CHANGE_MAX_CHANGE = 30;
//var CHANGE_MAX_CHANGE_QUICK = 60;
var CHANGE_MAX_CHANGE_QUICK = 0;
var CHANGE_DEFAULT_INTERVAL = 25;
var CHANGE_RATE_FACTOR = 3;
var gChangeMax = CHANGE_MAX_CHANGE;
var POLL_INTERVAL = 1000;
var PLAY_INTERVAL = 30000;
//var STYLE_LEFT_OFFSCREEN = "-5000px";
var STYLE_LEFT_OFFSCREEN = "-5000px";
var gMouseElem; // Stores the element that the mousr is over
var gStatusTimeoutObj = Object(); // Used as a string-addressed array
var gPlayContent = Object(); // Used to store the play status of content, 0=stopped, 1=playing
var gMouseInsideContent = Object(); // Used to know where the mouse is
var gLastContainerElemID; // Used to store the play status of content, 0=stopped, 1=playing
var gLastContentIndex = Object(); // Used to store the last content index in an array
var gLastContainerElemID; // Last container playing
var gActiveContentIndex = Object(); // Used to store the active content in an array
var gActiveContainerElemID; // Current container playing
var gNextContainerElemID; // Next container to play
var gNextContentIndex = Object(); // Used to store the next content index to play in an array indexed by containerID
var gResetContainerElemID; // reset this container's content
var TIMER_PLAY_INDEX = 0;
var TIMER_POLL_INDEX = 1;
var TIMER_MOVE_INDEX = 2;
var TOP_LEVEL_CONTAINER = "container";
var gPlayContainerStartIndex = Object(); // Containes the content index of the first content in each container
var gPlayContent = new Array(); // Stores all the content to be played
var gPlayContentIDToIndex = new Array(); // Stores the index for a particular content ID
var gPlayContentCount = 0; // Amount of content
var gPlayContentIndex = 0;
var gPlayContentPosition = 0; // Current active content
var gLastPlayContentPosition = 0;
var PLAY_CONTAINER_INDEX = 0;
var PLAY_PARENT_CONTENTID_INDEX = 1;
var PLAY_CONTENTID_INDEX = 2;
var PLAY_NEXT_INDEX = 3;
var PLAY_PREV_INDEX = 4;
var gMovingElement = 0; // Indicates if an element is being moved
var gMouseOverContent = 0; // Set if the mouse is over playing content
var gLastMouseOverContent = 0;
var gControlPlayStatus = "play"; // Status of pressed buttons for control
function controlPress(className) {
if(!document.getElementById('controlButtons')) return;
var elem;
switch(className) {
case('pause'):
elem = setImgSrc('controlPlayAndPause', '/Marketing/images/MVRZControlPlayDisabled.gif');
setInnerHtml('controlLabel', 'Paused');
gControlPlayStatus = elem.className = "play";
gMouseOverContent = 1;
break;
case('play'):
elem = setImgSrc('controlStop', '/Marketing/images/MVRZControlStop.gif');
if(gMouseOverContent) {
controlPress('pause');
} else {
elem = setImgSrc('controlPlayAndPause', '/Marketing/images/MVRZControlPause.gif');
setInnerHtml('controlLabel', 'Playing');
gControlPlayStatus = elem.className = "pause";
}
break;
case('stop'):
elem = setImgSrc('controlStop', '/Marketing/images/MVRZControlStopDisabled.gif');
elem = setImgSrc('controlPlayAndPause', '/Marketing/images/MVRZControlPlay.gif');
elem.className = "play";
setInnerHtml('controlLabel', 'Stopped');
gControlPlayStatus = "stop";
gMouseOverContent = 1;
//elem.className = "pause";
break;
default:
}
//debugAppend(gControlPlayStatus + " : ");
}
function mouseOverElement(ev) {
//var x, y;
var ev = ev || window.event;
if(!ev) return;
/* if(ev.pageX || ev.pageY){
x=ev.pageX;
y=ev.pageY;
} else {
x=ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y=ev.clientY + document.body.scrollTop - document.body.clientTop
}
*/
if (!(gMouseElem = (ev.target || ev.srcElement))) {
gMouseElem = "";
}
//debug('
+++++ 1 mouseOverElement('+x+','+y+')');
//test('hello test 1');
if(isMouseInsideElement('mainContent')) { // Update the controls
gMouseOverContent = 1;
if(gControlPlayStatus !== "stop") {
controlPress('pause');
addClass('tblContainer', 'hover');
} else {
removeClass('tblContainer', 'hover');
}
} else {
//debug('
removing Class');
//test('hello test 2');
removeClass('tblContainer', 'hover');
if(gControlPlayStatus !== "stop") {
controlPress('play');
gMouseOverContent = 0;
} else {
gMouseOverContent = 1;
}
}
//debug('
+++++ 2 mouseOverElement = '+gMouseOverContent);
}
function isMouseInsideElement(elemID) {
elem = document.getElementById(elemID);
if(!elem || !gMouseElem) return 0;
//debugAppend('
+++++isMouseInsideElement('+elemID+'), gMouseElem.id='+gMouseElem.id);
checkNode = gMouseElem;
do {
if(checkNode.id == elem.id) {
//debugAppend(' -- Yes');
return 1;
}
} while(checkNode=checkNode.parentNode);
//debugAppend(' -- No');
return 0;
}
function playContent(containerElemID, interval) {
//debugAppend('
1 playContent('+containerElemID+', '+interval+'), gLastContainerElemID='+gLastContainerElemID);
if(typeof containerElemID == "undefined") containerElemID = TOP_LEVEL_CONTAINER;
if(typeof interval == "undefined") interval = PLAY_INTERVAL;
// Build an array of the content for sequencing
buildContentArray(containerElemID);
gPlayContentPosition = 0; // At the start
//playLoop(interval);
schedulePlayLoop();
}
function buildContentArray(containerElemID, contentElemID) { // Constructs a linked list of content, recursive
//debugAppend('
buildContentArray('+containerElemID+')');
var i;
var containerElem = document.getElementById(containerElemID);
if(!containerElem) return 0;
// Find the content within this container
for(i=0; ibuildContentArray['+gPlayContentIndex+']::'+dumpArray(gPlayContent));
}
function getContainerNode(node) {
var i, ret;
ret = '';
//debugAppend(' (');
// Find the first container
for(i=0; i--stopContent('+containerElemID+'), gPlayContent['+index+']='+gPlayContent[index]);
}
function prevContent() {
gChangeMax = CHANGE_MAX_CHANGE;
advanceContent(-1);
}
function nextContent() {
gChangeMax = CHANGE_MAX_CHANGE;
advanceContent(1);
}
function showContent(group, id) {
contentID = 'container_content'+group+'_'+id;
index = gPlayContentIDToIndex[contentID];
//alert(group+", "+id+", "+contentID+", "+index);
gChangeMax = CHANGE_MAX_CHANGE_QUICK;
advanceContent(0, index);
}
function playLoop(interval) {
//debugAppend('
playLoop(), gMouseOverContent='+gMouseOverContent+', gMovingElement='+gMovingElement);
if(gMouseOverContent) {
gLastMouseOverContent = 1;
schedulePollLoop();
} else {
if(gMovingElement) {
schedulePollLoop();
} else {
if( gLastMouseOverContent ){
schedulePlayLoop();
} else {
// Transition to the next content
nextContent();
}
}
gLastMouseOverContent = 0;
}
}
function schedulePollLoop() {
clearTimeout(gStatusTimeoutObj[TIMER_POLL_INDEX]);
gStatusTimeoutObj[TIMER_POLL_INDEX] = setTimeout(function tmp(){playLoop(POLL_INTERVAL);}, POLL_INTERVAL);
//debugAppend('
schedulePollLoop');
}
function schedulePlayLoop() {
clearTimeout(gStatusTimeoutObj[TIMER_PLAY_INDEX]);
gStatusTimeoutObj[TIMER_PLAY_INDEX] = setTimeout(function tmp(){playLoop(PLAY_INTERVAL);}, PLAY_INTERVAL);
//debugAppend('
schedulePlayLoop');
}
function advanceContent(plusOrMinus, setIndex) { // Advance the content that is displayed
if(gMovingElement) return 0;
if(plusOrMinus != 0) {
var nextContentIndex = (gPlayContentPosition + plusOrMinus);
if(nextContentIndex<0) nextContentIndex = gPlayContentCount + nextContentIndex;
else if(nextContentIndex>=gPlayContentCount) nextContentIndex = (nextContentIndex % gPlayContentCount);
} else {
nextContentIndex = setIndex;
plusOrMinus = 1; // Move forwards
}
//debugAppend('
advanceContent('+plusOrMinus+'), gMovingElement='+gMovingElement+', gPlayContentPosition='+gPlayContentPosition+', nextContentIndex='+nextContentIndex);
// If it's the first content element then don't transition to it - it will already be displayed
nextContainerID = gPlayContent[nextContentIndex][PLAY_CONTAINER_INDEX];
nextStartElemIndex = gPlayContainerStartIndex[nextContainerID];
//debugAppend('
advanceContent, ('+nextContainerID+', '+nextStartElemIndex+') **** gPlayContentPosition='+gPlayContentPosition+', nextContentIndex='+nextContentIndex);
var nextContentID = gPlayContent[nextContentIndex][PLAY_CONTENTID_INDEX];
var activeContentID = gPlayContent[gPlayContentPosition][PLAY_CONTENTID_INDEX];
var containerID = gPlayContent[gPlayContentPosition][PLAY_CONTAINER_INDEX];
var parentContentID = gPlayContent[nextContentIndex][PLAY_PARENT_CONTENTID_INDEX];
//debugAppend('
setNextContent, activeContentID='+activeContentID+', nextContentID='+nextContentID);
if(activeContentID == nextContentID ) {
//debugAppend('
%%%% advanceContent, skipping move to same: '+activeContentID);
return; // Same, so no motion needed
}
var activeContent = document.getElementById(activeContentID);
var nextContent = document.getElementById(nextContentID);
var parentContent = document.getElementById(parentContentID);
var container = document.getElementById(containerID);
//debugAppend('
advanceContent, next id='+nextContent.id+', container for move='+containerID);
// Now set up the transition from the current to the new
// - Move the new content to the end/start for +/-
var elemWidth = container.width || container.offsetWidth;
var elemHeight = container.height || container.offsetHeight;
var inc, xstart, ystart;
//debugAppend('
advanceContent('+containerID+'), elemWidth='+elemWidth+', elemHeight='+elemHeight);
var goHorizontal=0;
xend = 0;
yend = 0;
if(plusOrMinus>0) { // Move forward, slide from right to left
if(goHorizontal) {
xstart = elemWidth;
ystart = 0;
} else {
xstart = 0;
ystart = elemHeight;
}
} else { // Move backwards, slide form left to right
if(goHorizontal) {
xstart = -elemWidth;
ystart = 0;
} else {
xstart = 0;
ystart = -elemHeight;
}
}
//debugAppend('
advanceContent() goHorizontal='+goHorizontal+', plusOrMinus='+plusOrMinus+', xstart='+xstart+', ystart='+ystart);
activeContent.style.zIndex = 99;
activeContent.style.left = STYLE_LEFT_OFFSCREEN; // Move offscreen
activeContent.style.top = '0px'; // Move to same level
nextContent.style.left = xstart+'px'; // Move offscreen
nextContent.style.top = ystart+'px'; // Move to same level
//debugAppend(' - #### showing nextContentID='+nextContentID);
//nextContent.style.display = 'block'; // Display it
nextContent.style.zIndex = 100; // To obscure the active content
// Make sure any parent block is also visible for this
if(parentContent) {
parentContent.style.left = '0px'; // Display it
parentContent.style.zIndex = 100;
}
gLastPlayContentPosition = gPlayContentPosition; // Currently active, about to be inactive
gPlayContentPosition = nextContentIndex; // About to be active
//debugAppend('
advanceContent - setting gPlayContentPosition='+gPlayContentPosition);
// Now move the elem until it's at the origin
if(typeof(gStatusTimeoutObj[containerID]) != 'undefined') clearTimeout(gStatusTimeoutObj[containerID]);
gMovingElement = 1;
transitionContentTo(nextContentIndex, xend, yend);
return;
}
function transitionContentTo(nextPlayIndex, x, y, ox, oy, interval) {
elemID = gPlayContent[nextPlayIndex][PLAY_CONTENTID_INDEX];
// Update the display
prefix = "container_content";
groupAndId = elemID.substr(prefix.length);
groupAndIdArray = groupAndId.split("_");
targetID = "playControl_"+groupAndIdArray[0]+"_"+groupAndIdArray[1];
addClass(targetID, "active");
// Set the background image too
lastElemID = gPlayContent[gLastPlayContentPosition][PLAY_CONTENTID_INDEX];
lastGroupAndId = lastElemID.substr(prefix.length);
lastGroupAndIdArray = lastGroupAndId.split("_");
//var containerID = gPlayContent[nextPlayIndex][PLAY_CONTAINER_INDEX];
var containerImageID = 'containerImage_'+groupAndIdArray[0];
var lastContainerImageID = 'containerImage_'+lastGroupAndIdArray[0];
if(containerImageID != lastContainerImageID) {
var containerImg = document.getElementById(containerImageID);
var lastContainerImg = document.getElementById(lastContainerImageID);
//debug('
transitionContentTo - '+nextPlayIndex+', '+gLastPlayContentPosition+' :: '+containerImageID+', '+lastContainerImageID);
if(lastContainerImg) lastContainerImg.style.left=STYLE_LEFT_OFFSCREEN;
containerImg.style.left="0px";
}
activeID = gPlayContent[gLastPlayContentPosition][PLAY_CONTENTID_INDEX];
groupAndId = activeID.substr(prefix.length);
groupAndIdArray = groupAndId.split("_");
targetID = "playControl_"+groupAndIdArray[0]+"_"+groupAndIdArray[1];
removeClass(targetID, "active");
moveElementTo(elemID, x, y, ox, oy, interval);
}
function moveElementTo(elemID) {
var x, y, ox, oy, interval;
var yinc=10;
var xinc=10;
var elem = document.getElementById(elemID);
if(!elem) {
//debugAppend(" - elem not set:"+elemID);
return;
}
var a=moveElementTo.arguments;
if(typeof a[1] != "undefined") x=a[1];
else x = elem.offsetLeft;
if(typeof a[2] != "undefined") y=a[2];
else y = elem.offsetTop;
if(typeof a[3] != "undefined") ox=a[3];
else ox = elem.offsetLeft;
if(typeof a[4] != "undefined") oy=a[4];
else oy = elem.offsetTop;
if(typeof a[5] != "undefined") {
if(a[5]>0) interval=a[5];
else interval=0;
} else interval = 25;
if(!interval) interval = TIMER_MOVE_INTERVAL;
//debugAppend('
moveElementTo, elemID='+elemID+', x='+x+', y='+y);
// Current pos
var xc = elem.offsetLeft;
var yc = elem.offsetTop;
var t = elem.style.top;
var l = elem.style.left;
xc = Math.round(l.substr(0,l.length-2));
yc = Math.round(t.substr(0,t.length-2));
//debugAppend('
moveElementTo, elemID='+elemID+', xc='+xc+', t='+t);
// Move towards the desired pos
doEnd=1;
if(xc != x || yc != y) {
//debugAppend(" - Y or X not done, interval="+interval);
if(interval>0 && gChangeMax>0) {
if(y != oy && yc != y) {
doEnd=0;
var dy = Math.round(Math.min(Math.max(Math.abs(yc-y)/CHANGE_RATE_FACTOR, CHANGE_MIN_CHANGE), gChangeMax));
//debugAppend(" - Y not done");
if( y > oy) {
//yn = Math.min(yc+yinc,y);
yn = yc+dy;
if(yn >= y) doEnd=1;
} else {
//yn = Math.max(yc-yinc, y);
yn = yc-dy;
if(yn <= y) doEnd=1;
}
elem.style.top = yn+'px';
} else yn = y;
if(x != ox && xc != x) {
doEnd=0;
var dx = Math.round(Math.min(Math.max(Math.abs(xc-x)/CHANGE_RATE_FACTOR, CHANGE_MIN_CHANGE), gChangeMax));
//debugAppend(" - X not done, dx="+dx);
if(x > ox) {
//xn = Math.min(xc+dx,x);
xn = xc+dx;
if(xn >= x) doEnd=1;
} else {
//xn = Math.max(xc-dx,x);
xn = xc-dx;
if(xn <= x) doEnd=1;
}
elem.style.left = xn+'px';
} else xn = x;
if(typeof(gStatusTimeoutObj[TIMER_MOVE_INDEX]) != 'undefined') clearTimeout(gStatusTimeoutObj[TIMER_MOVE_INDEX]);
if(!doEnd) gStatusTimeoutObj[TIMER_MOVE_INDEX] = setTimeout(function tmp(){moveElementTo(elemID,x,y,ox,oy,interval);}, interval);
} else {
elem.style.top = y+'px';
elem.style.left = x+'px';
}
}
if(doEnd) {
//debugAppend("
==== moveElementTo("+containerElemID+") completed move");
moveToCompleted();
}
//debugAppend("
moveElementTo::"+l+"/"+t+":: "+x+"/"+xc+"/"+ox+"/"+xn+"/"+dx+", "+y+"/"+yc+"/"+oy+"/"+yn+"/"+dy+", "+interval+"
");
}
function moveToCompleted() {
transitionCompleted();
schedulePlayLoop();
}
function transitionCompleted() {
lastContentElemID = gPlayContent[gLastPlayContentPosition][PLAY_CONTENTID_INDEX];
lastElem = document.getElementById(lastContentElemID);
gMovingElement = 0;
//debugAppend('
==== moveElementToCompleted:: gPlayContent['+gLastPlayContentPosition+'][PLAY_CONTENTID_INDEX]='+gPlayContent[gLastPlayContentPosition][PLAY_CONTENTID_INDEX]+', gPlayContent['+gPlayContentPosition+'][PLAY_CONTENTID_INDEX]='+gPlayContent[gPlayContentPosition][PLAY_CONTENTID_INDEX]);
if(lastElem) {
// Hide last elem if from the same container as the current one
lastContainerID = gPlayContent[gLastPlayContentPosition][PLAY_CONTAINER_INDEX];
currentContainerID = gPlayContent[gPlayContentPosition][PLAY_CONTAINER_INDEX];
lastStartIndex = gPlayContainerStartIndex[lastContainerID];
startElemID = gPlayContent[lastStartIndex][PLAY_CONTENTID_INDEX];
lastElem.style.left = STYLE_LEFT_OFFSCREEN; // Reset
lastElem.style.zIndex = 98; // Reset
} else {
//debugAppend("
==== moveElementToCompleted("+lastContentElemID+") not found");
}
}
var EXPAND_MIN_CHANGE = 1;
var EXPAND_MAX_CHANGE = 100;
var EXPAND_DEFAULT_INTERVAL = 25;
var EXPAND_RATE_FACTOR = 3;
var NODE_STATE_CLOSED = 0;
var NODE_STATE_OPEN = 1;
var NODE_SYMBOL_CLOSED = "
";
var NODE_SYMBOL_OPEN = "
";
var activeNodes = new Object();
function toggleNode(id) {
detailsElem = document.getElementById("node"+id+"Content").style;
////toggleExpandElement("node"+id+"Content");
if(detailsElem.display === "none") {
//debugAppend("
["+id+"] display=none");
var newState = "block";
//expandElement("node"+id+"Content");
detailsElem.display = newState;
//detailsElem.display = "block";
document.getElementById("node"+id+"Control").innerHTML = NODE_SYMBOL_OPEN;
activeNodes[id]=1;
} else {
//debugAppend("
["+id+"] display != none");
var newState = "none";
//unexpandElement("node"+id+"Content");
detailsElem.display = newState;
//detailsElem.display = "none";
document.getElementById("node"+id+"Control").innerHTML = NODE_SYMBOL_CLOSED;
activeNodes[id]=0;
}
if(elem=document.getElementById("node"+id+"State")) {
//alert("node"+id+"State");
if(newState == "none") {
elem.value = NODE_STATE_CLOSED;
} else {
elem.value = NODE_STATE_OPEN;
}
}
}