
function ouvrir(l,h,url) {
hauteur=Math.round((screen.availHeight-h)/2);
largeur=Math.round((screen.availWidth-l)/2);
window.open(url, "site", "toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,menubar=0,top="+hauteur+",left="+largeur+",width="+l+",height="+h);
}

//Fonction de vérification de saisie d'email au bon format
function verif_mail(email)
    {
	if (email!='')
	  {
		var reg_mail = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/	 
		if (!(reg_mail.exec(email)!=null))
		  {	
			//document.getElementById('error_5').style.display = "block";
		  	//document.getElementById('error_5').innerHTML = "L'adresse Email est invalide";
			//alert('no good');
		  }
	  }
	}


function verif_vide(lachaine) {

	lachaine_final = lachaine.replace(" ", ""); //renvoie une copie du String
	return lachaine_final;
	
}

String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g,"")}

function verif_nombre(monChamp,numero_champ) {
	reg = new RegExp("[^0-9]", "i");
		if (!reg.test(monChamp.value)){
			
			 //document.getElementById('error_'+numero_champ).innerHTML = "";
			 //document.getElementById('error_'+numero_champ).style.display = "none";
			
		}else{
		  
		  document.getElementById('error_'+numero_champ).style.display = "block";
		  document.getElementById('error_'+numero_champ).innerHTML = "Ce champ est uniquement numérique";

		  monChamp.value = monChamp.value.substring(0,monChamp.value.length-1);
		
		}
}


function verif_form_pro()
	
	{	
	
		var etapes = 0;
		
		longueur = document.forms['frm_peugeot_pro'].elements.length - 1;				
		
		// Vérification des champs de saisies textes
			
		var test_civ0 = document.forms['frm_peugeot_pro'].elements[0].checked;
		var test_civ1 = document.forms['frm_peugeot_pro'].elements[1].checked;
		var test_civ2 = document.forms['frm_peugeot_pro'].elements[2].checked;
		
		if (test_civ0  == false && test_civ1  == false && test_civ2 == false)
		
			{
				
				document.getElementById('error_2').style.display = "block";
			
			}else{
			
				document.getElementById('error_2').style.display = "none";
				etapes ++;
				
			}
		
		for (i=3 ; i<longueur; i++) { 
		
		   var test_champ = document.forms['frm_peugeot_pro'].elements[i].value;
		   test_champ = test_champ.trim();
			
			   if (test_champ == "") 
			   {
				   
				   
				   document.getElementById('error_'+i).style.display = "block";
					
					
			   }else{
				   
				   if (i == 5)			   
				   {
					   
					  if (test_champ!='')
						  {
							var reg_mail = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/	 
							if (!(reg_mail.exec(test_champ)!=null))
							  {	
								
								document.getElementById('error_5').style.display = "block";
								document.getElementById('error_5').innerHTML = "L'adresse Email est invalide";
								
							  }else{
								  
								document.getElementById('error_5').style.display = "none";
								etapes ++;
								
							  }
						  } 
					   
					   
					   
				   }else{
					   
					 document.getElementById('error_'+i).style.display = "none";
				   	 etapes ++;
						
					
				   }
				   
						   
				  
				   
			   }
		   
		   } 
		
		if (etapes == 9)
			{
				
				document.forms['frm_peugeot_pro'].elements['form_action'].value = "yes";
				document.forms['frm_peugeot_pro'].submit();
				
			}
		
		 
	}
	
function verif_form_cdp(nbro)
	
	{	
	
		var etapes = 0;
				
		longueur = document.forms['frm_peugeot_cdp'].elements.length - 1;				
		
		// Vérification des champs de saisies textes
			
		var test_civ0 = document.forms['frm_peugeot_cdp'].elements[0].checked;
		var test_civ1 = document.forms['frm_peugeot_cdp'].elements[1].checked;
		var test_civ2 = document.forms['frm_peugeot_cdp'].elements[2].checked;
		
		//longueur = longueur - (nbro + 2);
			
		if (test_civ0  == false && test_civ1  == false && test_civ2 == false)
		
			{
				
				document.getElementById('error_2').style.display = "block";
			
			}else{
			
				document.getElementById('error_2').style.display = "none";
				etapes ++;
				
			}
		
		for (i=3 ; i<longueur - nbro; i++) { 
		
		   var test_champ = document.forms['frm_peugeot_cdp'].elements[i].value;
		   test_champ = test_champ.trim();
			
			   if (test_champ == "") 
			   {
				   
				   
				   document.getElementById('error_'+i).style.display = "block";
					
					
			   }else{
				   
				   if (i == 5)			   
				   {
					   
					  if (test_champ!='')
						  {
							var reg_mail = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/	 
							if (!(reg_mail.exec(test_champ)!=null))
							  {	
								
								document.getElementById('error_5').style.display = "block";
								document.getElementById('error_5').innerHTML = "L'adresse Email est invalide";
								
							  }else{
								  
								document.getElementById('error_5').style.display = "none";
								etapes ++;
								
							  }
						  } 
					   
					   
					   
				   }else{
					   
					 document.getElementById('error_'+i).style.display = "none";
				   	 etapes ++;
						
					
				   }
				   
						   
				  
				   
			   }
		   
		   }
		
		// variable compte le nombre de champs et retire le nombre d'offres + le champ input caché
		
		var longueur_finale = longueur - 2;
		
		if (etapes == longueur_finale - nbro)
			
			{
				
				document.forms['frm_peugeot_cdp'].elements['form_action'].value = "ok";
				document.forms['frm_peugeot_cdp'].submit();
				
			}
		
		 
	}



