function HideCalque(nom) 
{
	if (document.all)
	{
		document.all[nom].style.visibility="hidden";
	}
	if (window.sidebar) 
	{
		document.getElementById(nom).style.visibility="hidden";
	}
	if (document.layers)
	{
		document.layers[nom].visibility="hide";
	}
}

function ShowCalque(nom) 
{
	if (document.all) 
	{
		document.all[nom].style.visibility="visible";
	}
	if (window.sidebar)
	{
		document.getElementById(nom).style.visibility="visible";
	}
	if (document.layers) 
	{
		document.layers[nom].visibility="show";
	}
}
function IsVisible(nom) 
{
	if (document.all) 
	{
		if(document.all[nom].style.visibility=="visible")
		return true;
	}
	if (window.sidebar)
	{
		if(document.getElementById(nom).style.visibility=="visible")
		return true;
	}
	if (document.layers) 
	{
		if(document.layers[nom].visibility=="show")
		return true;
	}
	return false;
}

function GetLeft(nom) 
{
	if (document.all) 
	{
		return parseInt(document.all[nom].style.left);
	}
	if (window.sidebar) 
	{
		return parseInt(document.getElementById(nom).style.left);
	}
	if (document.layers) 
	{
		return parseInt(document.layers[nom].left);
	}
}

function GetTop(nom) 
{
	if (document.all) 
	{
		return parseInt(document.all[nom].style.top);
	}
	if (window.sidebar) 
	{
		return parseInt(document.getElementById(nom).style.top);
	}
	if (document.layers) 
	{
		return parseInt(document.layers[nom].top);
	}
}

function GetWidth(nom) 
{
	if (document.all) 
	{
		return parseInt(document.all[nom].style.width);
	}
	if (window.sidebar) 
	{
		return parseInt(document.getElementById(nom).style.width);
	}
	if (document.layers) 
	{
		return parseInt(document.layers[nom].width);
	}
}

function SetWidth(nom,w) 
{
	if (document.all) 
	{
		document.all[nom].style.width=w;
	}
	if (window.sidebar) 
	{
		document.getElementById(nom).style.width=w;
	}
	if (document.layers) 
	{
		document.layers[nom].width=w;
	}
}

function GetHeight(nom) 
{
	if (document.all) 
	{
		return parseInt(document.all[nom].style.height);
	}
	if (window.sidebar) 
	{
		return parseInt(document.getElementById(nom).style.height);
	}
	if (document.layers) 
	{
		return parseInt(document.layers[nom].height);
	}
}

function SetHeight(nom,h) 
{
	if (document.all) 
	{
		document.all[nom].style.height=h;
	}
	if (window.sidebar) 
	{
		document.getElementById(nom).style.height=h;
	}
	if (document.layers) 
	{
		document.layers[nom].height=h;
	}
}

function GetContent(nom) 
{
	if (document.all) 
	{
		return document.all[nom].innerHTML;
	}
	if (window.sidebar) 
	{
		return document.getElementById(nom).innerHTML;
	}
	if (document.layers) 
	{
		return document.layers[nom].innerHTML;
	}
}

function SetContent(nom,value) 
{
	if (document.all) 
	{
		document.all[nom].innerHTML=value;
	}
	if (window.sidebar) 
	{
		document.getElementById(nom).innerHTML=value;
	}
	if (document.layers) 
	{
		document.layers[nom].innerHTML=value;
	}
}


function MoveCalque(nom,X,Y) 
{
	if (document.all)
	{
		document.all[nom].style.top=Y;
		document.all[nom].style.left=X;
	}
	if (window.sidebar)
	{
		document.getElementById(nom).style.top=Y;
		document.getElementById(nom).style.left=X;
	}
	if (document.layers)
	{
		document.layers[nom].top=Y;
		document.layers[nom].left=X;
	}
}

function GetPageWidth()
{
	if(document.all || document.layers)
		return parseInt(document.body.clientWidth);
	if(window.sidebar)
		return parseInt(window.innerWidth);
}

function CentrerCalque(nom,x)
{
		HideCalque(nom);
		MoveCalque(nom,(GetPageWidth()-GetWidth(nom))/2+x,GetTop(nom));
		ShowCalque(nom);		
}

var ttup=new Array();
var ttdown=new Array();
var ttleft=new Array();
var ttright=new Array();
var speed_scroll=2;
function MoveCalqueTo(nom,dir,stop,delay)
{
	switch(dir)
	{
		case "up":
			if (GetTop(nom)>stop)
			{
				MoveCalque(nom,GetLeft(nom),GetTop(nom)-speed_scroll);
				ttup[nom]=setTimeout("MoveCalqueTo('"+nom+"','"+dir+"','"+stop+"','"+delay+"')",delay);
			}
			break;
		case "down":
			if (GetTop(nom)<stop)
			{
				MoveCalque(nom,GetLeft(nom),GetTop(nom)+speed_scroll);
				ttdown[nom]=setTimeout("MoveCalqueTo('"+nom+"','"+dir+"','"+stop+"','"+delay+"')",delay);
			}
			break;
		case "left":
			if (GetLeft(nom)>stop)
			{
				MoveCalque(nom,GetLeft(nom)-speed_scroll,GetTop(nom));
				ttleft[nom]=setTimeout("MoveCalqueTo('"+nom+"','"+dir+"','"+stop+"','"+delay+"')",delay);
			}
			break;
		case "right":
			if (GetLeft(nom)<stop)
			{
				MoveCalque(nom,GetLeft(nom)+speed_scroll,GetTop(nom));
				ttright[nom]=setTimeout("MoveCalqueTo('"+nom+"','"+dir+"','"+stop+"','"+delay+"')",delay);
			}
			break;
	}
}


function StopMoveCalque(nom)
{
	clearTimeout(ttup[nom]);
	clearTimeout(ttdown[nom]);
	clearTimeout(ttright[nom]);
	clearTimeout(ttleft[nom]);
}

speed_auto_scroll=1;

function AutoScroll(nom,conteneur,delay)
{
if (GetTop(nom)>GetHeight(nom)*(-1))
	{
		MoveCalque(nom,GetLeft(nom),GetTop(nom)-speed_auto_scroll);
		auto_scroll=setTimeout("AutoScroll('"+nom+"','"+conteneur+"','"+delay+"')",delay);
	}
else
	{
		MoveCalque(nom,GetLeft(nom),GetHeight(conteneur));
		AutoScroll(nom,conteneur,delay);
	}
}

function StartStopAutoScroll(nom)
{
	if (speed_auto_scroll==1)
		speed_auto_scroll=0;
	else
		speed_auto_scroll=1;
}


//// Filtre sur calque et image

function SetFilters(nom,value)
{
	if (document.all)
		document.all[nom].style.filter=value;
	else
		{
			document.getElementById(nom).style.MozOpacity='100%';
			SetOpacity(nom,value);
		}
}



function GetOpacity(nom)
{
	if (document.all)
		return document.all[nom].filters.alpha.opacity;
	else
		{
			s=document.getElementById(nom).style.MozOpacity;
			return parseInt(s.replace('%',''));
		}
}

function SetOpacity(nom,value)
{
	if (document.all)
		document.all[nom].filters.alpha.opacity=value;
	else
		document.getElementById(nom).style.MozOpacity=value+"%";
}


function FadeIn(nom,delay)
{
	if (GetOpacity(nom)!=100)
	{
		setTimeout("FadeIn('"+nom+"','"+GetOpacity(nom)+"','"+delay+"')",delay);
		SetOpacity(nom,GetOpacity(nom)+10);
	}
}

function FadeOut(nom,delay)
{
	if (GetOpacity(nom)!=0)
	{
		setTimeout("FadeOut('"+nom+"','"+GetOpacity(nom)+"','"+delay+"')",delay);
		SetOpacity(nom,GetOpacity(nom)-10);
	}
}





//-----suite de calques
var CalqueActif=new Array();
var NbCalque=new Array();
var roll_calque=new Array();

function AddSerieCalque(nom,nb)
{
	CalqueActif[nom]=1;
	NbCalque[nom]=nb;
	roll_calque[nom]=false;
}

function ShowNextCalque(nom)
{
	HideCalque(nom+CalqueActif[nom]);
	if (CalqueActif[nom]<NbCalque[nom])
		CalqueActif[nom]++;
	else
		CalqueActif[nom]=1;
	ShowCalque(nom+CalqueActif[nom]);
}


function ShowNextCalqueF(nom)
{
	HideCalque(nom+CalqueActif[nom]);
	SetOpacity(nom+CalqueActif[nom],0);
	if (CalqueActif[nom]<NbCalque[nom])
		CalqueActif[nom]++;
	else
		CalqueActif[nom]=1;
	ShowCalque(nom+CalqueActif[nom]);
	FadeIn(nom+CalqueActif[nom]);
}

function ShowCalqueI(nom,indice)
{
	HideCalque(nom+CalqueActif[nom]);
	CalqueActif[nom]=indice;
	ShowCalque(nom+CalqueActif[nom]);
}

function HideAllCalque(nom)
{
	for(i=1;i<NbCalque[nom]+1;i++)
		HideCalque(nom+i);
}

function HideAllCalqueF(nom)
{
	for(i=1;i<NbCalque[nom]+1;i++)
	{
		HideCalque(nom+i);
		SetOpacity(nom+i,0);
	}
}


function ShowCalqueIF(nom,indice)
{
	HideCalque(nom+CalqueActif[nom]);
	SetOpacity(nom+CalqueActif[nom],0);
	CalqueActif[nom]=indice;
	ShowCalque(nom+CalqueActif[nom]);
	FadeIn(nom+CalqueActif[nom],4);
}

function ShowPreviousCalque(nom)
{
	HideCalque(nom+CalqueActif[nom]);
	if (CalqueActif[nom]>1)
		CalqueActif[nom]--;
	else
		CalqueActif[nom]=NbCalque[nom];
	ShowCalque(nom+CalqueActif[nom]);
}

function RollCalque(nom,delay)
{
	
	setTimeout("RollCalque('"+nom+"','"+delay+"')",delay);
	if (roll_calque[nom])
		ShowNextCalque(nom);
	
}

function RollCalqueF(nom,delay)
{
	
	setTimeout("RollCalqueF('"+nom+"','"+delay+"')",delay);
	if (roll_calque[nom])
		ShowNextCalqueF(nom);
	
}
function StartStopRollCalque(nom)
{
	if(roll_calque[nom])
		roll_calque[nom]=false;
	else
		roll_calque[nom]=true;
}
//-----------------------------------


///// images//-----suite d images

function ChangeImage(nom,value)
{
	if (document.all)
		document.all[nom].src=value;
	else
		if(document.getElementById)
			document.getElementById(nom).src=value;
		else
			nom.src=value;
}

var ListeImage=new Array();
var ImageActif=0;
var roll_image=false;
function AddImage(img)
{
	ListeImage[ListeImage.length]=img;
}

function ShowNextImage(nom)
{
	if (ImageActif<ListeImage.length-1)
		ImageActif++;
	else
		ImageActif=0;
	ChangeImage(nom,ListeImage[ImageActif]);
}

function ShowPreviousImage(nom)
{
	if (ImageActif>0)
		ImageActif--;
	else
		ImageActif=ListeImage.length-1;
	ChangeImage(nom,ListeImage[ImageActif]);
}

function RollImage(nom,delay)
{
	setTimeout("RollImage('"+nom+"','"+delay+"')",delay);
	if(roll_image)
		ShowNextImage(nom,delay);
}

function StartStopRollImage(nom,delay)
{
	if(roll_image)
		roll_image=false;
	else
		roll_image=true;
}
//-----------------------------------
var _msg =new Array();
var _msgActif=0;
var _msgIndice=0;

function AddMessage($m)
{
	_msg[_msg.length]=$m; // ajouter <br> dans messages pour aller ligne
	
}

function TypingMessage(calque,delay)
{
	if(_msg[_msgActif].substring(_msgIndice,_msgIndice+1)!='$' && _msgIndice>=0)
		SetContent(calque,GetContent(calque)+_msg[_msgActif].substring(_msgIndice,_msgIndice+1));
	else
		SetContent(calque,GetContent(calque)+'<br>');
	if (_msgIndice<_msg[_msgActif].length)
			_msgIndice++;
	else
			if(_msgActif<_msg.length-1)
			{
				_msgIndice=0;
				_msgActif++;
				SetContent(calque,'');
			}
			else
			{
				_msgIndice=0;
				_msgActif=0;
				SetContent(calque,'');
			}
	setTimeout("TypingMessage('"+calque+"','"+delay+"')",delay);			
}



