﻿var rotatorState = 1; //this is for remembering the tagline/image state when the rotator is off
var buttonState = 0;  //this is for the button state for keeping the infoBox up on button off and infoBox over 
var count = 1; //this is the counter for the page we are showing in the rotator
var t;         //this is the interval id
var flashOn = 1;

function initalize() {
    //change class of our container if js is ok
    var container = document.getElementById("componentContainer");
    if (flashOn == 0) {
        container.className = "js";
        timedRotate(); //start the rotator

    }

    try {
        var GIR = document.getElementById("GIRcall");
        GIR.setAttribute('href', 'javascript:void(0);');
        GIR.removeAttribute('target');

        var OD = document.getElementById("ODcall");
        OD.setAttribute('href', 'javascript:void(0);');
        OD.removeAttribute('target');
    } catch (e) {
    }
}


function updateButtonOver(buttonId) {
    killRotator();

    blockID = "infoBlock" + buttonId;
    document.getElementById(blockID).style.visibility = "visible";

    imageID = "image" + buttonId;
    document.getElementById(imageID).style.visibility = "visible";

    _buttonID = "Button" + buttonId;
    document.getElementById(_buttonID).style.backgroundColor = "#8B0000";

}

function updateButtonOff() {
    //off of button all info boxes can be off
    clearAllStates();
    //show default image
    var mainImage = document.getElementById("image0");
    if(mainImage != null)
    {
        mainImage.style.visibility = "visible";
    }
    //restart rotator
    rotatorState = 1; 
    timedRotate();
}
function updateInfoBoxOver() {
    killRotator();

    blockID = "infoBlock" + buttonState;
    document.getElementById(blockID).style.visibility = "visible";

    imageID = "image" + buttonState;
    document.getElementById(imageID).style.visibility = "visible";

    _buttonID = "Button" + buttonState;
    document.getElementById(_buttonID).style.backgroundColor = "#8B0000";
    
}
function timedRotate() {
    t = setInterval("switchSlide()", 9000);
}

function switchSlide() {
    //hide default image
    var mainImage = document.getElementById("image0");
    if (mainImage != null) {
        mainImage.style.visibility = "hidden";
    }
    

    previousState = rotatorState;
    rotatorState++;
    if (rotatorState == 5) { rotatorState = 1; }


    clearAllStates();

    //for ie...seems to run this code eventhough the flash is loaded in
//    if (document.getElementById(previousImageID) == null) {
//        clearInterval(t);
//        return;
//    }

    // previous count goes hidden and current count becomes visible
    blockID = "infoBlock" + previousState;
    document.getElementById(blockID).style.visibility = "visible";

    imageID = "image" + previousState;
    document.getElementById(imageID).style.visibility = "visible";

    _buttonID = "Button" + previousState;
    document.getElementById(_buttonID).style.backgroundColor = "#8B0000";
}

function killRotator() {
    //need to hide the tagline due to mouse
    var mainImage = document.getElementById("image0");
    if (mainImage != null) {
        mainImage.style.visibility = "hidden";
    }
    clearInterval(t);
}

function clearAllStates() {
    document.getElementById("infoBlock1").style.visibility = "hidden";
    document.getElementById("infoBlock2").style.visibility = "hidden";
    document.getElementById("infoBlock3").style.visibility = "hidden";
    document.getElementById("infoBlock4").style.visibility = "hidden";

    document.getElementById("image1").style.visibility = "hidden";
    document.getElementById("image2").style.visibility = "hidden";
    document.getElementById("image3").style.visibility = "hidden";
    document.getElementById("image4").style.visibility = "hidden";

    document.getElementById("Button1").style.backgroundColor = "#939394";
    document.getElementById("Button2").style.backgroundColor = "#939394";
    document.getElementById("Button3").style.backgroundColor = "#939394";
    document.getElementById("Button4").style.backgroundColor = "#939394";
}
