Index: /extensions/AMenuManager/amm_pip.class.inc.php
===================================================================
--- /extensions/AMenuManager/amm_pip.class.inc.php	(revision 4362)
+++ /extensions/AMenuManager/amm_pip.class.inc.php	(revision 4363)
@@ -49,4 +49,5 @@
     add_event_handler('blockmanager_apply', array(&$this, 'blockmanager_apply') );
     add_event_handler('loc_end_page_header', array(&$this->css, 'apply_CSS'));
+    add_event_handler('loc_end_page_tail', array(&$this, 'applyJS'));
   }
 
@@ -230,4 +231,31 @@
   }
 
+
+  public function applyJS()
+  {
+    global $user, $template;
+
+    $menu = new BlockManager("menubar");
+    $menu->load_registered_blocks();
+    $menu->prepare_display();
+
+    if ( ( ($block = $menu->get_block( 'mbAMM_randompict' ) ) != null ) && ($user['nb_total_images'] > 0) )
+    {
+      $local_tpl = new Template(AMM_PATH."admin/", "");
+      $local_tpl->set_filename('body_page', dirname($this->filelocation).'/menu_templates/menubar_randompic.js.tpl');
+
+      $data = array(
+        "delay" => $this->my_config['amm_randompicture_periodicchange'],
+        "blockHeight" => $this->my_config['amm_randompicture_height'],
+        "firstPicture" => $this->ajax_amm_get_random_picture()
+      );
+
+      $local_tpl->assign('data', $data);
+
+      $template->append('footer_elements', $local_tpl->parse('body_page', true));
+    }
+
+  }
+
 } // AMM_PIP class
 
Index: /extensions/AMenuManager/main.inc.php
===================================================================
--- /extensions/AMenuManager/main.inc.php	(revision 4362)
+++ /extensions/AMenuManager/main.inc.php	(revision 4363)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: Advanced Menu Manager
-Version: 2.1.2
+Version: 2.1.3
 Description: Gestion avancée du menu / Advanced management of menu
 Plugin URI: http://piwigo.org
@@ -44,6 +44,7 @@
 |         |            |    - es_ES
 |         |            |    - hu_HU (thx to sámli)
-|         |            |
-|         |            |
+| 2.1.3   | 2009/11/24 | * move the js for "random image" in the the footer
+|         |            |   (having the js inside the <dl> tag was not w3c
+|         |            |   compliant)
 |         |            |
 
@@ -70,5 +71,5 @@
 define('AMM_PATH' , PHPWG_PLUGINS_PATH . AMM_DIR . '/');
 
-define('AMM_VERSION' , '2.1.2'); // => ne pas oublier la version dans l'entête !!
+define('AMM_VERSION' , '2.1.3'); // => ne pas oublier la version dans l'entête !!
 
 global $prefixeTable, $page;
Index: /extensions/AMenuManager/menu_templates/menubar_randompic.js.tpl
===================================================================
--- /extensions/AMenuManager/menu_templates/menubar_randompic.js.tpl	(revision 4363)
+++ /extensions/AMenuManager/menu_templates/menubar_randompic.js.tpl	(revision 4363)
@@ -0,0 +1,73 @@
+{literal}
+<script type="text/javascript">
+var fixedHeight = {/literal}{$data.blockHeight}{literal};
+var vIntervalID;
+
+  $(document).ready(
+    function ()
+    {
+      {/literal}
+      {if $data.blockHeight>0}
+        $("#irandompicinner").height(fixedHeight);
+        {literal}$("#iammrpic").load( function () { computePositionTop(); } );{/literal}
+      {else}
+        {literal}
+        $("#iammrpic").load( function () { $("#irandompicinner").animate({height: ($("#iamm_ill0").innerHeight())+"px"}, "normal"); } );
+        {/literal}
+      {/if}
+      {if $data.delay > 0 }
+        vIntervalID = window.setInterval(getRandomPicture, {$data.delay});
+      {/if}
+      {literal}
+    }
+  );
+
+  function computePositionTop()
+  {
+    $("#iamm_ill0").css({top:(fixedHeight-$("#iamm_ill0").innerHeight())/2});
+  }
+
+  function getRandomPicture()
+  {
+    $.get("./index.php", {ajaxfct:"randompic"},
+      function (data)
+      {
+        $("#iamm_ill0").fadeTo('slow', 0, function ()
+        {
+          $("#iamm_ill0").html(data);
+
+          {/literal}
+          {if $data.blockHeight>0}
+            {literal}
+            $("#iammrpic").load( function () {
+              computePositionTop();
+              $("#iamm_ill0").fadeTo('slow', 1);
+            } );
+            {/literal}
+          {else}
+            {literal}
+            $("#iammrpic").load( function () {
+              $("#irandompicinner").animate({height: ($("#iamm_ill0").innerHeight())+"px"}, "normal", function ()
+              {
+                $("#iamm_ill0").fadeTo('slow', 1, function ()
+                {
+                  $("#irandompicinner").animate({height: this.clientHeight+"px"}, "normal");
+                });
+              });
+            } );
+            {/literal}
+          {/if}
+          {literal}
+
+        } );
+      }
+    );
+  }
+
+  {/literal}
+
+  {literal}
+
+
+</script>
+{/literal}
Index: /extensions/AMenuManager/menu_templates/menubar_randompic.tpl
===================================================================
--- /extensions/AMenuManager/menu_templates/menubar_randompic.tpl	(revision 4362)
+++ /extensions/AMenuManager/menu_templates/menubar_randompic.tpl	(revision 4363)
@@ -4,67 +4,4 @@
 <dt>{$block->get_title()}</dt>
 
-{literal}
-<script type="text/javascript">
-var fixedHeight = {/literal}{$block->data.blockHeight}{literal};
-
-  function init()
-  {
-    {/literal}
-    {if $block->data.blockHeight>0}
-      $("#irandompicinner").height(fixedHeight);
-      {literal}$("#iammrpic").load( function () { computePositionTop(); } );{/literal}
-    {else}
-      {literal}
-      $("#iammrpic").load( function () { $("#irandompicinner").animate({height: ($("#iamm_ill0").innerHeight())+"px"}, "normal"); } );
-      {/literal}
-    {/if}
-    {literal}
-  }
-
-  function computePositionTop()
-  {
-    $("#iamm_ill0").css({top:(fixedHeight-$("#iamm_ill0").innerHeight())/2});
-  }
-
-  function getRandomPicture()
-  {
-    $.get("./index.php", {ajaxfct:"randompic"},
-      function (data)
-      {
-        $("#iamm_ill0").fadeTo('slow', 0, function ()
-        {
-          $("#iamm_ill0").html(data);
-
-          {/literal}
-          {if $block->data.blockHeight>0}
-            {literal}
-            $("#iammrpic").load( function () {
-              computePositionTop();
-              $("#iamm_ill0").fadeTo('slow', 1);
-            } );
-            {/literal}
-          {else}
-            {literal}
-            $("#iammrpic").load( function () {
-              $("#irandompicinner").animate({height: ($("#iamm_ill0").innerHeight())+"px"}, "normal", function ()
-              {
-                $("#iamm_ill0").fadeTo('slow', 1, function ()
-                {
-                  $("#irandompicinner").animate({height: this.clientHeight+"px"}, "normal");
-                });
-              });
-            } );
-            {/literal}
-          {/if}
-          {literal}
-
-        } );
-      }
-    );
-  }
-
-
-</script>
-{/literal}
 
 <dd id="irandompicdd" class="randompicdd">
@@ -76,8 +13,2 @@
 </dd>
 
-<script type="text/javascript">
-  init();
-  {if $block->data.delay > 0 }
-    var vIntervalID = window.setInterval(getRandomPicture, {$block->data.delay});
-  {/if}
-</script>
