﻿var stop = false;
var ele = document.getElementById('news');
var timer1 = window.setInterval(hideText, 10000);
var timer2 = null;
var alpha = 100;
var itext = -1;

function hideText() {
    if (!stop) timer2 = window.setInterval(hidePanel, 30);
}

function hidePanel() {
    if (alpha > 0) {
        alpha -= 5;
        ele.setAttribute('style', 'opacity: ' + Math.round(alpha / 10) / 10);
    } else {
        changeText();
    }
}

function changeText() {
    window.clearInterval(timer2);
    itext++;
    if (itext >= text.length) itext = 0;
    ele.innerHTML = text[itext];
    timer2 = window.setInterval(showPanel, 30);
}

function showPanel() {
    if (alpha < 100) {
        alpha += 5;
        ele.setAttribute('style', 'opacity: ' + Math.round(alpha / 10) / 10);
    } else {
        window.clearInterval(timer2);
        timer2 = null;
    }
}