// Copyright Peter Gehrig and Urs Dudli at www.24fun.ch/
// If you add this script to a script-library or script-archive 
// you have to add a hyperlink to www.24fun.ch on the webpage 
// Le titre | le texte|le lien des messages
if( message == null )
{
    message= new Array();
}

// La hauteur de la boite de messages.
var scrollerheight=84

// La largeur de la boite de messages.
var scrollerwidth=220

// La distance par rapport au bord supérieur de la fenêtre.
var scrollertop = 375

// La distance par rapport au bord gauche de la fenêtre.
//var scrollerleft = 158
var scrollerleft = 258

// La distance entre le bord et le texte.
var scrollerpadding=5

// La largeur du bord de la boite de messages.
var backgroundborder=0

// La couleur de l'arrière-plan de la boite de messages.
var scrollerbgcolor="FFFFFF"

// Le temps de pause entre les message (en millisecondes).
var standstillfix=3000

////////////////////////////////////////////////
var cliptop=0
var clipbottom=scrollerheight-2*scrollerpadding
var clipleft=0
var clipright=scrollerwidth
var i_message=0
var mes_joined
var mes_split
var contenttext
var contentbg
//var totalheight=scrollerheight*(message.length)
var totalheight=(message.length > 1) ? scrollerheight*(message.length - 1) : scrollerheight
//var totalheight=scrollerheight
var i_height=0
var step=1
var pause=20
var standstillflex=1

function initiate(){
	
	contenttext="<table cellpadding=0 cellspacing=0 border=0 width="+(scrollerwidth-2*scrollerpadding)+">"
	contenttext+="<tr valign='top'><td height='"+scrollerheight+"'><br></td></tr>"
	for (i=0;i<=message.length-1;i++) {
		mes_joined=message[i]
		mes_split=mes_joined.split("|")
		contenttext+="<tr valign='top'><td height='"+scrollerheight+"' class='txtstd'><b>"+mes_split[1]+"</b><br><a href='"+mes_split[3]+"' class='linknews'><b>"+mes_split[0]+"</b></a><br>"+mes_split[2]+"</td></tr>";
	}
	contenttext+="</table>"
	
	contentbg="<table cellpadding=0 cellspacing=0 border="+backgroundborder+" width='"+scrollerwidth+"'><tr><td height='"+scrollerheight+"' bgcolor="+scrollerbgcolor+"> </td></tr></table>"
	
	if (document.all) {
		scrollertext.innerHTML=contenttext
		scrollerbg.innerHTML=contentbg
		document.all.scrollertext.style.posTop=scrollertop
		document.all.scrollertext.style.posLeft=scrollerleft
		document.all.scrollerbg.style.posTop=scrollertop-scrollerpadding
		document.all.scrollerbg.style.posLeft=scrollerleft-scrollerpadding
		document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
	}
	if (document.layers) {
		document.scrollertext.document.write(contenttext)
		document.scrollertext.document.close()
		document.scrollerbg.document.write(contentbg)
		document.scrollerbg.document.close()
		document.scrollertext.top=scrollertop
		document.scrollertext.left=scrollerleft
		document.scrollerbg.top=scrollertop-scrollerpadding
		document.scrollerbg.left=scrollerleft-scrollerpadding	
		document.scrollertext.clip.left=clipleft
        	document.scrollertext.clip.right=clipright
        	document.scrollertext.clip.top=cliptop
        	document.scrollertext.clip.bottom=clipbottom
	}
	if (document.getElementById && !document.all)
	{
		theText = document.getElementById("scrollertext")
		theBG	= document.getElementById("scrollerbg")
		
		theText.innerHTML=contenttext
		theBG.innerHTML=contentbg
		theText.style.top=scrollertop
		theText.style.left=scrollerleft
		theBG.style.top=scrollertop-scrollerpadding
		theBG.style.left=scrollerleft-scrollerpadding
		theText.style.clip= "rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
	}
	/*
	if( doScroll )
	{
		scroll()
	}
	*/
	
	
	scroll()
	
}

function scroll(){
	
	standstillflex=standstillfix
	if (document.all){
		
		if (i_height<scrollerheight) {
			i_height+=step
			cliptop+=step
			clipbottom+=step
			document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
			document.all.scrollertext.style.posTop-=step
			var timer=setTimeout("scroll()",pause)
		}

		else {
			if (document.all.scrollertext.style.posTop<=-(totalheight)) {
				document.all.scrollertext.style.posTop=scrollertop
				cliptop=0
				clipbottom=scrollerheight-2*scrollerpadding
				document.all.scrollertext.style.clip= "rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
				standstillflex=0
			}
			i_height=0
			clearTimeout(timer)
			if( doScroll ) var timer=setTimeout("scroll()",standstillflex)
		}
	}
	
	if (document.layers)
	{
		if (i_height<scrollerheight) {
				i_height+=step
				cliptop+=step
				clipbottom+=step
				document.scrollertext.clip.left=clipleft
        		document.scrollertext.clip.right=clipright
        		document.scrollertext.clip.top=cliptop
        		document.scrollertext.clip.bottom=clipbottom
				document.scrollertext.top-=step
				var timer=setTimeout("scroll()",pause)
			}

		else {
			if (document.scrollertext.top<=-(totalheight)) {
				document.scrollertext.top=scrollertop
				cliptop=0
				clipbottom=scrollerheight-2*scrollerpadding
				document.scrollertext.clip.left=clipleft
        		document.scrollertext.clip.right=clipright
        		document.scrollertext.clip.top=cliptop
        		document.scrollertext.clip.bottom=clipbottom
				standstillflex=0
			}
			i_height=0
			clearTimeout(timer)
			if( doScroll ) var timer=setTimeout("scroll()",standstillflex)
		}
	}
	
	if (document.getElementById && !document.all)
	{
		theText = document.getElementById("scrollertext")
		
		if (i_height<scrollerheight) {
			
			i_height+=step;
			cliptop+=step;
			clipbottom+=step;
			theText.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")";
			
			
			var sTop = theText.style.top;
			var top  = 0;
			
			if( sTop.indexOf("px")!=-1 )
			{
				sTop = sTop.substr(0,sTop.indexOf("px"));
			}
				
			top = parseInt(sTop);
			top -= step;
			
			theText.style.top = top;
			
			var timer=setTimeout("scroll()",pause);
		}

		else {
			var sTop = theText.style.top;
			var top  = 0;
			
			if( sTop.indexOf("px")!=-1 )
			{
				sTop = sTop.substr(0,sTop.indexOf("px"));
			}
					
			top = parseInt(sTop);  
			
			if (top<=-(totalheight)) {
				
				theText.style.top = scrollertop
				cliptop=0
				clipbottom=scrollerheight-2*scrollerpadding
				theText.style.clip = "rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
				standstillflex=0
			}
			
			i_height=0   
			//clearTimeout(timer)
			if( doScroll ) var timer=setTimeout("scroll()",standstillflex)
		}
	}
	
}