﻿
var anterior = 1;
function montaNoticia() {
    sobreBarraTitulo.innerHTML = "<span style='font-size:13px; color:white'><b>" + noticias[0][0] + "</b></span><br/>" + noticias[0][1];
    noticiaImg.style.backgroundImage = "url(imagens/Grande/" + noticias[0][2] + ")";
    noticiaImg.onclick = function() { location.href = "AirvoNews.aspx?Noticia=" + noticias[0][3]; } 
    for (var i = 1; i < 5; i++) {

        var titulo = noticias[i - 1][0];
        x = document.getElementById("noticia" + i);
        var divs = x.getElementsByTagName('div');
        divs[0].innerHTML = titulo;
        divs = x.getElementsByTagName('img');
        divs[0].src = "imagens/" + noticias[i - 1][2];

    }
}

function mudaNoticia(ind) {
    fade('sobreBarraTitulo');
    sobreBarraTitulo.innerHTML = "<span style='font-size:12px; color:white;text-decoration:none;'><b>" + noticias[indexs - 1][0] + "</b></span><br/>" + noticias[indexs - 1][1];
    noticiaImg.onclick = function() { location.href = "AirvoNews.aspx?Noticia=" + noticias[indexs - 1][3]; }
    noticiaImg.style.backgroundImage = "url(imagens/Grande/" + noticias[indexs - 1][2] + ")";
    obj = document.getElementById("noticia" + indexs);
    obj.style.backgroundColor = "#fafcd9";

}
function redirecionaNoticia(noticia) {
    
}


function limpaSelecoes() {
    for (var i = 1; i <= 4; i++) {
        if (i != indexs) {
            obj = document.getElementById("noticia" + i);
            obj.style.backgroundColor = "#ede5ba";
        }
    }
}
function mudaFundo(obj, num, posicao) {
    if (num == 1 && indexs != posicao) {
        obj.style.backgroundColor = "#f8f4e5";
        status = 1;
    }
    else {
        limpaSelecoes();
    }
    if (num == 0) { status = 0; }
    //limpaSelecoes();   

}


function mudaAbaAutomatica() {
    if (status == 0) {
        indexs = indexs >= 4 ? 0 : indexs++;
        indexs++;
        obj = document.getElementById("noticia" + indexs);
        obj.style.backgroundColor = "#ede5ba";
        limpaSelecoes();
        mudaNoticia(indexs);
    }
}
function mudaAbaClick(num) {
    indexs = num;
    limpaSelecoes();
    mudaNoticia(indexs);
}


var TimeToFade = 1000.0;

function fade(eid) {
    var element = document.getElementById(eid);
    element.FadeState = -2;
    element.FadeState = -1;
    if (element == null)
        return;

    if (element.FadeState == null) {
        if (element.style.opacity == null
        || element.style.opacity == ''
        || element.style.opacity == '0.8') {
            element.FadeState = -2;
        }
        else {
            element.FadeState = -2;
        }
    }

    if (element.FadeState == 1 || element.FadeState == -1) {
        element.FadeState = element.FadeState == 1 ? -1 : 1;
        element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
    }
    else {
        element.FadeState = element.FadeState == 2 ? -1 : 1;
        element.FadeTimeLeft = TimeToFade;
        element.style.display = element.FadeState == 2
        ? 'none' : 'block';
        setTimeout("animateFade(" + new Date().getTime()
        + ",'" + eid + "')", 33);
    }
}

function animateFade(lastTick, eid) {
    var curTick = new Date().getTime();
    var elapsedTicks = curTick - lastTick;

    var element = document.getElementById(eid);

    if (element.FadeTimeLeft <= elapsedTicks) {
        element.style.display = element.FadeState == 1
        ? 'block' : 'none';
        element.style.opacity = element.FadeState == 1
        ? '.85' : '0';
        element.style.filter = 'alpha(opacity = '
        + (element.FadeState == 1 ? '85' : '0') + ')';
        element.FadeState = element.FadeState == 1 ? 2 : -2;
        return;
    }

    element.FadeTimeLeft -= elapsedTicks;
    var newOpVal = element.FadeTimeLeft / TimeToFade;
    if (element.FadeState == 1)
        newOpVal = 1 - newOpVal;

    newOpVal = newOpVal * 0.85;
    element.style.opacity = newOpVal;
    element.style.filter =
      'alpha(opacity = ' + (newOpVal * 100) + ')';

    setTimeout("animateFade(" + curTick
      + ",'" + eid + "')", 33);
}

function Esconde() {
    document.getElementById('flash').style.visibility = "hidden";
}





