function sendAjaxData(data, page, method, div)
{
	if(document.all)
    {
        //Internet Explorer
        var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
    }//fin if
    else
    {
        //Mozilla
        var XhrObj = new XMLHttpRequest();
    }//fin else
    
    //d&eacute;finition de l'endroit d'affichage:
    var content = document.getElementById(div);
    
    //si on envoie par la m&eacute;thode GET:
    if(method == "GET")
    {
        if(data == 'null')
        {
            //Ouverture du fichier s&eacute;lectionn&eacute;:
            XhrObj.open("GET", page, true);
        }//fin if
        else
        {
            //Ouverture du fichier en methode GET
            XhrObj.open("GET", page+"?"+data, true);
        }//fin else
    }//fin if
    else if(method == "POST")
    {
        //Ouverture du fichier en methode POST
        XhrObj.open("POST", page + "?RANDOM="+Math.random()+String.fromCharCode(34), true); 
    }//fin elseif
 
    //Ok pour la page cible
    XhrObj.onreadystatechange = function()
    {
        if (XhrObj.readyState == 4 && XhrObj.status == 200){
        	if (XhrObj.responseText == 'Message envoy&eacute; !'){
				document.getElementById('courriel').value = 'Adresse e-mail';
				document.getElementById('tel').value = document.getElementById('tel_texte').value;
			}
        		
            content.innerHTML = XhrObj.responseText ;
    	}else
			content.innerHTML = '<img src="http://www.avantages-fiscaux.fr/wp-content/themes/elements-of-seo_1.4/images/loading.gif">';
    }    
 
    if(method == "GET")
    {
        XhrObj.send(null);
    }//fin if
    else if(method == "POST")
    {
        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(data);
    }//fin elseif
}//fin fonction SendData



function getFormValueToSendAjax(inputList, ajaxFile, idtype, reload_page, reload_div, emptyInput, divResult) {

	//alert(document.getElementById("hd_prov").value);
	var poststr = '';
	var inputValue = '';
	var inputName = '';
	
	if (inputList != '')
	{
		tabInput = inputList.split("|");
		for(cptInput=0;cptInput<tabInput.length;cptInput++)
		{
			inputName = tabInput[cptInput];
			
			if (document.getElementById(inputName)){ 
				
				inputValue = document.getElementById(inputName).value;
				poststr += inputName + "=" + inputValue + "&";
			}
		}
	}
	
	if (poststr != '')
		poststr = poststr.substring(0,poststr.length - 1);

	sendAjaxData(poststr, ajaxFile, 'POST', divResult, false, null, null, ''); 

}

function undisplayUpdatedText(){
	document.getElementById("updated_div").style.display = 'none';
}
function hiddenMessageBox(){
	Effect.Fade('updated_div', { duration: 2.0 });
}

function clearInputText(str){
	//str = id:0|libelle:|...
	tab = str.split("|");
	for(cptstr=0;cptstr<tab.length;cptstr++)
	{
		tabInput = tab[cptstr].split(":");
		if (document.getElementById(tabInput[0]))
		document.getElementById(tabInput[0]).value = tabInput[1];
	}	
}

function checkMail(mail) {
	if(mail!=""){
		if ((mail.indexOf("@")>=0)&&(mail.lastIndexOf(".")>mail.indexOf("@"))) {
			return true
		} else {
			return false
		}
	}else{
		return true
	}
}