function affiche_envoi(envoi_url, titre){

	bloc_envoi = document.getElementById('bloc-envoi');

	subpage = window.location.href.indexOf('/news/');
	if(subpage > -1){
		envoi_url = window.location.href;
		titre_cont = document.getElementById('NewsPostDetailTitle');
		titre = titre_cont.innerHTML;
	}


	posturl = '?page=36';
	postdata = 'envoi_url='+envoi_url+'&titre='+titre;

	xhr = prepaXhr(bloc_envoi);
	xhr.open( 'POST', posturl, true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send(postdata);

	myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}

	bloc_envoi.style.left=((myWidth/2)-200)+"px";
	bloc_envoi.style.display="block";

	divcontainer = document.getElementById('global');
 	divcontainer.style.filter="alpha(opacity=60)";
 	divcontainer.style.opacity=".40";
}

function envoi_envoi(){
	var nom = document.getElementById('nom').value;
	var prenom = document.getElementById('prenom').value;
	var email = document.getElementById('email').value;
	var message = document.getElementById('message').value;
	var pageurl = document.getElementById('page-url').href;
	var titre = document.getElementById('titre').value;

	var postdata = 'posted=1&envoi_url='+pageurl+'&titre='+titre+'&nom='+nom+'&prenom='+prenom+'&email='+email+'&message='+escape(encodeURI(message));
	xhr = prepaXhr(bloc_envoi);
	xhr.open( 'POST', posturl, true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send(postdata);
}

function cache_envoi(){
	bloc_envoi = document.getElementById('bloc-envoi');
	bloc_envoi.style.display='none';
	bloc_envoi.innerHTML='';
	divcontainer = document.getElementById('global');
	divcontainer.style.filter='alpha(opacity=0)';
	divcontainer.style.opacity='1';
}

function prepaXhr(el){
	var xhr;
	try {
		xhr = new ActiveXObject('Msxml2.XMLHTTP');
	}
	catch (e) {
		try {
			xhr = new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch (e2) {
			try {
				xhr = new XMLHttpRequest();
			}
			catch (e3) {
				xhr = false;
			}
		}
	}
	xhr.onreadystatechange  = function(){
		if(xhr.readyState  == 4) {
			if(xhr.status  == 200){
				var el_content = xhr.responseText;
				el.innerHTML = el_content;
			}
			else{
				el.innerHTML = "Error code " + xhr.status;
			}
		}
	};
	return xhr;
}
