Index: extensions/GMaps/admin/gmaps_amd_warning.tpl
===================================================================
--- extensions/GMaps/admin/gmaps_amd_warning.tpl	(revision 7125)
+++ extensions/GMaps/admin/gmaps_amd_warning.tpl	(revision 7125)
@@ -0,0 +1,3 @@
+<div class='warning'>
+{$gmaps_amd_warning}
+</div>
Index: extensions/GMaps/admin/gmaps_category_maps.tpl
===================================================================
--- extensions/GMaps/admin/gmaps_category_maps.tpl	(revision 7125)
+++ extensions/GMaps/admin/gmaps_category_maps.tpl	(revision 7125)
@@ -0,0 +1,456 @@
+{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"}
+{known_script id="jquery.ui.sortable" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.sortable.packed.js"}
+{known_script id="jquery.ui.dialog" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.dialog.packed.js"}
+{known_script id="maps.google.com/api" src="http://maps.google.com/maps/api/js?sensor=false"}
+
+
+{literal}
+
+<script type="text/javascript">
+
+
+  function assocManager ()
+  {
+    var properties = {
+      id:'',
+    }
+
+
+    /**
+     * initialize the page
+     */
+    this.init = function ()
+    {
+
+      $('#iDialogEdit')
+        .dialog(
+          {
+            autoOpen:false,
+            width:800,
+            height:450,
+            modal: true,
+            dialogClass: 'gcBgTabSheet gcBorder',
+            title: '{/literal}{"gmaps_manage_assoc"|@translate}{literal}',
+            buttons:
+              {
+                '{/literal}{"gmaps_ok"|@translate}{literal}':
+                  function()
+                  {
+                    if(checkValidity()) doUpdate();
+                  },
+                '{/literal}{"gmaps_cancel"|@translate}{literal}':
+                  function()
+                  {
+                    $('#iDialogEdit').dialog("close");
+                  }
+              }
+          }
+        );
+
+      $('#iBDAssocMapId').bind('change', changeMapDisplayType);
+
+      loadList();
+
+    }
+
+    /**
+     * called when the map is changed
+     * refresh the icon list
+     */
+    var changeMapDisplayType = function ()
+    {
+      switch($('#iBDAssocMapId option:selected').attr('dtype'))
+      {
+        case 'IC':
+        case 'IP':
+          $('#iBDAssocIconRow').show();
+          break;
+        case 'MP':
+          $('#iBDAssocIconRow').hide();
+          break;
+      }
+    }
+
+
+    /**
+     * manage the tabsheet
+     *
+     * @param String tabsheet : id of the tabsheet to display
+     */
+    this.displayTab = function (tabsheet)
+    {
+      switch(tabsheet)
+      {
+        case 'integration':
+          $('#iTabIntegration').css('display', 'block');
+          $('#iTabAssoc').css('display', 'none');
+          break;
+        case 'assoc':
+          $('#iTabIntegration').css('display', 'none');
+          $('#iTabAssoc').css('display', 'block');
+          break;
+      }
+    }
+
+
+    /**
+     * open the dialog box to edit the association properties
+     *
+     * @param String id : if set to '' => open dialogbox in 'add' mode
+     *                    otherwise edit the given association
+     */
+    this.editAssoc = function (id)
+    {
+      properties.id=id;
+      updateDialog('');
+      this.displayTab('assoc');
+      // >> because li items don't have id... :-(
+      $('#itab2 li').removeClass('selected_tab').addClass('normal_tab');
+      $('#itab2 li:first').addClass('selected_tab');
+      // <<
+
+      $('#iDialogEdit')
+        .bind('dialogopen', function ()
+          {
+            if(properties.id!='')
+            {
+              displayProcessing(true);
+
+              $.ajax(
+                {
+                  type: "POST",
+                  url: "{/literal}{$datas.urlRequest}{literal}",
+                  async: true,
+                  data: { ajaxfct:"admin.assoc.getAssoc", id:properties.id },
+                  success:
+                    function(msg)
+                    {
+                      updateDialog(msg);
+                      displayProcessing(false);
+                    }
+                }
+              );
+            }
+          }
+        )
+        .dialog("open");
+    }
+
+    /**
+     * delete an association
+     *
+     * @param String id : id of the association to delete
+     */
+    this.deleteAssoc = function (id)
+    {
+      $('#iDialogDelete')
+        .html('<br>{/literal}{"gmaps_pleaseConfirmAssoc"|@translate}{literal}')
+        .dialog(
+          {
+            autoOpen:true,
+            modal: true,
+            dialogClass: 'gcBgTabSheet gcBorder',
+            title: '{/literal}{"gmaps_deleteAssoc"|@translate}{literal}',
+            buttons:
+              {
+                '{/literal}{"gmaps_delete"|@translate}{literal}':
+                  function()
+                  {
+                    $(this).html("<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>");
+                    $.ajax(
+                      {
+                        type: "POST",
+                        url: "{/literal}{$datas.urlRequest}{literal}",
+                        async: true,
+                        data: { ajaxfct:"admin.assoc.deleteAssoc", id:id },
+                        success:
+                          function(msg)
+                          {
+                            $('#iDialogDelete').dialog("destroy");
+                            loadList();
+                          }
+                      }
+                    );
+                  },
+                '{/literal}{"gmaps_cancel"|@translate}{literal}':
+                  function()
+                  {
+                    $('#iDialogDelete').dialog("destroy");
+                  }
+              }
+          }
+        );
+    }
+
+    /**
+     * update values of the dialog box
+     *
+     * @param String items : json string ; if empty assume to reset all fields
+     *                       with blank
+     */
+    var updateDialog = function (items)
+    {
+      if(items=='')
+      {
+        $('#iBDAssocCatId').val(0);
+        $('#iBDAssocMapId').val($('#iBDAssocMapId option:first').val());
+        $('#iBDAssocApplySubCat').val('y');
+        $('#iBDAssocKmlFileUrl').val('');
+        $('#iBDAssocIcon').val($('#iBDAssocIcon option:visible:first').val());
+        $('#iBDAssocTitle').val('');
+      }
+      else
+      {
+        tmp=$.parseJSON(items);
+
+        $('#iBDAssocCatId').val(tmp.categoryId);
+        $('#iBDAssocMapId').val(tmp.mapId);
+        $('#iBDAssocApplySubCat').val(tmp.applySubCat);
+        $('#iBDAssocKmlFileUrl').val(tmp.kmlFileUrl);
+        $('#iBDAssocIcon').val(tmp.icon);
+        $('#iBDAssocTitle').val(tmp.title);
+      }
+
+      changeMapDisplayType();
+    }
+
+    /**
+     * reload the assocation list
+     */
+    var loadList = function ()
+    {
+      $('#iListAssoc').html("<br>{/literal}{'gmaps_loading'|@translate}{literal}<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>");
+
+      $.ajax(
+        {
+          type: "POST",
+          url: "{/literal}{$datas.urlRequest}{literal}",
+          async: true,
+          data: { ajaxfct:"admin.assoc.getList" },
+          success:
+            function(msg)
+            {
+              $("#iListAssoc").html(msg);
+            }
+        }
+      );
+    }
+
+
+    /**
+     * check for the validity of the map settings
+     */
+    var checkValidity = function ()
+    {
+      $('.error').removeClass('error');
+      ok=true;
+/*
+      if(checkIdValidity($('#iBDMapId').val())==false)
+      {
+        $('#iBDMapId').addClass('error');
+        alert('{/literal}{"gmaps_invalidId"|@translate}{literal}');
+        ok=false;
+      }
+*/
+      return(ok);
+    }
+
+    /**
+     * send assoc update to the server, and close the dialog box if everything
+     * is ok
+     */
+    var doUpdate = function ()
+    {
+      displayProcessing(true);
+
+      // build datas
+      datas = {
+        categoryId:$('#iBDAssocCatId').val(),
+        mapId:$('#iBDAssocMapId').val(),
+        applySubCat:$('#iBDAssocApplySubCat').val(),
+        kmlFileUrl:$('#iBDAssocKmlFileUrl').val(),
+        icon:$('#iBDAssocIcon').val(),
+        title:$('#iBDAssocTitle').val(),
+      }
+
+      $.ajax(
+        {
+          type: "POST",
+          url: "{/literal}{$datas.urlRequest}{literal}",
+          async: true,
+          data: { ajaxfct:"admin.assoc.setAssoc", id:properties.id, datas:datas },
+          success:
+            function(msg)
+            {
+              displayProcessing(false);
+
+              if(msg.match(/^[0-9]+$/i)!=null)
+              {
+                // result Ok ! => close the dialog box and reload the list
+                $('#iDialogEdit').dialog("close");
+                loadList();
+              }
+              else
+              {
+                returned=msg.split('!');
+                if(returned[0]!='') $('#'+returned[0]).addClass('error');
+                alert(returned[1]);
+              }
+            }
+        }
+      );
+    }
+
+    /**
+     * display or hide the processing flower
+     */
+    var displayProcessing = function (visible)
+    {
+      if(visible)
+      {
+        $('#iBDProcessing').css("display", "block");
+      }
+      else
+      {
+        $('#iBDProcessing').css("display", "none");
+      }
+    }
+
+    this.init();
+  }
+
+
+</script>
+
+{/literal}
+
+
+
+<h2>{'gmaps_associate_category_maps'|@translate}</h2>
+
+
+<div class='addMap'>
+  <a onclick="am.editAssoc('');">{'gmaps_add_a_new_association'|@translate}</a>
+</div>
+
+
+<table id='iHeaderListMaps' class="littlefont">
+  <tr>
+    <th>{'gmaps_category'|@translate}</th>
+    <th style="width:90px;">{'gmaps_apply_subcat'|@translate}</th>
+    <th style="width:90px;">{'gmaps_mapType'|@translate}</th>
+    <th style="width:356px;">{'gmaps_map'|@translate}</th>
+    <th style="width:90px;">{'gmaps_map_kmlfile'|@translate}</th>
+    <th width="40px">&nbsp;</th>
+  </tr>
+</table>
+
+
+
+<div id='iListAssoc' class="{$themeconf.name}">
+</div>
+<div id="iListAssocNb"></div>
+
+<div id="iDialogDelete">
+</div>
+
+<div id="iDialogEdit">
+  <div id='iBDProcessing' style="display:none;position:absolute;width:100%;height:100%;background:#000000;opacity:0.75">
+      <img src="plugins/GrumPluginClasses/icons/processing.gif" style="margin-top:100px;">
+  </div>
+
+  {$mapTabsheet}
+  <form>
+
+    <div id='iTabsContainer' style='height:100px;'>
+
+
+      <div id='iTabAssoc' style='display:none;'>
+        <table class="formtable">
+          <tr>
+            <td>{'gmaps_map'|@translate}</td>
+            <td>
+              <select id='iBDAssocMapId'>
+                  {foreach from=$datas.maps key=group item=mapGroup}
+                    <optgroup label="{'gmaps_displayTypeShort'|cat:$group|@translate}">
+                    {foreach from=$mapGroup item=map}
+                      <option value='{$map.id}' dtype='{$group}'>{$map.name}</option>
+                    {/foreach}
+                    </optgroup>
+                  {/foreach}
+              </select>
+            </td>
+          </tr>
+
+          <tr>
+            <td>{'gmaps_category'|@translate}</td>
+            <td>
+              <select id='iBDAssocCatId'>
+                  {foreach from=$datas.cats item=cat}
+                    <option value='{$cat.id}'>{$cat.name}</option>
+                  {/foreach}
+              </select>
+            </td>
+          </tr>
+
+          <tr>
+            <td>{'gmaps_apply_subcat'|@translate}</td>
+            <td>
+              <select id='iBDAssocApplySubCat'>
+                <option value='y'>{'gmaps_y'|@translate}</option>
+                <option value='n'>{'gmaps_n'|@translate}</option>
+              </select>
+            </td>
+          </tr>
+
+        </table>
+      </div>
+
+
+      <div id='iTabIntegration' style='display:none;'>
+        <table class='formtable'>
+
+          <tr id='iBDAssocTitleRow'>
+            <td>{'gmaps_map_title'|@translate}</td>
+            <td>
+              <input type="text" id='iBDAssocTitle' value='{$datas.title}' maxlength='200' size='55'>
+            </td>
+          </tr>
+
+          <tr id='iBDAssocIconRow'>
+            <td>{'gmaps_map_icon'|@translate}</td>
+            <td>
+              <select id='iBDAssocIcon'>
+                  {foreach from=$datas.icons item=icon}
+                    <option class='{$icon.type}' value='{$icon.file}'>{$icon.file}</option>
+                  {/foreach}
+              </select>
+            </td>
+          </tr>
+
+          <tr>
+            <td>{'gmaps_map_associate_kmlfile'|@translate}</td>
+            <td>
+              <input type="text" id="iBDAssocKmlFileUrl" maxlength='255' size='55' value="">
+            </td>
+          </tr>
+
+
+        </table>
+      </div>
+
+    </div>
+
+  </form>
+</div>
+
+
+
+
+
+{literal}
+<script type="text/javascript">
+  var am=new assocManager();
+</script>
+{/literal}
+
Index: extensions/GMaps/admin/gmaps_category_maps_iListMaps.tpl
===================================================================
--- extensions/GMaps/admin/gmaps_category_maps_iListMaps.tpl	(revision 7125)
+++ extensions/GMaps/admin/gmaps_category_maps_iListMaps.tpl	(revision 7125)
@@ -0,0 +1,24 @@
+<table class="littlefont">
+  {foreach from=$datas item=data}
+  <tr>
+    <td>{$data.catName}</td>
+    <td style="width:90px;">{$data.applySubCat}</td>
+    <th style="width:150px;">{$data.displayType}</th>
+    <td style="width:300px;">{$data.mapName}</td>
+    <td style="width:90px;">{$data.mapKmlFile}</td>
+
+    <td width="40px">
+      <img src="{$themeconf.admin_icon_dir}/edit_s.png"
+           class="button" alt="{'gmaps_edit'|@translate}"
+           title="{'gmaps_edit'|@translate}"
+           onclick='am.editAssoc({$data.id});'/>
+      <img src="{$themeconf.admin_icon_dir}/delete.png"
+           class="button"
+           alt="{'gmaps_delete'|@translate}"
+           title="{'gmaps_delete'|@translate}"
+           onclick='am.deleteAssoc({$data.id});'/>
+    </td>
+  </tr>
+  {/foreach}
+</table>
+
Index: extensions/GMaps/admin/gmaps_maps.tpl
===================================================================
--- extensions/GMaps/admin/gmaps_maps.tpl	(revision 7054)
+++ extensions/GMaps/admin/gmaps_maps.tpl	(revision 7125)
@@ -1,4 +1,3 @@
 {known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"}
-{known_script id="jquery.ui.sortable" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.sortable.packed.js"}
 {known_script id="jquery.ui.dialog" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.dialog.packed.js"}
 {known_script id="jquery.ui.slider" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.slider.packed.js"}
@@ -57,17 +56,40 @@
         );
 
-      $('#iBDMapId').bind('keyup focusout', function (event)
-        {
-          if(!checkIdValidity($(this).val()))
-          {
-            $(this).addClass('error');
-          }
-          else
-          {
-            $(this).removeClass('error');
+      $('#iBDDisplayTypeIC, #iBDDisplayTypeIP, #iBDDisplayTypeMP').bind('change',
+        function ()
+        {
+          switch($(this).val())
+          {
+            case 'IC':
+              $('#iBDZoomLevelRow').hide();
+              $('[name=fBDSizeMode]').attr('disabled', false);
+              break;
+            case 'IP':
+              $('#iBDZoomLevelRow').show();
+              $('[name=fBDSizeMode]').attr('disabled', false);
+              break;
+            case 'MP':
+              $('#iBDZoomLevelRow').show();
+              $('#iBDSizeModeF').attr('checked', true).change();
+              $('[name=fBDSizeMode]').attr('disabled', true);
+              break;
           }
         }
       );
 
+      $('#iBDSizeModeA, #iBDSizeModeF').bind('change',
+        function ()
+        {
+          switch($(this).val())
+          {
+            case 'A':
+              $('#iBDMapWidthSliderRow, #iBDMapHeightSliderRow').hide();
+              break;
+            case 'F':
+              $('#iBDMapWidthSliderRow, #iBDMapHeightSliderRow').show();
+              break;
+          }
+        }
+      );
 
       $("#iBDMapWidthSlider").slider(
@@ -326,5 +348,5 @@
      * @param String tabsheet : id of the tabsheet to display
      */
-    this.displayProp = function (tabsheet)
+    this.displayTab = function (tabsheet)
     {
       switch(tabsheet)
@@ -368,5 +390,9 @@
       properties.id=id;
       updateDialog('');
-      this.displayProp('general');
+      this.displayTab('general');
+      // >> because li items don't have id... :-(
+      $('#itab2 li').removeClass('selected_tab').addClass('normal_tab');
+      $('#itab2 li:first').addClass('selected_tab');
+      // <<
 
       $('#iDialogEdit')
@@ -458,6 +484,11 @@
       if(items=='')
       {
-        $('#iBDMapId').val('');
+        tmp={
+          sizeMode:'A',
+          displayTYpe:'IC'
+        }
         $('#iBDName').val('');
+        $('#iBDDisplayTypeIC').attr('checked', true);
+        $('#iBDSizeModeA').attr('checked', true);
         $('#iBDMapWidthSliderValue').val('470');
         $('#iBDMapHeightSliderValue').val('210');
@@ -486,6 +517,7 @@
 
         $('#iBDNumId').val(tmp.id);
-        $('#iBDMapId').val(tmp.mapId);
         $('#iBDName').val(tmp.name);
+        $('#iBDDisplayType'+tmp.displayType).attr('checked', true);
+        $('#iBDSizeMode'+tmp.sizeMode).attr('checked', true);
         $('#iBDMapWidthSliderValue').val(tmp.width);
         $('#iBDMapHeightSliderValue').val(tmp.height);
@@ -507,4 +539,5 @@
       }
 
+      $('#iBDDisplayType'+tmp.displayType+', #iBDSizeMode'+tmp.sizeMode).change();
       changeSize($('#iBDMapWidthSliderValue').val(), 'iBDMapWidthSlider');
       changeSize($('#iBDMapHeightSliderValue').val(), 'iBDMapHeightSlider');
@@ -558,11 +591,4 @@
       ok=true;
 
-      if(checkIdValidity($('#iBDMapId').val())==false)
-      {
-        $('#iBDMapId').addClass('error');
-        alert('{/literal}{"gmaps_invalidId"|@translate}{literal}');
-        ok=false;
-      }
-
       return(ok);
     }
@@ -578,6 +604,7 @@
       // build datas
       datas = {
-        mapId:$('#iBDMapId').val(),
         name:$('#iBDName').val(),
+        displayType:$('[name=fBDDisplayType]:checked').val(),
+        sizeMode:$('[name=fBDSizeMode]:checked').val(),
         width:$('#iBDMapWidthSliderValue').val(),
         height:$('#iBDMapHeightSliderValue').val(),
@@ -652,6 +679,6 @@
 <table id='iHeaderListMaps' class="littlefont">
   <tr>
-    <th style="width:150px;">{'gmaps_id'|@translate}</th>
     <th>{'gmaps_name'|@translate}</th>
+    <th style="width:150px;">{'gmaps_displayType'|@translate}</th>
     <th style="width:90px;">{'gmaps_dimensions'|@translate}</th>
     <th style="width:90px;">{'gmaps_zoomLevel'|@translate}</th>
@@ -685,23 +712,36 @@
         <table class='formtable'>
           <tr>
-            <td>{'gmaps_id'|@translate}</td>
-            <td>
-              <input type='text' id='iBDMapId' maxlength=12 size=12 value=''>
+            <td>{'gmaps_name'|@translate}</td>
+            <td>
+              <input type='text' id='iBDName' maxlength=80 size=60 value=''>
             </td>
           </tr>
 
           <tr>
-            <td>{'gmaps_name'|@translate}</td>
-            <td>
-              <input type='text' id='iBDName' maxlength=80 size=60 value=''>
-            </td>
-          </tr>
+            <td>{'gmaps_displayType'|@translate}</td>
+            <td>
+              <label><input type='radio' id='iBDDisplayTypeIC' name='fBDDisplayType' value='IC'>&nbsp;{'gmaps_displayTypeIC'|@translate}</label><br>
+              <label><input type='radio' id='iBDDisplayTypeIP' name='fBDDisplayType' value='IP'>&nbsp;{'gmaps_displayTypeIP'|@translate}</label><br>
+              <label><input type='radio' id='iBDDisplayTypeMP' name='fBDDisplayType' value='MP'>&nbsp;{'gmaps_displayTypeMP'|@translate}</label>
+            </td>
+          </tr>
+
         </table>
       </div>
 
       <div id='iTabDimensions' style='display:none;'>
+
         <table class="formtable">
           <tr>
-            <td>{'gmaps_width'|@translate}</td>
+            <td>{'gmaps_map_dimensions_are'|@translate}</td>
+            <td colspan="3">
+              <label><input type="radio" id="iBDSizeModeA" name="fBDSizeMode" value="A">&nbsp;{'gmaps_interface_dimensions_a'|@translate}</label><br>
+              <label><input type="radio" id="iBDSizeModeF" name="fBDSizeMode" value="F">&nbsp;{'gmaps_interface_dimensions_f'|@translate}</label>
+            </td>
+          </tr>
+
+          <tr id='iBDMapWidthSliderRow'>
+            <td>&nbsp;</td>
+            <td style='padding-left:30px;'>{'gmaps_width'|@translate}</td>
             <td>
               <input type="hidden" id="iBDMapWidthSliderValue" value="">
@@ -712,6 +752,7 @@
             </td>
           </tr>
-          <tr>
-            <td>{'gmaps_height'|@translate}</td>
+          <tr id='iBDMapHeightSliderRow'>
+            <td>&nbsp;</td>
+            <td style='padding-left:30px;'>{'gmaps_height'|@translate}</td>
             <td>
               <input type="hidden" id="iBDMapHeightSliderValue" value="">
@@ -775,5 +816,5 @@
       <div id='iTabZoomLevel' style='display:none;'>
         <table class='formtable'>
-          <tr>
+          <tr id='iBDZoomLevelRow'>
             <td>{'gmaps_zoomLevel'|@translate}</td>
             <td>
Index: extensions/GMaps/admin/gmaps_maps_iListMaps.tpl
===================================================================
--- extensions/GMaps/admin/gmaps_maps_iListMaps.tpl	(revision 7054)
+++ extensions/GMaps/admin/gmaps_maps_iListMaps.tpl	(revision 7125)
@@ -2,6 +2,6 @@
   {foreach from=$datas item=data}
   <tr>
-    <td style="width:150px;">{$data.mapId}</td>
     <td>{$data.name}</td>
+    <th style="width:150px;">{$data.displayType}</th>
     <th style="width:90px;">{$data.dimensions}</th>
     <th style="width:90px;">{$data.zoomLevel}</th>
Index: extensions/GMaps/gmaps.css
===================================================================
--- extensions/GMaps/gmaps.css	(revision 7054)
+++ extensions/GMaps/gmaps.css	(revision 7125)
@@ -1,8 +1,8 @@
 #iHeaderListMaps { width:100%; border:1px solid; border-collapse: collapse; margin-top:3px; }
-#iListMaps { width:100%; border:1px solid; height:280px; border-top:0px; overflow:auto; position:relative; left:-1px;}
-#iListMapsNb { width:99%; text-align:right; margin-bottom:8px; padding:2px; font-size:80%; }
-#iListMaps table, table.listMaps { width:100%; text-align:left; border-collapse: collapse; }
-#iListMaps.roma table tr:hover { cursor:pointer; background:#303030; }
-#iListMaps.clear table tr:hover { cursor:pointer; color: #D54E21; background:#dbe8f3; }
+#iListMaps, #iListAssoc { width:100%; border:1px solid; height:280px; border-top:0px; overflow:auto; position:relative; left:-1px;}
+#iListMapsNb, #iListAssocNb { width:99%; text-align:right; margin-bottom:8px; padding:2px; font-size:80%; }
+#iListMaps table, table.listMaps, #iListAssoc table { width:100%; text-align:left; border-collapse: collapse; }
+#iListMaps.roma table tr:hover, #iListAssoc.roma table tr:hover  { cursor:pointer; background:#303030; }
+#iListMaps.clear table tr:hover, #iListAssoc.clear table tr:hover { cursor:pointer; color: #D54E21; background:#dbe8f3; }
 div.addMap { text-align:left; }
 
@@ -41,4 +41,13 @@
 
 #itab2 {
-  margin:20px -6px 0 -10px;
+  border-top:1px solid;
+  margin:25px -6px 0 -10px;
+  padding-top:3px;
 }
+
+#iBDAssocCatId, #iBDAssocMapId {
+  font-family:monospace;
+  font-size:125%;
+}
+
+
Index: extensions/GMaps/gmaps2.css
===================================================================
--- extensions/GMaps/gmaps2.css	(revision 7125)
+++ extensions/GMaps/gmaps2.css	(revision 7125)
@@ -0,0 +1,120 @@
+
+div.gmapsPopup div.ui-dialog-titlebar {
+  display:block;
+  font-size:80%;
+  font-weight:bold;
+  margin:1px;
+  height:16px;
+  font-size:12px;
+  font-family:sans-serif;
+}
+
+div.gmapsPopup span.ui-icon-closethick {
+  display:block;
+
+}
+
+div.gmapsPopup {
+  color:#000000;
+  background:#ffffff;
+  border:8px solid #ffffff;
+  -moz-border-radius:8px;
+  -webkit-border-radius:8px;
+  -khtml-border-radius:8px;
+  border-radius:8px;
+}
+
+div.gmapsPopup div.ui-dialog-titlebar a {
+  -moz-border-radius:2px;
+  -webkit-border-radius:2px;
+  -khtml-border-radius:2px;
+  border-radius:2px;
+  border:1px solid #CCCCCC;
+  color:#000000;
+  display:inline-block;
+  width:11px;
+  height:11px;
+  padding:1px;
+  position:relative;
+  text-align:center;
+  top:-1px;
+  float:right;
+  font-size:9px;
+}
+div.gmapsPopup div.ui-dialog-titlebar a:hover {
+  background:#808080;
+  border:1px solid #ffffff;
+  color:#ffffff;
+}
+
+.ui-widget-overlay {
+  background:none repeat scroll 0 0 #000000;
+  left:0;
+  opacity:0.75;
+  position:absolute;
+  top:0;
+}
+
+#gmapsBoundMap, #gmapsCenterMap, #gmapsBoundKml {
+  margin-right:4px;
+}
+
+#ciGMIWC_title {
+  font-size:150%;
+}
+#ciGMIWC_thumb {
+  height:150px;
+  min-width:250px;
+  text-align:center;
+  width:100%;
+}
+#ciGMIWC_thumb tr {
+  vertical-align:middle;
+}
+#ciGMIWC_picnum {
+  font-style:italic;
+  position:relative;
+  text-align:right;
+  top:10px;
+}
+#ciGMIWC_img {
+  cursor:pointer;
+}
+
+#ciWALeft {
+  cursor:pointer;
+  width:28px;
+  height:56px;
+  background:transparent url(./img/waLeftI.png) no-repeat 0 0;
+  display:inline-block;
+}
+#ciWALeft:hover {
+  background:transparent url(./img/waLeftA.png) no-repeat 0 0;
+}
+
+#ciWARight {
+  cursor:pointer;
+  width:28px;
+  height:56px;
+  background:transparent url(./img/waRightI.png) no-repeat 0 0;
+  display:inline-block;
+}
+#ciWARight:hover {
+  background:transparent url(./img/waRightA.png) no-repeat 0 0;
+}
+
+#ciGMIWC_showcat {
+  background:#ffffff;
+  height:150px;
+  top:-160px;
+  position:relative;
+}
+
+#ciGMIWC_showcatList ul li a {
+  color:#0088EE;
+}
+#ciGMIWC_showcatList ul li a:hover {
+  color:#FF7700;
+}
+
+
Index: extensions/GMaps/gmaps_aip.class.inc.php
===================================================================
--- extensions/GMaps/gmaps_aip.class.inc.php	(revision 7054)
+++ extensions/GMaps/gmaps_aip.class.inc.php	(revision 7125)
@@ -22,4 +22,5 @@
 {
   protected $tabsheet;
+  protected $amdState;
 
   public function __construct($prefixeTable, $filelocation)
@@ -28,7 +29,19 @@
     $this->loadConfig();
     $this->configForTemplate();
+
+    $this->amdState=GMaps_root::checkAMDActivated();
+
+    $this->initRequest();
     $this->initEvents();
 
     $this->tabsheet = new tabsheet();
+
+
+    if($this->amdState!='advanced')
+    {
+      $this->tabsheet->add('amd_warning',
+                            l10n('gmaps_warning'),
+                            $this->getAdminLink()."&amp;fGMaps_tabsheet=amd_warning");
+    }
     $this->tabsheet->add('maps',
                           l10n('gmaps_maps'),
@@ -37,7 +50,15 @@
                           l10n('gmaps_associate_category_maps'),
                           $this->getAdminLink()."&amp;fGMaps_tabsheet=category_maps");
+/*
+    $this->tabsheet->add('kml_files',
+                          l10n('gmaps_kml_files_management'),
+                          $this->getAdminLink()."&amp;fGMaps_tabsheet=kml_files");
+    $this->tabsheet->add('search',
+                          l10n('gmaps_search'),
+                          $this->getAdminLink()."&amp;fGMaps_tabsheet=search");
     $this->tabsheet->add('help',
                           l10n('gmaps_help'),
                           $this->getAdminLink()."&amp;fGMaps_tabsheet=help");
+*/
   }
 
@@ -72,4 +93,7 @@
     switch($_REQUEST['fGMaps_tabsheet'])
     {
+      case 'amd_warning':
+        $this->displayAmdWarning();
+        break;
       case 'maps':
         $this->displayMaps();
@@ -77,4 +101,10 @@
       case 'category_maps':
         $this->displayCategoryMaps();
+        break;
+      case 'kml_files':
+        $this->displayKmlFiles();
+        break;
+      case 'search':
+        $this->displaySearch();
         break;
       case 'help':
@@ -116,5 +146,12 @@
 
     if(!($_REQUEST['fGMaps_tabsheet']!="maps" or
-         $_REQUEST['fGMaps_tabsheet']!="category_maps")) $_REQUEST['fGMaps_tabsheet']="maps";
+         $_REQUEST['fGMaps_tabsheet']!="category_maps" or
+         $_REQUEST['fGMaps_tabsheet']!="amd_warning"
+         //$_REQUEST['fGMaps_tabsheet']!="kml_files" or
+         //$_REQUEST['fGMaps_tabsheet']!="search" or
+         //$_REQUEST['fGMaps_tabsheet']!="help"
+         )) $_REQUEST['fGMaps_tabsheet']="maps";
+
+    if($_REQUEST['fGMaps_tabsheet']=="amd_warning" and $this->amdState=='advanced') $_REQUEST['fGMaps_tabsheet']="maps";
   }
 
@@ -137,14 +174,14 @@
     $mapTabsheet->add('general',
                           l10n('gmaps_properties_general'),
-                          '', true, "udm.displayProp('general');");
+                          '', true, "udm.displayTab('general');");
     $mapTabsheet->add('dimensions',
                           l10n('gmaps_dimensions'),
-                          '', false, "udm.displayProp('dimensions');");
+                          '', false, "udm.displayTab('dimensions');");
     $mapTabsheet->add('mapType',
                           l10n('gmaps_properties_mapType'),
-                          '', false, "udm.displayProp('mapType');");
+                          '', false, "udm.displayTab('mapType');");
     $mapTabsheet->add('zoomLevel',
                           l10n('gmaps_properties_zoomLevel'),
-                          '', false, "udm.displayProp('zoomLevel');");
+                          '', false, "udm.displayTab('zoomLevel');");
     $mapTabsheet->assign();
 
@@ -167,4 +204,37 @@
     global $template;
 
+    $template->set_filename('body_page',
+                dirname($this->getFileLocation()).'/admin/gmaps_category_maps.tpl');
+
+    $mapTabsheet = new GPCTabSheet('mapTabsheet', $this->tabsheet->get_titlename(), 'tabsheet2 gcBorder', 'itab2');
+    $mapTabsheet->add('assoc',
+                          l10n('gmaps_map_assoc'),
+                          '', false, "am.displayTab('assoc');");
+    $mapTabsheet->add('integration',
+                          l10n('gmaps_map_integration'),
+                          '', true, "am.displayTab('integration');");
+    $mapTabsheet->assign();
+
+
+    $datas=Array(
+      'urlRequest' => $this->getAdminLink('ajax'),
+      'cats' => $this->makeCategoriesTree(),
+      'maps' => $this->makeMapsList(),
+      'icons' => $this->makeIconsList(),
+    );
+    $template->assign('datas', $datas);
+
+    $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page');
+  }
+
+
+  /**
+   * display the kml file management page
+   *
+   */
+  protected function displayKmlFiles()
+  {
+    global $template;
+
     /*$template->set_filename('body_page',
                 dirname($this->getFileLocation()).'/admin/plugin_admin_maps.tpl');
@@ -174,9 +244,11 @@
   }
 
-  /**
-   * display the help page
-   *
-   */
-  protected function displayHelp()
+
+
+  /**
+   * display the search page
+   *
+   */
+  protected function displaySearch()
   {
     global $template;
@@ -189,4 +261,135 @@
   }
 
+
+  /**
+   * display the help page
+   *
+   */
+  protected function displayHelp()
+  {
+    global $template;
+
+    /*$template->set_filename('body_page',
+                dirname($this->getFileLocation()).'/admin/plugin_admin_maps.tpl');
+
+
+    $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page');*/
+  }
+
+
+
+  /**
+   * display a warning page if AMD is not installed
+   *
+   */
+  protected function displayAmdWarning()
+  {
+    global $template;
+
+    $template->set_filename('body_page',
+                dirname($this->getFileLocation()).'/admin/gmaps_amd_warning.tpl');
+
+    switch(GMaps_root::checkAMDActivated())
+    {
+      case 'none':
+      case 'inactive':
+        $template->assign('gmaps_amd_warning_inactive', sprintf(l10n('gmaps_amd_warning_inactive'), GMAPS_AMD_NEEDED));
+        break;
+      case 'basic':
+        $template->assign('gmaps_amd_warning_basic', l10n('gmaps_amd_warning_basic'));
+        break;
+    }
+    $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page');
+  }
+
+
+  /**
+   * build the categories tree
+   * @return Array : an array, ready to use in the template
+   */
+  private function makeCategoriesTree()
+  {
+    $returned=array(
+      array(
+        'id' => 0,
+        'name' => '-- '.l10n('gmaps_applyForAllTheGallery').' --'
+      )
+    );
+
+    $sql="SELECT id, name, global_rank
+          FROM ".CATEGORIES_TABLE."
+          ORDER BY global_rank";
+    $result = pwg_query($sql);
+    if($result)
+    {
+      while ($row = pwg_db_fetch_assoc($result))
+      {
+        $returned[]=array(
+          'id' => $row['id'],
+          'name' => str_repeat('&nbsp;&nbsp;', substr_count($row['global_rank'], '.')).$row['name']
+        );
+      }
+    }
+
+    return($returned);
+  } //makeCategoriesTree
+
+
+  /**
+   * build a maps list
+   * @return Array : an array, ready to use in the template
+   */
+  private function makeMapsList()
+  {
+    $returned=array(
+      'IC' => array(),
+      'IP' => array(),
+      'MP' => array()
+    );
+
+    $sql="SELECT id, name, displayType
+          FROM ".$this->tables['maps']."
+          ORDER BY displayType, name";
+    $result = pwg_query($sql);
+    if($result)
+    {
+      while($row = pwg_db_fetch_assoc($result))
+      {
+        $returned[$row['displayType']][]=array(
+          'id' => $row['id'],
+          'name' => $row['name']
+        );
+      }
+    }
+
+    return($returned);
+  } //makeCategoriesTree
+
+
+  /**
+   * build THE ICON LIST
+   * @return Array : an array, ready to use in the template
+   */
+  private function makeIconsList()
+  {
+    $returned=array();
+
+    $directory=scandir(GMAPS_PATH.'img/');
+    foreach($directory as $file)
+    {
+      $ext=(pathinfo($file, PATHINFO_EXTENSION));
+      if(preg_match('/^i.*(?:jpg|jpeg|png|gif)$/i', $file))
+      {
+        $returned[]=array(
+          'type' => (strtolower(substr($file,0,1))=='i')?'img':'other',
+          'file' => $file
+        );
+      }
+    }
+
+    return($returned);
+  } //makeCategoriesTree
+
+
 } //class
 
Index: extensions/GMaps/gmaps_ajax.php
===================================================================
--- extensions/GMaps/gmaps_ajax.php	(revision 7054)
+++ extensions/GMaps/gmaps_ajax.php	(revision 7125)
@@ -65,5 +65,13 @@
            $_REQUEST['ajaxfct']=='admin.maps.setMap' or
            $_REQUEST['ajaxfct']=='admin.maps.getMap' or
-           $_REQUEST['ajaxfct']=='admin.maps.deleteMap'
+           $_REQUEST['ajaxfct']=='admin.maps.deleteMap' or
+           $_REQUEST['ajaxfct']=='admin.assoc.getList' or
+           $_REQUEST['ajaxfct']=='admin.assoc.setAssoc' or
+           $_REQUEST['ajaxfct']=='admin.assoc.getAssoc' or
+           $_REQUEST['ajaxfct']=='admin.assoc.deleteAssoc' or
+
+           $_REQUEST['ajaxfct']=='public.maps.init' or
+           $_REQUEST['ajaxfct']=='public.maps.getMarkers' or
+           $_REQUEST['ajaxfct']=='public.maps.getMarkerInfos'
            )) $_REQUEST['ajaxfct']='';
 
@@ -74,14 +82,13 @@
       {
         /*
-         * check admin.maps.getList values
-         */
-        if($_REQUEST['ajaxfct']=="admin.maps.getList")
-        {
-        }
+         * no check for admin.maps.getList & admin.assoc.getList requests
+         */
+
 
         /*
-         * check admin.maps.getMap values
-         */
-        if($_REQUEST['ajaxfct']=="admin.maps.getMap")
+         * check admin.maps.getMap & admin.assoc.getAssoc values
+         */
+        if($_REQUEST['ajaxfct']=="admin.maps.getMap" or
+           $_REQUEST['ajaxfct']=="admin.assoc.getAssoc")
         {
           if(!isset($_REQUEST['id']) or
@@ -93,5 +100,6 @@
          * check admin.maps.deleteMap values
          */
-        if($_REQUEST['ajaxfct']=="admin.maps.deleteMap")
+        if($_REQUEST['ajaxfct']=="admin.maps.deleteMap" or
+           $_REQUEST['ajaxfct']=="admin.maps.deleteAssoc")
         {
           if(!isset($_REQUEST['id']) or
@@ -101,5 +109,5 @@
 
         /*
-         * check admin.maps.gsetMap values
+         * check admin.maps.setMap values
          */
         if($_REQUEST['ajaxfct']=="admin.maps.setMap")
@@ -112,5 +120,6 @@
           else
           {
-            if(!(isset($_REQUEST['datas']['mapId']) &&
+            if(!(isset($_REQUEST['datas']['displayType']) &&
+                 isset($_REQUEST['datas']['sizeMode']) &&
                  isset($_REQUEST['datas']['name']) &&
                  isset($_REQUEST['datas']['width']) &&
@@ -127,4 +136,11 @@
             else
             {
+              if(!($_REQUEST['datas']['displayType']=='IC' or
+                  $_REQUEST['datas']['displayType']=='IP' or
+                  $_REQUEST['datas']['displayType']=='MP')) $_REQUEST['ajaxfct']='';
+
+              if(!($_REQUEST['datas']['sizeMode']=='A' or
+                  $_REQUEST['datas']['sizeMode']=='F')) $_REQUEST['ajaxfct']='';
+
               if(!is_numeric($_REQUEST['datas']['width']) or
                   $_REQUEST['datas']['width']<100 or
@@ -158,4 +174,77 @@
         }
 
+
+        /*
+         * check admin.maps.setAssoc values
+         */
+        if($_REQUEST['ajaxfct']=="admin.assoc.setAssoc")
+        {
+          if(!isset($_REQUEST['id']) or
+             !isset($_REQUEST['datas']) or !is_array($_REQUEST['datas']))
+          {
+            $_REQUEST['ajaxfct']='';
+          }
+          else
+          {
+            if(!(isset($_REQUEST['datas']['categoryId']) &&
+                 isset($_REQUEST['datas']['mapId']) &&
+                 isset($_REQUEST['datas']['applySubCat']) &&
+                 isset($_REQUEST['datas']['kmlFileUrl']) &&
+                 isset($_REQUEST['datas']['icon']) &&
+                 isset($_REQUEST['datas']['title']) ))
+            {
+              $_REQUEST['ajaxfct']='';
+            }
+            else
+            {
+              if($_REQUEST['datas']['categoryId']=='' or
+                 $_REQUEST['datas']['categoryId']<0) $_REQUEST['ajaxfct']='';
+
+              if($_REQUEST['datas']['mapId']=='') $_REQUEST['ajaxfct']='';
+
+              if(!($_REQUEST['datas']['applySubCat']=='y' or
+                   $_REQUEST['datas']['applySubCat']=='n')) $_REQUEST['datas']['applySubCat']='y';
+            }
+          }
+        }
+
+
+        /*
+         * check public.maps.getMarkers values
+         */
+        if($_REQUEST['ajaxfct']=="public.maps.getMarkers")
+        {
+          if(!isset($_REQUEST['datas']) or
+             !is_array($_REQUEST['datas']))
+          {
+            $_REQUEST['ajaxfct']='';
+          }
+          else
+          {
+            if(!(isset($_REQUEST['datas']['requestId']) &&
+                 isset($_REQUEST['datas']['bounds']) &&
+                 isset($_REQUEST['datas']['width']) &&
+                 isset($_REQUEST['datas']['height']) &&
+                 isset($_REQUEST['datas']['distanceTreshold']) &&
+                 isset($_REQUEST['datas']['bounds']['north']) &&
+                 isset($_REQUEST['datas']['bounds']['south']) &&
+                 isset($_REQUEST['datas']['bounds']['east']) &&
+                 isset($_REQUEST['datas']['bounds']['west']) ))
+            {
+              $_REQUEST['ajaxfct']='';
+            }
+          }
+        }
+
+        /*
+         * check public.maps.getMarkerInfos values
+         */
+        if($_REQUEST['ajaxfct']=="public.maps.init")
+        {
+          if(!isset($_REQUEST['category']))
+          {
+            $_REQUEST['ajaxfct']='';
+          }
+        }
 
       }
@@ -183,4 +272,23 @@
           $result=$this->ajax_gmaps_admin_mapsDeleteMap($_REQUEST['id']);
           break;
+        case 'admin.assoc.getList':
+          $result=$this->ajax_gmaps_admin_assocGetList();
+          break;
+        case 'admin.assoc.getAssoc':
+          $result=$this->ajax_gmaps_admin_assocGetAssoc($_REQUEST['id']);
+          break;
+        case 'admin.assoc.setAssoc':
+          $result=$this->ajax_gmaps_admin_assocSetAssoc($_REQUEST['id'], $_REQUEST['datas']);
+          break;
+        case 'admin.assoc.deleteAssoc':
+          $result=$this->ajax_gmaps_admin_assocDeleteAssoc($_REQUEST['id']);
+          break;
+
+        case 'public.maps.init':
+          $result=$this->ajax_gmaps_public_mapsInit($_REQUEST['category']);
+          break;
+        case 'public.maps.getMarkers':
+          $result=$this->ajax_gmaps_public_mapsGetMarkers($_REQUEST['datas']);
+          break;
       }
       GPCAjax::returnResult($result);
@@ -208,7 +316,7 @@
       $datas=Array();
 
-      $sql="SELECT id, mapId, name, width, height, zoomLevel, mapType, mapTypeControl, navigationControl, scaleControl
+      $sql="SELECT id, name, displayType, sizeMode, width, height, zoomLevel, mapType, mapTypeControl, navigationControl, scaleControl
             FROM ".$this->tables['maps']."
-            ORDER BY id";
+            ORDER BY displayType ASC, name ASC";
       $result=pwg_query($sql);
       if($result)
@@ -216,5 +324,19 @@
         while($row=pwg_db_fetch_assoc($result))
         {
-          $row['dimensions']=$row['width'].'x'.$row['height'];
+          if($row['displayType']=='IC')
+          {
+            $row['zoomLevel']=l10n('gmaps_auto');
+          }
+
+          $row['displayType']=l10n('gmaps_displayTypeShort'.$row['displayType']);
+
+          if($row['sizeMode']=='A')
+          {
+            $row['dimensions']=l10n('gmaps_auto');
+          }
+          else
+          {
+            $row['dimensions']=$row['width'].'x'.$row['height'];
+          }
 
           $row['mapType']=l10n('gmaps_googleMapType_'.$row['mapType']);
@@ -244,24 +366,10 @@
       global $template;
 
-      // if create a new map, check if map id is unique
-      $sql="SELECT id, mapId FROM ".$this->tables['maps']."
-            WHERE mapId='".$properties['mapId']."';";
-      $result=pwg_query($sql);
-      if($result)
-      {
-        while($row=pwg_db_fetch_assoc($result))
-        {
-          if($row['id']!=$id)
-          {
-            return('iBDMapId!'.l10n('gmaps_mapIdAlreadyExist'));
-          }
-        }
-      }
-
       if($id=='')
       {
         $sql="INSERT INTO ".$this->tables['maps']."
-              VALUES ('', '".mysql_escape_string($properties['mapId'])."', '".
-                mysql_escape_string($properties['name'])."', '".
+              VALUES ('', '".mysql_escape_string($properties['name'])."', '".
+                $properties['displayType']."', '".
+                $properties['sizeMode']."', '".
                 $properties['width']."', '".
                 $properties['height']."', '".
@@ -278,5 +386,7 @@
       {
         $sql="UPDATE ".$this->tables['maps']."
-              SET name='".mysql_escape_string($properties['name'])."', mapId='".
+              SET name='".mysql_escape_string($properties['name'])."', displayType='".
+                $properties['displayType']."', sizeMode='".
+                $properties['sizeMode']."', width='".
                 $properties['mapId']."', width='".
                 $properties['width']."', height='".
@@ -307,5 +417,6 @@
         'id' => '',
         'name' => '',
-        'mapId' => '',
+        'displayType' => '',
+        'sizeMode' => '',
         'width' => 470,
         'height' => 210,
@@ -317,5 +428,5 @@
       );
 
-      $sql="SELECT id, mapId, name, width, height, zoomLevel, mapType, mapTypeControl, navigationControl, scaleControl
+      $sql="SELECT id, displayType, sizeMode, name, width, height, zoomLevel, mapType, mapTypeControl, navigationControl, scaleControl
             FROM ".$this->tables['maps']."
             WHERE id='$id';";
@@ -330,5 +441,5 @@
 
       return(json_encode($returned));
-    }
+    } //ajax_gmaps_admin_mapsGetMap
 
 
@@ -354,6 +465,504 @@
 
       return('ko!unknown error');
+    } //ajax_gmaps_admin_mapsDeleteMap
+
+
+
+
+
+    /**
+     * return a HTML list of defined associations
+     *
+     * @return String
+     */
+    private function ajax_gmaps_admin_assocGetList()
+    {
+      global $template;
+
+      $template->set_filename('list_page',
+                    dirname($this->getFileLocation()).'/admin/gmaps_category_maps_iListMaps.tpl');
+
+      $datas=Array();
+
+      $sql="SELECT pgcm.id, pgcm.categoryId, pct.name AS catName,
+                   pgmm.name AS mapName, pgmm.displayType,
+                   pgcm.kmlFileUrl, pgcm.imgSort, pgcm.applySubCat, pgcm.icon,
+                   pgcm.title
+            FROM (".$this->tables['category_maps']." pgcm
+                  LEFT JOIN ".CATEGORIES_TABLE." pct ON pct.id=pgcm.categoryId)
+                  LEFT JOIN ".$this->tables['maps']." pgmm ON pgcm.mapId = pgmm.id
+            ORDER BY pct.name, pgmm.displayType, pgcm.imgSort";
+      $result=pwg_query($sql);
+      if($result)
+      {
+        $keys=array(
+          'prev' => '',
+          'curr' => ''
+        );
+        while($row=pwg_db_fetch_assoc($result))
+        {
+          $keys['prev']=$keys['curr'];
+
+          $tmp=array(
+            'id' => $row['id'],
+            'catName' => ($row['categoryId']==0)?l10n('gmaps_applyForAllTheGallery'):$row['catName'],
+            'applySubCat' => l10n('gmaps_'.$row['applySubCat']),
+            'mapName' => $row['mapName'],
+            'mapKmlFile' => l10n('gmaps_'.(($row['kmlFileUrl']=='')?'n':'y')),
+            'icon' => $row['icon'],
+            'displayType' => l10n('gmaps_displayTypeShort'.$row['displayType']),
+            'title' => $row['title']
+          );
+
+          $keys['curr']=$row['categoryId'].$row['displayType'];
+
+          if($keys['curr']==$keys['prev'])
+          {
+            $tmp['catName']='';
+            $tmp['displayType']='';
+            $tmp['applySubCat']='';
+          }
+
+          $datas[]=$tmp;
+        }
+      }
+
+      $template->assign('datas', $datas);
+      return($template->parse('list_page', true));
+    } //ajax_gmaps_admin_assocGetList
+
+
+
+
+    /**
+     * set properties for a given association id ; if no association id is given
+     * create a new association
+     *
+     * @param String id : the association Id
+     * @param Array datas : properties of the association (assuming array index
+     *                      were checked by the checkRequest function)
+     * @return String : the num id, or an error message
+     */
+    private function ajax_gmaps_admin_assocSetAssoc($id, $properties)
+    {
+      global $template;
+
+      // if create a new assoc, get the last imgSort
+      $db=array(
+        'nbId' => 0,
+        'displayType' => '',
+        'maxImgSort' => 0
+      );
+
+      $sql="SELECT MAX(imgSort) AS maxImgSort, pgmm.displayType, COUNT(pgcm.id) AS nbId
+            FROM (".$this->tables['category_maps']." pgcm
+              LEFT JOIN ".$this->tables['maps']." pgmm ON pgmm.id = pgcm.mapId)
+              LEFT JOIN ".$this->tables['maps']." pgmm2 ON pgmm2.displayType=pgmm.displayType
+
+            WHERE categoryId='".$properties['categoryId']."'
+              AND pgmm2.id='".$properties['mapId']."'
+            GROUP BY pgmm.displayType;";
+      $result=pwg_query($sql);
+      if($result)
+      {
+        while($row=pwg_db_fetch_assoc($result))
+        {
+          $db=$row;
+        }
+      }
+
+      if($id=='' and
+          ($db['displayType']=='IC' or $db['displayType']=='IP') and
+          $db['nbId']>0
+        )
+      {
+        return('!'.l10n('gmaps_only_one_map_is_allowed_for_this_mode'));
+      }
+
+
+      if($id=='')
+      {
+        $sql="INSERT INTO ".$this->tables['category_maps']."
+              VALUES ('', '".
+                $properties['categoryId']."', '".
+                $properties['mapId']."', '".
+                ($db['maxImgSort']+1)."', '".
+                $properties['applySubCat']."', '".
+                $properties['kmlFileUrl']."', '".
+                $properties['icon']."', '".
+                mysql_escape_string($properties['title'])."');";
+        $result=pwg_query($sql);
+        $id=pwg_db_insert_id();
+      }
+      else
+      {
+        $sql="UPDATE ".$this->tables['category_maps']."
+              SET categoryId='".
+                $properties['categoryId']."', mapId='".
+                $properties['mapId']."', applySubCat='".
+                $properties['applySubCat']."', kmlFileUrl='".
+                $properties['kmlFileUrl']."', icon='".
+                $properties['icon']."', title='".
+                mysql_escape_string($properties['title'])."'
+              WHERE id='$id';";
+        $result=pwg_query($sql);
+      }
+
+      return($id);
+    } //ajax_gmaps_admin_assocSetAssoc
+
+
+
+
+    /**
+     * get properties for a given association id
+     *
+     * @param String id : the association Id
+     * @return String : data formatted in a JSON string
+     */
+    private function ajax_gmaps_admin_assocGetAssoc($id)
+    {
+      $returned=array(
+        'id' => '',
+        'categoryId' => 0,
+        'mapId' => '',
+        'applySubCat'=> 'y',
+        'kmlFileUrl' => '',
+        'icon' => '',
+        'title' => ''
+      );
+
+      $sql="SELECT id, categoryId, mapId, applySubCat, kmlFileUrl,
+                   icon, title
+            FROM ".$this->tables['category_maps']."
+            WHERE id='$id';";
+      $result=pwg_query($sql);
+      if($result)
+      {
+        while($row=pwg_db_fetch_assoc($result))
+        {
+          $returned=$row;
+        }
+      }
+
+      return(json_encode($returned));
+    } //ajax_gmaps_admin_assocGetAssoc
+
+
+
+
+    /**
+     * delete an association
+     *
+     * @param String id : if of the association to delete
+     * @return String : ok or ko
+     */
+    private function ajax_gmaps_admin_assocDeleteAssoc($id)
+    {
+      $sql="DELETE FROM ".$this->tables['category_maps']."
+            WHERE id='$id';";
+      $result=pwg_query($sql);
+      if($result) return('ok');
+
+      return('ko!unknown error');
+    } //ajax_gmaps_admin_assocDeleteAssoc
+
+
+    /**
+     * prepare the cache for the user / category
+     *
+     *
+     * @param Integer $category : the category Id, 0 if want to init map for all
+     *                            the gallery
+     * @return String : the requestId
+     */
+    private function ajax_gmaps_public_mapsInit($category)
+    {
+      global $prefixeTable, $template, $user, $conf;
+
+      $returned='';
+
+      $this->buildMapList($category, 'C');
+      if($category>0)
+      {
+        $sqlCatRestrict="AND FIND_IN_SET($category, pct.uppercats)!=0";
+      }
+      else
+      {
+        $sqlCatRestrict="";
+      }
+
+      if(count($this->maps)>0)
+      {
+        $scripts=array();
+        $bounds=array(
+          'N' => -90,
+          'S' => 90,
+          'E' => -180,
+          'W' => 180
+        );
+
+        // there is some maps to display
+        $requestId=date('Y-m-d h:i:s');
+
+        // delete cache (for user and data having more than 24h)
+        $sql="DELETE FROM ".$this->tables['cache']."
+              WHERE userId='".$user['id']."'
+                 OR requestId<'".date('Y-m-d h:i:s', time()-86400)."';";
+        pwg_query($sql);
+
+        // prepare the cache (same request in the 'GMaps_pip->displayCategoryPageMap' function)
+        $sql="SELECT DISTINCT pic.image_id, GROUP_CONCAT(DISTINCT pait.value ORDER BY pait.numID ASC SEPARATOR ';') AS coords,
+                GROUP_CONCAT(DISTINCT pic.category_id ORDER BY pic.category_id SEPARATOR ';') AS imageCatsId,
+                GROUP_CONCAT(DISTINCT pct.name ORDER BY pct.id SEPARATOR ';') AS imageCatsNames,
+                GROUP_CONCAT(DISTINCT IF(pct.permalink IS NULL, CONCAT('*', pct.id), pct.permalink) ORDER BY pct.id SEPARATOR ';') AS imageCatsPLink,
+                pit.name AS imageName, pit.path, pit.tn_ext
+              FROM ((((".USER_CACHE_CATEGORIES_TABLE." pucc
+                LEFT JOIN ".CATEGORIES_TABLE." pct ON pucc.cat_id = pct.id)
+                LEFT JOIN ".IMAGE_CATEGORY_TABLE." pic ON pic.category_id = pucc.cat_id)
+                LEFT JOIN ".$prefixeTable."amd_images_tags pait ON pait.imageId = pic.image_id)
+                LEFT JOIN ".$prefixeTable."amd_used_tags paut ON pait.numId = paut.numId)
+                LEFT JOIN ".IMAGES_TABLE." pit ON pit.id = pic.image_id
+              WHERE pucc.user_id = '".$user['id']."'
+               AND (paut.tagId = 'magic.GPS.LatitudeNum' OR paut.tagId = 'magic.GPS.LongitudeNum')
+               AND pic.image_id IS NOT NULL
+               $sqlCatRestrict
+               GROUP BY pic.image_id";
+/*
+ * get_sql_condition_FandF(
+                array
+                  (
+                    'forbidden_categories' => 'pic.category_id',
+                    'visible_categories' => 'pic.category_id',
+                    'visible_images' => 'pic.image_id'
+                  ),
+                'AND'
+              );
+*/
+        $result=pwg_query($sql);
+        if($result)
+        {
+          $massInsert=array();
+
+          while($row=pwg_db_fetch_assoc($result))
+          {
+            $coords=explode(';', $row['coords']);
+            $this->updateBounds($bounds, array(
+                'lat' => $coords[0],
+                'lng' => $coords[1]
+              )
+            );
+
+            $massInsert[]=array(
+              'userId' => $user['id'],
+              'requestId' => $requestId,
+              'imageId' => $row['image_id'],
+              'latitude' => $coords[0],
+              'longitude' => $coords[1],
+              'imageName' => mysql_escape_string($row['imageName']),
+              'imageTnFile' => dirname($row['path']).'/'.$conf['dir_thumbnail'].'/'.$conf['prefix_thumbnail'].get_filename_wo_extension(basename($row['path'])).'.'.$row['tn_ext'],
+              'imageCatsId' => $row['imageCatsId'],
+              'imageCatsNames' => mysql_escape_string($row['imageCatsNames']),
+              'imageCatsPLink' => $row['imageCatsPLink']
+            );
+          }
+
+          mass_inserts($this->tables['cache'], array('userId', 'requestId', 'imageId', 'latitude', 'longitude', 'imageName', 'imageTnFile', 'imageCatsId', 'imageCatsNames', 'imageCatsPLink'), $massInsert);
+
+          $returned=$requestId;
+        }
+      }
+
+      return($requestId);
     }
 
+
+    /**
+     * returns a list of markers
+     *
+     *
+     * @param Array $datas : 'requestId' id of the request
+     *                       'bounds'  (north, east, west, south) : only markers
+     *                          inside the given bounds are returned
+     *                       'width' : width of maps in pixels
+     *                       'height' : height of maps in pixels
+     * @return Array|String : a JSON string of an array of points (nbPictures, lat, lng)
+     */
+    private function ajax_gmaps_public_mapsGetMarkers($datas)
+    {
+      global $user, $page;
+
+      $returned=array();
+
+      /*
+       * the 'make_picture_url' function use the 'get_root_url' function which
+       * use the $page['root_path'] value
+       *
+       * here, this $page index doesn't exist, so we need to initialize it
+       */
+      $page['root_path']='';
+
+      if($datas['bounds']['east']<$datas['bounds']['west'])
+      {
+        /*  E = -xxx    W = +xxx
+         *  a(lng E:+x)
+         *  b(lng W:-x)
+         *
+         *  E         +180/-180     W
+         * (+)                     (-)
+         *  +-------------+---------+
+         *  |             :         |
+         *  |             :    b    |
+         *  |     a       :         |
+         *  |             :         |
+         *  +-------------+---------+
+         *
+         */
+        $lngClause="
+              longitude <= ".$datas['bounds']['east']."
+              OR longitude >= ".$datas['bounds']['west']." ";
+      }
+      else
+      {
+        /*  E = -xxx    W = +xxx
+         *  a(lng W:-x)
+         *  b(lng E:+x)
+         *
+         *  W             0         E
+         * (-)                     (+)
+         *  +-------------+---------+
+         *  |             :         |
+         *  |             :    b    |
+         *  |      a      :         |
+         *  |             :         |
+         *  +-------------+---------+
+         *
+         */
+        $lngClause="
+              longitude >= ".$datas['bounds']['west']."
+              AND longitude <= ".$datas['bounds']['east']." ";
+      }
+
+      $sql="SELECT latitude, longitude, imageId, imageCatsId, imageCatsNames, imageTnFile, imageName, imageCatsPLink
+            FROM ".$this->tables['cache']."
+            WHERE userId='".$user['id']."'
+              AND requestId='".$datas['requestId']."'
+              AND ($lngClause)
+              AND latitude >= ".$datas['bounds']['south']."
+              AND latitude <= ".$datas['bounds']['north']."
+            ORDER BY latitude, longitude;";
+
+      $result=pwg_query($sql);
+      if($result)
+      {
+        // compute ratio map size / bound size
+        $ratioW=($datas['bounds']['east']-$datas['bounds']['west'])/$datas['width'];
+        $ratioH=($datas['bounds']['north']-$datas['bounds']['south'])/$datas['height'];
+        // works with the highest ratio
+        $ratio=max($ratioW, $ratioH);
+
+
+        $points=array();
+        $groups=array();
+
+        while($row=pwg_db_fetch_assoc($result))
+        {
+          $points[]=$row;
+        }
+
+        /*
+         *  build groups
+         */
+        while(count($points)>0)
+        {
+          $currentGroup=array();
+          $currentGroup[]=array_shift($points);
+
+          $i=0;
+          while($i<count($points))
+          {
+            $dist=sqrt(pow($points[$i]['latitude']-$currentGroup[0]['latitude'],2) + pow($points[$i]['longitude']-$currentGroup[0]['longitude'],2))/$ratio;
+
+            if($dist <= $datas['distanceTreshold'])
+            {
+              $tmp=array_splice($points, $i, 1);
+              $currentGroup[]=$tmp[0];
+              $points=array_values($points); // reset array index...
+            }
+            else
+            {
+              $i++;
+            }
+          }
+
+          $groups[]=$currentGroup;
+          unset($currentGroup);
+        }
+
+        /*
+         * for each group, calculate coordinates for a unique representative
+         * point
+         */
+        foreach($groups as $keyGroup => $group)
+        {
+          $coords=array(
+            'nbImagesTxt' => '',
+            'nbImages' => 0,
+            'latitude' => 0,
+            'longitude' => 0,
+            'imagesTnFile' => array(),
+            'imagesCatsNames' => array(),
+            'imagesName' => array(),
+            'imagesCatsUrl' => array(),
+          );
+
+          foreach($group as $point)
+          {
+            $tmpCatsUrl=array();
+            $tmpCatsId=explode(';', $point['imageCatsId']);
+            $tmpCatsNames=explode(';', $point['imageCatsNames']);
+            $tmpCatsPLinks=explode(';', $point['imageCatsPLink']);
+
+            foreach($tmpCatsId as $key => $id)
+            {
+              $tmpCatsUrl[]=make_picture_url(
+                array(
+                  'image_id' => $point['imageId'],
+                  'category' => array(
+                    'id' => $id,
+                    'name' => $tmpCatsNames[$key],
+                    'permalink' => (substr($tmpCatsPLinks[$key],0,1)=='*')?'':$tmpCatsPLinks[$key],
+                  )
+                )
+              );
+            }
+
+            $coords['nbImages']++;
+            $coords['latitude']+=$point['latitude'];
+            $coords['longitude']+=$point['longitude'];
+            $coords['imagesTnFile'][]=$point['imageTnFile'];
+            $coords['imagesCatsNames'][]=$tmpCatsNames;
+            $coords['imagesName'][]=$point['imageName'];
+            $coords['imagesCatsUrl'][]=$tmpCatsUrl;
+          }
+          $coords['latitude']=$coords['latitude']/count($group);
+          $coords['longitude']=$coords['longitude']/count($group);
+          $coords['uniqueId']=md5($coords['latitude'].$coords['latitude']);
+
+          if($coords['nbImages']==1)
+          {
+            $coords['nbImagesTxt']=l10n('gmaps_1_picture');
+          }
+          else
+          {
+            $coords['nbImagesTxt']=sprintf(l10n('gmaps_nb_pictures'), $coords['nbImages']);
+          }
+
+          $returned[]=$coords;
+        }
+      }
+
+      return(json_encode($returned));
+    }
 
 
Index: extensions/GMaps/gmaps_install.class.inc.php
===================================================================
--- extensions/GMaps/gmaps_install.class.inc.php	(revision 7054)
+++ extensions/GMaps/gmaps_install.class.inc.php	(revision 7125)
@@ -48,8 +48,9 @@
 
       $tables_def=array(
-"CREATE TABLE   `".$this->tables['maps']."` (
+"CREATE TABLE `".$this->tables['maps']."` (
   `id` int(10) unsigned NOT NULL auto_increment,
-  `mapId` char(12) NOT NULL,
   `name` varchar(80) NOT NULL,
+  `displayType` char(2) NOT NULL,
+  `sizeMode` char(1) NOT NULL,
   `width` int(10) unsigned NOT NULL default '470',
   `height` int(10) unsigned NOT NULL default '210',
@@ -60,19 +61,30 @@
   `scaleControl` char(1) NOT NULL default 'y',
   `style` varchar(512) NOT NULL,
-  PRIMARY KEY  (`id`),
-  KEY `byMapId` (`mapId`)
+  PRIMARY KEY  (`id`)
 )",
-"CREATE TABLE   `".$this->tables['category_maps']."` (
+"CREATE TABLE `".$this->tables['category_maps']."` (
   `id` int(10) unsigned NOT NULL auto_increment,
-  `target` char(1) NOT NULL default 'P',
-  `category_id` smallint(5) unsigned NOT NULL,
-  `map_id` int(11) NOT NULL,
-  `sort` smallint(5) unsigned NOT NULL default '0',
+  `categoryId` smallint(5) unsigned NOT NULL,
+  `mapId` int(11) NOT NULL,
+  `imgSort` smallint(5) unsigned NOT NULL default '0',
   `applySubCat` char(1) NOT NULL default 'y',
   `kmlFileUrl` varchar(255) NOT NULL,
-  `marker` varchar(1) NOT NULL,
+  `icon` varchar(255) NOT NULL,
+  `title` varchar(200) NOT NULL,
   PRIMARY KEY  (`id`),
-  KEY `byTarget` USING BTREE (`target`,`category_id`,`sort`),
-  KEY `byCategorie` (`category_id`,`target`)
+  KEY `byCategorie` (`categoryId`,`mapId`)
+)",
+"CREATE TABLE `".$this->tables['cache']."` (
+  `userId` smallint(5) NOT NULL,
+  `requestId` timestamp NOT NULL default '0000-00-00 00:00:00',
+  `imageId` mediumint(8) NOT NULL,
+  `latitude` decimal(20,17) NOT NULL default '0.00000000000000000',
+  `longitude` decimal(20,17) NOT NULL default '0.00000000000000000',
+  `imageName` varchar(255) NOT NULL,
+  `imageTnFile` varchar(255) NOT NULL,
+  `imageCatsId` varchar(255) NOT NULL,
+  `imageCatsNames` varchar(255) NOT NULL,
+  `imageCatsPLink` varchar(255) NOT NULL,
+  PRIMARY KEY  USING BTREE (`userId`,`requestId`,`imageId`)
 )"
       );
Index: extensions/GMaps/gmaps_pip.class.inc.php
===================================================================
--- extensions/GMaps/gmaps_pip.class.inc.php	(revision 7054)
+++ extensions/GMaps/gmaps_pip.class.inc.php	(revision 7125)
@@ -18,27 +18,50 @@
 class GMaps_PIP extends GMaps_root
 {
-  protected $coords = array();
-  protected $maps = array();
-  protected $content = '';
-  protected $pictureGeolocated;
+  protected $maps = array(); //list of maps
+  protected $category=array(
+    'id' => 0,
+    'bounds' => array(
+      'N' => -90,
+      'S' => 90,
+      'E' => -180,
+      'W' => 180
+    ),
+    'icon' => array(
+      'style' => true,
+      'file' => '',
+      'width' => -1,
+      'height' => -1
+    )
+  );
+  protected $picture=array(
+    'geolocated' => false,
+    'coords' => array('lat' => 0, 'lng' => 0),
+    'content' => array(
+      'I' => array(), // icon display mode
+      'M' => array(), // meta display mode
+    ),
+    'properties' => array(),
+    'icon' => array(
+      'style' => true,
+      'file' => '',
+      'width' => -1,
+      'height' => -1
+      )
+  );
+  protected $css2;
 
   public function __construct($prefixeTable, $filelocation)
   {
     parent::__construct($prefixeTable, $filelocation);
+    $this->css2 = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."2.css");
     $this->loadConfig();
-
     $this->initEvents();
     $this->load_lang();
-
-    $this->pictureGeolocated=false;
-    $this->coords['lat']=0;
-    $this->coords['lng']=0;
-
-    $this->loadMaps();
   }
 
   public function __destruct()
   {
-    unset($section_page);
+    unset($maps);
+    unset($picture);
     parent::__destruct();
   }
@@ -61,7 +84,8 @@
     parent::initEvents();
 
-    //add_event_handler('loc_end_page_header', array(&$this, 'loadJS'));
-    add_event_handler('amd_jpegMD_loaded', array(&$this, 'prepareMap'));
-    add_event_handler('loc_begin_picture', array(&$this, 'applyMap'), 55);
+    add_event_handler('loc_begin_index', array(&$this, 'displayCategoryPageMap'));
+    add_event_handler('loc_begin_picture', array(&$this, 'displayPicturePageMap'), 55);
+    add_event_handler('amd_jpegMD_loaded', array(&$this, 'preparePictureMaps'));
+    add_event_handler('loc_end_page_header', array(&$this->css2, 'applyCSS'));
   }
 
@@ -72,113 +96,290 @@
   ------------------------------------------------------------------------- */
 
-
-
   /**
-   * build the maps
+   * this function display the map on the category page
    */
-  public function prepareMap($jpegMD)
-  {
-    global $template;
-
-    if(is_null($jpegMD->getTag('magic.GPS.LatitudeNum')) or
-       is_null($jpegMD->getTag('magic.GPS.LongitudeNum'))) return(false);
-
-    $this->coords['lat']=$jpegMD->getTag('magic.GPS.LatitudeNum')->getValue();
-    $this->coords['lng']=$jpegMD->getTag('magic.GPS.LongitudeNum')->getValue();
-
-    $this->pictureGeolocated=true;
-
-    $mapsProperties='';
-    foreach($this->maps as $val)
-    {
-      $this->content.="<div id='iGMaps".$val['id']."' style='width:".$val['width'].";height:".$val['height'].";".$val['style']."'></div>";
-
-      if($mapsProperties!='') $mapsProperties.=',';
-      $mapsProperties.="
-      {
-        id:'iGMaps".$val['id']."',
-        zoomLevel:".$val['zoomLevel'].",
-        displayMarker:".(($val['displayMarker']=='Y')?'true':'false').",
-        mapTypeId:'".$val['mode']."',
+  public function displayCategoryPageMap()
+  {
+    global $page, $prefixeTable, $template, $user, $conf;
+
+    if($page['section']=='categories')
+    {
+      if(isset($page['category']))
+      {
+        $this->category['id']=$page['category']['id'];
+        $this->buildMapList($page['category']['id'], 'C');
+        $sqlCatRestrict="AND FIND_IN_SET(".$page['category']['id'].", pct.uppercats)!=0";
       }
-      ";
-    }
-    $this->content="<div id='iGMapContent' style='text-align:center;'>".$this->content."</div>";
-
-    $template->append('head_elements',
+      else
+      {
+        $this->category['id']=0;
+        $this->buildMapList(0, 'C');
+        $sqlCatRestrict="";
+      }
+
+      if(count($this->maps)>0)
+      {
+        $scripts=array();
+
+        // check if there is picture with gps tag in the selected category
+        $sql="SELECT paut.tagId, MAX(CAST(pait.value AS DECIMAL(20,17))) AS maxValue, MIN(CAST(pait.value AS DECIMAL(20,17))) AS minValue
+              FROM (((".USER_CACHE_CATEGORIES_TABLE." pucc
+                LEFT JOIN ".CATEGORIES_TABLE." pct ON pucc.cat_id = pct.id)
+                LEFT JOIN ".IMAGE_CATEGORY_TABLE." pic ON pic.category_id = pucc.cat_id)
+                LEFT JOIN ".$prefixeTable."amd_images_tags pait ON pait.imageId = pic.image_id)
+                LEFT JOIN ".$prefixeTable."amd_used_tags paut ON pait.numId = paut.numId
+              WHERE pucc.user_id = '".$user['id']."'
+               AND (paut.tagId = 'magic.GPS.LatitudeNum' OR paut.tagId = 'magic.GPS.LongitudeNum')
+               AND pic.image_id IS NOT NULL
+               $sqlCatRestrict
+               GROUP BY paut.tagId";
+
+        $result=pwg_query($sql);
+        if($result)
+        {
+          $nb=0;
+          while($row=pwg_db_fetch_assoc($result))
+          {
+            switch($row['tagId'])
+            {
+              case 'magic.GPS.LatitudeNum':
+                $this->category['bounds']['N']=$row['maxValue'];
+                $this->category['bounds']['S']=$row['minValue'];
+                break;
+              case 'magic.GPS.LongitudeNum':
+                $this->category['bounds']['E']=$row['maxValue'];
+                $this->category['bounds']['W']=$row['minValue'];
+                break;
+            }
+            $nb++;
+          }
+
+          if($nb>0)
+          {
+            /*
+             * prepare js script for each map
+             */
+
+            foreach($this->maps as $keyMap => $map)
+            {
+              $scripts[]="
+              {
+                id:'iGMapsIcon',
+                zoomLevel:".$map['zoomLevel'].",
+                marker:true,
+                mapType:'".$map['mapType']."',
+                mapTypeControl:'".$map['mapTypeControl']."',
+                navigationControl:'".$map['navigationControl']."',
+                scaleControl:'".$map['scaleControl']."',
+                kmlFileUrl:'".$map['kmlFileUrl']."',
+                displayType:'".$map['displayType']."',
+                sizeMode:'".$map['sizeMode']."',
+                title:'".addslashes( ($map['title']=='')?l10n('gmaps_geolocation'):$map['title']  )."',
+                markers:[],
+                fitToBounds:true
+              }";
+
+              preg_match('/^i(\d+)x(\d+).*/i', basename($map['icon']), $result);
+              $this->category['icon']['iconStyle']=$map['iconStyle'];
+              $this->category['icon']['file']=$map['icon'];
+              $this->category['icon']['width']=isset($result[1])?$result[1]:-1;
+              $this->category['icon']['height']=isset($result[2])?$result[2]:-1;
+            }
+
+
+            $template->assign('maps', $this->maps);
+            $template->set_filename('gmapsCatMap',
+                        dirname($this->getFileLocation()).'/templates/gmaps_category.tpl');
+            $template->append('footer_elements', $template->parse('gmapsCatMap', true), false);
+
+            if(is_array($this->category['icon']))
+            {
+              $template->assign('mapIcon', $this->category['icon']);
+              $template->set_filename('gmapsIconButton',
+                          dirname($this->getFileLocation()).'/templates/gmaps_category_iconbutton.tpl');
+              $template->concat('PLUGIN_INDEX_ACTIONS', $template->parse('gmapsIconButton', true), false);
+              $template->assign('mapIcon');
+            }
+
+
+            $template->append('head_elements',
+  "<script type=\"text/javascript\">
+  gmaps =
+    {
+      lang:{
+        boundmap:'".l10n('gmaps_i_boundmap')."',
+        boundkml:'".l10n('gmaps_i_boundkml')."'
+      },
+      requestId:'',
+      categoryId:".$this->category['id'].",
+      bounds:
+        {
+          north:".$this->category['bounds']['N'].",
+          south:".$this->category['bounds']['S'].",
+          east:".$this->category['bounds']['E'].",
+          west:".$this->category['bounds']['W']."
+        },
+      maps:
+      [".implode(',', $scripts)."],
+    }
+  </script>", false);
+
+          }
+        }
+      }
+    }
+  }
+
+
+
+  /**
+   * this function display the map on the picture page
+   *
+   * the 'amd_jpegMD_loaded' event is triggered before the 'loc_begin_picture'
+   * event so, when this function is called the $this->picture var was already
+   * initialized
+   */
+  public function displayPicturePageMap()
+  {
+    global $page, $template;
+
+    if($this->picture['geolocated']==false) return(false);
+
+    if(count($this->picture['content']['MP'])>0)
+    {
+      // there is maps in meta display mode
+      $template->set_filename('gmapsMeta',
+                  dirname($this->getFileLocation()).'/templates/gmaps_picture_meta.tpl');
+      $template->assign('maps', $this->picture['content']['MP']);
+
+      $metadata=array
+        (
+          'TITLE' => l10n('gmaps_geolocation'),
+          'lines' =>
+            array(
+              /* <!--rawContent-->  is a trick to display raw data in tabs
+               * for the gally template
+               *
+               * on the default template, the displayed content is done
+               * normally
+               */
+              '<!--rawContent-->' => $template->parse('gmapsMeta', true)
+            )
+        );
+      $template->append('metadata', $metadata, false);
+    }
+
+    if(count($this->picture['content']['IP'])>0)
+    {
+      // there is maps in icon display mode
+      $template->assign('map', $this->picture['content']['IP'][0]);
+      $template->assign('mapIcon', $this->picture['icon']);
+
+      $template->set_filename('gmapsIconMap',
+                  dirname($this->getFileLocation()).'/templates/gmaps_picture_icon.tpl');
+      $template->append('footer_elements', $template->parse('gmapsIconMap', true), false);
+
+      $template->set_filename('gmapsIconButton',
+                  dirname($this->getFileLocation()).'/templates/gmaps_picture_iconbutton.tpl');
+      $template->concat('PLUGIN_PICTURE_ACTIONS',  $template->parse('gmapsIconButton', true), false);
+    }
+
+    if(count($this->picture['properties'])>0)
+    {
+      $template->append('head_elements',
 "<script type=\"text/javascript\">
   gmaps =
     {
+      lang:{
+        centermap:'".l10n('gmaps_i_centermap')."',
+        boundkml:'".l10n('gmaps_i_boundkml')."'
+      },
       coords:
       {
-        latitude:'".$this->coords['lat']."',
-        longitude:'".$this->coords['lng']."',
+        latitude:'".$this->picture['coords']['lat']."',
+        longitude:'".$this->picture['coords']['lng']."',
       },
       maps:
-      [$mapsProperties],
-    }
-</script>");
-
-
-    if(!isset($template->known_scripts)) $template->known_scripts=Array();
-
-    if(!array_key_exists('jquery', $template->known_scripts))
-    {
-      $template->known_scripts['jquery']='themes/default/js/jquery.packed.js';
-      $template->block_html_head(null, '<script type="text/javascript" src="themes/default/js/jquery.packed.js"></script>', $template->smarty, $false);
-    }
-
-    $template->known_scripts['maps.google.com/api']='http://maps.google.com/maps/api/js?sensor=false';
-    $template->block_html_head(null, '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>', $template->smarty, $false);
-
-    $template->known_scripts['gmaps.gmaps']='plugins/'.basename(dirname(__FILE__)).'/js/gmaps.js';
-    $template->block_html_head(null, '<script type="text/javascript" src="plugins/'.basename(dirname(__FILE__)).'/js/gmaps.js"></script>', $template->smarty, $false);
-
-
-    //$template->append('head_elements', '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>');
-    //$template->append('head_elements', '<script type="text/javascript" src="plugins/'.basename(dirname(__FILE__)).'/js/gmaps.js"></script>');
-  }
+      [".implode(',', $this->picture['properties'])."],
+    }
+</script>", false);
+    }
+  }
+
+
 
 
   /**
-   * add the maps container to the page
+   * prepare the maps for the picture page
+   *
+   * this function is called when the plugin AdvancedMetadata has finished to
+   * read the metadata ; if picture is not geolocated, there is no map to display
+   *
+   * @param JpegMetadata $jpegMD : a JpegMetadata object
    */
-  public function applyMap()
-  {
-    global $template;
-
-    if(!$this->pictureGeolocated) return(false);
-
-    $metadata=$template->get_template_vars('metadata');
-
-    $metadata[]=array
-      (
-        'TITLE' => l10n('gmaps_geolocation'),
-        'lines' =>
-          array(
-            '<!--rawContent-->' => $this->content
-          )
+  public function preparePictureMaps($jpegMD)
+  {
+    global $template, $page;
+
+    if(is_null($jpegMD->getTag('magic.GPS.LatitudeNum')) or
+       is_null($jpegMD->getTag('magic.GPS.LongitudeNum')) or
+       $page['section']!='categories') return(false);
+
+
+    $this->picture['geolocated']=true;
+    $this->picture['coords']['lat']=$jpegMD->getTag('magic.GPS.LatitudeNum')->getValue();
+    $this->picture['coords']['lng']=$jpegMD->getTag('magic.GPS.LongitudeNum')->getValue();
+
+
+    if(isset($page['category']))
+    {
+      $this->buildMapList($page['category']['id'], 'P');
+    }
+    else
+    {
+      $this->buildMapList(0, 'P');
+    }
+
+
+    foreach($this->maps as $map)
+    {
+      if($map['displayType']=='IP')
+      {
+        preg_match('/^i(\d+)x(\d+).*/i', basename($map['icon']), $result);
+        $this->picture['icon']=array(
+          'iconStyle' => $map['iconStyle'],
+          'file' => $map['icon'],
+          'width' => isset($result[1])?$result[1]:-1,
+          'height' => isset($result[2])?$result[2]:-1
+        );
+      }
+
+
+      $this->picture['content'][$map['displayType']][]=array(
+        'id' => $map['id'],
+        'width' => $map['width'],
+        'height' => $map['height'],
+        'style' => $map['style'],
+        'mode' => $map['displayType']
       );
-    $template->assign('metadata', $metadata);
-  }
-
-
-  /**
-   * loads the maps list
-   */
-  private function loadMaps()
-  {
-    $sql="SELECT id, width, height, zoomLevel, displayMarker, mode, style
-          FROM ".$this->tables['maps']."
-          ORDER BY id";
-    $result=pwg_query($sql);
-    if($result)
-    {
-      while($row=pwg_db_fetch_assoc($result))
-      {
-        $this->maps[]=$row;
-      }
-    }
-  }
+
+      $this->picture['properties'][]="
+      {
+        id:'iGMaps".(($map['displayType']=='IP')?'Icon':$map['id'])."',
+        zoomLevel:".$map['zoomLevel'].",
+        marker:true,
+        mapType:'".$map['mapType']."',
+        mapTypeControl:'".$map['mapTypeControl']."',
+        navigationControl:'".$map['navigationControl']."',
+        scaleControl:'".$map['scaleControl']."',
+        kmlFileUrl:'".$map['kmlFileUrl']."',
+        displayType:'".$map['displayType']."',
+        sizeMode:'".$map['sizeMode']."',
+        title:'".addslashes( ($map['title']=='')?l10n('gmaps_geolocation'):$map['title']  )."'
+      }";
+    }
+  }
+
+
 
 
Index: extensions/GMaps/gmaps_root.class.inc.php
===================================================================
--- extensions/GMaps/gmaps_root.class.inc.php	(revision 7054)
+++ extensions/GMaps/gmaps_root.class.inc.php	(revision 7125)
@@ -19,4 +19,54 @@
     protected $css;
 
+    /**
+     * check the available AMD release
+     */
+    static public function checkAMDRelease()
+    {
+      if(!defined('AMD_VERSION')) return(false);
+
+      $currentAMDRelease = explode(".", GPC_VERSION);
+
+      $neededAMDRelease=explode('.', GMAPS_AMD_NEEDED);
+      $major=$neededAMDRelease[0];
+      $minor=$neededAMDRelease[1];
+      $minor2=$neededAMDRelease[2];
+
+      if(($currentAMDRelease[0]>$major) ||
+         ($currentAMDRelease[0]==$major)&&($currentAMDRelease[1]>$minor) ||
+         ($currentAMDRelease[0]==$major)&&($currentAMDRelease[1]==$minor)&&($currentAMDRelease[2]>=$minor2))
+      {
+        return(true);
+      }
+      return(false);
+    }
+
+    /**
+     * check if AMD plugin is activated and mode
+     *
+     * @return String : 'none' if plugin is not installed
+     *                  'inactive' if plugin is not active
+     *                  'basic' if plugin active in basic mode
+     *                  'advanced' if plugin active in advanced mode
+     */
+    static public function checkAMDActivated()
+    {
+      if(!self::checkAMDRelease()) return('none');
+
+      $sql="SELECT state FROM ".PLUGINS_TABLE." WHERE id='AMetaData';";
+      $result=pwg_query($sql);
+      if($result)
+      {
+        $row=pwg_db_fetch_assoc($result);
+        if(!(isset($row['state']) and $row['state']='active')) return('inactive');
+
+        $amdConfig=array();
+        GPCCore::loadConfig('amd', $amdConfig);
+
+        return($amdConfig['amd_InterfaceMode']);
+      }
+    }
+
+
     public function __construct($prefixeTable, $filelocation)
     {
@@ -26,5 +76,5 @@
       $this->section_name=$this->getPluginNameFiles();
 
-      $this->setTablesList(array('maps', 'category_maps'));
+      $this->setTablesList(array('maps', 'category_maps', 'cache'));
       $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
     }
@@ -37,5 +87,4 @@
     public function initEvents()
     {
-      add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') );
     }
 
@@ -111,7 +160,117 @@
 
     /* ---------------------------------------------------------------------------
-      ajax functions
+
     --------------------------------------------------------------------------- */
 
+    /**
+     * update the given bound with the given coords
+     *
+     * @param &Array $bounds : the bounds (N,S,E,W)
+     * @param Array $coords  : coords (0=>lat, 1=>lng)
+     */
+    protected function updateBounds(&$bounds, $coords)
+    {
+      if($bounds['E']<$coords['lng']) $bounds['E']=$coords['lng'];
+      if($bounds['N']<$coords['lat']) $bounds['N']=$coords['lat'];
+      if($bounds['W']>$coords['lng']) $bounds['W']=$coords['lng'];
+      if($bounds['S']>$coords['lat']) $bounds['S']=$coords['lat'];
+    }
+
+    /**
+     * build the list of maps (initialize the $this->maps var)
+     *
+     * used by GMaps_ajax & GMaps_pip classes
+     *
+     * @param Array $categories : array of categories id (cat + parent list)
+     * @param String $page : 'P' for picture page, 'C' for category page
+     */
+    protected function buildMapList($category, $page)
+    {
+      global $template ;
+
+      if($page=='C')
+      {
+        $where=" displayType='IC' ";
+      }
+      else
+      {
+        $where=" (displayType='IP' or displayType='MP') ";
+      }
+
+      /*
+       * sql request select all possible association, sorted from the highest to
+       * the lowest priority
+       */
+      $sql="SELECT DISTINCT pgcm.id, pgcm.categoryId,
+              pgcm.imgSort, pgcm.applySubCat, pgcm.kmlFileUrl,
+              pgcm.icon, pgcm.title,
+              pgmm.displayType, pgmm.sizeMode,
+              pgmm.width, pgmm.height, pgmm.zoomLevel,
+              pgmm.mapType, pgmm.mapTypeControl, pgmm.scaleControl,
+              pgmm.navigationControl, pgmm.style,
+              IF(pgcm.categoryId=0, 0, pct.global_rank) AS priorityRank
+            FROM (".$this->tables['category_maps']." pgcm
+              LEFT JOIN ".$this->tables['maps']." pgmm ON pgcm.mapId = pgmm.id)
+              LEFT JOIN ".CATEGORIES_TABLE." pct ON (FIND_IN_SET(pgcm.categoryId, pct.uppercats)!=0 OR pgcm.categoryId=0)
+            WHERE $where ";
+      if($category!=0)
+      {
+        $sql.=" AND pct.id = '$category' ";
+      }
+      else
+      {
+        $sql.=" AND pgcm.categoryId = 0 ";
+      }
+      $sql.=" AND pgcm.applySubCat='y'
+            ORDER BY priorityRank DESC, pgmm.displayType ASC, pgcm.categoryId ASC, pgcm.imgSort ASC;";
+      $result=pwg_query($sql);
+
+      if($result)
+      {
+        // for each found row, choose the highest only
+        $pcat='';
+        $displayType=array(
+         'IC' => true,
+         'IP' => true,
+         'MP' => true,
+        );
+        while($row=pwg_db_fetch_assoc($result))
+        {
+          if($row['displayType']!='MP')
+          {
+            $themeConf=$template->get_template_vars('themeconf');
+            $fileName=preg_replace('/^([i|c]\d+x\d+)(?:_\d+){0,1}(\..*)/i', '$1$2', $row['icon']);
+
+            if(file_exists(PHPWG_ROOT_PATH.$themeConf['icon_dir'].'/gmaps/'.$fileName))
+            {
+              $row['icon']=$themeConf['icon_dir'].'/gmaps/'.$fileName;
+              $row['iconStyle']=false;
+            }
+            else
+            {
+              $row['icon']='plugins/GMaps/img/'.$row['icon'];
+              $row['iconStyle']=true;
+            }
+          }
+
+          if($displayType[$row['displayType']])
+          {
+            if($row['displayType']=='MP')
+            {
+              if($displayType['MP'] and ($row['categoryId']==$pcat or $pcat=='')) $this->maps[]=$row;
+              if($displayType['MP'] and $row['categoryId']!=$pcat and $pcat!='') $displayType['MP']=false;
+              $pcat=$row['categoryId'];
+            }
+            else
+            {
+              $this->maps[]=$row;
+              $displayType[$row['displayType']]=false;
+            }
+          }
+        }
+      }
+    }
+
+
 
   } //class
Index: extensions/GMaps/gmaps_version.inc.php
===================================================================
--- extensions/GMaps/gmaps_version.inc.php	(revision 7054)
+++ extensions/GMaps/gmaps_version.inc.php	(revision 7125)
@@ -18,3 +18,4 @@
   define('GMAPS_VERSION2', '00.02.00');
   define('GMAPS_GPC_NEEDED', '3.2.0');
+  define('GMAPS_AMD_NEEDED', '0.5.2'); //advanced metadata plugin is needed
 ?>
Index: extensions/GMaps/js/gmaps.js
===================================================================
--- extensions/GMaps/js/gmaps.js	(revision 7054)
+++ 	(revision )
@@ -1,70 +1,0 @@
-
-var viewportInitialized = false;
-
-function applyMap(properties)
-{
-  var latlng=new google.maps.LatLng(gmaps.coords.latitude, gmaps.coords.longitude);
-
-  var map = new google.maps.Map($("#"+properties.id).get(0),
-    {
-      mapTypeId: properties.mapTypeId,
-      zoom: properties.zoomLevel,
-      center:latlng,
-      navigationControl: true,
-      scaleControl: false,
-      mapTypeControl:true,
-      mapTypeControlOptions:
-        {
-          style:google.maps.MapTypeControlStyle.DROPDOWN_MENU
-        },
-      markerTitle:'',
-    }
-  );
-
-  if(properties.displayMarker)
-  {
-    var marker = new google.maps.Marker(
-      {
-        position:latlng,
-        map: map,
-        title:properties.markerTitle
-      }
-    );
-    properties.gMarker=marker;
-  }
-
-  properties.gMap=map;
-  properties.gMapCenter=latlng;
-}
-
-$(window).load(function ()
-  {
-    for(i=0;i<gmaps.maps.length;i++)
-    {
-      applyMap(gmaps.maps[i]);
-    }
-
-    /*
-     * this is need for the gally template, because the map initialisation don't
-     * works if the container is not visible
-     */
-    tabId=$('#iGMaps0').get(0).parentNode.parentNode.parentNode.id;
-    tabId='tab'+tabId.toUpperCase().substring(0,1)+tabId.substr(1);
-    $("#"+tabId+" a").bind('click', function ()
-     {
-        if(viewportInitialized==false)
-        {
-          for(i=0;i<gmaps.maps.length;i++)
-          {
-            google.maps.event.trigger(gmaps.maps[i].gMap, 'resize');
-            gmaps.maps[i].gMap.setCenter(gmaps.maps[1].gMapCenter);
-            $('#'+gmaps.maps[i].id+' span, #'+gmaps.maps[i].id+' a').css('font-size', '55.0%');
-          }
-        }
-        viewportInitialized=true;
-     }
-    );
-  }
-);
-
-
Index: extensions/GMaps/js/gmapsCategory.js
===================================================================
--- extensions/GMaps/js/gmapsCategory.js	(revision 7125)
+++ extensions/GMaps/js/gmapsCategory.js	(revision 7125)
@@ -0,0 +1,424 @@
+
+var currentMapLoad;
+
+/**
+ * create the map
+ *
+ * @param Object properties : map properties
+ * @param Integer gmapsIndex : index in the map list
+ */
+function createMap(properties, gmapsIndex)
+{
+  var map = new google.maps.Map($("#"+properties.id).get(0),
+    {
+      backgroundColor:'#ffffff',
+      mapTypeId: properties.mapType,
+      zoom: properties.zoomLevel,
+      center: gmaps.bounds.getCenter(),
+      navigationControl: (properties.navigationControl==-1)?false:true,
+      scrollwheel: (properties.navigationControl==-1)?false:true,
+      scaleControl: (properties.scaleControl=='n')?false:true,
+      mapTypeControl:(properties.mapTypeControl==-1)?false:true,
+      mapTypeControlOptions:
+        {
+          style:properties.mapTypeControl
+        },
+      markerTitle:'',
+    }
+  );
+
+  if(properties.kmlFileUrl!='')
+  {
+    kmlFile = new google.maps.KmlLayer(properties.kmlFileUrl,
+      {
+        preserveViewport:true
+      }
+    );
+  }
+  else
+  {
+    kmlFile=null;
+  }
+
+  map.kmlFile=kmlFile;
+  map.markers=new Array();
+  map.gmapsIndex=gmapsIndex;
+  properties.gMap=map;
+  properties.viewportInitialized=false;
+}
+
+/**
+ * load markers from the server
+ *
+ * @param Map map : the map
+ */
+function loadMarkers(map)
+{
+  datas={
+    requestId:gmaps.requestId,
+    bounds:{
+        north:map.getBounds().getNorthEast().lat(),
+        east:map.getBounds().getNorthEast().lng(),
+        south:map.getBounds().getSouthWest().lat(),
+        west:map.getBounds().getSouthWest().lng()
+      },
+    width:$(map.getDiv()).width(),
+    height:$(map.getDiv()).height(),
+    distanceTreshold:25
+  }
+
+  currentMapLoad=map;
+
+  $.ajax(
+    {
+      type: "POST",
+      url: "plugins/GMaps/gmaps_ajax.php",
+      async: true,
+      data: { ajaxfct:"public.maps.getMarkers", datas:datas },
+      success:
+        function(msg)
+        {
+          tmp=$.parseJSON(msg);
+          tmp.sort(compareMarkers);
+          applyMarkers(currentMapLoad, tmp);
+        }
+    }
+  );
+}
+
+/**
+ * apply markers to map
+ *
+ * @param Map map : the google map object
+ * @param Array markers : array of markers properties
+ *                        each marker is an object with properties :
+ *                          latitude, longitude, nbImages
+ */
+function applyMarkers(map, markers)
+{
+  if(currentMapLoad==null) return(false);
+
+  /*
+   * deleting markers from the map only if they are not in the new list
+   */
+  if(map.markers.length>0)
+  {
+    var i=0;
+    while(i<map.markers.length)
+    {
+      newListIndex=markerInList(map.markers[i].uniqueId, markers);
+      if(newListIndex==-1)
+      {
+        map.markers[i].marker.setMap(null);
+        map.markers.splice(i, 1);
+      }
+      else
+      {
+        markers.splice(newListIndex,1);
+        i++;
+      }
+    }
+  }
+
+  /*
+   * add new markers on the map
+   */
+  for(var i=0;i<markers.length;i++)
+  {
+    var marker = new google.maps.Marker(
+      {
+        position:new google.maps.LatLng(markers[i].latitude, markers[i].longitude),
+        map: currentMapLoad,
+        title:markers[i].nbImagesTxt
+      }
+    );
+
+    marker.info=markers[i];
+    marker.info.displayed=0;
+
+    map.markers.push(
+      {
+        marker:marker,
+        uniqueId:markers[i].uniqueId
+      }
+    );
+
+    google.maps.event.addListener(
+      marker,
+      'click',
+      function ()
+      {
+        displayWindowInfo(this);
+      }
+    );
+  }
+  currentMapLoad=null;
+}
+
+function compareMarkers(m1,m2)
+{
+  if(m1.uniqueId<m2.uniqueId)
+  {
+    return(-1);
+  }
+  else if(m1.uniqueId<m2.uniqueId)
+  {
+    return(1);
+  }
+  return(0);
+}
+
+function markerInList(uniqueId, markerList)
+{
+  for(var i=0;i<markerList.length;i++)
+  {
+    if(markerList[i].uniqueId==uniqueId) return(i)
+  }
+  return(-1);
+}
+
+/**
+ * display the infowindow
+ *
+ * @param Marker marker : the marker
+ */
+function displayWindowInfo(marker)
+{
+  gmaps.currentInfo=marker.info;
+  gmaps.infoWindow.close();
+  gmaps.infoWindow.setContent($('#iGMapsInfoWindowContent').clone().each(renameId).get(0));
+  gmaps.infoWindow.open(marker.map, marker);
+  displayPictureInfo(gmaps.currentInfo.displayed);
+}
+function renameId(i, e)
+{
+  if(e.id!='') e.id='c'+e.id;
+  $(e).children().each(renameId);
+}
+
+
+/**
+ *
+ */
+function displayPictureInfo(index)
+{
+  gmaps.currentInfo.displayed=index;
+  if(gmaps.currentInfo.imagesName[index]=='')
+  {
+    $('#ciGMIWC_title').html('&nbsp;');
+  }
+  else
+  {
+    $('#ciGMIWC_title').html(gmaps.currentInfo.imagesName[index]);
+  }
+  $('#ciGMIWC_img').attr('src', gmaps.currentInfo.imagesTnFile[index]);
+
+  $('#ciGMIWC_img').unbind();
+  if(gmaps.currentInfo.imagesCatsUrl[index].length==1)
+  {
+    $('#ciGMIWC_img').bind('click',
+      function ()
+      {
+        window.location=gmaps.currentInfo.imagesCatsUrl[gmaps.currentInfo.displayed][0];
+      }
+    );
+  }
+  else
+  {
+    $('#ciGMIWC_showcatList').html('');
+    for(var i=0;i<gmaps.currentInfo.imagesCatsUrl[index].length;i++)
+    {
+      $('#ciGMIWC_showcatList')
+        .append('<li><a href="'+gmaps.currentInfo.imagesCatsUrl[index][i]+'">'+gmaps.currentInfo.imagesCatsNames[index][i]+'</a></li>');
+    }
+    $('#ciGMIWC_img, #ciGMIWC_showcat')
+      .bind('mouseenter', function () { $('#ciGMIWC_showcat').css('display', 'block'); } )
+      .bind('mouseleave', function () { $('#ciGMIWC_showcat').css('display', 'none'); } );
+  }
+
+  if(gmaps.currentInfo.nbImages>1)
+  {
+    $('#ciGMIWC_picnum').html((index+1)+'/'+gmaps.currentInfo.nbImagesTxt);
+    $('#ciWALeft, #ciWARight').css('display', 'inline-block');
+  }
+  else
+  {
+    $('#ciGMIWC_picnum').html(gmaps.currentInfo.nbImagesTxt);
+    $('#ciWALeft, #ciWARight').css('display', 'none');
+  }
+}
+
+/**
+ *
+ */
+function displayPicturePrev()
+{
+  gmaps.currentInfo.displayed--;
+  if(gmaps.currentInfo.displayed<0) gmaps.currentInfo.displayed=gmaps.currentInfo.nbImages-1;
+  displayPictureInfo(gmaps.currentInfo.displayed);
+}
+
+/**
+ *
+ */
+function displayPictureNext()
+{
+  gmaps.currentInfo.displayed++;
+  if(gmaps.currentInfo.displayed>=gmaps.currentInfo.nbImages) gmaps.currentInfo.displayed=0;
+  displayPictureInfo(gmaps.currentInfo.displayed);
+}
+
+
+$(window).load(function ()
+  {
+    // all maps have the same intials bounds
+    gmaps.currentInfo=null;
+
+    gmaps.bounds = new google.maps.LatLngBounds(
+      new google.maps.LatLng(gmaps.bounds.south, gmaps.bounds.west),
+      new google.maps.LatLng(gmaps.bounds.north, gmaps.bounds.east)
+    );
+
+    gmaps.infoWindow = new google.maps.InfoWindow();
+    google.maps.event.addListener(
+     gmaps.infoWindow,
+     'closeclick',
+     function () {
+       $('body').append($('#iGMapsInfoWindowContent'));
+       gmaps.infoWindow.setContent('');
+       $('#ciGMIWC_img').unbind();
+     }
+    );
+
+
+    for(var i=0;i<gmaps.maps.length;i++)
+    {
+      // prepare google map maps
+      createMap(gmaps.maps[i], i);
+
+      // if size map depends from windows size, apply new dimensions to map
+      if(gmaps.maps[i].sizeMode=='A')
+      {
+        $('#'+gmaps.maps[i].id).css(
+          {
+            width: ($(window).width()*0.8)+'px',
+            height:($(window).height()*0.8)+'px'
+          }
+        );
+      }
+
+      // initialize dialog box for maps
+      $('#'+gmaps.maps[i].id+'Content').dialog(
+        {
+          autoOpen:false,
+          width:'auto',
+          height:'auto',
+          modal: true,
+          closeText:'X',
+          dialogClass: 'gmapsPopup',
+          title: gmaps.maps[i].title,
+          open: function ()
+            {
+              gmaps.currentMapLoadIndex=$(this).data('index');
+
+              /*
+               * initialize map on the server side (call the 'public.maps.init'
+               * function
+               */
+              $.ajax(
+                {
+                  type: "POST",
+                  url: "plugins/GMaps/gmaps_ajax.php",
+                  async: true,
+                  data: { ajaxfct:"public.maps.init", category:gmaps.categoryId },
+                  success:
+                    function(msg)
+                    {
+                      gmaps.requestId=msg;
+
+                      if(gmaps.maps[gmaps.currentMapLoadIndex].viewportInitialized==false)
+                      {
+                        /*
+                         * if the container is not visible when map are built, they are
+                         * not initialized correctly
+                         *
+                         * when dialog is opened for the first time, proceed to map
+                         * finalization :
+                         *  - resize
+                         *  - center the map
+                         *  - add handlers on events 'dragend' and 'zoom_change'
+                         *    allowing to reload markers according to the new viewport
+                         */
+                        google.maps.event.trigger(gmaps.maps[gmaps.currentMapLoadIndex].gMap, 'resize');
+
+
+                        if(gmaps.maps[gmaps.currentMapLoadIndex].fitToBounds)
+                        {
+                          gmaps.maps[gmaps.currentMapLoadIndex].gMap.fitBounds(gmaps.bounds);
+                        }
+                        else
+                        {
+                          gmaps.maps[gmaps.currentMapLoadIndex].gMap.setCenter(gmaps.bounds.getCenter());
+                        }
+
+                        // reduce copyright size... ^_^
+                        $('#'+gmaps.maps[gmaps.currentMapLoadIndex].id+' span, #'+gmaps.maps[gmaps.currentMapLoadIndex].id+' a').css('font-size', '55.0%');
+
+                        if(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile!=null)
+                          gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile.setMap(gmaps.maps[gmaps.currentMapLoadIndex].gMap);
+
+                        google.maps.event.addListener(
+                          gmaps.maps[gmaps.currentMapLoadIndex].gMap,
+                          'dragend',
+                          function()
+                          {
+                            loadMarkers(this);
+                            $('#gmapsBoundMap').css('display', 'inline');
+                            $('#gmapsBoundKml').css('display', 'inline');
+                          }
+                        );
+
+                        google.maps.event.addListener(
+                          gmaps.maps[gmaps.currentMapLoadIndex].gMap,
+                          'zoom_changed',
+                          function()
+                          {
+                            loadMarkers(this);
+                            gmaps.infoWindow.close();
+                            $('#gmapsBoundMap').css('display', 'inline');
+                            $('#gmapsBoundKml').css('display', 'inline');
+                          }
+                        );
+
+                        // loads the markers
+                        loadMarkers(gmaps.maps[gmaps.currentMapLoadIndex].gMap);
+                        gmaps.maps[gmaps.currentMapLoadIndex].viewportInitialized=true;
+                      }
+
+                    }
+                }
+              );
+            }
+        }
+      ).data('index', i);
+
+      $('div.gmapsPopup div.ui-dialog-titlebar')
+      .append('<a href="" id="gmapsBoundMap" style="display:none;" onclick="gmaps.maps[gmaps.currentMapLoadIndex].gMap.fitBounds(gmaps.bounds); $(this).css(\'display\', \'none\').blur(); return(false);">'+
+              '<span>&there4;</span></a>');
+      $('#gmapsBoundMap').attr('title', gmaps.lang.boundmap);
+
+      if(gmaps.maps[i].gMap.kmlFile!=null)
+      {
+        $('div.gmapsPopup div.ui-dialog-titlebar')
+          .append('<a href="" id="gmapsBoundKml" onclick="gmaps.maps[gmaps.currentMapLoadIndex].gMap.fitBounds(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile.getDefaultViewport()); $(this).css(\'display\', \'none\').blur(); return(false);">'+
+                  '<span>&sim;</span></a>');
+        $('#gmapsBoundKml').attr('title', gmaps.lang.boundkml);
+      }
+
+
+    }
+
+  }
+);
+
+
Index: extensions/GMaps/js/gmapsPicture.js
===================================================================
--- extensions/GMaps/js/gmapsPicture.js	(revision 7125)
+++ extensions/GMaps/js/gmapsPicture.js	(revision 7125)
@@ -0,0 +1,191 @@
+
+var viewportInitialized = {
+  icon:false,
+  meta:false
+};
+
+function applyMap(properties)
+{
+  var latlng=new google.maps.LatLng(gmaps.coords.latitude, gmaps.coords.longitude);
+
+  var map = new google.maps.Map($("#"+properties.id).get(0),
+    {
+      mapTypeId: properties.mapType,
+      zoom: properties.zoomLevel,
+      center:latlng,
+      navigationControl: (properties.navigationControl==-1)?false:true,
+      scrollwheel: (properties.navigationControl==-1)?false:true,
+      scaleControl: (properties.scaleControl=='n')?false:true,
+      mapTypeControl:(properties.mapTypeControl==-1)?false:true,
+      mapTypeControlOptions:
+        {
+          style:properties.mapTypeControl
+        },
+      markerTitle:'',
+    }
+  );
+
+  if(properties.marker)
+  {
+    var marker = new google.maps.Marker(
+      {
+        position:latlng,
+        map: map,
+        title:properties.markerTitle
+      }
+    );
+  }
+
+  if(properties.kmlFileUrl!='')
+  {
+    kmlFile = new google.maps.KmlLayer(properties.kmlFileUrl,
+      {
+        preserveViewport:true
+      }
+    );
+  }
+  else
+  {
+    kmlFile=null;
+  }
+
+  map.kmlFile=kmlFile;
+
+
+  properties.gMap=map;
+  properties.gMapCenter=latlng;
+}
+
+$(window).load(function ()
+  {
+    gmaps.currentMapLoadIndex=-1;
+
+    for(i=0;i<gmaps.maps.length;i++)
+    {
+      applyMap(gmaps.maps[i]);
+      gmaps.maps[i].gMap.setCenter(gmaps.maps[i].gMapCenter);
+      $('#'+gmaps.maps[i].id+' span, #'+gmaps.maps[i].id+' a').css('font-size', '55.0%');
+
+      if(gmaps.maps[i].gMap.kmlFile!=null)
+        gmaps.maps[i].gMap.kmlFile.setMap(gmaps.maps[i].gMap);
+
+      if(gmaps.maps[i].displayType=='IP')
+      {
+        gmaps.currentMapLoadIndex=i;
+        if(gmaps.maps[i].sizeMode=='A')
+        {
+          $('#iGMapsIcon').css(
+            {
+              width: ($(window).width()*0.8)+'px',
+              height:($(window).height()*0.8)+'px'
+            }
+          );
+        }
+      }
+    }
+
+    /*
+     * this trick is needed for the gally template, because the map initialisation
+     *  don't works if the container is not visible
+     *
+     * for the classic default template, this code is ignored
+     *
+     * >>>
+     */
+    if($('#iGMapContent').length>0)
+    {
+      tabId=$('#iGMapContent').get(0).parentNode.parentNode.id;
+      tabId='tab'+tabId.toUpperCase().substring(0,1)+tabId.substr(1);
+      $("#"+tabId+" a").bind('click', function ()
+       {
+          if(viewportInitialized.meta==false)
+          {
+            for(i=0;i<gmaps.maps.length;i++)
+            {
+              if(gmaps.maps[i].displayType=='MP')
+              {
+                google.maps.event.trigger(gmaps.maps[i].gMap, 'resize');
+                gmaps.maps[i].gMap.setCenter(gmaps.maps[1].gMapCenter);
+                $('#'+gmaps.maps[i].id+' span, #'+gmaps.maps[i].id+' a').css('font-size', '55.0%');
+              }
+            }
+            viewportInitialized.meta=true;
+          }
+       }
+      );
+    }
+    /*
+     * <<<
+     */
+
+
+    /*
+     * manage the popup map
+     */
+    if($('#iGMapsIconContent').length>0)
+    {
+      $('#iGMapsIconContent').dialog(
+        {
+          autoOpen:false,
+          width:'auto',
+          height:'auto',
+          modal: true,
+          closeText:'X',
+          dialogClass: 'gmapsPopup',
+          title: gmaps.maps[gmaps.currentMapLoadIndex].title,
+          open: function ()
+            {
+              if(viewportInitialized.icon==false && gmaps.currentMapLoadIndex!=-1)
+              {
+                google.maps.event.trigger(gmaps.maps[gmaps.currentMapLoadIndex].gMap, 'resize');
+                gmaps.maps[gmaps.currentMapLoadIndex].gMap.setCenter(gmaps.maps[gmaps.currentMapLoadIndex].gMapCenter);
+                $('#iGMapsIcon span, #iGMapsIcon a').css('font-size', '55.0%');
+                if(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile!=null)
+                  gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile.setMap(gmaps.maps[gmaps.currentMapLoadIndex].gMap);
+                viewportInitialized.icon=true;
+              }
+
+              google.maps.event.addListener(
+                gmaps.maps[gmaps.currentMapLoadIndex].gMap,
+                'dragend',
+                function()
+                {
+                  $('#gmapsCenterMap').css('display', 'inline');
+                  $('#gmapsBoundKml').css('display', 'inline');
+                }
+              );
+
+              google.maps.event.addListener(
+                gmaps.maps[gmaps.currentMapLoadIndex].gMap,
+                'zoom_changed',
+                function()
+                {
+                  $('#gmapsCenterMap').css('display', 'inline');
+                  $('#gmapsBoundKml').css('display', 'inline');
+                }
+              );
+            }
+        }
+      );
+
+      $('div.gmapsPopup div.ui-dialog-titlebar')
+      .append('<a href="" id="gmapsCenterMap" style="display:none;" onclick="gmaps.maps[gmaps.currentMapLoadIndex].gMap.setCenter(gmaps.maps[gmaps.currentMapLoadIndex].gMapCenter); $(this).css(\'display\', \'none\').blur(); return(false);">'+
+              '<span>&bull;</span></a>');
+      $('#gmapsCenterMap').attr('title', gmaps.lang.centermap);
+
+      if(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile!=null)
+      {
+        $('div.gmapsPopup div.ui-dialog-titlebar')
+          .append('<a href="" id="gmapsBoundKml" onclick="gmaps.maps[gmaps.currentMapLoadIndex].gMap.fitBounds(gmaps.maps[gmaps.currentMapLoadIndex].gMap.kmlFile.getDefaultViewport()); $(this).css(\'display\', \'none\').blur(); return(false);">'+
+                  '<span>&sim;</span></a>');
+        $('#gmapsBoundKml').attr('title', gmaps.lang.boundkml);
+      }
+
+
+    }
+
+
+  }
+);
+
+
Index: extensions/GMaps/language/fr_FR/plugin.lang.php
===================================================================
--- extensions/GMaps/language/fr_FR/plugin.lang.php	(revision 7054)
+++ extensions/GMaps/language/fr_FR/plugin.lang.php	(revision 7125)
@@ -1,3 +1,9 @@
 <?php
+
+$lang['To install this plugin, you need to install Grum Plugin Classes %s before']="Pour installer ce plugin, vous devez au préalable installer le plugin Grum Plugin Classes %s";
+$lang['To install this plugin, you need to install Advanced Metadata %s before']="Pour installer ce plugin, vous devez au préalable installer le plugin Advanced Metadata %s";
+$lang['gmaps_amd_warning_inactive']="Attention ! <br><br>Le plugin Advanced Metadata %s ne semble pas être installé/activé : les cartes ne pourront être affichées tant qu'il ne sera pas activé.";
+$lang['gmaps_amd_warning_basic']="Attention ! <br><br>Le plugin Advanced Metadata fonctionne en mode 'basique' : les cartes associées aux catégories ne pourront pas être affichées.";
+$lang['gmaps_warning']='Avertissement';
 
 $lang['gmaps_release']='v';
@@ -5,9 +11,14 @@
 $lang['gmaps_geolocation'] = 'Géolocalisation';
 $lang['gmaps_maps'] = 'Cartes';
+$lang['gmaps_map'] = 'Carte';
 $lang['gmaps_associate_category_maps'] = 'Association des cartes';
+$lang['gmaps_search'] = 'Rechercher';
+$lang['gmaps_kml_files_management'] = 'Gestion des fichiers KML';
 $lang['gmaps_help'] = 'Aide';
 
 $lang['gmaps_maps_management']='Gestion des cartes';
 
+$lang['gmaps_y'] = "Oui";
+$lang['gmaps_n'] = "Non";
 $lang['gmaps_ok'] = "Ok";
 $lang['gmaps_cancel'] = "Annuler";
@@ -16,13 +27,11 @@
 $lang['gmaps_loading'] = "Chargement...";
 
-$lang['gmaps_config_map']="Paramétrage d\'une carte";
+$lang['gmaps_config_map']="Paramétrage d\\'une carte";
 $lang['gmaps_pleaseConfirmMetadataDelete_1']="La carte ainsi que toutes les associations qui en dépendent seront supprimées.";
 $lang['gmaps_pleaseConfirmMetadataDelete_2']="Merci de confirmer la suppression.";
+$lang['gmaps_pleaseConfirmAssoc']="Merci de confirmer la suppression.";
 $lang['gmaps_deleteMap']="Suppression de la carte";
-$lang['gmaps_invalidId']="Identifiant invalide !";
-$lang['gmaps_mapIdAlreadyExist']="Une carte avec cet identifiant existe déjà !";
 $lang['gmaps_add_a_new_map']="Ajouter une carte";
 
-$lang['gmaps_id']="Identifiant de la carte";
 $lang['gmaps_name']="Nom";
 $lang['gmaps_dimensions']="Dimensions";
@@ -31,7 +40,19 @@
 $lang['gmaps_width']="Largeur";
 $lang['gmaps_height']="Hauteur";
+$lang['gmaps_auto']="Automatique";
+$lang['gmaps_displayType']="Méthode d'affichage";
 
-$lang['gmaps_fullScreen']="Plein écran";
-$lang['gmaps_zoomAuto']="Automatique";
+$lang['gmaps_displayTypeShortIC']="Catégorie (lightbox)";
+$lang['gmaps_displayTypeShortIP']="Photo (lightbox)";
+$lang['gmaps_displayTypeShortMP']="Photo (métadonnée)";
+$lang['gmaps_displayTypeIC']="A afficher sur la page d'une catégorie (lightbox)";
+$lang['gmaps_displayTypeIP']="A afficher sur la page d'une photo (lightbox)";
+$lang['gmaps_displayTypeMP']="A afficher sur la page d'une photo (en tant que métadonnée)";
+
+$lang['gmaps_map_dimensions_are']="Les dimensions de la carte sont :";
+$lang['gmaps_interface_dimensions_f']="Fixées";
+$lang['gmaps_interface_dimensions_a']="Adaptées à la taille de la fenêtre";
+
+
 $lang['gmaps_googleMapType_hybrid']="Mixte";
 $lang['gmaps_googleMapType_terrain']="Relief";
@@ -65,8 +86,38 @@
 $lang['gmaps_googleMapControlPos_BR']="En bas à droite";
 
-
 $lang['gmaps_properties_general']="Propriétés";
 $lang['gmaps_properties_mapType']="Gestion de l'affichage";
 $lang['gmaps_properties_zoomLevel']="Gestion du zoom";
 
+$lang['gmaps_add_a_new_association']="Ajouter une nouvelle association";
+$lang['gmaps_category']="Catégorie";
+$lang['gmaps_picture']="Photo";
+$lang['gmaps_nb_pictures']="%s photos";
+$lang['gmaps_1_picture']="1 photo";
+$lang['gmaps_apply_subcat']="Appliquer aux sous-catégories";
+$lang['gmaps_map_id']="Carte";
+$lang['gmaps_map_kmlfile']="Présence fichier KML";
+$lang['gmaps_map_icon']="Icone";
+$lang['gmaps_map_kmlfile']="Associer un fichier KML";
+$lang['gmaps_map_associate_kmlfile']="Associer un fichier KML (saisir l'URL)";
+
+$lang['gmaps_map_integration']="Intégration dans la galerie";
+$lang['gmaps_map_assoc']="Caractéristiques";
+
+$lang['gmaps_manage_assoc']="Gestion d\\'une association";
+$lang['gmaps_deleteAssoc']="Suppression d\\'une association";
+
+
+$lang['gmaps_applyForAllTheGallery']="Toute la galerie";
+$lang['gmaps_only_one_map_is_allowed_for_this_mode']="Un paramétrage existe déjà pour cette association";
+$lang['gmaps_view_map']="Localiser la photo sur une carte";
+$lang['gmaps_map_title']="Titre";
+
+
+
+$lang['gmaps_i_boundmap']="Adapter la taille de la carte pour voir tous les éléments";
+$lang['gmaps_i_boundkml']="Adapter la taille de la carte pour voir l\\'intégralité du tracé";
+$lang['gmaps_i_centermap']="Centrer la carte";
+$lang['gmaps_i_show_this_picture_in']="Voir cette photo dans la catégorie :";
+
 ?>
Index: extensions/GMaps/maintain.inc.php
===================================================================
--- extensions/GMaps/maintain.inc.php	(revision 7054)
+++ extensions/GMaps/maintain.inc.php	(revision 7125)
@@ -40,8 +40,16 @@
 }
 
-function gpcMsgError(&$errors)
+function gpcMsgError(&$errors, $errorMessage)
 {
-  global $gpcNeeded;
-  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), GMAPS_GPC_NEEDED);
+  switch($errorMessage)
+  {
+    case 'gpc':
+      $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), GMAPS_GPC_NEEDED);
+      break;
+    case 'amd':
+      $msg=sprintf(l10n('To install this plugin, you need to install Advanced Metadata %s before'), GMAPS_AMD_NEEDED);
+      break;
+  }
+
   if(is_array($errors))
   {
@@ -64,13 +72,17 @@
 {
   global $prefixeTable, $gpcInstalled;
-  if($gpcInstalled)
+  if(!$gpcInstalled)
   {
-    $gmaps=new GMaps_Install($prefixeTable, __FILE__);
-    $result=$gmaps->install();
+    gpcMsgError($errors, 'gpc');
+    return(false);
   }
-  else
+  if(GMaps_root::checkAMDActivated()=='none')
   {
-    gpcMsgError($errors);
+    amdMsgError($errors, 'amd');
+    return(false);
   }
+
+  $gmaps=new GMaps_Install($prefixeTable, __FILE__);
+  $result=$gmaps->install();
 }
 
@@ -107,5 +119,5 @@
   else
   {
-    gpcMsgError($errors);
+    gpcMsgError($errors, 'gpc');
   }
 }
Index: extensions/GMaps/templates/gmaps_category.tpl
===================================================================
--- extensions/GMaps/templates/gmaps_category.tpl	(revision 7125)
+++ extensions/GMaps/templates/gmaps_category.tpl	(revision 7125)
@@ -0,0 +1,36 @@
+{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
+{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"}
+{known_script id="jquery.ui.dialog" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.dialog.packed.js"}
+{known_script id="maps.google.com/api" src="http://maps.google.com/maps/api/js?sensor=false"}
+{known_script id="gmaps.category" src=$ROOT_URL|@cat:"plugins/GMaps/js/gmapsCategory.js"}
+
+{foreach from=$maps item=map}
+  <div id='iGMapsIconContent' style='display:none;'>
+      <div id='iGMapsIcon' style='width:{$map.width}px;height:{$map.height}px;{$map.style}'></div>
+  </div>
+{/foreach}
+
+
+<div id='iGMapsInfoWindow' style='display:none;'>
+  <div id='iGMapsInfoWindowContent'>
+    <div id='iGMIWC_title'>Titre de la photo</div>
+
+    <table id='iGMIWC_thumb'>
+      <tr>
+        <td style='width:28px;'><div id='iWALeft' onclick='displayPicturePrev();'></div></td>
+        <td>
+          <img id='iGMIWC_img' src=''>
+        </td>
+        <td style='width:28px;'><div id='iWARight' onclick='displayPictureNext();'></div></td>
+      </tr>
+    </table>
+
+    <div id='iGMIWC_picnum'>0/0 photo</div>
+
+    <div id='iGMIWC_showcat' style='display:none;'>
+      <span>{'gmaps_i_show_this_picture_in'|@translate}</span>
+      <ul id='iGMIWC_showcatList'>
+      </ul>
+    </div>
+  </div>
+</div>
Index: extensions/GMaps/templates/gmaps_category_iconbutton.tpl
===================================================================
--- extensions/GMaps/templates/gmaps_category_iconbutton.tpl	(revision 7125)
+++ extensions/GMaps/templates/gmaps_category_iconbutton.tpl	(revision 7125)
@@ -0,0 +1,9 @@
+<li><a id="icon_gmaps"
+   class="button {if $mapIcon.width!=-1 and $mapIcon.height!=-1}size{$mapIcon.width}x{$mapIcon.height}{/if}"
+   {if $mapIcon.iconStyle}
+   style="display:inline-block;background:url({$mapIcon.file});{if $mapIcon.width!=-1}width:{$mapIcon.width}px;{/if}{if $mapIcon.height!=-1}height:{$mapIcon.height}px;{/if}"
+   {/if}
+   title="{'gmaps_view_map'|@translate}"
+   href=''
+   onclick='$("#iGMapsIconContent").dialog("open"); return(false);'></a>
+</li>
Index: extensions/GMaps/templates/gmaps_picture_icon.tpl
===================================================================
--- extensions/GMaps/templates/gmaps_picture_icon.tpl	(revision 7125)
+++ extensions/GMaps/templates/gmaps_picture_icon.tpl	(revision 7125)
@@ -0,0 +1,9 @@
+{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
+{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"}
+{known_script id="jquery.ui.dialog" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.dialog.packed.js"}
+{known_script id="maps.google.com/api" src="http://maps.google.com/maps/api/js?sensor=false"}
+{known_script id="gmaps.picture" src=$ROOT_URL|@cat:"plugins/GMaps/js/gmapsPicture.js"}
+
+<div id='iGMapsIconContent' style='display:none;'>
+    <div id='iGMapsIcon' style='width:{$map.width}px;height:{$map.height}px;{$map.style}'></div>
+</div>
Index: extensions/GMaps/templates/gmaps_picture_iconbutton.tpl
===================================================================
--- extensions/GMaps/templates/gmaps_picture_iconbutton.tpl	(revision 7125)
+++ extensions/GMaps/templates/gmaps_picture_iconbutton.tpl	(revision 7125)
@@ -0,0 +1,8 @@
+<a id="icon_gmaps"
+   class="button {if $mapIcon.width!=-1 and $mapIcon.height!=-1}size{$mapIcon.width}x{$mapIcon.height}{/if}"
+   {if $mapIcon.iconStyle}
+   style="display:inline-block;background:url({$mapIcon.file});{if $mapIcon.width!=-1}width:{$mapIcon.width}px;{/if}{if $mapIcon.height!=-1}height:{$mapIcon.height}px;{/if}"
+   {/if}
+   title="{'gmaps_view_map'|@translate}"
+   href=''
+   onclick='$("#iGMapsIconContent").dialog("open"); return(false);'></a>
Index: extensions/GMaps/templates/gmaps_picture_meta.tpl
===================================================================
--- extensions/GMaps/templates/gmaps_picture_meta.tpl	(revision 7125)
+++ extensions/GMaps/templates/gmaps_picture_meta.tpl	(revision 7125)
@@ -0,0 +1,9 @@
+{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
+{known_script id="maps.google.com/api" src="http://maps.google.com/maps/api/js?sensor=false"}
+{known_script id="gmaps.picture" src=$ROOT_URL|@cat:"plugins/GMaps/js/gmapsPicture.js"}
+
+<div id='iGMapContent' style='text-align:center;'>
+  {foreach from=$maps item=map}
+    <div id='iGMaps{$map.id}' style='width:{$map.width}px;height:{$map.height}px;display:inline-block;{$map.style}'></div>
+  {/foreach}
+</div>
