<!--

var IMMO_MensualiteMini = IMMO_MontantMini / 100.0 ;
var IMMO_MensualiteMaxi = IMMO_MontantMaxi / 100.0 ;
var ASS_AgeMini = 18 ;
var ASS_AgeMaxi = 69 ;
var IMMO_PRET = 'D' ;
var IMMO_MENS = 'M' ;

var B_MAROC = 'MAC' ;
var B_TUNISIE = 'TUN' ; 


var LibDevise = (SITE_Devise.length) ? SITE_Devise : " Euros" ;
var indication = "Indiquez le montant dont vous avez besoin<br>à partir de "+AffMont(IMMO_MontantMini)+" " + LibDevise ;
var erreurMontant="\nSaisissez un montant compris entre\n"+AffMont(IMMO_MontantMini)+ " " + LibDevise + " et "+AffMont(IMMO_MontantMaxi)+" " + LibDevise + " dans le champs \"Montant souhaité\"";
var erreurApport="\nLe montant de l'apport ne peut être négatif dans le champs \"Apport personnel\" !";
var erreurAge="\nL'âge doit être compris entre "+ ASS_AgeMini + " et " + ASS_AgeMaxi + " ans dans le champs \"Votre âge\"";

var erreurMensMini="\nSaisissez un remboursement plus élévé\ndans le champs \"Montant à rembourser tous les mois\"";
var erreurMensMaxi="\nSaisissez un remboursement moins élévé\ndans le champs \"Montant à rembourser tous les mois\"";

// Approche montant / mensualite
function Valid_Immo(theForm)
{
TYPE_BANQ = theForm.H_Userbanq.value ;
if ( TYPE_BANQ  == 'RUS') { // special russie	
	Init_Loan_Russia(theForm) ;
	return (InitApportImmo (theForm)) ;
	}
	
	
if (theForm.Usermont){ // champs unique pour les donnees montant
	var Usertmp = ChampsRenvoiNum(theForm.Usermont) ;
	if (theForm.H_Userappr.value == IMMO_PRET) 
	theForm.T_Userpret.value = theForm.Usermont.value;
	if (theForm.H_Userappr.value == IMMO_MENS) theForm.T_Usermens.value = theForm.Usermont.value;
 } 
			
if (theForm.T_Userpret && theForm.H_Userappr.value == IMMO_PRET)
	{
		
	var UserPret = ChampsRenvoiNum(theForm.T_Userpret);
	if( UserPret < IMMO_MontantMini || (IMMO_MontantMaxi && UserPret > IMMO_MontantMaxi) )  {
    	alert(erreurMontant);
    	if(theForm.T_Userpret.type == 'hidden') // champs unique pour recup valeur
    		theForm.Usermont.focus();
    	else
    		theForm.T_Userpret.focus();
    	return (false);
  		}
  	}
if (theForm.T_Userapport)  	
	{
	var UserApport = ChampsRenvoiNum(theForm.T_Userapport);
	if (UserApport < 0 ) {
      alert(erreurApport);
    	theForm.T_Userapport.focus(); return (false);
    	}
	}	
if (theForm.T_Usermens && theForm.H_Userappr.value == IMMO_MENS)  	
	{
	var UserMens = ChampsRenvoiNum(theForm.T_Usermens);
   	if (UserMens < IMMO_MensualiteMini ||(IMMO_MensualiteMaxi &&  UserMens > IMMO_MensualiteMaxi)) {
   		var erreurMens = (UserMens < IMMO_MensualiteMini) ? erreurMensMini : erreurMensMaxi ;
    	alert(erreurMens);
    	if(theForm.T_Usermens.type == 'hidden')
    		theForm.Usermont.focus();
    	else
    		theForm.T_Usermens.focus();
    	return (false);
   		}
	} 
if (theForm.T_Userage)  	
	{
	var UserAge = ChampsRenvoiNum(theForm.T_Userage);
	if (UserAge < ASS_AgeMini || UserAge > ASS_AgeMaxi ) {
      	alert(erreurAge);
    		theForm.T_Userage.focus(); return (false);
    		}
	}

// spécial maroc
if ( TYPE_BANQ == B_MAROC || TYPE_BANQ == B_TUNISIE) {
	if (theForm.T_Userduree)  	// test duree
		{
		var Userduree = ChampsRenvoiNum(theForm.T_Userduree);
		if (Userduree < IMMO_DureeAnMini || (IMMO_DureeAnMaxi && Userduree > IMMO_DureeAnMaxi) ) {
      	alert('Indiquez une durée entre '+ IMMO_DureeAnMini + ' et ' + IMMO_DureeAnMaxi + ' ans');
    		theForm.T_Userduree.focus();return (false);
    		}
		}
	if (theForm.T_Usertaux)  	// test taux
		{
		var Usertaux = ChampsRenvoiNum(theForm.T_Usertaux);
		if (Usertaux < IMMO_TauxMini ||(IMMO_TauxMaxi && Usertaux > IMMO_TauxMaxi)) {
      	alert('Indiquez un taux de prêt ' + ((Usertaux < IMMO_TauxMini) ? 'plus élévé.' : ('au maximum de ' + IMMO_TauxMaxi + ' %.')));
    		theForm.T_Usertaux.focus(); return (false);
    		}
		}

	if (theForm.T_Userduree2)  	// test duree2
		{
		var Userduree2 = ChampsRenvoiNum(theForm.T_Userduree2);
		if (Userduree2)
		if (Userduree2 < IMMO_DureeAnMini ||(IMMO_DureeAnMaxi && Userduree2 > IMMO_DureeAnMaxi )) {
			alert('Vous pouvez indiquer une 2ème durée entre '+ IMMO_DureeAnMini + ' et ' + IMMO_DureeAnMaxi + ' ans sinon tapez 0.');
    		theForm.T_Userduree2.focus(); return (false);
    		}
		}
	if (theForm.T_Usertaux2)  	// test taux2
		{
		var Usertaux2 = ChampsRenvoiNum(theForm.T_Usertaux2);
		if (Usertaux2)
		if (Usertaux2 < IMMO_TauxMini || (IMMO_TauxMaxi && Usertaux2 > IMMO_TauxMaxi) ) {
      		alert('Vous pouvez indiquer un 2ème taux de prêt ' + ((Usertaux < IMMO_TauxMini) ? 'plus élévé.' : ('au maximum de ' + IMMO_TauxMaxi + ' %.')) + ' sinon tapez 0.');
    		theForm.T_Usertaux2.focus(); return (false);
    		}
		}

	}
// alert (theForm.T_Userpret.value+'|'+ theForm.T_Userapport.value);
// fin maroc
return (true);
}



// renvoi la valeur en flot ou 0.0 si vide ou non numerique 

function RenvoiNum(valChaine)
{
var valnum =  valChaine.replace(/\,|\./g, '_');
valnum = valnum.replace(/[a-z]|\W|/gi, ''); // lettre et car non num et non _
valnum = valnum.replace(/\,|\./g, '_') ;
valnum = valnum.replace(/_/g, '.');
if (valnum == '' ) valnum = '0' ;
var valeurNum = parseFloat(valnum);
return (valeurNum) ;
}

function ChampsRenvoiNum(Champs) {
var valeurNum = RenvoiNum(Champs.value) ;
if (Champs.value.length && valeurNum != 0) Champs.value = String(valeurNum) ;
return (valeurNum) ;
}

// affiche sur format 000 000 
function AffMont(valeur,pos){
  	var strval = new String(valeur);
  	var valnum = RenvoiNum(strval);
	
	var val = (Math.round(parseFloat(valnum) * Math.pow(10,2))/100.);

	var ftval = '';
  	strval = new String(val);
  	var k = strval.indexOf('.'); // traite la virgule sur 2 decim
  		if (k != -1) {
  			if (k > strval.length - 3){ strval += '0';}
		}
		else {k =  strval.length; }
		if (k > 3) {
		  // traite le format 000 000 
		  var j =  3 - ((Math.ceil(k/3) * 3) - k) ;
		  ftval = strval.substring(0, j) + ' '; 
		  var t3 = 1;
		  	for (i = j;  i < strval.length ;  i++)
		   	{
			   ch = strval.charAt(i);
			   ftval += ch;
			   if (t3++ == 3 && k > i + 1) { ftval += ' '; t3 = 1}
		   	}
		 }
  else {ftval = strval; }
 return(ftval);
}


function GetParameterForm(Nom){
var param= unescape(document.location.search.substring(1));
param = param.replace(/€/g ,'');
param = param.replace(/&#8364;|\s|EUR/g , '');
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 '';}
}


// recup param from page appel formulaire
function Loading(theForm){
var Userapport = GetParameterForm("T_Userapport") ;
var Userpret   = GetParameterForm("T_Userpret") ;
var Usermens   = GetParameterForm("T_Usermens") ;
var Userage    = GetParameterForm("T_Userage") ;

if (theForm.T_Usermens && Usermens !='')  	
	{
	theForm.T_Usermens.value = Usermens;
	if (theForm.T_Userapport != null) theForm.T_Userapport.value = Userapport; 
	if (theForm.T_Userage != null) theForm.T_Userage.value = Userage; 
  	theForm.T_Usermens.focus();
	}
if (theForm.T_Userpret && Userpret != '')
	{
	theForm.T_Userpret.value = Userpret;
	if (theForm.T_Userapport != null) theForm.T_Userapport.value = Userapport;
	if (theForm.T_Userage != null) theForm.T_Userage.value = Userage; 
	theForm.T_Userpret.focus(); 
 	}
if (theForm.T_Userpret && Usermens == '')
	theForm.T_Userpret.focus(); 

return (false);
}

// reset formulaire field saisie par user
function ResetFormUser(theForm) {
  var firstfield =-1 ; 
   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 = '' ;
     	firstfield = (firstfield == -1) ? i : firstfield ;
     	}
     if (typechamps.indexOf('select') != -1 ) {theForm.elements[i].selectedIndex = 0 ; }
     }
if (firstfield != -1) theForm.elements[firstfield].focus();
}


// util cookies

 // Expir cookie
var expdate = new Date();

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}



//-->