/* PushChannel with JavaScript 
	author:Sylvain Hamel
	version:1.0
*/

// value for the pushChanel width and height 
var pushWidth=150;
var pushHeight=150;
//value for news height and origin in the push chanel ,and the destination where the news disappear
var newsHeight=25;
var newsOrigin= 175;
var newsDestination=30;
//background color of push chanel
var bg="white" ;
var news = new Array();
var spacer = new Array();


//---------------------- NEWS SECTION HERE ----------------------------------------------------

//news messages if you need more news add to the end of this array with the syntax ,'<new Msg>'
var newsMsg =['Bienvenue sur le site de Blanchard,Roy et Ass.',
              'Les mises à jour sont sous la rubrique mise à jour'];
			  
//must be position related to the news in the newsMsg array ,if no url enter null
var newsLink=[ null , './miseajour.html',null];


//--------------------- AUTOMATIC SECTION -------------------------------------------

//write the html document
document.write('<div id="pusher"'+
				' style=" background-color:'+bg+'; width:'+pushWidth +';height:'+pushHeight+'">'+
				'<div id="banner" align="center" style="background-color:#B92335 ; height:25">'+
				'<font size="+2" face="Arial" color="White">Nouvelles</font></div>'
				)

//write all the news
for ( var i=0; i < newsMsg.length ; i++){
	document.write('<div id="News'+i+'" '+
					'style="position:absolute; top:'+newsOrigin+' ;height:'+newsHeight+
				    ';background-color:'+bg+';visibility:hidden;font-family:Arial ;font-size:8pt">')
	
	if ( isNaN(newsLink[i]))
		document.write('<a href="'+newsLink[i]+'">'+newsMsg[i]+'</a></div>');
	else
		document.write( newsMsg[i]+'</div>');
}

document.write('</div>');
// ----------------------- END OF AUTOMATIC SECTION -------------------------------------
				
//push the news upward				
function pushNews(){

	//build the array of news
	var spacerUnit =50;
	
	for(var i=0; i< newsMsg.length ; i++){
		news[i] = document.all.item("News"+i);
		news[i].style.visiblity="hidden";
		
		spacer[i] = newsOrigin + (spacerUnit * i)
		news[i].style.posTop = spacer[i];
	}
	animateNews();
}

function animateNews(){
	moveNews();
	timer=setTimeout('animateNews()',125)
}

//move the news upward
function moveNews(){ 

	var displayOther =false;
	var activeNews;
	
	
	for ( var i =0; i < news.length ; i++){
	
		//move the good news
		activeNews = news[i];
		activeNews.style.posTop -=1;
		
		if ( activeNews.style.posTop < 125 )
		  activeNews.style.visibility ="visible";
		
		if ( activeNews.style.posTop == newsDestination){
			activeNews.style.visibility="hidden";
			activeNews.style.posTop= newsOrigin;
		}  
	}
}
