//send to a friend
function makeRequest(url,id) {
//alert (url);
//alert (id);
	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			//http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { alertContents(http_request,id); };
	http_request.open('GET', url, true);
	http_request.send(null);
	//alert(http_request.responseText);
}

	function alertContents(http_request,id) {	
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				if ( id == 'contact') {document.getElementById('sendComment').innerHTML = http_request.responseText;}
				else if (id == 'inscription') {document.getElementById('sendit').innerHTML = http_request.responseText;}
				
				
			} else {
				alert('There was a problem with the request.');
				//alert("ready :" + http_request.readyState);
				alert("status :" + http_request.status);
			}
		}
	}
	

function submit_inscription() {
var validEmail = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	if (
		(document.oi_form.politesse.value == "") ||
		(document.oi_form.prenom.value == "") ||
		(document.oi_form.nom.value == "") ||
		(document.oi_form.email.value == "")
		)
		{
			alert("Veuillez s.v.p. remplir tous les champs.");
			return false;
		}
		if (validEmail.test(document.oi_form.email.value) == false) {
			document.oi_form.email.focus();
			alert("Veuillez vérifier votre adresse de courriel.");
			return false;
		}
		
	else {
	document.getElementById('sendit').style.display = "block";
		var id = 'inscription';
		var Goto = document.oi_form.goto.value;
		var Politesse = document.oi_form.politesse.value;
		var Prenom = document.oi_form.prenom.value;
		var Nom = document.oi_form.nom.value;
		var Email= document.oi_form.email.value;
		var Groupe= document.oi_form.groupe.value;
		var apl = 'http://track.vdl2.com/oi/108/81177190dba41a0ee0cfb2a67431292d?';
		var url = apl + 
		'goto=' + escape (Goto) + 
		'&politesse=' + escape (Politesse) +
		'&prenom=' + escape (Prenom) + 
		'&nom=' + escape (Nom) + 
		'&groupe=' + escape (Groupe) + 
		'&email=' + escape (Email);
		makeRequest('/php/ajaxhttprequest.php?url='+ escape(url),id);
		//alert(url);
		display('sendit');
		hide('formsendit');
		return false;
	}
}

function submit_contact() {
var validEmail = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	if (
		(document.comment_form.prenom.value == "") ||
		(document.comment_form.nom.value == "") ||
		(document.comment_form.comment.value == "") ||
		(document.comment_form.EMAIL.value == "")
		)
		{
			alert("Veuillez s.v.p. remplir tous les champs.");
			return false;
		}
	if (validEmail.test(document.comment_form.EMAIL.value) == false) {
			document.comment_form.EMAIL.focus();
			alert("Veuillez vérifier votre adresse de courriel.");
			return false;
		}
	else {
	document.getElementById('sendComment').style.display = "block";
		var id = 'contact';
		var Langue = document.comment_form.LANGUE.value;
		var Politesse = document.comment_form.politesse.value;
		var Prenom = document.comment_form.prenom.value;
		var Nom = document.comment_form.nom.value;
		var Email= document.comment_form.EMAIL.value;
		var Comment= document.comment_form.comment.value;
		var apl = '/cgi-bin/webmail?';
		var url = apl + 
		'IDX=' + escape ('contact') +
		'&LANGUE=' + escape (Langue) +
		'&politesse=' + escape (Politesse) +
		'&prenom=' + escape (Prenom) + 
		'&nom=' + escape (Nom) + 
		'&comment=' + escape (Comment) + 
		'&EMAIL=' + escape (Email);
		//alert(url);
		makeRequest(url,id);
		display('sendComment');
		hide('form-comment');
		return false;
	}
}






function hide(id){
document.getElementById(id).style.display = "none";
}
function display(id){
document.getElementById(id).style.display = 'inline';
}

