
/////////////////////////////////////////////////// 
// Concernant l'affichage des erreurs en javascript
///////////////////////////////////////////////////

var checkOk = new Image();
var checkNo = new Image();
var tabMois = new Array()

tabMois[0] = "Janvier" 
tabMois[1] = "F&#233;vrier" 
tabMois[2] = "Mars" 
tabMois[3] = "Avril" 
tabMois[4] = "Mai" 
tabMois[5] = "Juin" 
tabMois[6] = "Juillet" 
tabMois[7] = "Ao&#233;t" 
tabMois[8] = "Septembre" 
tabMois[9] = "Octobre" 
tabMois[10] = "Novembre" 
tabMois[11] = "D&#233;cembre" 

checkOk.src = "/images/checkOk.gif"
checkNo.src = "/images/checkNo.gif"

//-----------------------------------
// Met toutes les images check à blanc
function emptyCheckError()
{
	msg = "liste de images \n"
	for (i=0 ; i<document.images.length ; i++)
	{
		if ( document.images[i].name.substr(0,6) == "check_" )
		{
			document.images[i].src = checkOk.src
			msg = msg + document.images[i].src + " - " + document.images[i].name + "\n"
		}
	}
//	alert(msg);
}
function emptyCheckErrorNet()
{
	msg = "liste de images \n"
	for (i=0 ; i<document.images.length ; i++)
	{
	//alert(document.images[i].name);
	msg = msg +document.images[i].name +document.images[i].id.substr(document.images[i].name.length-11,11)+'\n'
		if ( document.images[i].id.substr(document.images[i].id.length-12,11) == "check_error" )
		{
			document.images[i].src = checkOk.src
			msg = msg + document.images[i].src + " - " + document.images[i].id + "\n"
		}
	}
	//alert(msg);
}

//-----------------------------------------------------
// Affiche un marque rouge devant le champ où il y a une 
// erreur
function checkError(imageName)
{
	
	
	document.images[imageName].src = checkNo.src
}



//-------------------------------------------------
// Fonction d'ouverture d'une popup avec ascensseur
function openWindow(url, dimx, dimy,winName)
{
  featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrolling=auto,scrollbars=yes,resizable=no,width="+ dimx + ",height=" + dimy;
  myWindow = window.open(url,winName,featur);	
}

// Fonctiion d'impression de la page
function PrintPage()
{
	if(window.print) { window.print(); }
	else { alert('ATTENTION :\n Votre navigateur ne supporte par cette fonctionnalitée JavaScript.'); }
}

function removeAccents(str)
{
	var str2 = str;
	str2 = str2.replace(/[ÀÁÂÃÄÅ]/g,"A");
	str2 = str2.replace(/[àáâãäå]/g,"a");
	str2 = str2.replace(/[ÒÓÔÕÖØ]/g,"O");
	str2 = str2.replace(/[òóôõöø]/g,"o");
	str2 = str2.replace(/[ÈÉÊË]/g,"E");
	str2 = str2.replace(/[èéêë]/g,"e");
	str2 = str2.replace(/[ÌÍÎÏ]/g,"I");
	str2 = str2.replace(/[ìíîï]/g,"i");
	str2 = str2.replace(/[ÙÚÛÜ]/g,"U");
	str2 = str2.replace(/[ùúûü]/g,"u");
	str2 = str2.replace(/[Ÿ]/g,"Y");
	str2 = str2.replace(/[ÿ]/g,"y");
	str2 = str2.replace(/[Ñ]/g,"N");
	str2 = str2.replace(/[ñ]/g,"n");
	str2 = str2.replace(/[Ç]/g,"C");
	str2 = str2.replace(/[ç]/g,"c");
	return str2;
}

//---------------------------------
// Test si la valeur est numérique 
function tester(chaine) { 
 var chain = new String(chaine);
 erreur=0;
  for (var i = 0; i < chain.length ; i++) 
   { 
    var chainez = chain.substring (i, i + 1); 
    if (chainez < "0" || "9" < chainez) 
         {
          erreur=2 ; 
          break;
          } 
   } 
 if (erreur == 2 ) 
   { 
     alert ("Veuillez saisir une valeur numerique" ) ;    
     erreur=0;
     return false;
   }
 else {return true;}
}
//---------------------------------
// Test si la valeur est numérique 
function isNumeric(chaine) { 
 var chain = new String(chaine);
 erreur=0;
  for (var i = 0; i < chain.length ; i++) 
   { 
    var chainez = chain.substring (i, i + 1); 
    if (chainez < "0" || "9" < chainez) 
         {
          erreur=2 ; 
          break;
          } 
   } 
 if (erreur == 2 ) 
   { 
     erreur=0;
     return false;
   }
 else {return true;}
}



  //------------------------------
  // Test le numéro de téléphone 
  function test_NumTel(num)
  {
	var val 
	val = deleteEspace(num)
	
	if (val == ""){	return false }
	else
	{
		// Valeur numérique ?
		if ( !(tester(val)) )
		{
			return false
		}

		if ((val.length < 10) || (val.length > 14))
		{
			alert('N° de téléphone ou de fax incorrect.')
			return false
		}
	}
	return true 
  }

//----------------------------
// Test adresse
function test_adresse(address)
{
	if(AdresseDeleteChar(address) == "")
	{
		alert('Veuillez nous indiquer votre adresse.');	
		return false;
	}

	var reg = new RegExp("[^a-zA-Z0-9\-\']", "g");
	if(reg.test(removeAccents(deleteEspace(address))))
	{
		// Not allowed char has been found.
		// value is not valid
		alert("Le champ Adresse est invalide. Les caractères spéciaux ou de ponctuation ne sont pas autorisés.");
		return false;
	}
	
	return true;
}
function test_lieudit(address)
{
	var reg = new RegExp("[^a-zA-Z0-9\-\']", "g");
	if(reg.test(removeAccents(deleteEspace(address))))
	{
		// Not allowed char has been found.
		// value is not valid
		alert("Le champ Lieu dit est invalide. Les caractères spéciaux ou de ponctuation ne sont pas autorisés.");
		return false;
	}
	
	return true;
}

//----------------------------
// Test le nom et le prénom
function test_name(name, field)
{
  var chainez;
  if (deleteEspace(name) == "")
  {
  	alert('Veuillez nous indiquer votre Nom et Prénom.');
  	return false;
  }
  if (name.length > 32) {
  	msg = 'Le taille des champs est limitées à 32 ';
  	alert(msg);
  	return false;
  }
  /*for (var i = 0; i < name.length ; i++) 
  { 
  	chainez = name.substring (i, i + 1); 
  	if ((chainez > "0") && (chainez < "9") ) 
      {
        msg = 'Les champs Nom et Prénom ne peuvent pas contenir de caractère numérique.'
        alert(msg)
        return false
        break;
  	} 
  }*/

  // 09/2009
  var reg = new RegExp("[^a-zA-Z\-\']", "g");
  if(reg.test(removeAccents(deleteEspace(name))))
  {
	// Not allowed char has been found.
	// value is not valid
	alert("Le champ " + field + " est invalide. Les caractères spéciaux, numériques ou de ponctuation ne sont pas autorisés.");
	return false;
  }
  
  return true;
}

//----------------------------
// Test le nom et le prénom du conjoint
function test_name_partner(name)
{
  var chainez
  if (deleteEspace(name) == "")
  {
  	alert('Veuillez nous indiquer le Nom et le Prénom de votre conjoint.')
  	return false
  }
  if (name.length > 32) {
  	msg = 'Le taille des champs est limitées à 32 '
  	alert(msg)
  	return false
  }
  for (var i = 0; i < name.length ; i++) 
  { 
  	chainez = name.substring (i, i + 1); 
  	if ((chainez > "0") && (chainez < "9") ) 
      {
        msg = 'Les champs Nom et Prénom ne peuvent pas contenir de caractère numérique.'
        alert(msg)
        return false
        break;
  	} 
  } 	
  return true
}

//----------------------------
// Test le nom et le prénom de l'enfant
function test_name_child(name)
{
  var chainez
  if (deleteEspace(name) == "")
  {
  	alert('Veuillez nous indiquer le Nom et le Prénom de votre enfant.')
  	return false
  }
  if (name.length > 32) {
  	msg = 'Le taille des champs est limitées à 32 '
  	alert(msg)
  	return false
  }
  for (var i = 0; i < name.length ; i++) 
  { 
  	chainez = name.substring (i, i + 1); 
  	if ((chainez > "0") && (chainez < "9") ) 
      {
        msg = 'Les champs Nom et Prénom ne peuvent pas contenir de caractère numérique.'
        alert(msg)
        return false
        break;
  	} 
  } 	
  return true
}



// ------------------------------
// TEST DE L'ADRESSE
// ------------------------------
function AdresseDeleteChar (adresse)
{
	// Supprime les espaces et les retours chariots
	retour = ""
	lenChaine = adresse.length 
	i=0
	codeStr_i = ''
	while (i < lenChaine)
	{
		subSTR_i = adresse.substr(i,1)
		codeStr_i = adresse.charCodeAt(i)
		if ( (codeStr_i != 32) && (codeStr_i != 10) && (codeStr_i != 13) )
		{
			retour = retour.concat(subSTR_i)
		}
		i++
	}
	return retour
}



  //-------------------------------
  // Test et modifie le code postal
  function testCP(val)
  {
		// Test si la valeur est numérique
		var msgCP
		if (val == ""){	return false }
		else
		{
			if ( !(tester(val)) )
			{
				return false
			}
		
			// Test si la valeur est un code postal
			if ( val.length != 5 ) 
			{
				alert('Code postal incorrect : un code postal est composé de 5 chiffres')
				return false
			}

			msgCP = "Etes-vous certain d\'avoir saisi un code postal du territoire français ?"
				
			// Test si le CP est compris entre 2 valeurs
			if ( (val < 1000) || (val > 99000) || ((val >= 96000) && (val <= 96999)))
			{
				alert(msgCP)
				return false
			}
			
			// Test si le CP correspond à la Corse
			
			/*
			if ( (20000 <= val) && (val < 21000) )
			{
				alert(msgCP)
				return false
			}
			*/
		}
		return true
  }// Fin de TestCP

  function ModifCP(CPName,CP)
  {
	formName = 'Form1';
	//formName = SearchFormName(window.event.srcElement.name)
	valCP = document.forms[GetIndexForm(formName)].elements[GetIndexElement(CPName)].value
	if (valCP != CP)
	{
		if (testCP(valCP) ) 
		{
			//alert(document.forms[GetIndexForm(formName)].action)		
			//document.forms[GetIndexForm(formName)].action = '#'+CPName;
			//alert(document.forms[GetIndexForm(formName)].action)
			document.forms[GetIndexForm(formName)].submit() ;
		}
		else
		{
			document.forms[GetIndexForm(formName)].elements[GetIndexElement(CPName)].value = ""
		}
	} 
  }

  // FIN - Test et modifie le code postal
  //---------------------------------------

  
//--------------------------------------
// Test la syntaxe de l'adresse email 


  function TestEmail_old(val)
  {
	if (val == ""){	return false }
	else
	{
		msg = "ATTENTION : \n Votre adresse e-mail est incorrecte."
		if (val.indexOf("@") > 1)
		{
			i = val.indexOf("@")
			if ((val.indexOf(".", i) != -1) &&
				(val.indexOf(".", i) < val.length - 1) )
			{
				return true;
			}
			else
			{
				alert(msg);
				return false;
			}
		}
		else
		{
			alert(msg);
			return false;
		}
	}
	return true ;
  }// Fin de TestEmail


//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------

  function TestEmail(myEmail)
  {
    var tmp_email = trim(myEmail,' ');
	if (TestSpace(tmp_email)){
		alert('Veuillez vérifier votre adresse email.');
		return false;
	}
	var tmp_email = deleteEspace(myEmail);
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(tmp_email))
		return true;
	else
		{
			alert('Veuillez vérifier votre adresse email.');
			return false;
		}
  }// Fin de TestEmail


// --------------------------
// Suppression des espaces 
//---------------------------
function  deleteEspace(chaine)
{
	retour = ""
	lenChaine = chaine.length 
	i=0
	while (i < lenChaine)
	{
		subSTR_i = chaine.substr(i,1)
		codeStr_i = chaine.charCodeAt(i)
		if ( subSTR_i != " " )
		{
			retour = retour.concat(subSTR_i)
		}
		i++
	}
	return retour
}

// --------------------------
// test si il y a des espaces 
//---------------------------
function  TestSpace(chaine)
{
	var lenChaine = chaine.length ;
	var i=0;
	while (i < lenChaine)
	{
		subSTR_i = chaine.substr(i,1);
		if (subSTR_i == ' ')
		{
			return true;
		}
		i++
	}
	return false;
}


// Compare la date du jour avec la date passe en parametre
// return	true si (date_du_jour > date_entree_en_parametres)
//			false sinon
function diff_date(MonJour,MonMois,MonAnnee)
{
  var date=new Date();
  var annee=date.getFullYear();
  var mois=date.getMonth()+1;
  var jour=date.getDate();
 
  MonJour=trimStart(MonJour,"0")
  MonMois=trimStart(MonMois,"0")
  
  if (MonAnnee > annee)
  {
	return false
  }
  else
  {
	if (MonAnnee == annee)
	{
		
	  if (MonMois > mois)
	  {
		
		return false
	  } 
	  else 
	  {
		if (MonMois == mois)
		{
			if (MonJour > jour) { 
		
			return false 
			}	
		}
	  }
	}
  }

  return true
}

function equal_now_date(MonJour,MonMois,MonAnnee)
{
  var date=new Date();
  var annee=date.getFullYear();
  var mois=date.getMonth()+1;
  var jour=date.getDate();

  if ((MonJour == jour) && (MonMois == mois) && (MonAnnee == annee))
  {
	return true;
  }
  else
  {
	return false;
  }	
}

// Calcul la différence entre 2 date en nb de mois
function diff_mois(jour1,mois1,annee1,jour2,mois2,annee2)
{
  var diffAn
  var diffMois  
  
  diffAn = annee2 - annee1 
  diffMois = mois2 - mois1 + (diffAn * 12)
  if (jour1 > jour2) { diffMois = diffMois - 1 } 
  
  return diffMois
}

// Test la date de naissance 
function test_birth_date (check_naiss,date_naiss_jour,date_naiss_mois,date_naiss_annee)
{
  //var formName = document.forms[0].name
  var formName
  formName = SearchFormName(date_naiss_annee)
  
  var date=new Date();
  var annee=date.getFullYear();
  var mois=date.getMonth()+1;
  var jour=date.getDate();
  
  var naiss_annee = document.forms[GetIndexForm(formName)].elements[date_naiss_annee].value
  var naiss_mois = document.forms[GetIndexForm(formName)].elements[date_naiss_mois].options[document.forms[GetIndexForm(formName)].elements[date_naiss_mois].selectedIndex].value
  var naiss_jour = document.forms[GetIndexForm(formName)].elements[date_naiss_jour].options[document.forms[GetIndexForm(formName)].elements[date_naiss_jour].selectedIndex].value

  // Test si les dates ont ete saisie
  if (naiss_jour == "")
  {
	alert('Veuillez saisir la date de naissance.');
	document.forms[GetIndexForm(formName)].elements[date_naiss_jour].focus();
	checkError(check_naiss)
	return false;
  }
  if (naiss_mois == "")
  {
	alert('Veuillez saisir la date de naissance.');
	document.forms[GetIndexForm(formName)].elements[date_naiss_mois].focus();
	checkError(check_naiss)
	return false;
  }
  if (naiss_annee == "")
  {
	alert('Veuillez saisir la date de naissance.');
	document.forms[GetIndexForm(formName)].elements[date_naiss_annee].focus();
	document.forms[GetIndexForm(formName)].elements[date_naiss_annee].select();
	checkError(check_naiss)
	return false;
  }

  // Date de naissance < 0 ans 
  if (( annee - naiss_annee) < 0)
  {
	msg = "Etes-vous certain de ne pas vous être trompé dans la saise \n" ;
	msg = msg + "de la date de naissance : " + naiss_jour + "/" + naiss_mois + "/" + naiss_annee + ".\n"  ;
	alert(msg);

	document.forms[GetIndexForm(formName)].elements[date_naiss_annee].focus();
	document.forms[GetIndexForm(formName)].elements[date_naiss_annee].select();
	checkError(check_naiss)
	return false;
  }
 
  return true

}

// Recherche le nom du formulaire contenant l'element myElt
function SearchFormName(myElt)
{
	alert('searchfromname');
	var nbForm;
	var nbItem;
	var nameItem; 
	var FormName = "Form1";
	nbForm = document.forms.length;
	for (i=0 ; i<nbForm ; i++)
	{
		nbItem = document.forms[i].length;
		for (j=0 ; j<nbItem ; j++)
		{
			nameItem = document.forms[i].elements[j].name;
			if (nameItem == myElt) 
			{ 
				FormName = document.forms[i].name;
				return FormName;
			}
		}
	}
	return FormName;
}


// Test l'année saisie
function testerAn(chaine) { 
 if(chaine!="")
 {
   erreur=0
   for (var i = 0; i < chaine.length ; i++) 
   { 
    var chainez = chaine.substring (i, i + 1); 
    if (chainez < "0" || "9" < chainez) 
         {
          erreur=2 ; 
          break;
          } 
   } 
   if (erreur == 2 ) 
   { 
     alert ("Veuillez saisir une valeur numerique" ) ;    
     return false;
   }
   if ( (chaine < 1000) || (chaine > 9999))
   { 
	alert("Veuillez saisir l\'année sur 4 chiffres "); 
	return false;
   }
 }
  return true
}

function trimStart(s,c)
{
var iLen = s.length;
var sOut = "";
var chr = "";

for (var i=0; i<iLen; i++)
{
	chr = s.charAt(i); 
	if ((c == "0") && (iLen == 1))
		sOut = c;
	else { 
		if ((chr==c) && (sOut.length==0)){
		}
		else
		{
			sOut = sOut + chr; 
		}
	}
}
return sOut;
}

function trimEnd(s,c)
{
var iLen = s.length;
var sOut = "";
var chr = "";

for (var i=iLen-1; i>=0; i--)
{
	chr = s.charAt(i); 
	if ((chr==c) && (sOut.length==0)){
	}
	else
	{
		sOut = chr + sOut; 
	}
}
return sOut;
}
function trim(s,c){
	return trimEnd(trimStart(s,c),c);
}

function IIf(bool_arg,val1,val2){
	if (bool_arg)
		return val1;
	else
		return val2;
}
function GetIndexForm(FormName){
	var i_form=0;
	var y=0;
	for (y=0;y<document.forms.length;y++){
		if (document.forms[y].name == FormName)
			i_form = y;
	}
	return i_form;
}

function GetIndexElement(ElementName){
	formName = 'Form1' //SearchFormName(event.srcElement.name)
	var i_form=0;
	i_form = GetIndexForm(formName);
	var i;
	for(i=0;i<=document.forms[i_form].elements.length-1;i++){
		if (document.forms[i_form].elements[i].name == ElementName){
			return i;
			break;
		}
	}
	return -1;
}

function SetSelected(formName, ctrlSelect, strValue){
	var i=0;
	
	for (i=0; i<document.forms[GetIndexForm(formName)].elements[ctrlSelect].length; i++) {
		if ((strValue!='') && (strValue == document.forms[GetIndexForm(formName)].elements[ctrlSelect].options[i].value)){
			document.forms[GetIndexForm(formName)].elements[ctrlSelect].options[i].selected=true;
			break;
		}
	}
}
function LoadList(ArrayText,ArrayValues,ctrlSelect,strdefaultvalue,formname){
   	var i=0;
   	var i_selected=0;
   	document.forms[GetIndexForm(formName)].elements[ctrlSelect].length=ArrayText.length - 1;
	for (i=0; i<ArrayText.length; i++) {
		if ((strdefaultvalue!='') && (strdefaultvalue == ArrayValues[i].toString()))
			i_selected = i;
		document.forms[GetIndexForm(formName)].elements[ctrlSelect].options[i]= new Option(ArrayText[i],ArrayValues[i]);
	}
	document.forms[GetIndexForm(formName)].elements[ctrlSelect].options[i_selected].selected=true;
}

function completeDate(strDate){
	if (strDate.length==4){
		strDate =  "01/01/" + strDate;
	}
	if (strDate.length==8){
		var strprefix="19";
		if (parseInt(strDate.substring(6,8)) < 20)
			strprefix="20";
		strDate = strDate.substring(0,6) + strprefix + strDate.substring(6,8);
	}
	return strDate;
}

function calcul_age(str_date){
	str_date = completeDate(str_date);
	str_date = str_date.substr(3,2) + "/" + str_date.substr(0,2) + "/" + str_date.substr(6,4);
	var dannee=-1, dmois=-1, djour=-1, dheure=-1, dminute=-1; 
	var compDat = new Date(str_date); 
	var msparan = 365.25 * 24 * 60 * 60 * 1000; 
	var msparjour = 24 * 60 * 60 * 1000; 
	var daten = new Date(); 
	var changeA = dannee; 
	var changeJ = djour; 
	var diffMs = daten.getTime() - compDat.getTime(); 
	dannee = Math.floor(diffMs / msparan); 
	diffMs -= dannee * msparan; 
	djour = Math.floor(diffMs / msparjour); 
	diffMs -= djour * msparjour; 
	if (diffMs < 0)
		return -1;
	return dannee;
}

function calcul_age_with_date_ref(str_date, str_date_ref){
	str_date = completeDate(str_date);
	str_date_ref = completeDate(str_date_ref);
	str_date = str_date.substr(3,2) + "/" + str_date.substr(0,2) + "/" + str_date.substr(6,4);
	str_date_ref = str_date_ref.substr(3,2) + "/" + str_date_ref.substr(0,2) + "/" + str_date_ref.substr(6,4);
	var dannee=-1, dmois=-1, djour=-1, dheure=-1, dminute=-1; 
	var compDat = new Date(str_date); 
	var msparan = 365.25 * 24 * 60 * 60 * 1000; 
	var msparjour = 24 * 60 * 60 * 1000; 
	var daten = new Date(str_date_ref); 
	var changeA = dannee; 
	var changeJ = djour; 
	var diffMs = daten.getTime() - compDat.getTime(); 
	dannee = Math.floor(diffMs / msparan); 
	diffMs -= dannee * msparan; 
	djour = Math.floor(diffMs / msparjour); 
	diffMs -= djour * msparjour; 
	if (diffMs < 0)
		return -1;
	return dannee;
}
function calcul_age_jour(str_date){
	str_date = completeDate(str_date);
	str_date = str_date.substr(3,2) + "/" + str_date.substr(0,2) + "/" + str_date.substr(6,4);
	var str_NowDate;
	str_NowDate = NowDate();
	str_NowDate = str_NowDate.substr(3,2) + "/" + str_NowDate.substr(0,2) + "/" + str_NowDate.substr(6,4);
	var dannee=-1, dmois=-1, djour=-1, dheure=-1, dminute=-1; 
	var compDat = new Date(str_date); 
	var msparan = 365.25 * 24 * 60 * 60 * 1000; 
	var msparjour = 24 * 60 * 60 * 1000; 
	var daten = new Date(str_NowDate); 
	var changeA = dannee; 
	var changeJ = djour; 
	var diffMs = daten.getTime() - compDat.getTime(); 
	if (diffMs < 0)
		return -1;
	dannee = Math.floor(diffMs / msparan); 
	diffMs -= dannee * msparan; 
	djour = Math.floor(diffMs / msparjour); 
	diffMs -= djour * msparjour; 
	return djour;
}

function Get_Month(str_date){
	str_date = completeDate(str_date);
	str_date = str_date.substr(3,2) + "/" + str_date.substr(0,2) + "/" + str_date.substr(6,4);
	var theDate = new Date(str_date);
	if ((theDate.getMonth() + 1).toString().length == 1)
		return "0" + (theDate.getMonth() + 1).toString();
	else
		return (theDate.getMonth() + 1).toString();
}

function Get_Day(str_date){
	str_date = completeDate(str_date);
	str_date = str_date.substr(3,2) + "/" + str_date.substr(0,2) + "/" + str_date.substr(6,4);
	var theDate = new Date(str_date);
	
	if ((theDate.getDate()).toString().length == 1)
		
		return "0" + (theDate.getDate() ).toString();
	else		
		return (theDate.getDate()).toString();
}

function Get_Year(str_date){
	str_date = completeDate(str_date);
	str_date = str_date.substr(3,2) + "/" + str_date.substr(0,2) + "/" + str_date.substr(6,4);
	var theDate = new Date(str_date);
	if ((theDate.getYear()).toString().length == 2)
		return "19" + (theDate.getYear()).toString();
	else
		if ((theDate.getYear()).toString().length == 3)
			return "20" + (theDate.getYear()).toString().substr(1,2);
		else
			return (theDate.getYear()).toString();
}

function Get_TextMonth(str_month){
	var MoisTxt;	
	if (str_month.toString().length == 1)
		str_month = "0" + str_month.toString();
	switch (str_month)
	{
		case "01":
	        MoisTxt = "janvier";
			break;
		case "02":
	        MoisTxt = "février";
			break;
		case "03":
	        MoisTxt = "mars";
			break;
		case "04":
	        MoisTxt = "avril";
			break;
		case "05":
	        MoisTxt = "mai";
			break;
		case "06":
	        MoisTxt = "juin";
			break;
		case "07":
	        MoisTxt = "juillet";
			break;
		case "08":
	        MoisTxt = "août";
			break;
		case "09":
	        MoisTxt = "septembre";
			break;
		case "10":
	        MoisTxt = "octobre";
			break;
		case "11":
	        MoisTxt = "novembre";
			break;
		case "12":
			MoisTxt = "décembre";
			break;
	}
	return MoisTxt;
}

function DateToString(theDate)
{
	var str_day="";
	var str_month="";
	if (theDate.getDate().toString().length==1)
		str_day = "0" + theDate.getDate().toString();
	else
		str_day = theDate.getDate().toString();
	if ((theDate.getMonth()+1).toString().length==1)
		str_month = "0" + (theDate.getMonth()+1).toString();
	else
		str_month = (theDate.getMonth()+1).toString();
		
	if (theDate.getYear() < 1000)
		return str_day + '/' + str_month + '/' + (1900 + theDate.getYear()).toString() 
	else
		return str_day + '/' + str_month + '/' + theDate.getYear().toString() 

}

function NowDate(){
	var theDate = new Date();
	theDate.setDate(theDate.getDate());
	return DateToString(theDate);
}

function compute_date(str_date, str_operator, compute_value, str_part_of_date_to_compute){
	str_date = completeDate(str_date);
	str_date = str_date.substr(3,2) + "/" + str_date.substr(0,2) + "/" + str_date.substr(6,4);
	var theDate = new Date(str_date);
	
	
	switch (str_part_of_date_to_compute)
	{
		case "DAY":
			if (str_operator=="+")
				theDate.setDate(theDate.getDate() + parseInt(compute_value));
			else
				theDate.setDate(theDate.getDate() - parseInt(compute_value));
			break;
		case "MONTH":
			if (str_operator=="+")
				theDate.setMonth((theDate.getMonth()) + parseInt(compute_value));
			else
				theDate.setMonth((theDate.getMonth()) - parseInt(compute_value));
			break;
		case "YEAR":
			if (str_operator=="+") 
			{
				if (theDate.getYear() < 1000)
					theDate.setYear(parseInt((1900 + theDate.getYear()).toString()) + parseInt(compute_value));
				else
					theDate.setYear(parseInt(theDate.getYear().toString()) + parseInt(compute_value));
			}
			else
			{
				if (theDate.getYear() < 1000)
					theDate.setYear(parseInt((1900 + theDate.getYear()).toString()) - parseInt(compute_value));
				else
					theDate.setYear(parseInt(theDate.getYear().toString()) - parseInt(compute_value));
			}
			break;
	}
	var str_day="";
	var str_month="";
	if (theDate.getDate().toString().length==1)
		str_day = "0" + theDate.getDate().toString();
	else
		str_day = theDate.getDate().toString();
	if ((theDate.getMonth()+1).toString().length==1)
		str_month = "0" + (theDate.getMonth()+1).toString();
	else
		str_month = (theDate.getMonth()+1).toString();
		
	if (theDate.getYear() < 1000)
		return str_day + '/' + str_month + '/' + (1900 + theDate.getYear()).toString() 
	else
		return str_day + '/' + str_month + '/' + theDate.getYear().toString() 
}

function compute(val1,str_signe,val2){
	switch (str_signe)
	{
		case "+":
			return (parseInt(val1) + parseInt(val2));
			break;
		case "-":
			return (parseInt(val1) - parseInt(val2));
			break;
		case "*":
			return (parseInt(val1) * parseInt(val2));
			break;
		case "/":
			return (parseInt(val1) / parseInt(val2));
			break;
	}
}

function compare_date(str_date1,str_date2){
	str_date1 = completeDate(str_date1);
	str_date2 = completeDate(str_date2);
	var len;
	var str_char;
	var str_temp='';
	var i_pos=-1;
	len = str_date1.length;
	for (i=0 ; i<=len ; i++)
	{
		str_char = str_date1.charAt(i);
		if ((str_char=='/') || (i==len)) {
			if (str_date1.substr(i_pos + 1,i - i_pos - 1).length==1)
				str_temp = '0' + str_date1.substr(i_pos + 1,i - i_pos - 1) + str_temp;
			else
				str_temp = str_date1.substr(i_pos + 1,i - i_pos - 1) + str_temp;
			i_pos=i;
		}
	}
	str_date1=str_temp;
	str_temp='';
	i_pos=-1;
	
	len = str_date2.length;
	for (i=0 ; i<=len ; i++)
	{
		str_char = str_date2.charAt(i);
		if ((str_char=='/') || (i==len)) {
			if (str_date2.substr(i_pos + 1,i - i_pos - 1).length==1)
				str_temp = '0' + str_date2.substr(i_pos + 1,i - i_pos - 1) + str_temp;
			else
				str_temp = str_date2.substr(i_pos + 1,i - i_pos - 1) + str_temp;
			i_pos=i;
		}
	}
	str_date2=str_temp;
	return (parseInt(str_date1) > parseInt(str_date2));
}

function compare_date_equal(str_date1,str_date2){

	str_date1 = completeDate(str_date1);
	str_date2 = completeDate(str_date2);
	
	//alert('compare_date_equal:'+str_date1+'>'+str_date2);
	var len;
	var str_char;
	var str_temp='';
	var i_pos=-1;
	len = str_date1.length;
	for (i=0 ; i<=len ; i++)
	{
		str_char = str_date1.charAt(i);
		if ((str_char=='/') || (i==len)) {
			if (str_date1.substr(i_pos + 1,i - i_pos - 1).length==1)
				str_temp = '0' + str_date1.substr(i_pos + 1,i - i_pos - 1) + str_temp;
			else
				str_temp = str_date1.substr(i_pos + 1,i - i_pos - 1) + str_temp;
			i_pos=i;
		}
	}
	str_date1=str_temp;
	str_temp='';
	i_pos=-1;
	
	len = str_date2.length;
	for (i=0 ; i<=len ; i++)
	{
		str_char = str_date2.charAt(i);
		if ((str_char=='/') || (i==len)) {
			if (str_date2.substr(i_pos + 1,i - i_pos - 1).length==1)
				str_temp = '0' + str_date2.substr(i_pos + 1,i - i_pos - 1) + str_temp;
			else
				str_temp = str_date2.substr(i_pos + 1,i - i_pos - 1) + str_temp;
			i_pos=i;
		}
	}
	str_date2=str_temp;
	
	return (parseInt(str_date1) >= parseInt(str_date2));
}

function Invalid_car_plate(str_Value)
{

	// Supprime les espaces de la chaine de caractere
	carplate = deleteEspace(str_Value);
	carplate = carplate.toUpperCase();
	len = carplate.length;
	
	if (len != str_Value.length)
		return 1;
	
	var reg = /^[0-9]{2,4}[A-Z]{2,3}[0-9]{1,2}[A-B]{0,1}$/;
	var IsValid = reg.test(carplate);
	
	if (!IsValid)
		return 2;
		
	//return (!IsValid);
	return 0;
}

	function isNumeric(strSaisie) {
		var iNumeric = 1;

		if (strSaisie != "") {
			for (i=0; i < strSaisie.length; i++)
				if (strSaisie.charAt(i) < '0' || strSaisie.charAt(i) > '9')
					iNumeric = 0;
			if (iNumeric == 1)
				return true;
		}
		return false;
	}

/* retourne true pour les nombres réels 4.23 ou 4,25 */	
function isSingle(strSaisie)
{

var myString = strSaisie;
var inThere = myString.match(/^\d+([\.\,]?\d+)?$/g);
if (inThere) {
   return true;
}
else {
     return false;
	}
}	


function isDate(maDate) {
	if (new Date(maDate)=="NaN" || new Date(maDate)=="Invalid Date"){
		var tabDateTmp = (maDate).split("/");
		var JJ_tmp = tabDateTmp[0];
		var MM_tmp = tabDateTmp[1];
		var AA_tmp = tabDateTmp[2];
		var maDate_tmp = MM_tmp + "/" + JJ_tmp + "/" + AA_tmp;
		if (new Date(maDate_tmp)=="NaN" || new Date(maDate_tmp)=="Invalid Date"){
			return false;
		}
	}
	tabDate = (maDate).split("/");
	if(tabDate.length!=3) return false;
	
	JJ = tabDate[0]
	MM = tabDate[1]
	AA = tabDate[2]

	

	if ( isNaN(JJ) || isNaN(MM) || isNaN(AA) )  return false;
	
	if (!isNumeric(JJ)) return false;
	if (!isNumeric(MM)) return false;
	if (!isNumeric(AA)||AA.length!=4) return false;


	newDate = new Date(maDate)	

	iJJ = new Number(JJ);
	iMM = new Number(MM);
	iAA = new Number(AA);
	

	if (iJJ < 1 || iJJ > 31) return false;
	if (iAA < 1901 ) return false;
	if (iAA > 2020 ) return false;  
	
	//Mois de 30 jours
	if (iJJ>30&&(iMM==2||iMM==4||iMM==6||iMM==9||iMM==11)) return false;
	
	//Mois de Fevrier 
	if (iMM==2){
	if (iJJ>29)  return false;
	
	if ((iJJ>28)&&!(((iAA % 4)==0) && ((iAA % 100)!=0) || ((iAA % 400)==0))) return false;
	}
	
	if (iMM < 1 || iMM > 12) return false;
	return true;
}

function GotoChaineAvaleGroup(iGroupID,str_FunctionName){
	if (!(document.getElementById('Group_' + iGroupID.toString()))){
		window.location.href='/Pages/ChaineAvale/chaineavale.aspx?' + str_FunctionName + '=' + iGroupID;
	}
}

function GotoGroup(iGroupID,str_FunctionName, PageName){
	if (!(document.getElementById('Group_' + iGroupID.toString()))){
		window.location.href= PageName + '?' + str_FunctionName + '=' + iGroupID;
	}
}

function CoefBonus(iUsageType,nbAnneeAssurance){
	var tabCoefBonus=new Array(3)
	for (i=0; i<3; i++)
	{
	tabCoefBonus[i]=new Array(13)
	}
	// 1) Usage autre que Tournee
	tabCoefBonus[1][0]=100
	tabCoefBonus[1][1]=95
	tabCoefBonus[1][2]=90
	tabCoefBonus[1][3]=85
	tabCoefBonus[1][4]=80
	tabCoefBonus[1][5]=76
	tabCoefBonus[1][6]=72
	tabCoefBonus[1][7]=68
	tabCoefBonus[1][8]=64
	tabCoefBonus[1][9]=60
	tabCoefBonus[1][10]=57
	tabCoefBonus[1][11]=54
	tabCoefBonus[1][12]=51
	tabCoefBonus[1][13]=50

	// 2) Usage Tournée
	tabCoefBonus[2][0]=100
	tabCoefBonus[2][1]= 93  
	tabCoefBonus[2][2]= 86  
	tabCoefBonus[2][3]= 79  
	tabCoefBonus[2][4]= 73  
	tabCoefBonus[2][5]= 67  
	tabCoefBonus[2][6]= 62  
	tabCoefBonus[2][7]= 57  
	tabCoefBonus[2][8]= 53  
	tabCoefBonus[2][9]= 50  
	
	return tabCoefBonus[parseInt(iUsageType)][parseInt(nbAnneeAssurance)]
}
function TestCoefBonusWithBirthDate(strBonus,nbAnneePermis){
	if (strBonus != ''){
		var sng_bonus = parseFloat(strBonus) * 100;
		if ((nbAnneePermis < 12) && (sng_bonus == 50))
			return false;
		if ((nbAnneePermis < 11) && (sng_bonus < 51))
			return false;
		if ((nbAnneePermis < 10) && (sng_bonus < 54))
			return false;
		if ((nbAnneePermis < 9) && (sng_bonus < 57))
			return false;
		if ((nbAnneePermis < 8) && (sng_bonus < 60))
			return false;
		if ((nbAnneePermis < 7) && (sng_bonus < 64))
			return false;
		if ((nbAnneePermis < 6) && (sng_bonus < 68))
			return false;
		if ((nbAnneePermis < 5) && (sng_bonus < 72))
			return false;
		if ((nbAnneePermis < 4) && (sng_bonus < 76))
			return false;
		if ((nbAnneePermis < 3) && (sng_bonus < 80))
			return false;
		if ((nbAnneePermis < 2) && (sng_bonus < 85))
			return false;
		if ((nbAnneePermis < 1) && (sng_bonus < 90))
			return false;
	}
	return true;
}
function If_exist_then_apply(strExistVariable,strExpressionToEval){
	if ((GetIndexElement(strExistVariable)) > -1){
		return eval(strExpressionToEval);
	}
}

function GetCarUsage(iIndice){
switch(iIndice) 
{
	default: 
		return "Privé";
		
	case "2":
		return "Privé et  trajet travail";
	case "3":
		return "Privé et professionnel";
	case "4":
		return	"Tournées régulières";
	case "1":
		return "Privé";

	}
}

function VerifyCarSinistre(nbDisaster,formName,iEltId){
	var i=1;
	var nbMois, DisasterMois, DisasterAnnee;
	var dateJ=new Date();
	var annee=dateJ.getFullYear();
	var mois=dateJ.getMonth()+1;

	// Sinistres
	
	var sinistre;
	var nbSinistre;
	var selectNameSinistre;
	var selectNameDateSin;
		
		
		
		while (i <= nbDisaster )
		{
			// Initialisation des variables
			selectNameDateSin = iEltId+':txtSinDate_'+i;
			if (document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value == ''){
				DisasterMois=0;
				DisasterAnnee=0;
			}
			else {
				if (document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.length != 7){
					DisasterMois=0;
					DisasterAnnee=0;
				}
				else {
					if (document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(0,1) == '0')
						DisasterMois = parseInt(document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(1,1));
					else
						DisasterMois = parseInt(document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(0,2));
					DisasterAnnee = parseInt(document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(3,4));
				}
			}
			
			
			if ((DisasterMois == 0) || (DisasterAnnee== 0))
			{
				alert('La date du '+ i +'e sinistre n\'est pas correctement renseignée.')
				document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus();
				return false
			}
			nbMois = 12 * (annee - DisasterAnnee) - (DisasterMois - mois)

			if (nbMois < 0){
				alert('Vérifier la cohérence des dates pour votre ' + i + 'e sinistre.')
				document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus()
				return false;
			} 

			if (nbMois > 36){
				msg = "Les sinistres déclarés il y a plus de 36 mois ne doivent pas être pris en considération."
				alert(msg)
				document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus()
				return false;
			} 
			i = i + 1
		} // fin du while 
	return true;	
}

// useful in Moto Form, for moto disasters
function VerifyMotoSinistre(nbDisaster,formName,iEltId)
{
	var i = 1;
	var nbMois, MotoDisasterType, DisasterMois, DisasterAnnee
	var dateJ=new Date();
	var annee=dateJ.getFullYear();
	var mois=dateJ.getMonth()+1;

	// Sinistres
	var sinistre
	var nbSinistre
	var selectNameSinistre
		
		while (i <= nbDisaster )
		{
			// Initialisation des variables
			selectNameDateSin = iEltId+':txtMotoSinDate_'+i;
			selectNameMotoDisasterType = iEltId+':MotoDisasterType_'+i;
			if (document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value == ''){
				DisasterMois=0;
				DisasterAnnee=0;
			}
			else {
				if (document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.length != 7){
					DisasterMois=0;
					DisasterAnnee=0;
				}
				else {
					if (document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(0,1) == '0')
						DisasterMois = parseInt(document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(1,1));
					else
						DisasterMois = parseInt(document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(0,2));
					DisasterAnnee = parseInt(document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(3,4));
				}
			}
								
			MotoDisasterType = document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameMotoDisasterType)].value;
			// alert(MotoDisasterType);

			
			// test type not selected
			if (MotoDisasterType == 0) 
			{
				alert('Le type du '+ i +'e sinistre moto n\'est pas renseigné.')
				document.forms[GetIndexForm(formName)].elements[selectNameMotoDisasterType].focus() 

				return false
			}

			// test date not selected
			if ((DisasterMois == 0) || (DisasterAnnee== 0))
			{
				alert('La date du '+ i +'e sinistre moto n\'est pas renseignée.');
				
				if (DisasterMois == 0) { document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus() }
				else {document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus() } 
				
				return false;
			}
			nbMois = 12 * (annee - DisasterAnnee) - (DisasterMois - mois);
			//alert(nbMois + ' mois')

			if (nbMois < 0){
				alert('Vérifier la cohérence des dates pour votre ' + i + 'e sinistre moto.');
				document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus();
				return false;
			} 

			if (nbMois > 36){
				msg = "Les sinistres moto déclarés il y a plus de 36 mois ne doivent pas être pris en considération.";
				alert(msg);
				document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus();
				return false;
			} 
			i = i + 1
		} // fin du while 
	return true;	
}

// useful in Loans contol 
function VerifyLoan(formName, iEltId)
{
	var i = 1;
	
   // get loan nb
	var sLoanNbCtrlName;
	var sLoanNb = "";
	
	sLoanNbCtrlName = 'LOAN_NB';
	sLoanNb = document.forms[GetIndexForm(formName)].elements[GetIndexElement(sLoanNbCtrlName)].value;

	// alert(sLoanNb)

	// Prêts
	var sAmountCtrlName;
	var sLoanTypeCtrlName;
	var sInterestRateCtrlName;
	var sDurationCtrlName;
	var sDifferedCtrlName;
	var sLoanRateTypeCtrlName;
	
	var sAmount = "";
	var sAmountSummation=0 ;
	var sLoanType = "";
	var sInterestRate = "";
	var sDuration = "";
	var sDiffered = "";
	var sLoanRateType="";
	
	while (i <= sLoanNb)
		{
			// Initialisation des variables
			sAmountCtrlName = iEltId + ':txtAmount_' + i;
			sLoanTypeCtrlName = iEltId + ':ddlLoanType_' + i;
			sInterestRateCtrlName = iEltId + ':txtInterestRate_' + i;
			sDurationCtrlName = iEltId + ':txtDuration_' + i;
			sDifferedCtrlName = iEltId + ':txtDiffered_' + i;
			sLoanRateTypeCtrlName=iEltId + ':ddlRateType_' + i;
			
			//type de taux
			sLoanRateType=document.forms[GetIndexForm(formName)].elements[GetIndexElement(sLoanRateTypeCtrlName)].value;
			  // alert(sLoanNbName);
			sAmount = document.forms[GetIndexForm(formName)].elements[GetIndexElement(sAmountCtrlName)].value;
			 // alert(sAmount);

			sInterestRate = document.forms[GetIndexForm(formName)].elements[GetIndexElement(sInterestRateCtrlName)].value;
			 // alert(sInterestRate);

			sDuration = document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDurationCtrlName)].value;
			 // alert(sDuration);

			sDiffered = document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDifferedCtrlName)].value;
			 // alert(sDiffered);

			sLoanType = document.forms[GetIndexForm(formName)].elements[GetIndexElement(sLoanTypeCtrlName)].value;
			 // alert(sLoanType);

			// 1. check amount 
			if (sAmount == "")
				{
					alert('Veuillez indiquer le montant à assurer');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sAmountCtrlName)].focus();
					return false;
				}
			if (isNumeric(sAmount) == false)
				{
					alert('Veuillez indiquer le montant à assurer sans point ni virgule');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sAmountCtrlName)].focus();
					return false;
				}

			if (parseInt(sAmount) == 0)
				{
					alert('Veuillez indiquer le montant à assurer supérieur à zéro');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sAmountCtrlName)].focus();
					return false;
				}

			if (parseInt(sAmount) > 10000000)
				{
					alert('La somme totale empruntée doit être inférieure à 10 000 000 €');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sAmountCtrlName)].focus();
					return false;
				}
				sAmountSummation+=parseInt(sAmount);
				if(i==2)
				{
					if(sAmountSummation> 10000000)
					{
						alert('La somme totale empruntée doit être inférieure à 10 000 000 €');
  						document.forms[GetIndexForm(formName)].elements[GetIndexElement(sAmountCtrlName)].focus();
						return false;
					}
				}
// 2. test type not selected
			if (sLoanType == "--") 
				{
					if(sLoanNb==2)
						alert('Le type du  prêt '+ i +' n\'est pas renseigné.')
					else
						alert('Le type du prêt n\'est pas renseigné.');
  					document.forms[GetIndexForm(formName)].elements[sLoanTypeCtrlName].focus() 
					return false;
				}
				// test type de taux
			if(sLoanRateType=="--")
				{	
					alert('Veuillez indiquer le type de taux.');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sLoanRateTypeCtrlName)].focus();
					return false;				
				}
			// 3. test interest rate
			if (sInterestRate == "")
				{
					alert('Veuillez indiquer le taux hors assurance.');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sInterestRateCtrlName)].focus();
					return false;
				}

			if (isSingle(sInterestRate) == false)
				{
					alert('Veuillez entrer une valeur numérique pour le taux');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sInterestRateCtrlName)].focus();
					return false;
				}
			/*if (sInterestRate == 0)
				{
					alert('Veuillez entrer une valeur supérieure à zéro pour le taux');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sInterestRateCtrlName)].focus();
					return false;
				}*/
			if (parseInt(sInterestRate) >20)
				{
					alert('Le taux du  prêt ne peut pas être supérieur à 20%');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sInterestRateCtrlName)].focus();
					return false;
				}
			//if (sInterestRate > 1525000)
			//	alert('Veuillez saisir un montant inférieur à 1525000 Euros');
			
			// 4. test duration
			if (sDuration == "")
				{
					alert('Veuillez indiquez la durée du prêt.');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDurationCtrlName)].focus();
					return false;
				}

			if (isNumeric(sDuration) == false)
				{
					alert('Veuillez indiquer une valeur numerique pour la durée du prêt');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDurationCtrlName)].focus();
					return false;
				}
			if (parseInt(sDuration) == 0)
				{
					alert('Veuillez indiquez une durée du prêt supérieure à 0 mois.');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDurationCtrlName)].focus();
					return false;
				}
			if (parseInt(sDuration) > 720)
				{
					alert('La durée de votre prêt doit être inférieure à 720 mois (60 ans).');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDurationCtrlName)].focus();
					return false;
				}

			// 5. test differed
			if (sDiffered == "")
				{
					sDiffered = "0";
					document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDifferedCtrlName)].value = "0";
//					alert('le champ différé doit être saisi.');
//  			    document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDifferedCtrlName)].focus();
//					return false;
				}

			if (isNumeric(sDiffered) == false)
				{
					alert('Le champ différé doit être numerique');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDifferedCtrlName)].focus();
					return false;
				}
/*
			if (parseInt(sDiffered) == 0)
				{
					alert('le champ différé doit > 0.');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDifferedCtrlName)].focus();
					return false;
				}
*/
			if (parseInt(sDiffered) > sDuration)
				{
					if(sLoanNb==2)
					{
						if(i==1)
							alert('La durée du différé du premier prêt ne peut pas être supérieure à la durée de ce prêt');
						if (i==2)
							alert('La durée du différé du second prêt ne peut pas être supérieure à la durée de ce prêt');
					}
					else
						alert('La durée du différé ne peut pas être supérieure à la durée du prêt');
  						document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDifferedCtrlName)].focus();
						return false;
				}
			
			// nombre de mois de differe > 0  et type de credit = amortisable  ou in fine ????
			if ((sDiffered > 0) && ((sLoanType == 'AF') || (sLoanType == 'AV') || (sLoanType == 'IV') || (sLoanType == 'IF')) )
				{
					alert('Soit votre prêt comporte une période de différé et vous devez modifiez le type de prêt ; soit il ne comporte pas de différé et vous devez indiquer 0 dans le champ différé.');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDifferedCtrlName)].focus();
					return false;
				}

			// nombre de mois de differe = 0  et type de credit = differe????
			if ((sDiffered == 0) && ((sLoanType == 'DF') || (sLoanType == 'DV') ) )
				{
					alert('Soit votre prêt comporte une période de différé et vous devez modifiez le type de prêt ; soit il ne comporte pas de différé et vous devez indiquer 0 dans le champ différé.');
  			        document.forms[GetIndexForm(formName)].elements[GetIndexElement(sDifferedCtrlName)].focus();
					return false;
				}
				
			if (parseInt(sAmount) <= 15000)
			{
				if(confirm('Etes-vous sûr(e) d\'avoir saisi le bon montant, le montant renseigné nous semble faible pour un prêt immobilier ?') == false)
				{
  					document.forms[GetIndexForm(formName)].elements[GetIndexElement(sAmountCtrlName)].focus();
					return false;
				}
			}

			i = i + 1
		} // fin du while 
		//verification de la date de deblocage
		//date non vide
			var txtLOAN_DATE_1=document.forms[GetIndexForm(formName)].elements[GetIndexElement((iEltId + ':txtLOAN_DATE_1'))];
			if (txtLOAN_DATE_1.value== "")
			{
				alert("Veuillez saisir la date de déblocage du prêt");
				txtLOAN_DATE_1.focus();
				return false;
			}
			
			var deblocageDateMin = new Date();
			deblocageDateMin.setDate(deblocageDateMin.getDate());
			var sdeblocageDateMin = DateToString(deblocageDateMin);
			if ((compare_date_equal(sdeblocageDateMin,txtLOAN_DATE_1.value)==true)) {
				alert("Veuillez saisir une date de déblocage postérieure au  " + sdeblocageDateMin + "");
				txtLOAN_DATE_1.focus();
				return false;
			}
			
		
	return true;	
}


// useful in Moto Form, for car disasters
function VerifyMotoCarSinistre(nbDisaster,formName,iEltId)
{
	var i = 1;
	var nbMois, CarDisasterType, DisasterMois, DisasterAnnee;
	var dateJ=new Date();
	var annee=dateJ.getFullYear();
	var mois=dateJ.getMonth()+1;

	// Sinistres
	var sinistre;
	var nbSinistre;
	var selectNameSinistre;
	var selectNameDateSin;
		
		while (i <= nbDisaster )
		{
			// Initialisation des variables
			selectNameCarDisasterType = iEltId+':CarDisasterType_'+i;
			selectNameDateSin = iEltId+':txtSinDate_'+i;
			if (document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value == ''){
				DisasterMois=0;
				DisasterAnnee=0;
			}
			else {
				if (document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.length != 7){
					DisasterMois=0;
					DisasterAnnee=0;
				}
				else {
					if (document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(0,1) == '0')
						DisasterMois = parseInt(document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(1,1));
					else
						DisasterMois = parseInt(document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(0,2));
					DisasterAnnee = parseInt(document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameDateSin)].value.substr(3,4));
				}
			}
			
			
						
			CarDisasterType = document.forms[GetIndexForm(formName)].elements[GetIndexElement(selectNameCarDisasterType)].value;
			// alert(CarDisasterType);

			
			// test type not selected
			if (CarDisasterType == 0) 
			{
				alert('Le type du '+ i +'e sinistre auto n\'est pas renseigné.')
				document.forms[GetIndexForm(formName)].elements[selectNameCarDisasterType].focus() 

				return false
			}

			// test date not selected
			if ((DisasterMois == 0) || (DisasterAnnee== 0))
			{
				alert('La date du '+ i +'e sinistre auto n\'est pas renseignée.')
				
				if (DisasterMois == 0) { document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus() }
				else {document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus() } 
				
				return false
			}
			nbMois = 12 * (annee - DisasterAnnee) - (DisasterMois - mois)
			//alert(nbMois + ' mois')

			if (nbMois < 0){
				alert('Vérifier la cohérence des dates pour votre ' + i + 'e sinistre auto.')
				document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus()
				return false;
			} 

			if (nbMois > 36){
				msg = "Les sinistres auto déclarés il y a plus de 36 mois ne doivent pas être pris en considération."
				alert(msg)
				document.forms[GetIndexForm(formName)].elements[selectNameDateSin].focus()
				return false;
			} 
			i = i + 1
		} // fin du while 
	return true;	
}

function Deploy_test_NumTel(num)
  {
	var val; 
	val = deleteEspace(num);
	
	if (val == ""){	return false }
	else
	{
		// Valeur numérique ?
		if ( !(isNumeric(val)) )
		{
			return false;
		}

		if ((val.length < 10) || (val.length > 14))
		{
			return false;
		}
	}
	return true;
  }

  function DeployTestEmail(myEmail)
  {
	var tmp_email = trim(myEmail,' ');
	if (TestSpace(tmp_email))
		return 1;
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(tmp_email))
		return 0;
	else
		return 1;
  }
  
  	function Len(Expression) {
		return Expression.toString().length;
	}
	function Left(Str, Length) {
		return Str.substring(0, Length);
	}

	function Right(Str, Length) {
		return Str.substring(Len(Str) - Length, Len(Str));
	}

	function JJMMAAAA(strdate, b_alert){
			var jour, mois, annee;
			var chaine;
			var i, len;
			// teste si la chaine existe
			len	= strdate.length;
			if (len==0) { 
				return ""; 
			}
			//positionnement sur le premier chiffre
			i = 0;
			while (((strdate.charAt(i)<'0')||(strdate.charAt(i)>'9'))&&(++i<len)) {}
			if (i==len) { 
				if ((b_alert) && (strdate != ''))
					alert('Format de date incorrect (format : JJ/MM/AAAA).');
				return ""; 
			}

			// extraction du jour
			chaine = "";
			jour	= 0;
			while ((strdate.charAt(i)>='0')&&(strdate.charAt(i)<='9'))
			{
				chaine += strdate.charAt(i);
				jour = jour*10 + eval(strdate.charAt(i),10);
				i++;
				if (i>=len) break;
			}
							
			if ((jour>31)||(jour==0))
			{
				if ((chaine.length==6)||(chaine.length==8))
				{
					//forme jjmmaa ou jjmmaaaa
					jour  = eval(chaine.charAt(0),10)*10+eval(chaine.charAt(1),10);
					mois  = eval(chaine.charAt(2),10)*10+eval(chaine.charAt(3),10);
					annee = eval(chaine.charAt(4),10)*10+eval(chaine.charAt(5),10);
					if (chaine.length==8)
					{
						annee = annee*100 + eval(chaine.charAt(6),10)*10+eval(chaine.charAt(7),10);
					}
					if ((jour>31)||(jour==0)||(mois>12)||(mois==0)) { 
						if ((b_alert) && (strdate != ''))
							alert('Format de date incorrect (format : JJ/MM/AAAA).');
						return ""; 
					}	
				}
				else { 
					if ((b_alert) && (strdate != ''))
						alert('Format de date incorrect.');
					return ""; 
				}
			}
			else
			{
						
				//positionnement sur le deuxieme chiffre
				while (((strdate.charAt(i)<'1')||(strdate.charAt(i)>'9'))&&(++i<len)) {}
				if (i==len) { 
					if ((b_alert) && (strdate != ''))
						alert('Format de date incorrect (format : JJ/MM/AAAA).');
					return ""; 
				}

				// extraction du mois
				mois = 0;
				while ((strdate.charAt(i)>='0')&&(strdate.charAt(i)<='9'))
				{
					mois = mois*10 + eval(strdate.charAt(i),10);
					i++;
					if (i>=len) break;
				}
				if ((mois>12)||(mois==0)) { 
					if ((b_alert) && (strdate != ''))
						alert('Format de date incorrect (format : JJ/MM/AAAA).');
					return "";  
				}
			
				//positionnement sur le troisieme chiffre
				while (((strdate.charAt(i)<'0')||(strdate.charAt(i)>'9'))&&(++i<len)) {}
				if (i==len) { 
					if ((b_alert) && (strdate != ''))
						alert('Format de date incorrect (format : JJ/MM/AAAA).');
					return ""; 
				}
				
				// extraction de l'année
				annee	= 0;
				while ((strdate.charAt(i)>='0')&&(strdate.charAt(i)<='9'))
				{
					annee = annee*10 + eval(strdate.charAt(i),10);
					i++;
					if (i>=len) break;
				}
			}
			// fenêtrage
			if (annee<15)
			{
				annee += 2000;
			}
			if (annee<100)
			{
				annee += 1900;
			}		
			if ((annee>=100) && (annee.toString().length == 3))
			{
				alert('Format de date incorrect (format : JJ/MM/AAAA).');
				return "";
			}			
			
			var jourbis, moisbis;
			jourbis = "" + eval(jour);
			moisbis = "" + eval(mois);
			
			if ( jourbis.length<2 )
			{
				jourbis = "0" + eval(jour);
			}
			
			if ( moisbis.length<2 )
			{
				moisbis = "0" + eval(mois);
			}
			
			return	"" + jourbis + "/" + moisbis + "/" + annee;
		}	
		
		function MMAAAA(strdate, b_alert){
			var mois, annee;
			var chaine;
			var i, len;
		
			// teste si la chaine existe
			len	= strdate.length;
			if (len==0) { 
				if ((b_alert) && (strdate != ''))
					alert('Format de date incorrect.');
				return ""; 
			}

			//positionnement sur le premier chiffre
			i = 0;
			while (((strdate.charAt(i)<'0')||(strdate.charAt(i)>'9'))&&(++i<len)) {}
			if (i==len) { 
				if ((b_alert) && (strdate != ''))
					alert('Format de date incorrect.');
				return ""; 
			}

			// extraction du mois
			chaine	= "";
			mois	= 0;
			while ((strdate.charAt(i)>='0')&&(strdate.charAt(i)<='9'))
			{
				chaine += strdate.charAt(i);
				mois = mois*10 + eval(strdate.charAt(i),10);
				i++;
				if (i>=len) break;
			}
							
			if ((mois>12)||(mois==0))
			{
				if ((chaine.length==4)||(chaine.length==6))
				{
					//forme mmaa ou mmaaaa
					mois  = eval(chaine.charAt(0),10)*10+eval(chaine.charAt(1),10);
					annee = eval(chaine.charAt(2),10)*10+eval(chaine.charAt(3),10);
					if (chaine.length==6)
					{
						annee = annee*100 + eval(chaine.charAt(4),10)*10+eval(chaine.charAt(5),10);
					}
					if ((mois>12)||(mois==0)) { 
						if ((b_alert) && (strdate != ''))
							alert('Format de date incorrect.');
						return ""; 
					}	
				}
				else { 
					if ((b_alert) && (strdate != ''))
						alert('Format de date incorrect.');
					return ""; 
				}
			}
			else
			{
						
				//positionnement sur le deuxieme chiffre
				while (((strdate.charAt(i)<'0')||(strdate.charAt(i)>'9'))&&(++i<len)) {}
				if (i==len) { 
					if ((b_alert) && (strdate != ''))
						alert('Format de date incorrect.');
					return ""; 
				}
				
				// extraction de l'année
				annee	= 0;
				while ((strdate.charAt(i)>='0')&&(strdate.charAt(i)<='9'))
				{
					annee = annee*10 + eval(strdate.charAt(i),10);
					i++;
					if (i>=len) break;
				}
			}
				
			// fenêtrage
			if ((annee<15) && (annee >= 0))
			{
				annee += 2000;
			}
			if ((annee<100) && (annee >= 15))
			{
				annee += 1900;
			}	
			//(annee>=100) &&		
			if ( (annee.toString().length != 4))
			{
				alert('Format de date incorrect.');
				return "";
			}		
			if (mois.toString().length == 1){
				mois = '0' + mois;
			}
			return	"" + mois + "/" + annee;
		}	
		
		function AAAA(strdate){
			var annee;
			var i, len;
		
			// teste si la chaine existe
			len	= strdate.length;
			if (len==0) { return ""; }

			//positionnement sur le premier chiffre
			i = 0;
			while (((strdate.charAt(i)<'0')||(strdate.charAt(i)>'9'))&&(++i<len)) {}
			if (i==len) { return ""; }

			// extraction de l'année
			annee	= 0;
			while ((strdate.charAt(i)>='0')&&(strdate.charAt(i)<='9'))
			{
				annee = annee*10 + eval(strdate.charAt(i),10);
				i++;
				if (i>=len) break;
			}
										
			// fenêtrage
			if (annee<15)
			{
				annee += 2000;
			}
			if (annee<100)
			{
				annee += 1900;
			}			

			return	"" + annee;
		}	

	function replaceChar(str, out, add) {
		temp = "" + str; // temporary holder

		while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
		}
		return temp;
	}
	
	function verifbonus(strBonus, b_alert){
		var b_virgule = true;
		if (strBonus == '1')
			strBonus = '100';
		if (strBonus == '2')
			strBonus = '200';
		if (strBonus == '3')
			strBonus = '300';
		if ((1 - parseFloat("0,99")) == 1) {
			b_virgule = false;
		} 
		var coefBM=strBonus;
		var coefBMNok=false ;
		var indexSeparator = 0;
		var indexPoint=coefBM.indexOf(".");
		var pointNoK=false ;
		if(indexPoint==-1){
		pointNoK=true ;
		}
		else if(indexPoint==1 && coefBM.length==3){
		coefBM=coefBM+"0" ;
		}
		if(pointNoK){
		var indexVirgule=coefBM.indexOf(",");
		if(indexVirgule==-1){
		coefBMNok=true ;
		}
		else if(indexVirgule==1 && coefBM.length==3){
		coefBM=coefBM+"0" ;
		}
		}
		if(coefBM.length==0 || coefBM.length!=4){
		coefBMNok=true ;
		}
		if(isNaN(coefBM.substring(0,1))|| isNaN(coefBM.substring(2,4))){
		coefBMNok=true ;
		}
		var strRetValue = '';
		if(coefBMNok){
			if ((indexPoint==-1) && (indexVirgule == -1)) {
				if ((isNumeric(coefBM)) && (coefBM.length == 3))
					strRetValue = coefBM.substr(0,1) + '.' + coefBM.substr(1,2);
					if (b_virgule)
						strRetValue = replaceChar(strRetValue,'.',',');
					else
						strRetValue = replaceChar(strRetValue,',','.');
					var strFirstNb='';
					var strSecondNb='';
					strFirstNb = strRetValue.substr(0,1);
					if (strFirstNb == '0'){
						strSecondNb = strRetValue.substr(2,1);
						if (parseInt(strSecondNb) < 5)
							strRetValue = '';
					}
					else {
						strSecondNb = coefBM.substr(2,2);
						if (((parseInt(strSecondNb) > 50) && (parseInt(strFirstNb) >= 3)) || (parseInt(strFirstNb) > 3))
							strRetValue = '';
					}
					if ((b_alert) && (strRetValue == '') && (strBonus != ''))
						alert('Format de Bonus-Malus incorrect, il ne peut être inférieur à 0.50 ou supérieur à 3.50');
					return strRetValue;
			}
		if ((b_alert) && (strRetValue == '') && (strBonus != ''))
			alert('Format de Bonus-Malus incorrect.');
		return strRetValue;
		}
		else{
			if (b_virgule){
				strRetValue = replaceChar(coefBM,'.',',');
				indexSeparator=strRetValue.indexOf(",");
			}
			else {
				strRetValue = replaceChar(coefBM,',','.');
				indexSeparator=strRetValue.indexOf(".");
			}
			var strFirstNb='';
			var strSecondNb='';
			strFirstNb = coefBM.substr(0,indexSeparator);
			if (strFirstNb == '0'){
				strSecondNb = coefBM.substr(2,1);
				if (parseInt(strSecondNb) < 5){
					strRetValue = '';
				}
			}
			else {
				strSecondNb = coefBM.substr(2,2);
				if (((parseInt(strSecondNb) > 50) && (parseInt(strFirstNb) >= 3)) || (parseInt(strFirstNb) > 3))
					strRetValue = '';
			}
			if ((b_alert) && (strRetValue == '') && (strBonus != ''))
				alert('Format de Bonus-Malus incorrect, il ne peut être inférieur à 0.50 ou supérieur à 3.50');
			return strRetValue;
		}
	}
	
	function getLastDay(strMMAAAA){
		var len=0;
		var strMonth;
		var strYear;
		len	= strMMAAAA.length;
			if (len==0) { return ""; }
		strMMAAAA = replaceChar(strMMAAAA,'/','');
		strMonth = strMMAAAA.substr(0,2);
		if (strMonth.substr(0,1) == '0')
			strMonth = strMonth.substr(1,1);
		strYear = strMMAAAA.substr(2,4);
		var oDate = new Date(parseInt(strYear),parseInt(strMonth) - 1,1);
		var iDay;
		with (oDate){
			setMonth(getMonth() + 1);
			setDate(getDate()-1);
			iDay = getDate();
		}
		if (iDay > 0)
			return iDay.toString();
		else
			return "";
	}
	
	
	function IsNull(param1,param2){
		if (param1 != '')
			return param1;
		else
			return param2;
	}
	function IsNullNumeric(param1,param2){
		if (param1 != '')
			return parseFloat(param1);
		else
			return parseFloat(param2);
	}
	
	function IsNullWithFormName(str_formName,param1,param2){
		var strValue = '';
		if (document.forms[GetIndexForm(str_formName)].elements[GetIndexElement(param1)])
			strValue = document.forms[GetIndexForm(str_formName)].elements[GetIndexElement(param1)].value;
		if (strValue != '')
			return strValue;
		else
			return param2;
	}
	function IsNullNumericWithFormName(str_formName,param1,param2){
		var strValue = '';
		if (document.forms[GetIndexForm(str_formName)].elements[GetIndexElement(param1)])
			strValue = document.forms[GetIndexForm(str_formName)].elements[GetIndexElement(param1)].value;
		if (strValue != '')
			return parseFloat(strValue);
		else
			return parseFloat(param2);
	}
	
	function IsExist(str_formName,param1,param2){
		//alert(param1);
		//alert(GetIndexElement(param1));
		//alert(param1);
		if (GetIndexElement(param1) == -1)
			return param2;
		else
			return document.forms[GetIndexForm(str_formName)].elements[GetIndexElement(param1)].value;
	}

	function VehiculeDatesAreOK(str_formName, str_FirstCarDrivingDateTag , str_PurchaseDateTag, str_car_owning_status, b_new_vehicule){
	
		var str_PurchaseDate = ""; 
		var str_FirstCarDrivingDate = ""; 
		var b_FirstCarDrivingDate = true;
		if (GetIndexElement(str_PurchaseDateTag) != -1){
			str_PurchaseDate = document.forms[GetIndexForm(str_formName)].elements[GetIndexElement(str_PurchaseDateTag)].value;
		}
		if (GetIndexElement(str_FirstCarDrivingDateTag) != -1){
			str_FirstCarDrivingDate = document.forms[GetIndexForm(str_formName)].elements[GetIndexElement(str_FirstCarDrivingDateTag)].value;
		}
		else {
			b_FirstCarDrivingDate = false;
		}
		if (((isDate(str_PurchaseDate)==false))) {
			alert("Veuillez saisir la date d'achat de votre véhicule.");
			eval(str_PurchaseDateTag + '_focus();');
			return false;
		}
		if ((((str_car_owning_status==1) && (diff_date(Get_Day(str_PurchaseDate),Get_Month(str_PurchaseDate),Get_Year(str_PurchaseDate))==false)))) {
			alert("Etes-vous certain que la date d\'achat du véhicule est " + Get_TextMonth(Get_Month(str_PurchaseDate).toString()) + " " + Get_Year(str_PurchaseDate).toString() + " ? \nA la première question, vous avez déclaré que votre recherche d\'assurance concerne un véhicule que vous possédez déjà.");
			eval(str_PurchaseDateTag + '_focus();');
			return false;
		}
		if (b_FirstCarDrivingDate) {
			if ((((isDate(str_FirstCarDrivingDate)==false) && (str_car_owning_status==1))) || (((isDate(str_FirstCarDrivingDate)==false) && (str_car_owning_status!=1) && (b_new_vehicule == false)))) {
				alert("Veuillez saisir la date de première mise en circulation de votre véhicule.");
				eval(str_FirstCarDrivingDateTag + '_focus();');
				return false;
			}
		}
		
		if (b_FirstCarDrivingDate) {
			if ((((str_car_owning_status==1) && (compare_date_equal(str_PurchaseDate,str_FirstCarDrivingDate)==false))) || (((str_car_owning_status!=1) && (b_new_vehicule == false) && (compare_date_equal(str_PurchaseDate,str_FirstCarDrivingDate)==false)) )) {
				alert("La date d'achat du véhicule ne peut être antérieure à la date de 1 ère mise en circulation.");
				eval(str_FirstCarDrivingDateTag + '_focus();');
				return false;
			}
		}
		
		if ((((isDate(str_PurchaseDate)==false) && ((str_car_owning_status==4) || (str_car_owning_status==3))))) {
			alert("Veuillez saisir la date d\'achat prévue de votre véhicule.");
			eval(str_PurchaseDateTag + '_focus();');
			return false;
		}
		if ((((str_car_owning_status==3) && (compare_date_equal(str_PurchaseDate,NowDate())==false)))) {
			alert("Etes-vous certain que la date d\'achat prévue du véhicule est le " + str_PurchaseDate.toString() + " ? \nA la première question, vous avez déclaré que votre recherche d\'assurance concerne un véhicule que vous êtes en train d\'acheter.");
			eval(str_PurchaseDateTag + '_focus();');
			return false;
		}
		
		if (b_FirstCarDrivingDate) {
			if ((((str_car_owning_status==1) && (compare_date_equal(str_PurchaseDate,str_FirstCarDrivingDate)==false))) || (((str_car_owning_status!=1) && (b_new_vehicule == false) && (compare_date_equal(str_PurchaseDate,str_FirstCarDrivingDate)==false)) )) {
				alert("La date d'achat du véhicule est-elle bien antérieure à la date de 1 ère mise en circulation ? \nEtes-vous certain d'avoir acheté le véhicule en  " + str_PurchaseDate + " ? \nEtes-vous certain que votre véhicule a été mis en circulation en  " + Get_Month(str_FirstCarDrivingDate) + "/ " + Get_Year(str_FirstCarDrivingDate) + " ?");
				eval(str_FirstCarDrivingDateTag + '_focus();');
				return false;
			}
		}
		
		return true;
	}
	
	function MotoDatesAreOK(str_formName, str_FirstDrivingDateTag){
	

		var str_FirstDrivingDate = ""; 
		str_FirstDrivingDate = document.forms[GetIndexForm(str_formName)].elements[GetIndexElement(str_FirstDrivingDateTag)].value;

		if ((isDate(str_FirstDrivingDate)==false)) {
			alert("Veuillez saisir la date de première mise en circulation de votre moto.");
			eval(str_FirstDrivingDateTag + '_focus();');
			return false;
		}
		else
			if ((compare_date(document.forms[GetIndexForm(str_formName)].elements[GetIndexElement(str_FirstDrivingDateTag)].value,NowDate()))) {
				alert("La date de première mise en circulation ne peut-être supérieure à la date du jour.\nSi vous cherchez une assurance pour une moto neuve que vous ne possédez pas encore, indiquez le mois et l'année en cours.");
				eval(str_FirstDrivingDateTag + '_focus();');
				return false;
			}
		return true;
	}
	


	
	function TestBool(strBool){
		if (strBool.toLowerCase() == 'true')
			return true;
		else
			return false;
	}
	
	function testCarYear(i_annee_debut,i_annee_fin,d_firstCarDrivingDate)
	{
            if(i_annee_debut!=0 && i_annee_fin !=0)
			{	
				if(((i_annee_debut - 2) <= Get_Year(d_firstCarDrivingDate) || (i_annee_debut + 2) >= Get_Year(d_firstCarDrivingDate)) || ((i_annee_fin - 2) <= Get_Year(d_firstCarDrivingDate)  || (i_annee_fin+ 2) >= Get_Year(d_firstCarDrivingDate) ) )
					return true;
				else
					return false;
				
			}
			else if(i_annee_fin !=0 && i_annee_debut==0)
			{
				if ((i_annee_fin + 2) >= Get_Year(d_firstCarDrivingDate))
					return true;

				else
					return false;

			}
			else if(i_annee_fin ==0 && i_annee_debut!=0)
			{
				if ((i_annee_debut- 2) <= Get_Year(d_firstCarDrivingDate) )
					return true;
				else
					return false;
					
			}
			else
				return true;
							
	}
	
	function TestAjaxCar(){
		var strXml = "<TABLE cellspacing=\"0\" cellpadding=\"0\" width=\"600\"><TR><TD colspan=\"6\" align=\"center\">&lt;b&gt;PEUGEOT 807&lt;/b&gt;&lt;BR&gt;&lt;BR&gt;Nous avons trouv?1 v?cules correspondant aux crit?s s?ctionn?&lt;BR&gt;&lt;BR&gt;&lt;b&gt;Si vous d?rez modifier votre recherche &lt;A style=\"COLOR: blue\" HREF=\"#recherche\"&gt;cliquez ici&lt;/A&gt;&lt;/b&gt;.&lt;BR&gt;&lt;BR&gt;</TD></TR><TR><TD Width=\"180\" class=\"colonnegrise\" align=\"center\">&lt;A HREF=\"javascript:GetGTAList('Form1','2006','0');\"&gt;&lt;b&gt;Version&lt;/b&gt;&lt;/A&gt;</TD><TD Width=\"60\" class=\"colonnegrise\" align=\"center\">&lt;A HREF=\"javascript:GetGTAList('Form1','2006','4');\"&gt;&lt;b&gt;Alim.&lt;/b&gt;&lt;/A&gt;</TD><TD Width=\"90\" class=\"colonnegrise\" align=\"center\">&lt;A HREF=\"javascript:GetGTAList('Form1','2006','5');\"&gt;&lt;b&gt;Carrosserie&lt;/b&gt;&lt;/A&gt;</TD><TD Width=\"31\" class=\"colonnegrise\" align=\"center\">&lt;A HREF=\"javascript:GetGTAList('Form1','2006','1');\"&gt;&lt;b&gt;Cv&lt;/b&gt;&lt;/A&gt;</TD><TD Width=\"81\" class=\"colonnegrise\" align=\"center\">&lt;A HREF=\"javascript:GetGTAList('Form1','2006','2');\"&gt;&lt;b&gt;Type Mine&lt;/b&gt;&lt;/A&gt;</TD><TD Width=\"107\" class=\"colonnegrise\" align=\"center\">&lt;A HREF=\"javascript:GetGTAList('Form1','2006','3');\"&gt;&lt;b&gt;Ann?de sortie&lt;/b&gt;&lt;/A&gt;</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33054';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33054';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI 16V CONFORT&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHWB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2005</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33057';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33057';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI 16V CONFORT PACK&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHWB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2005</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33073';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33073';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI CONFORT&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHTB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2006</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33033';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33033';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI NATIVE&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHTB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2004</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33021';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33021';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI NAVTECH ON BOARD&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHTB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2003</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33052';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33052';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI NAVTEQ ON BOARD&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHWB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2005</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33048';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33048';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI NORWEST&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHWB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2005</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33050';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33050';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI SR&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHWB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2005</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33006';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33006';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI SR&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHTB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2002</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33051';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33051';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI ST&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHWB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2005</TD></TR><TR><TD Width=\"180\" align=\"left\">&lt;table width=\"220\"&gt;&lt;tr&gt;&lt;td valign=\"top\" width=\"21\"&gt;&lt;input type=\"radio\" name=\"model\" onclick=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33007';document.forms[GetIndexForm('Form1')].submit();\"&gt;&lt;/td&gt;&lt;td align=\"left\" valign=\"top\" width=\"199\"&gt;&lt;A style=\"COLOR: blue\" href=\"Javascript:document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarPower')].value='7';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postCarMakeName')].value='PEUGEOT';document.forms[GetIndexForm('Form1')].elements[GetIndexElement('ctl100:postGTA')].value='PE33007';document.forms[GetIndexForm('Form1')].submit();\"&gt;2.0 HDI ST&lt;br&gt;&lt;/A&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td heigth=\"1\" colspan=\"2\"&gt;&lt;img src=\"/images/common/line_vehi.gif\" border=\"0\"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</TD><TD Width=\"75\" align=\"center\" class=\"colonnegrise\">Diesel</TD><TD Width=\"75\" align=\"center\">Break</TD><TD Width=\"31\" align=\"center\" class=\"colonnegrise\">7 cv</TD><TD Width=\"81\" align=\"center\">EBRHTB</TD><TD Width=\"107\" align=\"center\" class=\"colonnegrise\">2002</TD></TR><TR><TD colspan=\"6\">&lt;BR&gt;&lt;BR&gt;</TD></TR><TR><TD colspan=\"6\" align=\"center\" class=\"colonnegrise\">&lt;b&gt;MODIFIER VOTRE CHOIX&lt;/b&gt;</TD></TR></TABLE>";
		if(document.all)
			var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		else
		{
			var xmlDoc = document.implementation.createDocument("", "", null);	
		}
		if (xmlDoc.loadXML(strXml))
			return true;
		else
			return false;		
	}

	function ImmatriculationValide(immatriculation)

	{
		var reg = /^[0-9]{2}[ \\-]?[a-zA-Z]{3}[ \\-]?[0-9]{2}$|^[0-9]{2}[ \\-]?[a-zA-Z]{2}[ \\-]?[0-9]{2}$|^[0-9]{3}[ \\-]?[a-zA-Z]{3}[ \\-]?[0-9]{1}[a-zA-Z]{1}$|^[0-9]{3}[ \\-]?[a-zA-Z]{2}[ \\-]?[0-9]{2}$|^[0-9]{4}[ \\-]?[a-zA-Z]{2}[ \\-]?[0-9]{2}$|^[0-9]{4}[ \\-]?[a-zA-Z]{3}[ \\-]?[0-9]{2}$|^[0-9]{4}[ \\-]?[a-zA-Z]{3}[ \\-]?[0-9]{1}[a-zA-Z]{1}$|^[0-9]{4}[ \\-]?[a-zA-Z]{2}[ \\-]?[0-9]{1}[a-zA-Z]{1}$|^[0-9]{3}[ \\-]?[a-zA-Z]{3}[ \\-]?[0-9]{2}$|^[0-9]{8}$|^[a-zA-Z]{2}[ \\-]?[0-9]{3}[ \\-]?[a-zA-Z]{2}$/; 
	
		return (reg.exec(immatriculation)!=null)
		
	}

	//specify page to pop-under
	var popunder="\/Pages\/Sondage\/aidez_nous_a_ameliorer_assurland.htm";
	var popunderrestit="\/Pages\/Sondage\/aidez_nous_a_ameliorer_assurland_restit.htm";

	//specify popunder window features
	//set 1 to enable a particular feature, 0 to disable
	var winfeatures="width=700,height=510,scrollbars=0,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0";

	
	function LoadSurveyMonkey(){
		loadornot(false);
	}
	function LoadSurveyMonkeyRestit(){
		loadornot(true);
	}
	function UnLoadSurveyMonkeyQuest(){
		Unloadpopunder(false);
	}
	function UnLoadSurveyMonkeyRestit(){
		Unloadpopunder(true);
	}
	function get_cookie(Name) {
		var search = Name + "=";
		var returnvalue = "";
		if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search);
			if (offset != -1) { // if cookie exists
				offset += search.length;
				// set index of beginning of value
				end = document.cookie.indexOf(";", offset);
				// set index of end of cookie value
				if (end == -1)
					end = document.cookie.length;
				returnvalue=unescape(document.cookie.substring(offset, end));
			}
		}
		return returnvalue;
	}
	
	function set_cookie(Name,Value) {
		document.cookie = Name + '=' + escape(Value);
	}
	
	function Unloadpopunder(bRestit){
		if (bRestit)
			set_cookie('popunderrestit','no');
		else
			set_cookie('popunder','no');
	}

	function loadornot(bRestit){
		if (bRestit){
			if ((get_cookie('popunderrestit')=='') || (get_cookie('popunderrestit')=='no')){
				set_cookie('popunderrestit','yes');
				loadpopunder(true);
			}
		}
		else {
			if ((get_cookie('popunder')=='') || (get_cookie('popunder')=='no')){
				set_cookie('popunder','yes');
				loadpopunder(false);
			}
			
		}
	}

	function loadpopunder(bRestit){
		if (bRestit){
			win3=window.open(popunderrestit,"",winfeatures);
			win3.blur();
		}
		else {
			win2=window.open(popunder,"",winfeatures);
			win2.blur();
		}
		
		window.focus();
	}
	

	function GetDivState(strDivName){
		if (document.getElementById) { // DOM3 = IE5, NS6 
			return (document.getElementById(strDivName).style.visibility == 'visible') ? 1 : 0;
		} 
		else { 
			if (document.layers) { // Netscape 4 
				return (document.layers[strDivName].visibility == 'show') ? 1 : 0; 
			} 
			else { // IE 4 
				(document.all[strDivName].style.visibility == 'visible') ? 1 : 0;
			} 
		} 		
	}
	
	function ShowAgencyPanelIfNeeded(){
		if (GetDivState('divAgence') == 0){
			Showhidediv('divAgence',1);
		}
	}
	
	function Showhidediv(strDivName,iState) { // 1 visible, 0 hidden

		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById(strDivName).style.visibility =  iState ? 'visible' : 'hidden';
		} 
		else { 
			if (document.layers) { // Netscape 4 
				document.layers[strDivName].visibility = iState ? 'show' : 'hide'; 
			} 
			else { // IE 4 
				document.all[strDivName].style.visibility = iState ? 'visible' : 'hidden';
			} 
		} 
	} 
	
	function Showhidediv2(strDivName,iState) { // 1 visible, 0 hidden

		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById(strDivName).style.display =  iState ? 'block' : 'none';
		} 
		else { 
			if (document.layers) { // Netscape 4 
				document.layers[strDivName].display = iState ? 'block' : 'none'; 
			} 
			else { // IE 4 
				document.all[strDivName].style.display = iState ? 'block' : 'none';
			} 
		} 
	} 

function checkPhoneNumber(phoneNo)
{ 
	/*if (phoneNo.substring(0,1) == '0'){
		var phoneRE = /0[1-568]\d{8}/; 
		if (phoneNo.match(phoneRE)) 
			return false; 
		else
			return true;  
	}
	else
		return true;*/
	// Update 02/2009
	var phoneRE = /0[1-9]\d{8}/;
	if (phoneRE.test(phoneNo))
		return false; /* Opposit value to use in deploy ? */
	else
		return true;
}

function checkPhoneNumber_SwissLife(num)
{
	num = deleteEspace(num);

	if(checkPhoneNumber(num))
	{
		return true; /* Opposit value to use in deploy ? */
	}

	// SwissLife requirement (02/2009)
	//tout numéro ce qui ne comporte pas 10 caractères et ne commence pas par un 0
	// => checkPhoneNumber(...)

	var i = 0;
	var count = 1;
	var c = "";
	var c2 = "";

	//tout numéro comportant une suite de 5 chiffres identiques
	for(i=0; i<num.length; i++)
	{
		if(num.charAt(i) == c)
			count += 1;
		else
			count = 1;
		c = num.charAt(i);
		if(count >= 5)
		{
			return true; /* Opposit value to use in deploy ? */
		}
	}

	//tout numéro comportant une suite de 2 chiffres identiques au moins 3 fois (01 01 01)
	count = 1;
	c = "";
	for(i=0; i<num.length; i+=2)
	{
		c2 = num.charAt(i) + num.charAt(i+1)
		if(c2 == c)
			count += 1;
		else
			count = 1;
		c = c2;
		if(count >= 3)
		{
			return true; /* Opposit value to use in deploy ? */
		}
	}

	return false;
}
	
	function emptyCityList(formName,ddlInseeCode){
		var form = eval(document.forms[GetIndexForm(formName)]);
		form.elements[GetIndexElement(ddlInseeCode)].options.length= 0;
	}

function VerifCycloPlate(strPlate)
{
	var regexp = /^(([a-z]|[A-Z])([a-z]|[A-Z])?\d\d\d?([a-z]|[A-Z]))$/;	
	if (strPlate.match(regexp))
		return true;
	else 
		return false;
}
function ShowHideBlock(id,show)
{
	if(show=='1')
		document.getElementById(id).style.display='block';
	else
		document.getElementById(id).style.display='none';
}

function TableRowDisplayManager(display, rows)
	{
		// Show / Hide rows
		var elt;
		for(var i = 0; i < rows.length; i++)
		{
			elt = document.getElementById(rows[i]);	
			if(elt != null)
			{
				if(display == true)
				{
					if (typeof window.opera!="undefined")
					{
						elt.style.display = 'table-row';
					}
					else if (navigator.appName == 'Microsoft Internet Explorer')
					{
						elt.style.display = 'block';
					}
					else
					{
						elt.style.display = 'table-row';	
					}
				}
				else
				{
					elt.style.display = 'none';
				}
			}
		}
	}
	
	function doNothing(){
	
	}
	function GetZipCodeHelp(ev, divName, divID){
		hideOtherZipCodeHelp(divID);
		getMouseXY(ev);
		setDivPosition(divName,mouseX - 200,mouseY - 200);
		IfExistShowhidediv(divName,1);
	}
	function hideOtherZipCodeHelp(sdivID){
		var iDivID;
		var i;
		iDivID = parseInt(replaceChar(sdivID,'ctl',''));
		for(i=1;i<100;i++){
			IfExistShowhidediv('ctl' + (iDivID + i).toString() + ':DivZCodeHelp',0);
			IfExistShowhidediv('ctl' + (iDivID - i).toString() + ':DivZCodeHelp',0);
		}
	}
	function FillInseeCode(sForm,lbInseeSearch,tbZipCode,ddlInseeCode,TAGZIPCODE, TAGINSEE){
		var lbInseeSearchObj;
		var tb;
		lbInseeSearchObj = document.forms[GetIndexForm(sForm)].elements[GetIndexElement(lbInseeSearch)];
		
		if (lbInseeSearchObj.selectedIndex >= 0){
			if (lbInseeSearchObj.options[lbInseeSearchObj.selectedIndex].value != '0'){
				tb = document.forms[GetIndexForm(sForm)].elements[GetIndexElement(tbZipCode)];
				tb.value = lbInseeSearchObj.options[lbInseeSearchObj.selectedIndex].value.split('|')[1];
				document.forms[GetIndexForm(sForm)].elements[GetIndexElement(TAGZIPCODE)].value = tb.value;
				GetCityWithDefaultValue(sForm,tbZipCode,ddlInseeCode,document.forms[GetIndexForm(sForm)].elements[GetIndexElement(ddlInseeCode)].value, document.forms[GetIndexForm(sForm)].elements[GetIndexElement(ddlInseeCode)],lbInseeSearchObj.options[lbInseeSearchObj.selectedIndex].value.split('|')[0]);
				document.forms[GetIndexForm(sForm)].elements[GetIndexElement(TAGINSEE)].value = lbInseeSearchObj.options[lbInseeSearchObj.selectedIndex].value.split('|')[0];
			}
		}
	}
	function getMouseXY(e)
	{ 
		if (!e) e = window.event; 

		if (e)
		{ 
			if (e.pageX || e.pageY)
			{
			mouseX = e.pageX;
			mouseY = e.pageY;
			algor = '[e.pageX]';
			if (e.clientX || e.clientY) algor += ' [e.clientX] '
			}
			else if (e.clientX || e.clientY)
			{
				mouseX = e.clientX + document.body.scrollLeft;
				mouseY = e.clientY + document.body.scrollTop;
				algor = '[e.clientX]';
				if (e.pageX || e.pageY) algor += ' [e.pageX] '
			} 
		}
	}
	