// FadeOut - Color hasta el que va al sacar una noticia
// FadeIn  - Color hasta el que llega al mostrar una noticia
var m_FadeOut1 = 255;  // R
var m_FadeOut2 = 255;  // G
var m_FadeOut3 = 255;  // B
var m_FadeIn1 = 0;  // R
var m_FadeIn2 = 0;  // G
var m_FadeIn3 = 0;  // B
var m_Fade1 = 0;  // R
var m_Fade2 = 0;  // G
var m_Fade3 = 0;  // B
var m_FadeStep = 6;          // De a cuantos valores cambia el color
var m_FadeWait = 10000;       // Cuanto tiempo está visible una noticia
var m_bFadeOut = true;       // Si se tiene que hacer fade out
var milisegundosIntervaloFade = 10;
var m_iFadeInterval;
var arrFadeLinks;            // Arreglo con links para las noticias
var arrFadeTitles;           // Arreglo con títulos para las noticias
var arrFadeHour;             // Arreglo con hora para las noticias
var arrFadeCursor = 0;       // Noticia que se está mostrando
var arrFadeMax;              // Indice máximo a utilizar
var elementoHoraNoticia = "elementoHoraNoticia";
var elementoTituloNoticia = "elementoTituloNoticia";
var elementoSeparadorNoticia = "elementoSeparadorNoticia";
function Fadewl(){setTimeout(iniciarFadeNoticias, m_FadeWait);arrFadeLinks = new Array();arrFadeTitles = new Array();arrFadeHour = new Array();setupFadeLinks();arrFadeMax = arrFadeLinks.length - 1;setNoticia();}
function iniciarFadeNoticias(){m_iFadeInterval = setInterval(fade_ontimer, milisegundosIntervaloFade);}
function setNoticia(){var horaNoticia = document.getElementById(elementoHoraNoticia);try {horaNoticia.removeChild(horaNoticia.firstChild);} catch (e) {}horaNoticia.appendChild(document.createTextNode(arrFadeHour[arrFadeCursor]));var tituloNoticiaViejo = document.getElementById(elementoTituloNoticia);var padre = tituloNoticiaViejo.parentNode;padre.removeChild(tituloNoticiaViejo);var tituloNoticia = document.createElement("a");tituloNoticia.appendChild(document.createTextNode(arrFadeTitles[arrFadeCursor]));tituloNoticia.setAttribute("href", arrFadeLinks[arrFadeCursor]);tituloNoticia.setAttribute("target", "_blank");tituloNoticia.setAttribute("id", elementoTituloNoticia);padre.appendChild(tituloNoticia);}
function fade_ontimer(){if (m_bFadeOut) {m_Fade1 += m_FadeStep;m_Fade2 += m_FadeStep;m_Fade3 += m_FadeStep;if (m_Fade1 >= m_FadeOut1 && m_Fade2 >= m_FadeOut2 && m_Fade3 >= m_FadeOut3) {arrFadeCursor++;if (arrFadeCursor > arrFadeMax) {arrFadeCursor = 0;}setNoticia();m_bFadeOut = false;}} else {m_Fade1 -= m_FadeStep;m_Fade2 -= m_FadeStep;m_Fade3 -= m_FadeStep;if (m_Fade1 <= m_FadeIn1 && m_Fade2 <= m_FadeIn2 && m_Fade3 <= m_FadeIn3) {clearInterval(m_iFadeInterval);setTimeout(Faderesume, m_FadeWait);m_bFadeOut = true;}}var tituloNoticia = document.getElementById(elementoTituloNoticia);var horaNoticia = document.getElementById(elementoHoraNoticia);var separadorNoticia = document.getElementById(elementoSeparadorNoticia);if (m_Fade1 < m_FadeIn1) m_Fade1 = m_FadeIn1;  if (m_Fade1 > m_FadeOut1) m_Fade1 = m_FadeOut1;if (m_Fade2 < m_FadeIn2) m_Fade2 = m_FadeIn2;  if (m_Fade2 > m_FadeOut2) m_Fade2 = m_FadeOut2;if (m_Fade3 < m_FadeIn3) m_Fade3 = m_FadeIn3;  if (m_Fade3 > m_FadeOut3) m_Fade3 = m_FadeOut3;var color = "#" + ToHex(m_Fade1) + ToHex(m_Fade2) + ToHex(m_Fade3);tituloNoticia.style.color = color;horaNoticia.style.color = color;separadorNoticia.style.color = color;}
function Faderesume(){m_iFadeInterval = setInterval(fade_ontimer, milisegundosIntervaloFade);}
function ToHex(strValue){try {var result = parseInt(strValue).toString(16);while (result.length != 2) {result = "0" + result;}return result.toUpperCase();} catch (e) {}}
