<!--
// francais par defaut
var V_EN = 0 ;
var FROM_ANNU = false ;
function GetParameter(Nom){ // special formulaire
var valret = ''
valret = Parameter(Nom, document.location.search.substring(1));
try {
if (!valret.length && parent.length)
	valret = Parameter(Nom, parent.location.search.substring(1));
	}
catch (error) {
	 return valret ;
     ;
	}	
return valret ;
}


function Parameter(Nom, urlparam){
var param= unescape(urlparam);
	for ( ; param.indexOf('€') != -1 ; ) // remplace + par et
		param = param.replace('€' ,'EUR');
var P = param.split("&");
var PName= new Array();
var PValue= new Array();
for(i=0;i<P.length;i++){
PName[i]=P[i].substring(0,P[i].indexOf("="));
PValue[i]=P[i].substring(P[i].indexOf("=")+1);
}
var resultat=false;
for(i=0;i<PName.length;i++){
	if(PName[i]==Nom){resultat=true;return unescape(PValue[i]);}                   
	}
if(!resultat){return '';}
}


String.prototype.trim = function()
{ return this.replace(/(^\s*)|(\s*$)/g, ""); }

// customisatiom
var SUBJECTFORM = GetParameter("subject") ;
SUBJECTFORM = SUBJECTFORM.trim() ;

if (typeof defpays != 'undefined')
	document.write("<script src=\"\/contact\/agences\/Desc\/global_DESC.js\" type=\"text\/javascript\"><\/script>" ); // descripteur global	



function Valid_Form(theForm){
 	var field  ;
// routage in end 
// sup espace gaiche et droite
 for ( var i= 0 ; i < theForm.elements.length  ; i++)
	{
     	var typechamps = theForm.elements[i].type.toLowerCase();
     	if (typechamps.indexOf('text') != -1 && theForm.elements[i].value != '') {
     		var strvalue = theForm.elements[i].value ;
    		strvalue = strvalue.trim();
    		theForm.elements[i].value = strvalue ;
    		}
	}

 	field = (V_EN) ? theForm.f_Subject : theForm.f_Objet ; 
  if (field != null){
  	if (!field.value.length)
  	{
    	alert((V_EN) ? "Please fill the Type of enquiry." : "Précisez l'objet de votre demande.");
    	field.focus();
    	return (false);
  	}
  else
  	if (theForm.f_Titre != null)
  		theForm.f_Titre.value = field.value;
   }

field = (V_EN) ? theForm.f_Last_Name : theForm.f_Nom ; 	
  if (field!= null)
  if (!field.value.length)
  {
    alert((V_EN) ? "Please fill your Last Name." : "Précisez votre Nom.");
    field.focus();
    return (false);
  }
field = (V_EN) ? theForm.f_First_Name : theForm.f_Prenom ; 	
  if (field != null)
  if (!field.value.length)
  {
    alert((V_EN) ? "Please fill your First Name." : "Précisez votre Prénom.");
    field.focus();
    return (false);
  }
field = (V_EN) ? theForm.f_Address : theForm.f_Adresse;   
  if (field != null)
  if (!field.value.length)
  {
    alert((V_EN)? "Please fill your Address." :"Précisez votre Adresse.");
    field.focus();
    return (false);
  }

field = (V_EN) ? theForm.f_Post_Code: theForm.f_CP ;   
  if (field != null)
  {
  	var LenCP = 5 ;
  	if (theForm.LenCP != null) LenCP = theForm.LenCP.value ;
  	if (LenCP > 0) {
  		if (field.value.length != LenCP || !ReturnPermis(field.value,'0123456789'))
		{
    		alert(((V_EN)? "Please fill your Post Code - " : "Précisez votre Code postal - ") + LenCP +((V_EN)? " digits" : " chiffres.") );
    		field.focus();
    		return (false);
  		}
  	}
  }
 field = (V_EN) ? theForm.f_City: theForm.f_Ville ;  
  if ( field != null)
  if (! field.value.length)
  {
    alert((V_EN)? "Please fill your City.": "Précisez la Ville.");
    field.focus();
    return (false);
  }
field = (V_EN) ? theForm.f_Phone: theForm.f_Tel;  
  if (field != null)
  {
  	var LenTel = 10 ;
  	if (theForm.LenTel != null) LenTel = theForm.LenTel.value ;
  	if (LenTel > 0 ) {
		if (field.value.length < LenTel || !ReturnPermis(field.value,'(+) 0123456789'))
  		{
		alert(((V_EN)? "Please fill your Phone Number - " : "Indiquez un N° de téléphone sur " )+ LenTel + ((V_EN)? " digits" : " chiffres."));
		field.focus();
    		return (false);
  		}
  	  if (theForm.f_Preference != null)
  		if (theForm.f_Preference.selectedIndex == 0)
  		{
  	alert((V_EN) ? "Select your preferences for a phone call.": "Précisez vos préférences pour un appel téléphonique.");
    	theForm.f_Preference.focus();
    	return (false);
  		}
  	}
  }

// Controle adresse email 
  if (theForm.f_Email != null) {
  	theForm.f_Email.value = theForm.f_Email.value.trim() ;
  	if (!is_email(theForm.f_Email.value))
   	{
   		alert ((V_EN) ? "Please fill your email address." : "Pour obtenir une réponse, indiquez votre adresse e-mail.");
   		theForm.f_Email.focus();
   		return (false);
   	}

   	
  }
// version E_mail non obli ou ctlr si renseigné
// Emetteur direct en from pour réponse
  if (theForm.f_E_mail != null) {
  	theForm.f_E_mail.value = theForm.f_E_mail.value.trim() ;
  	if (theForm.f_E_mail.value.length ){ // si renseigné
  		if (!is_email(theForm.f_E_mail.value)) {
  		   	alert ((V_EN) ? "Please fill your email address." : "Pour obtenir une réponse, indiquez votre adresse e-mail valide.");
   				theForm.f_E_mail.focus();
   				return (false);
   				}

			}
  }

 field = (V_EN) ? theForm.f_Situation : theForm.f_Client ;   
  if (field != null)
  if (field.selectedIndex == 0)
  {
   alert((V_EN) ? "Select your situation." : "Précisez votre Situation.");
    field.focus();
    return (false);
  }


  var client = false ; 
  if (theForm.f_Client != null) {
   	var repuserclient = theForm.f_Client.options[theForm.f_Client.selectedIndex].value.toLowerCase().substring(0,1) ;
		if (repuserclient == 'o' || repuserclient == 'y')	client = true ;
		}


  if (client && field != null && theForm.f_Agence != null){ // cas non traité en EN
  	var Nagence = theForm.f_Agence.value ;
  	if (Nagence.length != 5 || !ReturnPermis(Nagence,'0123456789') || Nagence == '00000')
  		{
    	alert("Vous avez déclaré être client de notre banque.\nPour mieux traiter votre demande,\nmerci de préciser les 5 chiffres de votre N° d'Agence.");
    	theForm.f_Agence.focus();
    	return (false);
  		}
  	if (Nagence == 30004 ){
    	alert("Indiquez les 5 chiffres du N° d'Agence ou Code Guichet.");
    	theForm.f_Agence.select();
    	return (false);
   		}  	
  	}
  	
  if (client && field != null && theForm.f_Nom_Agence != null) { // cas non traité en EN
  	if (!theForm.f_Nom_Agence.selectedIndex)
  		{
    //	alert("Vous avez déclaré être client de notre banque.\nPour mieux traiter votre demande,\nmerci de préciser le Nom de votre Agence.");
    	theForm.f_Nom_Agence.focus();
    	return (false);
  		}
  	}


  if (client && field != null && theForm.agence_client_ville != null) { // test bmci
 		if (!FROM_ANNU && !theForm.agence_client_ville.selectedIndex ){
   	//	alert("Vous avez déclaré être client de notre banque.\nPour mieux traiter votre demande,\nmerci de préciser la ville de votre Agence.");
   		theForm.agence_client_ville.focus();
   		return (false);
 			}

  	}


  	
  if (theForm.f_Message != null)
  if (theForm.f_Message.value.length > 800)
  {
    alert((V_EN) ? "Your message cannot exceed 800 characters." : "Votre message ne peut excéder 800 caractères.");
    theForm.f_Message.focus();
    return (false);
  }

  
 

 // customisation
 if (SUBJECTFORM.length) {
 	 theForm.f_Titre.value = SUBJECTFORM ; // modif du titre
 	 theForm.f_[1].value = (V_EN) ? "This person is interested by the indicated offer and wishes to be contacted " : "Cette personne est intéressée par l'offre désignée et souhaite être contactée." ; // complement texte
 	}




return (true);
}



function is_email(email)
  {
     if (email.toLowerCase().indexOf('www.') != -1) return (false) ;
     var reg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]{2,}[.][a-zA-Z0-9]{2,4}$/ ;
     var reg2 = /[.@]{2,}/ ;
     return ((reg.exec(email)!=null) && (reg2.exec(email)==null)) ;
  }


function ReturnPermis(val,carpermis){
 var retour = false ;
    for(var i=0; i<val.length; i++){
       retour = false ;
       for(var j=0;j<carpermis.length;j++){
    	   if(val.charAt(i) == carpermis.charAt(j)) { retour = true ; break ; }
    	    }
    	}
return(retour);
}



function Loading(theForm){
var urlFrom = document.referrer.toString().toLowerCase(); 
if (urlFrom.indexOf('contactez_nous') !=-1 && document.getElementById("entetecontact")) // form encapsulé
	document.getElementById("entetecontact").style.display ='none' ;
FROM_ANNU = (urlFrom.indexOf('agences/annuaire') !=-1) ? true : false ;

// reset

 for ( var i= 0 ; i < theForm.elements.length  ; i++) {
    var typechamps = theForm.elements[i].type.toLowerCase();
    if (typechamps.indexOf('text') != -1 ) {theForm.elements[i].value = '' ;}
     if (typechamps.indexOf('select') != -1 ) {theForm.elements[i].selectedIndex = 0 ; }
	}
var field = (V_EN) ? theForm.f_Subject : theForm.f_Objet ; 
if(SUBJECTFORM.length) {
	if (field  != null) {
		field.value = SUBJECTFORM ;
		field.readOnly = true ;
		}
	theForm.f_Civilite.focus();
	}
else
	if (field != null) field.focus() ;	

var msg = GetParameter('f_Message');
if (msg.length)
	theForm.f_Message.value= msg ;

var msg = GetParameter('f_mailto');
if (msg.length)
	theForm.f_mailto.value= msg ;

}

function BackPage() {
try {
if (parent.document.getElementById("AgenceContact"))
	parent.document.getElementById("AgenceContact").style.display = "none"; 
else
	history.back();	
	}
catch (error) {
	 history.back();	
     ;
	}
}
// --------- lien annuaire
function FindAgenceVilleClient(theForm) {
if (FROM_ANNU) {theForm.f_Agence_indiquee.value = SUBJECTFORM ; return (0) ;}
var villeagence = false ; 
var situation = theForm.f_Client.selectedIndex ; 
var repuser = theForm.f_Client.options[situation].value.toLowerCase().substring(0,1) ;
var client = (repuser == 'o' || repuser == 'y') ? true : false ;
if (theForm.f_Agence_indiquee) theForm.f_Agence_indiquee.value = '' ;
if (document.getElementById("agence_client")) {
		document.getElementById("agence_client").style.display = (situation) ? 'block' : 'none';
		if (situation)
			document.getElementById("agence_client_lib").innerHTML = (client) ? 'Pour vous repondre plus rapidement, merci de préciser votre agence.' : 'Si vous le souhaitez, vous pouvez choisir une agence proche de vous.' ;
		villeagence = true ;
		}
// if (!client) theForm.f_Message.focus();
if (situation)
	if (villeagence) {
		document.getElementById("agence_nom_client").style.display = 'none' ;
		document.getElementById("agence_adresse_client").style.display = 'none' ;
		MakeListeVilleAg(theForm.agence_client_ville);
		}
	else
		if (theForm.f_Agence != null)
				theForm.f_Agence.focus() ;
	else
		if (theForm.f_Agence_client != null)
			theForm.f_Agence_client.focus() ;
	
}

function FindAgenceNomClient(theForm) {
	MakeListeVilleAg(theForm.agence_client_nom, theForm.agence_client_ville.value);
	var lenlist = theForm.agence_client_nom.length ; 

	FindAgenceAdresseClient(theForm); // one or multi ag
	
	if (lenlist > 2) {
		document.getElementById("agence_nom_client").style.display ='block'  ;	
		// theForm.agence_client_nom.selectedIndex = 0 ;
		theForm.agence_client_nom.focus()	
		}
	else {
		document.getElementById("agence_nom_client").style.display = 'none' ;
		if(theForm.f_Message) theForm.f_Message.focus();
		}
		
}
function FindAgenceAdresseClient(theForm) {
	var displayag = document.getElementById("agence_adresse_client") ;
	var agcodeind = theForm.agence_client_nom.options[theForm.agence_client_nom.selectedIndex].value ;
	var idagNum = parseFloat(agcodeind);
	
	if (theForm.f_Agence_indiquee)
	theForm.f_Agence_indiquee.value = (idagNum) ? DATA_AGENCES_BY_VILLE[agcodeind].split('|')[1].replace(/;/g," - ") : theForm.agence_client_ville.value  + ' - Agence non précisée' ;

	if (displayag) {
		var content = (idagNum) ? 'Agence '+ DATA_AGENCES_BY_VILLE[agcodeind].split('|')[0].replace(/;/g,"<br>") : ''  ;
		displayag.style.display = (idagNum) ? 'block' : 'none';
		if (idagNum && AG_GOOGLE_MAP && parseInt(DATA_AGENCES_BY_VILLE[agcodeind].split('|')[2])) { 
				content+= " -  voir le <a href=\"javascript:void(0);\" onMouseover=\"window.status=\'\';return true;\" onMouseout=\"window.status=\'\';return true;\"";
				content+= " onclick=\'WinPlanAgence(\"" + agcodeind + "\");\' >"+ liblinkmap.toLowerCase() + "</a>" ;
				}
		displayag.innerHTML = content ;
		
		}
}
// --------- fin lien annuaire
//-->
