﻿var _tt_currentQuote = 0;
var _tt_fader = null;
var _ttElement = null;
var _ttCurrentOpacity = 100;

function tt_initTtFade() {
    _ttElement = document.getElementById("ttContainer");
    tt_fadeComplete();
}

function tt_fadeComplete() {
    setTimeout("tt_fadeOut()", _tt_Delay);
}

function tt_fadeIn() {
    _ttCurrentOpacity += 5;
    tt_changeOpacity(_ttCurrentOpacity, _ttElement);
    if (_ttCurrentOpacity < 100) {
        setTimeout("tt_fadeIn()", 50);
    }
    else {
        tt_fadeComplete();
    }
}

function tt_fadeOut() {
    _ttCurrentOpacity -= 5;
    tt_changeOpacity(_ttCurrentOpacity, _ttElement);
    if (_ttCurrentOpacity >= 0) {
        setTimeout("tt_fadeOut()", 50);
    }
    else {
        _tt_currentQuote++;        
        if (_tt_currentQuote >= _ttText.length) {
            _tt_currentQuote = 0;
        }
        document.getElementById("ttContainer").innerHTML = _ttText[_tt_currentQuote];
        tt_fadeIn();
    }
}

function tt_changeOpacity(opacity, element) {
    if (element != null) {
        var object = element.style;
        object.filter = "alpha(opacity=" + opacity + ")";
        object.opacity = (opacity / 100);
        object.MozOpacity = (opacity / 100);
        object.KhtmlOpacity = (opacity / 100);
    }
}