﻿//you must declare masterFadeTextBannerArray in your code

//<style type="text/css">
//#masterFadeTextBanner {
//    zoom: 1; /* necessary for IE */
//}
//</style>   

var ie4 = document.all && !document.getElementById;
var DOM2 = document.getElementById;

var masterFadeTextBannerTransparency = 0;
var masterFadeTextBannerPauseSeconds = 10;
var masterFadeTextBannerIsFadingIn = true;

var masterFadeTextBannerDelaySeconds = .2;
var masterFadeTextBannerArrayCount = 0;
var masterFadeTextBannerArrayCurrentSetTimeOutDelay = masterFadeTextBannerDelaySeconds;


masterFadeTextBanner();
function masterFadeTextBanner() {
    if (document.getElementById && masterFadeTextBannerArray != null && (masterFadeTextBannerArray.length > 0)) {

        if (document.getElementById("masterFadeTextBanner").innerHTML == "") {
            document.getElementById("masterFadeTextBanner").innerHTML = masterFadeTextBannerArray[masterFadeTextBannerArrayCount];
        }

        masterFadeTextBannerArrayCurrentSetTimeOutDelay = masterFadeTextBannerDelaySeconds;
        
        	//for (var i=0;i<11;i++)
		        //setTimeout('setOpacity('+i+')',1000*i);
        
        if (masterFadeTextBannerIsFadingIn && masterFadeTextBannerTransparency < 100) {
            masterFadeTextBannerTransparency = masterFadeTextBannerTransparency + 10;

            //if fully fadded in
            if (masterFadeTextBannerTransparency == 100) {
                //pause the text to show it for the defined amount of time
                masterFadeTextBannerArrayCurrentSetTimeOutDelay = masterFadeTextBannerPauseSeconds;
            }
        }
        else {
            masterFadeTextBannerIsFadingIn = false;

            masterFadeTextBannerTransparency = masterFadeTextBannerTransparency - 10;
            
            //if we are fully fadded out
            if (masterFadeTextBannerTransparency == 0) {
                masterFadeTextBannerIsFadingIn = true;

                //change to next text item
                if ((masterFadeTextBannerArrayCount + 1) < (masterFadeTextBannerArray.length)) {
                    masterFadeTextBannerArrayCount = masterFadeTextBannerArrayCount + 1;
                }
                else {

                    masterFadeTextBannerArrayCount = 0;
                }

                //change text
                document.getElementById("masterFadeTextBanner").innerHTML = masterFadeTextBannerArray[masterFadeTextBannerArrayCount];                             
            }
        }

        if ((masterFadeTextBannerArray.length > 1)) {
            if (ie4) {
                //alert("here ie4");
                document.getElementById("masterFadeTextBanner").style.filters.alpha.opacity = masterFadeTextBannerTransparency;
            }
            else {
                if (DOM2) {
                    //alert("here DOM2" + " " + masterFadeTextBannerTransparency);
                    document.getElementById("masterFadeTextBanner").style.opacity = masterFadeTextBannerTransparency / 100;
                    document.getElementById("masterFadeTextBanner").style.filter = 'alpha(opacity=' + masterFadeTextBannerTransparency + ')';
                }
            }
        }
            
        
        //multiply by 1000 because it needs to be in milliseconds
        setTimeout("masterFadeTextBanner()", masterFadeTextBannerArrayCurrentSetTimeOutDelay * 1000);
    }


}

function setOpacity(value) {
    document.getElementById("masterFadeTextBanner").style.opacity = value / 10;
    document.getElementById("masterFadeTextBanner").style.filter = 'alpha(opacity=' + value * 10 + ')';
}    