	correct = true;
	departcorrect = false;
		function getXhr(){
                                var xhr = null;
				if(window.XMLHttpRequest) // Firefox et autres
				   xhr = new XMLHttpRequest();
				else if(window.ActiveXObject){ // Internet Explorer
				   try {
			                xhr = new ActiveXObject("Msxml2.XMLHTTP");
			            } catch (e) {
			                xhr = new ActiveXObject("Microsoft.XMLHTTP");
			            }
				}
				else { // XMLHttpRequest non supporté par le navigateur
				   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
				   xhr = false;
				}
                                return xhr
			}

			/**
			* Méthode qui sera appelée sur le click du bouton
			*/
			function chercheDepart(){
				var xhr = getXhr()
				// On défini ce qu'on va faire quand on aura la réponse
				xhr.onreadystatechange = function(){
					// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
					if(xhr.readyState == 4 && xhr.status == 200){
						//alert(xhr.responseText);
						reponse = xhr.responseText;
						//alert(reponse);
						if(reponse!='false')
							{
							document.getElementById('depart_infos').innerHTML = "<img src='../pics/correct.gif' alt='Correct'/> "+xhr.responseText;
							document.getElementById('depart_infos').style.fontWeight = "bold";
							document.getElementById('depart_infos').style.color = "green";
							document.getElementById('departement').style.border = "green solid 1px";
							document.getElementById('departement').style.backgroundColor = "#D2FAB2";
							document.getElementById('nom_depart').value = xhr.responseText;
							departcorrect = true;
							return(true);
							}
						else
							{
							document.getElementById('depart_infos').innerHTML = "<img src='../pics/erreur.gif' alt='Erreur'/> "+"Département non trouvé, recommencez";
							document.getElementById('depart_infos').style.fontWeight = "bold";
							document.getElementById('depart_infos').style.color = "red";
							document.getElementById('departement').style.border = "red solid 1px";
							document.getElementById('departement').style.backgroundColor = "#FDCDCD";
							correct = false;
							departcorrect = false;
							return(false);
							}
					}
				}

				// Ici on va voir comment faire du post
				xhr.open("POST","getdepart.php5",true);
				// ne pas oublier ça pour le post
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				// ne pas oublier de poster les arguments
				// ici, l'id de l'auteur
				sel = document.getElementById('departement');
				depart = sel.value;

				xhr.send("depart="+depart);
				//xhr.open("GET","getdepart.php5",true);
				//xhr.send(null);
			}

			function verifMail()
			{
				nomChamp = 'mail';
				champ = document.getElementById(nomChamp);
				adresse = champ.value;
				var place = adresse.indexOf("@",1);
				var point = adresse.indexOf(".",place+1);
				if(adresse=='')
				{
						champInfo = document.getElementById(nomChamp+'_infos');
						champInfo.innerHTML = "";
						champInfo.style.fontWeight = "";
						champ.style.border = "gray solid 1px";
						champ.style.backgroundColor = "white";
						return(false);
				}
				else
				{
					if ((place > -1)&&(adresse.length >2)&&(point > 1))
						{
						return champRempli('mail');
						}
					else
						{
						champInfo = document.getElementById(nomChamp+'_infos');
						champInfo.innerHTML = "<img src='../pics/erreur.gif' alt='Erreur'/> Format mail incorrect";
						champInfo.style.fontWeight = "bold";
						champInfo.style.color = "red";
						champ.style.border = "red solid 1px";
						champ.style.backgroundColor = "#FDCDCD";
						correct = false;
						return(false);
						}
				}
			}

			function champRempli(nomChamp)
				{
				champCourant=document.getElementById(nomChamp);
					if(champCourant.value!='')
						{
						champInfo = document.getElementById(nomChamp+'_infos');
						champInfo.innerHTML = "<img src='../pics/correct.gif' alt='Correct'/> ";
						champInfo.style.fontWeight = "bold";
						champCourant.style.border = "green solid 1px";
						champCourant.style.backgroundColor = "#D2FAB2";
						return(true);
						}
					else
						{
						champInfo = document.getElementById(nomChamp+'_infos');
						champInfo.innerHTML = "";
						champInfo.style.fontWeight = "";
						champCourant.style.border = "gray solid 1px";
						champCourant.style.backgroundColor = "white";
						correct = false;
						return(false);
						}
				}

			function champRempliSSImage(nomChamp)
				{
				champCourant=document.getElementById(nomChamp);
					if(champCourant.value!='')
						{
						champCourant.style.border = "green solid 1px";
						champCourant.style.backgroundColor = "#D2FAB2";
						return(true);
						}
					else
						{
						champInfo = document.getElementById(nomChamp+'_infos');
						champInfo.innerHTML = "";
						champInfo.style.fontWeight = "";
						champCourant.style.border = "gray solid 1px";
						champCourant.style.backgroundColor = "white";
						correct = false;
						return(false);
						}
				}
			/**
			 *
			 * @access public
			 * @return void
			 **/
			function selectRempli(nomChamp)
				{
				champCourant=document.getElementById(nomChamp);
					if(champCourant.options[champCourant.selectedIndex].value!=0)
						{
						champInfo = document.getElementById(nomChamp+'_infos');
						champInfo.innerHTML = "<img src='../pics/correct.gif' alt='Correct'/> ";
						champInfo.style.fontWeight = "bold";
						champCourant.style.border = "green solid 1px";
						champCourant.style.backgroundColor = "#D2FAB2";
						return(true);
						}
					else
						{
						champInfo = document.getElementById(nomChamp+'_infos');
						champInfo.innerHTML = "";
						champInfo.style.fontWeight = "";
						champCourant.style.border = "gray solid 1px";
						champCourant.style.backgroundColor = "white";
						correct = false;
						return(false);
						}
				}

			function chargement()
			{
				correct = true;
				maill = document.getElementById('mail').value;
				if(maill!='')
					{
					verifMail();
					}
				//selectRempli('typeClient');
				selectRempli('typeEvent');
				champRempli('nom');
				champRempli('prenom');
				champRempli('dateEvent');
				//champRempli('validville');
			}

			function envoyer(form)
			{
				if(verifMail() && champRempli('nom') && champRempli('prenom') && champRempli('dateEvent'))
					{
					form.submit();
					return(true);
					}
				else
					{
					champInfo = document.getElementById('erreurs');
					champInfo.innerHTML = "<br /><img src='pics/erreur.gif' alt='Erreurs' /> Erreurs dans le formulaire, veuillez remplir tous les champs.<br />";
					champInfo.style.color='red';
					champInfo.style.fontWeight='bold';
					return (false);
					}
				//correct = true;
			}

			/**
			 *
			 * @access public
			 * @return void
			 **/
			function changerImage(idGroupe,image)
			{
				champCourant=document.getElementById('image_'+idGroupe);
				champCourant.innerHTML = "<img src=\'"+image+"\' alt=\'\' />";
			}


			function openCloseDiv(nomDiv)
			{
				id = document.getElementById(nomDiv);
				if(id.style.display=='block')
				{
				id.style.display= 'none';
				id.style.visibility= 'hidden';
				}
				else
				{
				id.style.display= 'block';
				id.style.visibility= 'visible';
				}
			}

			/**
			 *
			 * @access public
			 * @return void
			 **/

		function toggleAll(name,val) {

		var inputs	= document.getElementsByTagName('input');
		var count	= inputs.length;

		for (i = 0; i < count; i++) {

			_input = inputs.item(i);

			if (_input.type == 'checkbox' && _input.id.indexOf('chk-'+val+'-' + name) != -1) {

				_input.checked = document.getElementById(name + '-all').checked;

			}

		}

	}


	/**
	 *
	 * @access public
	 * @return void
	 **/
	function afficherDiv(nomAff,nomCach)
	{
		var aff = document.getElementById(nomAff);
		var cach = document.getElementById(nomCach);
		// On cache le div
		cach.style.display='none';
		cach.style.visibility='hidden';
		// On affiche le div
		aff.style.display='block';
		aff.style.visibility='visible';
	}


	function progression(idBarre,i,maxI,maxTailleBarre)
    {
       if(i <= maxI)
       {
           var gdBarre = document.getElementById('barFixe');    //barre qu'il faut garder fixe
           gdBarre.style.width = maxTailleBarre+"px";

           var barre = document.getElementById('progressionBar');           //barre qu'il faut faire évoluer

           var x = (i*maxTailleBarre)/maxI;

           var pourcent = Math.round((i*100)/maxI);

           barre.style.width = x+"px";
           barre.style.height = "10px";

           var pourcentage = document.getElementById('afficheProgression');       //affiche pourcentage
           pourcentage.innerHTML = pourcent+"%";

       }
    }

    function addslashes (str) {
    // Escapes single quote, double quotes and backslash characters in a string with backslashes  
    // 
    // version: 1103.1210
    // discuss at: http://phpjs.org/functions/addslashes
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ates Goral (http://magnetiq.com)
    // +   improved by: marrtins
    // +   improved by: Nate
    // +   improved by: Onno Marsman
    // +   input by: Denny Wardhana
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   improved by: Oskar Larsson Högfeldt (http://oskar-lh.name/)
    // *     example 1: addslashes("kevin's birthday");
    // *     returns 1: 'kevin\'s birthday'
    str = stripslashes(str);
    return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
    }

    function stripslashes (str) {
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ates Goral (http://magnetiq.com)
    // +      fixed by: Mick@el
    // +   improved by: marrtins
    // +   bugfixed by: Onno Marsman
    // +   improved by: rezna
    // +   input by: Rick Waldron
    // +   reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +   input by: Brant Messenger (http://www.brantmessenger.com/)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: stripslashes('Kevin\'s code');
    // *     returns 1: "Kevin's code"
    // *     example 2: stripslashes('Kevin\\\'s code');
    // *     returns 2: "Kevin\'s code"
    return (str + '').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {
        case '\\':
            return '\\';
        case '0':
            return '\u0000';
        case '':
            return '';
        default:
            return n1;
        }
    });
}

