﻿var slideshowadds = new Array();
var clearoutstanding = false;
var forcepostback = false;
var clockpopup;
var slideshoweditsaving = false;
var slideshoweditforcesave = false;

function ShowSubjectBody(el) {
    if (el.childNodes[1]) el.childNodes[0].childNodes[0].src = "UIImages/Theme2/SubjectHide.png";
    if (el.childNodes[1]) el.childNodes[1].style.display = "block";
}
function HideSubjectBody(el) {
    el.childNodes[0].childNodes[0].src = "UIImages/Theme2/SubjectShow.png";
    if (el.childNodes[1]) el.childNodes[1].style.display = "none";
}
function ShowSearchBody(el) {
    if (el.childNodes[1]) el.childNodes[1].style.display = "block";
}
function HideSearchBody(el) {
    if (el.childNodes[1]) el.childNodes[1].style.display = "none";
}
function textBoxFocus(tb)
{
    tb.style.borderColor = "#ac616a";
}

function textBoxBlur(tb)
{
    tb.style.borderColor = "#9c9e9f";
}

function CloseSlideShowChangeMenu() {
    document.getElementById("SlideShowChangeMenu").style.display = "none";
}

function changeSlideShow() {
    document.getElementById("SlideShowChangeMenu").style.display = "block";
}

function showBigButtonBorder(b) {
    b.style.backgroundImage = "url( UIImages/Theme2/BigButtonBorder.png )";
}
function hideBigButtonBorder(b) {
    b.style.backgroundImage = "none";
}
function showBigDropDownBorder(b) {
    b.style.backgroundImage = "url( UIImages/Theme2/BigDropDownBorder.png )";
}
function hideBigDropDownBorder(b) {
    b.style.backgroundImage = "none";
}
function showDropDownBorder(b) {
    b.style.backgroundImage = "url( UIImages/Theme2/DropDownBorder.png )";
}
function hideDropDownBorder(b) {
    b.style.backgroundImage = "none";
}

function addToSlideShow(balid, button) {
    if (button) {
  //      var clock = document.getElementById("ClockPopUp");
        clockpopup = button.parentNode.parentNode.children[0].children[0];
        clockpopup.style.display = "block";
    }
    var fm = document.SsThumb;
    if (fm) fm.sendBalIdToSshow(balid);
    else
        slideshowadds[slideshowadds.length] = balid;
}

function clearSlideShow() {
    var fm = document.SsThumb;
    if (fm) fm.clearSshow();
    else
        clearoutstanding = true;
}

function getFlashMovie(movieName) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}

function ShowZoom(balid) {
    if (balid != -1) {
        document.getElementById("BlockingPanel").style.display = "block";
        sizeUpBlockingPanel();
        document.getElementById("FlashContainer").innerHTML =
        AC_FL_RunContent(
		    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
		    'width', '800',
		    'height', '700',
		    'src', 'ZoomLoader',
		    'quality', 'high',
		    'pluginspage', 'http://www.adobe.com/go/getflashplayer',
		    'align', 'middle',
		    'play', 'true',
		    'loop', 'true',
		    'scale', 'showall',
		    'wmode', 'window',
		    'devicefont', 'false',
		    'id', 'Zoom',
		    'bgcolor', '#ffffff',
		    'name', 'ZoomLoader',
		    'menu', 'true',
		    'allowFullScreen', 'true',
		    'allowScriptAccess', 'sameDomain',
		    'movie', 'ZoomLoader',
		    'FlashVars', 'balid=' + balid + "&servername=" + serverName(),
		    'salign', ''
		    );
        window.document.ZoomLoader.focus();
        forcepostback = false;
    }
}
function ShowIntro() {
    var w = document.getElementById("IntroContainer").offsetWidth;
    var h = document.getElementById("IntroContainer").offsetHeight;
    document.getElementById("IntroContainer").innerHTML =
        AC_FL_RunContent(
		    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
		    'width', w,
		    'height', h,
		    'src', 'Intro',
		    'quality', 'high',
		    'pluginspage', 'http://www.adobe.com/go/getflashplayer',
		    'align', 'middle',
		    'play', 'true',
		    'loop', 'true',
		    'scale', 'showall',
		    'wmode', 'opaque',
		    'devicefont', 'false',
		    'id', 'Intro',
		    'bgcolor', '#ffffff',
		    'name', 'Intro',
		    'menu', 'true',
		    'allowFullScreen', 'true',
		    'allowScriptAccess', 'sameDomain',
		    'movie', 'Intro',
		    'FlashVars', "servername=" + serverName(),
		    'salign', ''
		    );
}

function ShowSsThumb(ssid, clientcode) {
        document.getElementById("SsThumbViewerFlash").innerHTML =
        AC_FL_RunContent(
		    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
		    'width', '75',
		    'height', '75',
		    'src', 'SsThumb',
		    'quality', 'high',
		    'pluginspage', 'http://www.adobe.com/go/getflashplayer',
		    'align', 'middle',
		    'play', 'true',
		    'loop', 'true',
		    'scale', 'showall',
		    'wmode', 'opaque',
		    'devicefont', 'false',
		    'id', 'SsThumb',
		    'bgcolor', '#ffffff',
		    'name', 'SsThumb',
		    'menu', 'true',
		    'allowFullScreen', 'false',
		    'allowScriptAccess', 'sameDomain',
		    'movie', 'SsThumb',
		    'FlashVars', 'ssid=' + ssid + "&clientcode=" + clientcode + "&servername=" + serverName(),
		    'salign', ''
		    );
        if (slideshowadds.length > 0) setTimeout("doSlideShowAdds( )", 500);
        if (clearoutstanding) setTimeout("clearSlideShow( )", 500);
}

function doSlideShowAdds() {
    var fm = document.SsThumb;
    for (var i = 0; i < slideshowadds.length; i++)
        fm.sendBalIdToSshow(slideshowadds[i]);
}

function viewSlideShow(ssid, clientcode) {
    document.getElementById("BlockingPanel").style.display = "block";
    sizeUpBlockingPanel();
    document.getElementById("FlashContainer").innerHTML =
        AC_FL_RunContent(
		    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
		    'width', '800',
		    'height', '700',
		    'src', 'SlideShowLoader',
		    'quality', 'high',
		    'pluginspage', 'http://www.adobe.com/go/getflashplayer',
		    'align', 'middle',
		    'play', 'true',
		    'loop', 'true',
		    'scale', 'showall',
		    'wmode', 'window',
		    'devicefont', 'false',
		    'id', 'SlideShowLoader',
		    'bgcolor', '#ffffff',
		    'name', 'SlideShowLoader',
		    'menu', 'true',
		    'allowFullScreen', 'true',
		    'allowScriptAccess', 'sameDomain',
		    'movie', 'SlideShowLoader',
		    'FlashVars', 'ssid=' + ssid + "&clientcode=" + clientcode + "&servername=" + serverName(),
		    'salign', ''
		    );
    window.document.SlideShowLoader.focus();
    forcepostback = false;


}

function editSlideShow(ssid, ins, su, cc) {
    document.getElementById("BlockingPanel").style.display = "block";
    sizeUpBlockingPanel();
    document.getElementById("FlashContainer").innerHTML =
        AC_FL_RunContent(
		    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
		    'width', '800',
		    'height', '700',
		    'src', 'SlideShowEditLoader',
		    'quality', 'high',
		    'pluginspage', 'http://www.adobe.com/go/getflashplayer',
		    'align', 'middle',
		    'play', 'true',
		    'loop', 'true',
		    'scale', 'showall',
		    'wmode', 'window',
		    'devicefont', 'false',
		    'id', 'SlideShowEditLoader',
		    'bgcolor', '#ffffff',
		    'name', 'SlideShowEditLoader',
		    'menu', 'true',
		    'allowFullScreen', 'true',
		    'allowScriptAccess', 'sameDomain',
		    'movie', 'SlideShowEditLoader',
		    'FlashVars', 'ssid=' + ssid + '&isinstitution=' + ins + '&issu=' + su + "&servername=" + serverName() + "&clientcode=" + cc,
		    'salign', ''
		    );
    window.document.SlideShowEditLoader.focus();
    forcepostback = true;
    slideshoweditforcesave = false;

}

function CloseFlash() {
    if (forcepostback) {
        slideshoweditforcesave = true;
        if (!slideshoweditsaving) {
            var fm = document.SlideShowEditLoader;
            fm.forceSave();
        }
    }
    else {
        document.getElementById("FlashContainer").innerHTML = '';
        document.getElementById("BlockingPanel").style.display = "none";
    }
}

function SlideShowSaveStart( a ) {
    slideshoweditsaving = true;
}

function SlideShowSaveEnd() {
    slideshoweditsaving = false;
    if (slideshoweditforcesave) {
        document.getElementById("FlashContainer").innerHTML = '';
        document.getElementById("BlockingPanel").style.display = "none";
        theForm.submit();
    }
}

function SlideShowSaved() {
        document.getElementById("FlashContainer").innerHTML = '';
        document.getElementById("BlockingPanel").style.display = "none";
        theForm.submit();

}

var illustrationControlLeftWidth;
var illustrationControlRightWidth;
var illustrationControlLeftVisible;
var illustrationControlRightVisible;
var illustrationPanelWidth;
var illustrationPanelHeight;
var illustrationPanelSpeed;
var illustrationPanel;
var illustrationLeftPressed;
var illustrationRightPressed;

function OlympicsPosterInit() {
    illustrationControlLeftWidth = document.getElementById("illustrationControlLeft").offsetWidth;
    illustrationControlRightWidth = document.getElementById("illustrationControlRight").offsetWidth;
    illustrationControlLeftVisible = false;
    illustrationControlRightVisible = false;
    var posspanels = document.getElementsByTagName( "div" );
    for (var i = 0; i < posspanels.length; i++) {
        if (posspanels[i].className == 'Illustrations') illustrationPanel = posspanels[i];
    }
    illustrationPanelWidth = 0;
    illustrationPanelHeight = 0;

    for (var i = 0; i < illustrationPanel.childNodes.length; i++) {
        var illuswidth = illustrationPanel.childNodes[i].childNodes[0].offsetWidth;
        illustrationPanel.childNodes[i].style.width = illuswidth + "px";
        illustrationPanel.childNodes[i].style.left = illustrationPanelWidth + "px";
        illustrationPanelWidth += ( illuswidth + 10 );
        if (illustrationPanel.childNodes[i].offsetHeight > illustrationPanelHeight) {
            illustrationPanelHeight = illustrationPanel.childNodes[i].offsetHeight;
      }
  }
  for (var i = 0; i < illustrationPanel.childNodes.length; i++) {
      illustrationPanel.childNodes[i].style.top = ((illustrationPanelHeight - illustrationPanel.childNodes[i].offsetHeight) / 2) + "px";
  }

  illustrationPanel.style.left = ( (document.getElementById("illustrationFrame").offsetWidth - illustrationPanelWidth) / 2 ) + "px";

  document.getElementById("illustrationFrame").style.height = ( illustrationPanelHeight + 8 ) + "px";
    illustrationPanelSpeed = 0;
    illustrationLeftPressed = false;
    illustrationRightPressed = false;
    setInterval("illustrationOnFrame( )", 42);

}

function illustrationStartLeft() {
    illustrationLeftPressed = true;
}
function illustrationStopLeft() {
    illustrationLeftPressed = false;
}
function illustrationStartRight() {
    illustrationRightPressed = true;
}
function illustrationStopRight() {
    illustrationRightPressed = false;
}

   
function illustrationOnFrame() {
    var framespeed = 8;
    var illustrationControlLeft = document.getElementById("illustrationControlLeft");
    if (illustrationControlLeftVisible && illustrationControlLeft.offsetLeft < 0) {
        illustrationControlLeft.style.left = (illustrationControlLeft.offsetLeft + framespeed) + "px";
    }
    else if (!illustrationControlLeftVisible && illustrationControlLeft.offsetLeft > -illustrationControlLeftWidth) {
        illustrationControlLeft.style.left = (illustrationControlLeft.offsetLeft - framespeed) + "px";
    }
    var illustrationControlRight = document.getElementById("illustrationControlRight");
    var right = illustrationControlRight.style.right;
    if (right.endsWith("px")) right = right.substring(0, right.indexOf( 'p' ));
    if (illustrationControlRightVisible && right < 0) {
        illustrationControlRight.style.right = (( right * 1 ) + framespeed) + "px";
    }
    else if (!illustrationControlRightVisible && right > -illustrationControlRightWidth) {
        illustrationControlRight.style.right = (right - framespeed) + "px";
    }
    if (illustrationLeftPressed && illustrationPanelSpeed < 20) {
        illustrationPanelSpeed++;
    }
    else if (illustrationRightPressed && illustrationPanelSpeed > -20) {
        illustrationPanelSpeed--;
    }
    else {
        illustrationPanelSpeed -= ( illustrationPanelSpeed == 0 ? 0 : ( illustrationPanelSpeed > 0 ? 1 : -1 ) );
    }
    var left = illustrationPanel.style.left;
    if (left.endsWith("px")) left = left.substring(0, left.indexOf('p'));
    if (left - illustrationPanelSpeed < 0 &&
        left - illustrationPanelSpeed > document.getElementById( "illustrationFrame" ).offsetWidth - illustrationPanelWidth ) {
        illustrationPanel.style.left = (left - illustrationPanelSpeed) + "px";
    }
    if (left >= 0) illustrationControlRightVisible = false;
    if (left <= document.getElementById("illustrationFrame").offsetWidth - illustrationPanelWidth ) illustrationControlLeftVisible = false;
}

function showIllustrationControls() {
    illustrationControlLeftVisible = true;
    illustrationControlRightVisible = true;
    
}
function hideIllustrationControls() {
    illustrationControlLeftVisible = false;
    illustrationControlRightVisible = false;

}


