function diapoSetMaxiImage(img)
{
	document.getElementById("maxiImage").src=img;
}
function diapoGetCurrentID()
{
	current = document.getElementById("maxiImage").src;
	reg = new RegExp(/([0-9]+)\.jpg/);
	return parseInt(current.match(reg)[1]);
}
function diapoSetNext(nb,nom)
{
	current = diapoGetCurrentID();
	next = current+1;
	if(current==nb)
		next=0;
	diapoSetMaxiImage('diapo_'+nom+'/'+next+'.jpg');
}
function diapoSetPrev(nb,nom)
{
	current = diapoGetCurrentID();
	prev = current-1;
	if(current==0)
		prev=nb;
	diapoSetMaxiImage('diapo_'+nom+'/'+prev+'.jpg');
}

window.onload=function()
{
	//Gestionnaire de message
	url=document.location.href;
	if(url.indexOf('?msg=')>0)
	{
		alert(URLDecode(url.substr(url.indexOf('?msg=')+5,url.length)));
	}
}

function URLEncode(plaintext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};

function URLDecode(encoded)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;
};

function setDisplay(cible,mode)
{
	cible=document.getElementById(cible);
	if(cible!=null)
	{
		cible.style.display=mode;
		return true;
	}
	return false;
}

function getDisplay(cible)
{
	cible=document.getElementById(cible);
	if(cible!=null)
	{
		return cible.style.display;
	}
	return false;
}

function switchDisplay(cible)
{
	if(getDisplay(cible)=='block')
		setDisplay(cible,'none');
	else
		setDisplay(cible,'block');
}


//****************************************************************************

var lastTimeout=0;
function toolTip(message,titre,duree)
{
	if(titre=='')
	{
		titre='<img src=images/trombone.gif align=absmiddle> Aide';
	}

	myToolTipTitre=document.getElementById('toolTipTitre');
	myToolTipTitre.innerHTML=titre;
	
	myToolTipTexte=document.getElementById('toolTipTexte');
	myToolTipTexte.innerHTML=message;

	myToolTip=document.getElementById('toolTip');
	myToolTip.style.display='block';
	
	clearTimeout(lastTimeout);
	lastTimeout=setTimeout('toolTipErase()',duree);
}
function toolTipErase()
{
	myToolTip=document.getElementById('toolTip');
	myToolTip.style.display='none';
	myToolTipTexte=document.getElementById('toolTipTexte');
	myToolTipTexte.innerHTML='';
}
function toolTipInit()
{
	document.write('<div id="toolTip" style="display:none;">');
	document.write('<div id="toolTipTitre"></div>');
	document.write('<div id="toolTipTexte"></div>');
	document.write('</div>');
}
toolTipInit()

//*******************************************************************************************
//******* Gestionnaire de la position de la souris ******************************************
//*******************************************************************************************
var _mouseX=0;
var _mouseY=0;
function mouseMove (e)
{ 
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		_mouseX = e.pageX;
		_mouseY = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		_mouseX = e.clientX + document.body.scrollLeft;
		_mouseY = e.clientY + document.body.scrollTop;
	}
	
	myToolTip = document.getElementById('toolTip');
	myToolTip.style.left=Math.min(_mouseX+20,screen.width-200);
	myToolTip.style.top=_mouseY+20;
}
if (document.layers) 
	document.captureEvents(Event.MOUSEMOVE); 
if (document.layers || document.all) 
	document.onmousemove = mouseMove; 
if (document.addEventListener) 
	document.addEventListener('mousemove', mouseMove, true); 
//*******************************************************************************************