
	// ### Création d'un nouvel Objet AUDIO (avec sources WAV & MP3)
	function newSound(source)
	{ // string (sans extension)
		objetSon = new Audio(); // inutile !
		objetSon = document.createElement("audio");
		objetSon.innerHTML = '<source src="img/'+source+'.mp3" type="audio/mpeg" /><source src="img/'+source+'.wav" type="audio/x-wav" />';
		return objetSon;
	}
	function newBackSound(source)
	{
		backSource = [];
		backSource[0] = newSound(source); backSource[0].load();
		backSource[1] = newSound(source); backSource[1].load();
		return backSource;
	}
	function pauseBackSound(objetSon)
	{
		objetSon[0].currentTime = 0; objetSon[0].pause();
		objetSon[1].currentTime = 0; objetSon[1].pause();
	}
	function playBackSound(objetSon)
	{
		objetSon[0].addEventListener('ended', function(){
			this.currentTime = 0;
			this.pause();
			objetSon[1].play();
			}, false);
		objetSon[1].addEventListener('ended', function(){
			this.currentTime = 0;
			this.pause();
			objetSon[0].play();
			}, false);
		objetSon[0].play();
	}

	// ### Requête AJAX
	function ajaxGet(data)
	{ // format =>   clef :: valeur || clef2 :: valeur2 ||
		var retour = new Array;
		if (data.length>0)
		{
			details = data.split('||');
			for (i=0;i<details.length;i++)
			{
				ledetail = details[i];
				detail = ledetail.split('::');
				retour[detail[0]] = detail[1];
			}
		}
		retour['eof'] = 'ok';
		return retour;
	}
	function ajaxSend(url,data,reponse)
	{
		var xmlhr_object = null;
			if (window.XMLHttpRequest)
				xmlhr_object = new XMLHttpRequest();
			else if (window.ActiveXObject)
				xmlhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhr_object.onreadystatechange = function()
			{
				if (xmlhr_object.readyState == 4)
				{
  					retour = reponse+'("'+xmlhr_object.responseText+'");';
					eval(retour);
				}
			}
		xmlhr_object.open("POST", url, true);
		xmlhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhr_object.send(data);
	}

	// ### Remplir ou Récupérer le contenu d'un Objet
	function setHTML(id,html)
	{
		document.getElementById(id).innerHTML = html;
	}
	function getHTML(id)
	{
		return document.getElementById(id).innerHTML;
	}

	// ### Simplification d'utlisation des Objets
	function setObject(id)
	{
		return document.getElementById(id);
	}
	function imgObject(id,img)
	{
		document.getElementById(id).style.background = 'url('+img+') center center no-repeat';
	}

	// ### Afficher et Cacher un Objet
	function showObject(id)
	{
		document.getElementById(id).style.display = 'block';
	}
	function hideObject(id)
	{
		document.getElementById(id).style.display = 'none';
	}
	function swapObject(id)
	{
		if (document.getElementById(id).style.display=='block')	document.getElementById(id).style.display = 'none';
		else document.getElementById(id).style.display = 'block';
	}

	// ### Modifier l'Opacité (alpha) d'un Objet
	function setOpacity(id,pourcent)
	{
		document.getElementById(id).style.filter='alpha(opacity='+pourcent+')';
		if (pourcent>=100)
		{
			document.getElementById(id).style.mozOpacity='1.0';
			document.getElementById(id).style.opacity='1.0';
		}
		else
		{
			if (pourcent<10) {pourcent='0'+pourcent;}
			document.getElementById(id).style.mozOpacity='0.'+pourcent;
			document.getElementById(id).style.opacity='0.'+pourcent;
		}
	}

	// ### Fonctions sur les Nombres
	//function d2h(d) {return d.toString(16);}
	//function h2d(h) {return parseInt(h,16);}
	function dechex(number)
	{
		if (number < 0) number = 0xFFFFFFFF + number + 1;
		return parseInt(number, 10).toString(16);
	}
	function hexdec (hex_string)
	{
		hex_string = (hex_string + '').replace(/[^a-f0-9]/gi, '');
		return parseInt(hex_string, 16);
	}
	// ### Formater un Nombre
	function numberFormat(nb)
	{
		nouveauNombre = '';
		txtNombre = ''+Math.round(nb);
		decalage=0;
		nbChiffres = txtNombre.length;
		for (chiffre=nbChiffres;chiffre>0;chiffre--)
		{
			nouveauNombre = txtNombre.substring( (chiffre-1) , chiffre ) + nouveauNombre;
			decalage++;
			if ( (decalage>2) && (chiffre>1) )
			{
				nouveauNombre = '.'+nouveauNombre;
				decalage = 0;
			}
		}
		return nouveauNombre;
	}

	// ### Gestion d'un Bouton Radio dans un Formulaire HTML
	function getCheckedValue(radioObj)
	{
		if (!radioObj) return false;
		var radioLength = radioObj.length;
		if (radioLength == undefined)
			if (radioObj.checked)
				return radioObj.value;
			else
				return false;
		for (var i = 0; i < radioLength; i++)
			if (radioObj[i].checked) return radioObj[i].value;
		return false;
	}
	function setCheckedValue(radioObj, newValue)
	{
		if (!radioObj) return false;
		var radioLength = radioObj.length;
		if (radioLength == undefined)
		{
			radioObj.checked = (radioObj.value == newValue.toString());
			return false;
		}
		for (var i = 0; i < radioLength; i++)
		{
			radioObj[i].checked = false;
			if (radioObj[i].value == newValue.toString())
				radioObj[i].checked = true;
		}
	}

	// ### Gestion de la Souris et des Drag & Drop
	var mouseX; var mouseY; var isDrag = false; var maxZindex = 200;
	function getDrag(id2drag)
	{
		idDrag = id2drag;
		dragX = mouseX - parseInt(document.getElementById(idDrag).style.left);
		dragY = mouseY - parseInt(document.getElementById(idDrag).style.top);
		getZindex = parseInt(document.getElementById(idDrag).style.zIndex);
			maxZindex++; if (maxZindex<getZindex) maxZindex=getZindex;
		document.getElementById(idDrag).style.zIndex = maxZindex;
		isDrag = true;
	}
	function moveDrag(e)
	{
		mouseX = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
		mouseY = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
		if (isDrag)
		{
			document.getElementById(idDrag).style.left = (mouseX-dragX)+'px';
			document.getElementById(idDrag).style.top = (mouseY-dragY)+'px';
		}
	}
	function looseDrag(e)
	{
		isDrag = false;
	}
		if (navigator.appName.substring(0,3) == "Net") document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = moveDrag;
		document.onmouseup = looseDrag;

