// JavaScript Document

//copyright Capturator S.r.l.
//scrolling news script

//display the news div on the homepage
function show_news ()
{
document.getElementById('news').style.visibility="visible";
document.getElementById('news_text').style.visibility="visible";
start_news();
}


//delay between news
var news_delay=10000;

//delay for text apparition
var text_delay=100;

//Nb of colors for the grafation
var color_item=4;

//delay for text disparition
var display_delay=news_delay-(text_delay*color_item*2);

//news array inserted in news_summary.php

//gradation colors
var color= new Array();
color[0] = "#FFFFFF";
color[1] = "#E5BFBF";
color[2] = "#CC7F7F";
color[3] = "#B34040";
color[4] = "#990000";

i=0;
j=0;
k=color_item;

//start scrolling news
function start_news(){
display_news();
text_gradation();
}

//display scrolling news
function display_news(){

document.getElementById('news_text').innerHTML=news[i++];

	if (i < news.length){	
	setTimeout('display_news()',news_delay);	
	}

	if (i >= news.length)
	{i=0;
	setTimeout('display_news()',news_delay);}
}

//display text
function text_gradation(){
j=0;
k=color_item;
text_appear();
setTimeout('text_disappear()',display_delay);
setTimeout('text_gradation()',news_delay);
}	
	
//text apparition
function text_appear(){
document.getElementById('news_text').style.color=color[j++];
if (j < color_item){
setTimeout('text_appear()',text_delay);}
}

//text disparition
function text_disappear(){
document.getElementById('news_text').style.color=color[k--];
if (k > 0){
setTimeout('text_disappear()',text_delay);}
}


