
/**function contacter(to){

	var contact = document.forms.contact;
	var vehicule = contact.vehicule.value;
	if(to == 'pro') {
		var nom = contact.nom.value;
		var prenom = contact.prenom.value;
		var tel = contact.tel.value;
		var commentaire = contact.commentaire.value;
		var association = contact.association.value;
	}
	var cp = contact.cp.value;
	var email = contact.email.value;
	var nlchoix = contact.nlchoix;
	var msg = document.getElementById("msg");

	msg.style.display = '';	
	msg.innerHTML = '<img alt="Indicator" src="/media/indicator.gif" />';
	
	if(nlchoix[0].checked) {
		nlchoix = nlchoix[0].value;
	}
	else { nlchoix = 0 };

	getXhr();
	if(xhr) {
		xhr.onreadystatechange = function() {
			if(xhr.readyState == 4 && xhr.status == 200) {
				reponse = clean(xhr.responseXML.documentElement);
				etat = reponse.getElementsByTagName("etat")[0].firstChild.nodeValue;
				message = reponse.getElementsByTagName("message")[0].firstChild.nodeValue + '<br>';

				if(etat == 'ERR') {
					err = reponse.getElementsByTagName("err");

					message += '<ul style="text-align:left">';
					for(cpt=0; cpt<err.length; cpt++) {
						e = err[cpt].firstChild.nodeValue;
						message += '<li>' + e + '</li>';
					}
					message += '</ul>';
				}

				msg.innerHTML = message;
			}
		}
	}

	xhr.open("POST", '/' + to + '/contact/', true);
	xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

	xhr.send("nom="+ escape(nom) + "&prenom="+ escape(prenom) + "&email=" + email + "&tel=" + tel + "&cp=" + cp +
				"&commentaire=" + escape(commentaire) + "&nlchoix=" + nlchoix + "&vehicule=" + vehicule + "&association=" + association);
}*/

function contacter(to)
{
	var contact = document.forms.contact;
	var vehicule = contact.vehicule.value;
	if(to == 'pro') {
		var nom = contact.nom.value;
		var prenom = contact.prenom.value;
		var tel = contact.tel.value;
		var commentaire = contact.commentaire.value;
		var association = contact.association.value;
	}
	var cp = contact.cp.value;
	var email = contact.email.value;
	var nlchoix = contact.nlchoix;
	var msg = $('msg');

	showHideElement('submit');
	
	msg.style.display = '';	
	msg.innerHTML = '<img alt="Indicator" src="/media/indicator.gif" />';
	
	nlchoix = getCheckedValue(nlchoix);
		
	if(to == 'pro') {
		
		var myAjax = new Ajax.Request('http://switch.atdmt.com/action/020cr1_CaradisiacAchatOccasionPRO	ThankYouPagede_4', {method: 'post', parameters: ''});
		
		var reponse = '';
		if(nlchoix && nom && prenom && email && tel && cp) {
			
			if(nlchoix == 1) {
				
				reponse = 'oui';
			
			} else {
			
				reponse = 'non';
			}

			var myAjax = new Ajax.Request('http://switch.atdmt.com/action/020cr1_CaradisiacAchatOccasionPROThankYouPagede_4/v3/ato.' + vehicule + '/atc1.' + reponse, {method: 'get', parameters: ''});
		}
	}
	
	var url = '/' + to + '/contact/';
	var params = 'nom=' + escape(nom) + '&prenom=' + escape(prenom) + '&email=' + email + '&tel=' + tel + '&cp=' + cp +
				'&commentaire=' + escape(commentaire) + '&nlchoix=' + nlchoix + '&vehicule=' + vehicule + '&association=' + association
				
	var myAjax = new Ajax.Request(url, {method: 'post', parameters: params, onComplete: response_contacter});
}

function response_contacter(originalRequest)
{
	var msg = $('msg');
	reponse = originalRequest.responseXML;
	
	etat = reponse.getElementsByTagName("etat")[0].firstChild.nodeValue;
	message = reponse.getElementsByTagName("message")[0].firstChild.nodeValue + '<br>';
	
	if(etat == 'ERR') {
		err = reponse.getElementsByTagName("err");
				
		message += '<ul style="text-align:left">';
		for(cpt=0; cpt<err.length; cpt++) {
			e = err[cpt].firstChild.nodeValue;
			message += '<li>' + e + '</li>';
		}
		message += '</ul>';
	}
	
	msg.innerHTML = message;	
	
	showHideElement('submit');
}