function pageScroll(i, pos_y)
{
	if (i < 20)
	{
		window.scrollBy(0, pos_y);
		scrolldelay = setTimeout(function(){ pageScroll(i + 1, pos_y)}, 10);
	}
	else
		clearTimeout(scrolldelay);
}

function scroll_to_id(id)
{
	var elt = document.getElementById(id);
	var pos_y = -document.documentElement.scrollTop - document.body.scrollTop;
	while( elt != null ) 
	{
		pos_y += elt.offsetTop;
		elt = elt.offsetParent;
	}
	pageScroll(0, pos_y / 20)
	window.scrollBy(0, pos_y % 20);
}

function Scroll_News(time, id)
{
	this.pos = 0;
	this.time = time;
	this.id = id;
	this.elt = document.getElementById(id);
	this.news = new Array();
}

Scroll_News.prototype = 
{
	add_news : function(title, href)
	{
		var link_ = document.createElement('a');
		link_.href = href;
		link_.innerHTML = title;
		this.news.push(link_);
	},
	
	launch : function()
	{
		if (!this.elt)
		{
			alert("this.elt !exist");
			this.elt = document.getElementById(this.id);
		}
		while (this.elt.hasChildNodes() && (this.elt.firstChild != this.elt.lastChild))
		{
			this.elt.removeChild(this.elt.firstChild);
		}
		if (this.news.length == 1)
		{
			this.elt.removeChild(this.elt.firstChild);
			this.elt.appendChild(this.news[this.pos]);
		}
		else	
			this.boucle();
	},
	
	boucle : function()
	{
		if (this.pos > this.news.length - 1)
			this.pos = 0;
		this.elt.removeChild(this.elt.firstChild);
		this.elt.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+ 100 + ");";	
		this.elt.appendChild(this.news[this.pos]);
		++this.pos;
		setTimeout("scroll_news.fadding(1)", this.time);
	},
	
	fadding : function(opac)
	{
		opac -= 0.05;
		if (opac >= 0)
		{
			this.elt.style.opacity = opac;
			// For Internet Explorer
			this.elt.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+ opac * 100 + ");";	
			setTimeout(function() {scroll_news.fadding(opac);}, 50);
		}
		else
		{
			if (opac >= -0.3)
			{
				this.elt.style.opacity = 0;
				this.elt.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+ 0 + ");";
				setTimeout(function() {scroll_news.fadding(opac);}, 100);
			}
			else
			{
				this.elt.style.opacity = 1;
				this.elt.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+ 100 + ");";				
				this.boucle();
			}
		}
	}
}

var scroll_news = null;