function checkFormulaireDetailCatalogue() {
	var tab_id_error = Array('error_societe', 'error_nom', 'error_email','error_cp', 'error_pays', 'error_telephone', 'error_captcha');
	var tab_id_input = Array('entreprise_o', 'nom_o', 'email_o','cp_o', 'pays_o', 'telephone_o', 'captcha_o');
	var no_problem = true;
	var ver = false;
	var verCaptcha = false;
	/*for (var n = 0; n < tab_id_error.length; n++) {
		document.getElementById(tab_id_error[n]).style.display='none';
	}*/
	for (var n = 0; n < tab_id_error.length; n++) {
		var input = document.getElementById(tab_id_input[n]);
		var span_error = document.getElementById(tab_id_error[n]);
		if (((input.tagName == 'INPUT' || input.tagName == 'TEXTAREA') && input.value == '') || (input.tagName == 'SELECT' && input.value == -1)) {
			span_error.className="erreur_catalog";
			no_problem = false;
		}
		else
			span_error.className="required_catalog";
	}

	if (document.getElementById('email_o').value) {
		document.getElementById('error_email').className="erreur_catalog";
		verMail = verifEmailCatalogue(document.getElementById('email_o'), false);
	}
	else{
		document.getElementById('error_email').className="required_catalog";
	}
	if (document.getElementById('captcha_o').value) {
		document.getElementById('error_email').className="required_catalog";
		verCaptcha = verifCaptcha(document.getElementById('captcha_o'));
	} 
	else
		document.getElementById('error_captcha').className="erreur_catalog";

	if (verCaptcha == true && verMail == true && no_problem == true) {
		return true;
	}
	else {
		return false;
	}
}

function writeTagErrorEmail(ret) {
	document.getElementById('error_email').style.display = 'inline';
	if (ret == '1') {
		writetag('error_email', '<img src="images/coche.gif" alt="Email valide" border="0" />');
	}
	else {
		writetag('error_email', 'Email invalide !');
	}
}



function check_email() {
	if (xmlhttp_check_mail.readyState==4) {
		if (xmlhttp_check_mail.status==200) {
			var ret = xmlhttp_check_mail.responseText;
			writeTagErrorEmail(ret);
		} 
		else {
			/*alert("_____________________________________________________________________________________________________Problem retrieving XML data on check_email(),statut : "+xmlhttp_check_mail.status);*/
		}
	}
	else {
		writetag('error_email', '<img src=\"images/loading.gif\" alt=\"En cours\" width=\"15\" />En cours...');
	}
}

var xmlhttp_check_mail;

function verifEmailCatalogue(email, mode) {
	if (email.value.length == 0) {
		writeTagErrorEmail(0)
		return false;
	}
	var modele = /^[a-z0-9\-_\.]+@[a-z0-9.-]{2,}[.][a-z]{2,5}$/i;
	if (!modele.test(email.value)){
		writeTagErrorEmail(0);
		return false;
	}
	writetag('error_email', '');
	xmlhttp_check_mail = createXMLHttpRequest();
	if (xmlhttp_check_mail!=null) {
		if (mode == true) {
			xmlhttp_check_mail.onreadystatechange = check_email;
		}
		xmlhttp_check_mail.open("GET",'index.php?p=10&sp=0&email='+escape(email.value),mode);
		xmlhttp_check_mail.send(null);
		if (mode == false) {
			var ret = xmlhttp_check_mail.responseText;
			writeTagErrorEmail(ret);
			if (ret == 1) {
				return true;
			}
			return false;
		}
	}
}


function expo_catalog(){
	if (checkFormulaireDetailCatalogue()){
		document.getElementById('submit_demande_catalogue').value = true;
		document.getElementById('formContentId').submit();
	}
}
