function checkMail(email){
	var regEx = new RegExp("^[a-zA-Z0-9._-]+\@[a-zA-Z0-9.-]{2,}\.[a-zA-Z]{2,4}$");
	return(regEx.test(email));
}

function is_all_num(chaine)
{
	var i;
	for(i=0;i<chaine.length;i++)
		{
		if(isNaN(parseInt(chaine.substring(i,i+1))))
			return false;}
	return true;
}

function bm_filtre1()
{
	if  (!(document.brochure.gamme[0].checked || document.brochure.gamme[1].checked || document.brochure.gamme[2].checked || document.brochure.gamme[3].checked || document.brochure.gamme[4].checked || document.brochure.gamme[5].checked || document.brochure.gamme[6].checked || document.brochure.gamme[7].checked || document.brochure.gamme[8].checked || (document.brochure.plus && document.brochure.plus.checked) || (document.brochure.plus[0] && document.brochure.plus[0].checked) || (document.brochure.plus[1] && document.brochure.plus[1].checked)))
	{
		alert("Merci de bien vouloir faire votre choix de brochure avant de remplir votre formulaire. Merci")
	}
	else
	{
		document.brochure.submit()
	}
}


//***BROCHURES***//

//***PAGE: "/espace_contact/04_selection/04_01_accueil.asp"	
function BackBrochure(RV_NOM,AV_NOM,RV_CODE_GENE,AV_CODE_GENE)
{
	opener.document.forms[0].distri.value 		= RV_NOM;
	opener.document.forms[0].repa.value 		= AV_NOM;
	opener.document.forms[0].distri_code.value 	= RV_CODE_GENE;
	opener.document.forms[0].repa_code.value 	= AV_CODE_GENE;
	window.close()
}

function rechercher()
{
	if (!document.forms.recherche.no_departement.options[0].selected)
	{
		document.forms.recherche.no_departement2.value='';
		document.forms.recherche.submit()
	}
	else
	{
		alert ("veuillez sélectionner un département pour le réseau vente !")
	}
}	

function rechercher2()
{
	if (document.forms.recherche.no_departement2.value!='')
	{
		document.forms.recherche.submit()
	}
	else
	{
		alert ("veuillez sélectionner un département pour le réseau vente !")
	}
}	

function avrechercher()
{
	if (!document.forms.avrecherche.avno_departement.options[0].selected)
	{
		document.forms.avrecherche.avno_departement2.value='';
		document.forms.avrecherche.submit()
	}
	else
	{
		alert ("veuillez sélectionner un département pour le service après-vente !")
	}
}	

function avrechercher2()
{
	if (document.forms.avrecherche.avno_departement2.value!='')
	{
		document.forms.avrecherche.submit()
	}
	else
	{
		alert ("veuillez sélectionner un département pour le service après-vente !")
	}
}
//***FIN PAGE

//***PAGE: "/brochures/formulaire2.asp"
function nombreVehicule() {

	if(document.all)
	{
		for(i=1;i<4;i++) {
			document.all[i+'vehicule'].style.display    = "none";
			document.all[i+'vehicule'].style.visibility = "hidden";
		}
		nbr = document.brochure.nombre.options[document.brochure.nombre.selectedIndex].value;
		for(i=1;i<=nbr;i++) {
			document.all[i+'vehicule'].style.display    = "block";
			document.all[i+'vehicule'].style.visibility = "visible";
		}

	}
	if(navigator.userAgent.indexOf("Gecko") != -1)
	{
		for(i=1;i<4;i++)
		{
			document.getElementById(i+"vehicule").style.display="none";
			document.getElementById(i+"vehicule").style.visibility="hidden";
		}
		nbr = document.brochure.nombre.options[document.brochure.nombre.selectedIndex].value;
		for(i=1;i<=nbr;i++)
		{
			document.getElementById(i+"vehicule").style.display="block";
			document.getElementById(i+"vehicule").style.visibility="visible";
		}

	}
}

function nombreEnfants()
{
	if(document.all)
	{
		for(i=1;i<6;i++)
		{
			document.all[i+'enfant'].style.display="none";
			document.all[i+'enfant'].style.visibility="hidden";
		}
		nbr = document.brochure.nombre_enfant.options[document.brochure.nombre_enfant.selectedIndex].value;
		if(nbr=="Autre")
			nbr=5;
			
		for(i=1;i<=nbr;i++)
		{
			document.all[i+'enfant'].style.display="block";
			document.all[i+'enfant'].style.visibility="visible";
		}

	}
	if(navigator.userAgent.indexOf("Gecko") != -1)
	{
		for(i=1;i<6;i++)
		{
			document.getElementById(i+"enfant").style.display="none";
			document.getElementById(i+"enfant").style.visibility="hidden";
		}
		nbr = document.brochure.nombre_enfant.options[document.brochure.nombre_enfant.selectedIndex].value;
		if(nbr=="Autre")
			nbr=5;
			
		for(i=1;i<=nbr;i++)
		{
			document.getElementById(i+"enfant").style.display="block";
			document.getElementById(i+"enfant").style.visibility="visible";
		}

	}
}

function PopupCentre(url,namepopup,largeur,hauteur,options)
{
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	
	if (screen.width>800) left = 180
	
	window.open(url,namepopup,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function bm_filtre2()
{
	var str="Les champs suivants sont obligatoires :\n--------------------\n";
	var vide = false;

	if (!(document.brochure.civilite[0].checked || document.brochure.civilite[1].checked || document.brochure.civilite[2].checked)){
		vide = true;
		str+="- Civilité\n";
	}
	if (document.brochure.nom.value ==""){
		vide = true;
		str+="- Nom\n";
	}
	if (document.brochure.prenom.value ==""){
		vide = true;
		str+="- Prénom\n";
	}
	if(document.brochure.adresse_postale.value ==""){
		vide = true;
		str+="- Adresse postale\n";
	}
	if( isNaN(document.brochure.code_postal.value) || document.brochure.code_postal.value=="" || document.brochure.code_postal.value.length < 5 ){
		vide = true;
		str+="- Code postal\n";
	}
	if(document.brochure.ville.value ==""){
		vide = true;
		str+="- Ville\n";
	}
	if( (!document.brochure.adresse_type[0].checked)&&(!document.brochure.adresse_type[1].checked) ){
		vide = true;
		str+="- Adresse de domicile ou entreprise?\n";		
	}
	if( document.brochure.tel_bur.value =="" && document.brochure.tel_dom.value =="" && document.brochure.tel_port.value =="" ){
		vide = true;
		str+="- Téléphone\n";
	}
	if(!checkMail(document.brochure.email.value)){
		vide = true;
		str+="- E-mail (invalide)\n";
	}
	if( !(document.brochure.authorize[0].checked || document.brochure.authorize[1].checked) ){
		vide = true;
		str+="- Autorisation de diffusion d'informations\n";
	}
	/*if( (document.brochure.marque1.value =="Autre") && (document.brochure.nombre.options[document.brochure.nombre.selectedIndex].value > 0) ){
		vide = true;
		str+="- Marque\n";
	}*/

	if (vide==true){
		alert(str);
		document.brochure.nom.focus();
	} else {
		document.forms['brochure'].submit();
	}
}
//***FIN PAGE


//***E-BROCHURES***//

//***PAGE: "/e_brochure/01_ebrochure.asp"
function checkFormStep1()
{
	var str="Les champs suivants sont obligatoires :\n--------------------\n";
	var vide = false;

	if (!(document.ebrochure.civilite[0].checked || document.ebrochure.civilite[1].checked || document.ebrochure.civilite[2].checked)){
		vide = true;
		str+="- Civilité\n";
	}
	if (document.ebrochure.nom.value ==""){
		vide = true;
		str+="- Nom\n";
	}
	if (document.ebrochure.prenom.value ==""){
		vide = true;
		str+="- Prénom\n";
	}
	if(document.ebrochure.adresse.value ==""){
		vide = true;
		str+="- Adresse\n";
	}
	if( isNaN(document.ebrochure.cp.value) || document.ebrochure.cp.value=="" || document.ebrochure.cp.value.length < 5 ){
		vide = true;
		str+="- Code postal\n";
	}
	if(document.ebrochure.ville.value ==""){
		vide = true;
		str+="- Ville\n";
	}
	if( (!document.ebrochure.adresse2[0].checked)&&(!document.ebrochure.adresse2[1].checked) ){
		vide = true;
		str+="- Adresse de domicile ou entreprise?\n";		
	}
	if( document.ebrochure.tel_bur.value =="" && document.ebrochure.tel_dom.value =="" && document.ebrochure.tel_port.value =="" ){
		vide = true;
		str+="- Téléphone\n";
	}
	if(!checkMail(document.ebrochure.email.value)){
		vide = true;
		str+="- E-mail (invalide)\n";
	}
	if( !(document.ebrochure.authorize[0].checked || document.ebrochure.authorize[1].checked) ){
		vide = true;
		str+="- Autorisation de diffusion d'informations\n";
	}

	if (vide==true){
		alert(str);
		document.ebrochure.nom.focus();
	} else {
		document.forms['ebrochure'].submit();
	}
}
//***FIN PAGE

//***PAGE: "/e_brochure/03_ebrochure_valide.asp"
function checkFormStep3()
{
	document.ebrochure.submit();
}
//***FIN PAGE

//***PAGE: "/e_brochure/05_ebrochure_merci.asp"
function DirectDownload(file)
{
document.location="06_ebrochure_directdownload.asp?ebrochure="+file
}
//***FIN PAGE

function set_modele(sel,modele) {
	var xhr_object = null;   
        
	if(window.XMLHttpRequest) { // FIREFOX
		xhr_object = new XMLHttpRequest();
	} else if(window.ActiveXObject) { // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		return(false);
	}  
   
	xhr_object.open("POST", "/brochures/modele.asp", true);   
 
	xhr_object.onreadystatechange = function() {   
		if(xhr_object.readyState == 4) {
			eval(xhr_object.responseText);   
		}
	}

	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");   
	var data = "myselect="+sel+"&modele="+modele;   
	xhr_object.send(data);

}

function showBrochures(type)
{
	if(type == 1)
	{
		document.getElementById('service1').style.display = "";
		document.getElementById('gamme5').style.display = "";
		document.brochure.plus[1].checked = false;
		document.getElementById('service2').style.display = "none";
		document.brochure.action = "/e_brochure/01_ebrochure.asp";
	}
	else if(type == 2)
	{
		document.getElementById('service2').style.display = "";
		document.brochure.plus[0].checked = false;
		document.brochure.gamme[4].checked = false;
		document.getElementById('service1').style.display = "none";
		document.getElementById('gamme5').style.display = "none";
		document.brochure.action = "/brochures/2dbrochure.asp";
	}
	
}