diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 556f86517913755c9f5da40ba74d523af4cd612b..0ce30b18155ae37400ec1c1538f428fc3832be28 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -325,10 +325,22 @@ class Form
 			{
 				$obj = $this->db->fetch_object($resql);
 				$pays_id = $obj->rowid?$obj->rowid:'';
+				
+				// On applique un delai d'execution pour le bon fonctionnement
+				$mode = substr($htmloption,-9,6);
+				if ($mode == 'create')
+				{
+					$htmloption = 'onChange="ac_delay(\'autofilltownfromzip_save_refresh_create()\',\'500\')"';
+				}
+				else
+				{
+					$htmloption = 'onChange="ac_delay(\'autofilltownfromzip_save_refresh_edit()\',\'500\')"';
+				}
+				
 				print '<div>';
-				print '<input type="text" size="45" id="pays" name="pays" value="'.$obj->libelle.'" />';
+				print '<input type="text" size="45" id="pays" name="pays" value="'.$obj->libelle.'" '.$htmloption.' />';
 				print '<span id="indicator1" style="display: none">'.img_gif('Working...','ajaxworking').'</span>';
-				print '<input type="hidden" name="pays_id" id="pays_id" value="'.$pays_id.'" '.$htmloption.' />';
+				print '<input type="hidden" name="pays_id" id="pays_id" value="'.$pays_id.'" />';
 				print '</div>';
 				print '<div id="hint" class="autocomplete"></div>';
 				print '<script type="text/javascript">';
diff --git a/htdocs/lib/lib_head.js b/htdocs/lib/lib_head.js
index 004061dd4b90b029400f5c89d1c26a3419762961..c9296e110df3608f51f8b40130738db112e415f7 100644
--- a/htdocs/lib/lib_head.js
+++ b/htdocs/lib/lib_head.js
@@ -609,4 +609,15 @@ function ac_return(field, item){
         id = idCache[0].replace('-idcache', '');
         // et on l'affecte au champ cach�
         $(field.name+'_id').value = id;
+}
+
+/*=================================================================
+	Purpose:  Applique un d�lai avant execution
+	Input:    funct, delay
+	Author:   Regis Houssin
+	Licence:  GPL
+==================================================================*/
+ function ac_delay(funct,delay) {
+ 	// d�lai exprim� en millisecondes avant le d�clenchement de l'action
+  setTimeout(funct,delay);
 }
\ No newline at end of file