	/*	
		é
		test()
		@desc : Fonction pour tester javascript
		@param : null
		@return : affiche une boite de dialogue "OK"
	*/
	function test()
	{
		alert("OK");
	}
	
	
	/*
		createXHR() 
		@desc : Initialisation d'un objet pour traitement AJAX
		@param : null
		@return : objet XMLHttpRequest ou un objet ActiveX en fonction du navigateur
		--
		@remarques : Fonction indispensable pour les traitements AJAX
	*/
	function createXHR()  
	{
		var req = null; 

		if (window.XMLHttpRequest)
		{
			req = new XMLHttpRequest();

		} 
		else if (window.ActiveXObject) 
		{
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e)
			{
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		return req;
	}
	
	/*
		trim(myString)
		@desc : supprime les espaces de début et de fin de chaine
		@param string myString : chaine a traiter
		@return string : une chaine emputée des espaces inutiles

	*/	
	function trim(myString)
	{
		return myString.replace(/^\s+/g,'').replace(/\s+$/g,'');
	}
	
	/*
		VerificationEmail(myString)
		@desc : verifie la validité d'une adresse mail
		@param string myString : chaine a verifier
		@return bool : true or false en fonction de la validité

	*/
	function VerificationEmail(myString)
	{
		if(myString!="")	
		{
			if (myString.indexOf("@") != "-1" &&
			    myString.indexOf(".") != "-1")
			    return true;
			else
			{
				return false;
			}
		}
	}
		
	/*
		ucfirst( str ) 
		@desc : met la première lettre en majuscule
		@param string str : chaine a modifier
		@return string : chaine de retour

	*/
	function ucfirst( str ) 
	{
		str += '';
	    var f = str.charAt(0).toUpperCase();
	    return f + str.substr(1);
	}
	
	/*
		ucwords( str ) 
		@desc : met la première lettre de chaque mot en majuscule
		@param string str : chaine a modifier
		@return string : chaine de retour

	*/
	function ucwords( str ) 
	{
        return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase ( ); } );
	}
	
	
	
	
	function cut_nbre(val)
	 {
		var nbre_str = val.toString();
		var nbre =  0;
		if(nbre_str.length > 1) {
			nbre = parseInt(nbre_str.charAt(0))+parseInt(nbre_str.charAt(1));
		} else {
			nbre = val;
		}
		return nbre;
	}
	
	
	
	
	
	function verif_syntaxURL(elm)
	{
		var chiffres = new RegExp("[0-9a-zA-Z_]"); /* Modifier pour : var chiffres = new RegExp("[0-9]"); */
		var verif;
		for(x = 0; x < elm.value.length; x++)
		{
			verif = chiffres.test(elm.value.charAt(x));
			
		
			if(verif == false)
			{
				elm.value = elm.value.substr(0,x) + elm.value.substr(x+1,elm.value.length-x+1); 
				x--;
			}
		}
		
	}
	
	
	
		
	function limite(textarea, max)
	{
	    if(textarea.value.length >= max)
	    {
	        textarea.value = textarea.value.substring(0,max);
			document.getElementById('max_desc').style.color="#c6231f";
	    }
		else
		{
			document.getElementById('max_desc').style.color="#a0a0a0";
		}
	    var reste = max - textarea.value.length;
	    var affichage_reste = "reste : "+ reste ;
	    document.getElementById('max_desc').innerHTML = affichage_reste;
	}
	
	function bp_verif_form_contact(mail,prenom,nom,tel,objet,message)
	{
		if(trim(mail)!="" && trim(prenom)!="" && trim(nom)!="" && trim(tel)!="" && trim(objet)!="" && trim(message)!="")
		{
			if(VerificationEmail(mail))
				return 0;
			else
				return 1;
		}
		else
		{
			return 2;
		}
	}
	
	function bp_envoi_mail_contact()
	{
		var txt_contact_mail=document.getElementById('txt_contact_mail').value;
		var txt_contact_prenom=document.getElementById('txt_contact_prenom').value;
		var txt_contact_nom=document.getElementById('txt_contact_nom').value;
		var txt_contact_tel=document.getElementById('txt_contact_tel').value;
		var txt_contact_obj=document.getElementById('txt_contact_obj').value;
		var txt_contact_mess=document.getElementById('txt_contact_mess').value;
		
		
		var div_msg=document.getElementById('contact_avert');
		
		div_msg.innerHTML="&nbsp;";
		
		
		var verif_form= bp_verif_form_contact(txt_contact_mail,txt_contact_prenom,txt_contact_nom,txt_contact_tel,txt_contact_obj,txt_contact_mess);
		
		
		
		
		
		
		var req = createXHR();
		req.onreadystatechange = function()
		{ 
			if(req.readyState == 4)
			{
				//alert(req.readyState);
				if(req.status == 200)
				{	
					div_msg.innerHTML=req.responseText;
					if(verif_form==0)
						bp_reset_mail_contact();
				}
				else	
				{
					div_msg.style.color="#c6231f";
					div_msg.innerHTML="Erreur: code " + req.status + " " + req.statusText;
				}
			}
		}
		
				
		var data="txt_contact_mail="+txt_contact_mail+"&txt_contact_prenom="+txt_contact_prenom+"&txt_contact_nom="+txt_contact_nom+"&txt_contact_tel="+txt_contact_tel+"&txt_contact_obj="+txt_contact_obj+"&txt_contact_mess="+txt_contact_mess+"&verif_form="+verif_form;
		req.open("POST", "traitement_envoi_mail_contact.php", true);
		req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-1');
		req.send(data);
			
		
	}
	
	
	function bp_reset_mail_contact()
	{
		document.getElementById('txt_contact_mail').value="";
		document.getElementById('txt_contact_prenom').value="";
		document.getElementById('txt_contact_nom').value="";
		document.getElementById('txt_contact_tel').value="";
		document.getElementById('txt_contact_obj').value="";
		document.getElementById('txt_contact_mess').value="";
	}
	
	
