
var ClickDown = false;
var PosY = 0;
var obj = null;
var Hauteur = 0;

//document.onmousemove=Move();
function Move()
{	
	if(ClickDown == true)
	{
		var taille = event.y - PosY + Hauteur;
		taille = taille + "px";
		obj.style.height= taille;
	}
}

function Down(Num)
{	
	document.body.style.cursor='s-resize';
	obj = document.getElementById("MyDiv"+ Num);
	ClickDown=true;
	PosY = event.y;
	var height = obj.style.height +" ";
	var pos = height.indexOf('px');
	if(pos == -1)
		pos = height.length;
	height = height.substring(0,pos);
	if(height == '' || height == ' ')
		height = "50";
	Hauteur = parseInt(height);
}
function Up()
{	
	ClickDown=false;
	
	try
	{
		if( obj.style.display != 'none')
			document.body.style.cursor = 'default';
	}
	catch(ex)
	{
	}
}
function Click(Num)
{
	var vis = 'block';
	var pasvis = 'none';
	if( document.getElementById("ImgUp"+ Num).style.display != 'none')
	{
		pasvis = vis;
		vis = 'none';
	}
	document.getElementById("MyDiv"+ Num).style.display=vis; 
	document.getElementById("ImgUp"+ Num).style.display = vis;
	document.getElementById("ImgDown"+ Num).style.display = pasvis;
	if(document.getElementById("resize_bas"+ Num) != null)
		document.getElementById("resize_bas"+ Num).style.display = vis;
}
function MouseOver(Num)
{
	if(document.getElementById("MyDiv"+ Num).style.display == 'none')
		document.body.style.cursor='default';
	else
	{
		if(ClickDown == true)
			document.body.style.cursor='s-resize';
		else
			document.body.style.cursor='pointer';
	}
		
		
		//this.style.cursor='s-resize';
		//this.style.cursor='wait';
		//document.body.style.cursor='wait';
		//document.body.style.cursor='s-resize';
}
function MouseOut()
{
	//this.style.cursor='cursor: default';
	document.body.style.cursor='';
}


// La hauteur de la boite de messages.
var scrollerheight=300
// Le temps de pause entre les message (en millisecondes).
var arret=3000
var step=1
var pause=10
var NumStop= -1;

var timer = new Array()
var height = new Array()
var cliptop = new Array()
var clipbottom = new Array()
var totalheight= new Array()

function initiate(num, nbLignes, scrollHeight, withArret)
{
	scrollerheight = scrollHeight;
	if(withArret == 1)
		arret = 3000;
	else
		arret = 500;
	totalheight[num]= scrollerheight*(nbLignes+1);
	height[num]=0;
	cliptop[num]=0;
	clipbottom[num]=scrollerheight
	
	/* code modifier*/
	/*
	document.getElementById("scrollertext"+ num).style.top="0px";
	document.getElementById("scrollertext"+ num).style.left="0px";
	*/
	/* Code obsolete */
	
	if (document.all) {
		document.getElementById("scrollertext"+ num).style.posTop=0
		document.getElementById("scrollertext"+ num).style.posLeft=0
//		document.getElementById("scrollertext"+ num).style.clip="rect("+cliptop[num]+" "+scrollerheight+" "+clipbottom[num]+" 0)"
	}
	else if (document.layers) {
		document.getElementById("scrollertext"+ num).top=0
		document.getElementById("scrollertext"+ num).left=0
//		document.getElementById("scrollertext"+ num).clip.left=0
//	   	document.getElementById("scrollertext"+ num).clip.right=scrollerheight
//       	document.getElementById("scrollertext"+ num).clip.top=cliptop[num]
//		document.getElementById("scrollertext"+ num).clip.bottom=clipbottom[num]
	}
	else
	{
		document.getElementById("scrollertext"+ num).style.top="0px";
		document.getElementById("scrollertext"+ num).style.left="0px";
	}
	
	scroll(num)
}

function scroll(num)
{

	if(NumStop == num)
	{
		clearTimeout(timer[num]);
		timer[num]=setTimeout("scroll("+ num +")",pause)
	}
	else
	{
		/* Code rajouté */
		/*
		if (height[num]<scrollerheight) 
		{
			height[num]+=step
			cliptop[num]+=step
			clipbottom[num]+=step
			document.getElementById("scrollertext"+ num).style.top = parseInt(document.getElementById("scrollertext"+ num).style.top)-step+'px';
			
			clearTimeout(timer[num])
			timer[num]=setTimeout("scroll("+ num +")",pause)
		}
		else 
		{
			if (parseInt(document.getElementById("scrollertext"+ num).style.top) <=-(totalheight[num])) 
			{
				document.getElementById("scrollertext"+ num).style.top = '0px'
				cliptop[num]=0
				clipbottom[num]=scrollerheight
				height[num]=0
				clearTimeout(timer[num])
				timer[num]=setTimeout("scroll("+ num +")",pause)
			}
			else
			{
				height[num]=0
				clearTimeout(timer[num])
				timer[num]=setTimeout("scroll("+ num +")",arret)
			}
		}
		*/
		/* Code obsolete */
		
		if (document.all)
		{
			if (height[num]<scrollerheight) 
			{
				height[num]+=step
				cliptop[num]+=step
				clipbottom[num]+=step
//				document.getElementById("scrollertext"+ num).style.clip="rect("+cliptop[num]+" "+scrollerheight+" "+clipbottom[num]+" 0)"
				document.getElementById("scrollertext"+ num).style.posTop-=step
				clearTimeout(timer[num])
				timer[num]=setTimeout("scroll("+ num +")",pause)
			}
			else 
			{
				if (document.getElementById("scrollertext"+ num).style.posTop<=-(totalheight[num])) 
				{
					document.getElementById("scrollertext"+ num).style.posTop=0
					cliptop[num]=0
					clipbottom[num]=scrollerheight
//					document.getElementById("scrollertext"+ num).style.clip="rect("+cliptop[num]+" "+scrollerheight+" "+clipbottom[num]+" 0)"
					height[num]=0
					clearTimeout(timer[num])
					timer[num]=setTimeout("scroll("+ num +")",pause)

				}
				else
				{
					height[num]=0
					clearTimeout(timer[num])
					timer[num]=setTimeout("scroll("+ num +")",arret)
				}
			}
		}
		else if (document.layers)
		{
			if (height[num]<scrollerheight) 
			{
				height[num]+=step
				cliptop[num]+=step
				clipbottom[num]+=step
//				document.getElementById("scrollertext"+ num).clip.left=0
//		       		document.getElementById("scrollertext"+ num).clip.right=scrollerheight
//	        		document.getElementById("scrollertext"+ num).clip.top=cliptop[num]
//        			document.getElementById("scrollertext"+ num).clip.bottom=clipbottom[num]
				document.getElementById("scrollertext"+ num).top-=step
				clearTimeout(timer[num])
				timer[num]=setTimeout("scroll("+ num +")",pause)
			}
			else 
			{
				if (document.scrollertext.top<=-(totalheight[num])) 
				{
					document.getElementById("scrollertext"+ num).top=0
					cliptop[num]=0
					clipbottom[num]=scrollerheight
//					document.getElementById("scrollertext"+ num).clip.left=0
//       				document.getElementById("scrollertext"+ num).clip.right=scrollerheight
//	        			document.getElementById("scrollertext"+ num).clip.top=cliptop[num]
//	        			document.getElementById("scrollertext"+ num).clip.bottom=clipbottom[num]
					height[num]=0
					clearTimeout(timer[num])
					timer[num]=setTimeout("scroll("+ num +")",pause)
				}
				else
				{
					height[num]=0
					clearTimeout(timer[num])
					timer[num]=setTimeout("scroll("+ num +")",arret)
				}
			}
		}
		else
		{
			if (height[num]<scrollerheight) 
			{
				height[num]+=step
				cliptop[num]+=step
				clipbottom[num]+=step
				document.getElementById("scrollertext"+ num).style.top = parseInt(document.getElementById("scrollertext"+ num).style.top)-step+'px';
				
				clearTimeout(timer[num])
				timer[num]=setTimeout("scroll("+ num +")",pause)
			}
			else 
			{
				if (parseInt(document.getElementById("scrollertext"+ num).style.top) <=-(totalheight[num])) 
				{
					document.getElementById("scrollertext"+ num).style.top = '0px'
					cliptop[num]=0
					clipbottom[num]=scrollerheight
					height[num]=0
					clearTimeout(timer[num])
					timer[num]=setTimeout("scroll("+ num +")",pause)
				}
				else
				{
					height[num]=0
					clearTimeout(timer[num])
					timer[num]=setTimeout("scroll("+ num +")",arret)
				}
			}	
		}
	}
}

function Stopper(num)
{
	NumStop = num;
}

function GoOn(num)
{
	NumStop=-1;  
}



var delay = 3000; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)

var fcontent=new Array();
var fadecounter=new Array();


var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;


function changecontent(num){

	if(NumStop == num)
	{
		clearTimeout(fadecounter[num]);
		fadecounter[num]=setTimeout("changecontent("+num+")",100)
	}
	else
	{
		var begintag='<div style="font: normal 14px Arial; padding: 5px;" onmouseover=Stopper('+num+') onmouseout=GoOn('+num+')>';
  		if (index>=fcontent[num].length)
    		index=0
  		if (DOM2){
    			document.getElementById("fscroller"+num).innerHTML=begintag+fcontent[num][index]+'</div>'
 			linkcolorchange(1,num);
    			colorfade(1, num);
  		}
  		else if (ie4)
    			document.getElementById("fscroller"+num).innerHTML=begintag+fcontent[num][index]+'</div>';
  		index++
	}
}

function linkcolorchange(step, num){
  var obj=document.getElementById("fscroller"+num).getElementsByTagName("A");
  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color=getstepcolor(step);
  }
}

function colorfade(step,num) {
  if(step<=maxsteps) {	
    document.getElementById("fscroller"+num).style.color=getstepcolor(step);
    linkcolorchange(step,num);
    step++;
    fadecounter[num]=setTimeout("colorfade("+step+","+num+")",stepdelay);
  }else{
    clearTimeout(fadecounter[num]);
    document.getElementById("fscroller"+num).style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
    setTimeout("changecontent("+num+")", delay);
	
  }   
}

function getstepcolor(step) {
  var diff
  var newcolor=new Array(3);
  for(var i=0;i<3;i++) {
    diff = (startcolor[i]-endcolor[i]);
    if(diff > 0) {
      newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
    } else {
      newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
    }
  }
  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

function StartPading(num,nb)
{
fcontent[num]=new Array();
for(var i=0;i<nb;i++) 
{
	fcontent[num][i]=document.getElementById("fcontent"+num+'-'+i).innerHTML
}
if (ie4||DOM2)
  document.write('<div id="fscroller'+num+'" ></div>');
changecontent(num)
}

