function displayItem($data, $config)
 {
     global $CFG_GLPI;
     $itemtype = $data['itemtype'];
     $itemtype2 = '';
     if ($itemtype == 'host' || $itemtype == 'service') {
         $itemtype2 = $itemtype;
         $itemtype = 'PluginMonitoringDisplayview';
     }
     $item = new $itemtype();
     $content = '';
     $title = $item->getTypeName();
     $event = '';
     $width = '';
     if ($itemtype == "PluginMonitoringService") {
         $content = $item->showWidget($data['items_id'], $data['extra_infos']);
         if (!isset($item->fields['plugin_monitoring_components_id'])) {
             return false;
         }
         $title .= " : <a href=\"" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display.form.php?itemtype=PluginMonitoringService&items_id=" . $data['items_id'] . "\">" . Dropdown::getDropdownName(getTableForItemType('PluginMonitoringComponent'), $item->fields['plugin_monitoring_components_id']);
         $title .= '</a> ' . __('on', 'monitoring') . ' ';
         $pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host();
         $pmComponentscatalog_Host->getFromDB($item->fields["plugin_monitoring_componentscatalogs_hosts_id"]);
         if (isset($pmComponentscatalog_Host->fields['itemtype']) and $pmComponentscatalog_Host->fields['itemtype'] != '') {
             $itemtype2 = $pmComponentscatalog_Host->fields['itemtype'];
             $item2 = new $itemtype2();
             $item2->getFromDB($pmComponentscatalog_Host->fields['items_id']);
             $title .= str_replace("'", "\"", $item2->getLink() . " (" . $item2->getTypeName() . " / " . $data['extra_infos'] . ")");
         }
         $width = "width: 475,";
     } else {
         if ($itemtype == "PluginMonitoringWeathermap") {
             $content = $item->showWidget($data['items_id'], $data['extra_infos']);
             $content = '<div id="weathermap-' . $data['items_id'] . '">' . $content . "</div>";
             $event = ", " . $item->widgetEvent($data['items_id']);
             $title .= " : " . Dropdown::getDropdownName(getTableForItemType('PluginMonitoringWeathermap'), $data['items_id']);
             $item->getFromDB($data['items_id']);
             $width = "width:" . $item->fields['width'] * $data['extra_infos'] / 100 . ",";
         } else {
             if ($itemtype2 != '') {
                 $content = $item->showWidget2($data['id']);
             } else {
                 $content = $item->showWidget($data['items_id']);
             }
             if ($data['itemtype'] == 'PluginMonitoringServicescatalog') {
                 $width = "width: 202,";
             } else {
                 $width = "width: 180,";
             }
         }
     }
     if ($config == 0 && $itemtype != "PluginMonitoringService") {
         $title = '';
     }
     echo "<script>\n         var left = 0;\n         var topd = 0;\n         var obj = document.getElementById('panel');\n         if (obj.offsetParent) {\n           do {\n             left += obj.offsetLeft;\n             topd += obj.offsetTop;\n           } while (obj = obj.offsetParent);\n         }\n\n        var item" . $data['id'] . " = new Ext.Panel({\n             closable: true,           \n             title: '" . $title . "',\n             x: " . $data['x'] . ",\n             y: " . $data['y'] . ",\n             html       : '" . $content . "',\n             baseCls : 'x-panel',\n             layout : 'fit',\n             bodyStyle: 'background:transparent',\n             ";
     if ($config == 0 && $itemtype != "PluginMonitoringService") {
         echo "border: false,";
     }
     echo "renderTo: Ext.getBody(),\n             floating: false,\n             frame: false,\n             " . $width . "\n             autoHeight  : true,\n             layout: 'fit',\n             draggable: {\n                 //Config option of Ext.Panel.DD class.\n                 //It's a floating Panel, so do not show a placeholder proxy in the original position.\n                 insertProxy: false,\n\n                 //Called for each mousemove event while dragging the DD object.\n                 onDrag : function(e){\n                     //Record the x,y position of the drag proxy so that we can\n                     //position the Panel at end of drag.\n                     var el = this.proxy.getEl();\n                     this.x = el.getLeft(true) - left - 5;\n                     this.y = el.getTop(true) - topd - 5;\n\n\n                     //Keep the Shadow aligned if there is one.\n                     var s = this.panel.getEl().shadow;\n                     if (s) {\n                         s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());\n                     }\n                 },\n\n                 //Called on the mouseup event.\n                 endDrag : function(e){\n                     this.panel.setPosition(this.x, this.y);\n";
     if ($config == '1') {
         echo "      Ext.get('updatecoordonates').load({\n                        url: '" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/ajax/displayview_itemcoordinates.php',\n                        scripts: true,\n                        params:'id=" . $data['id'] . "&x=' + (this.x)  + '&y=' + (this.y)\n                     });\n";
         echo "      if (this.x < 1) {\n                        this.panel.destroy();\n                     }\n                     if (this.y < 0) {\n                        this.panel.destroy();\n                     }\n            \n            ";
     }
     echo "      }\n             }\n             " . $event . "\n         });\n     </script>";
     //.show()
     if ($itemtype == "PluginMonitoringService") {
         $pmComponent = new PluginMonitoringComponent();
         $item = new $itemtype();
         $item->getFromDB($data['items_id']);
         $pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']);
         $pmServicegraph = new PluginMonitoringServicegraph();
         $pmServicegraph->displayGraph($pmComponent->fields['graph_template'], "PluginMonitoringService", $data['items_id'], "0", $data['extra_infos'], "js");
     } else {
         if ($itemtype == "PluginMonitoringComponentscatalog") {
             $pmComponentscatalog = new PluginMonitoringComponentscatalog();
             $pmComponentscatalog->ajaxLoad($data['items_id']);
         } else {
             if ($itemtype == "PluginMonitoringServicescatalog") {
                 $pmServicescatalog = new PluginMonitoringServicescatalog();
                 $pmServicescatalog->ajaxLoad($data['items_id']);
             } else {
                 if ($itemtype2 != '') {
                     $pmDisplayview = new PluginMonitoringDisplayview();
                     $pmDisplayview->ajaxLoad2($data['id']);
                 } else {
                     if ($itemtype == "PluginMonitoringDisplayview") {
                         $pmDisplayview = new PluginMonitoringDisplayview();
                         $pmDisplayview->ajaxLoad($data['items_id']);
                     }
                 }
             }
         }
     }
     if ($itemtype == "PluginMonitoringWeathermap") {
         //         echo "<script type='text/javascript'>
         //            function updateimagew".$data['items_id']."() {
         //               var demain=new Date();
         //               document.getElementById('weathermap-".$data['items_id']."').innerHTML = demain.getTime() + '".$content."';
         //            }
         //            setInterval(updateimagew".$data['items_id'].", 50000);
         //         </script>";
         //      }
         echo "<script type='text/javascript'>\n         var mgr = new Ext.UpdateManager('weathermap-" . $data['items_id'] . "');\n         mgr.startAutoRefresh(50, \"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/widgetWeathermap.php\", \"id=" . $data['items_id'] . "&extra_infos=" . $data['extra_infos'] . "\", \"\", true);\n         </script>";
     }
     return true;
 }
   function slideSlider($id) {
      global $CFG_GLPI, $DB;

      echo "<script type='text/javascript'>
         function fittext(itemid) {
            document.getElementById(itemid).style.fontSize = '50px';
            var fontsize = 50;
            while(document.getElementById(itemid).offsetWidth > 120) {
               fontsize--;
               if (fontsize > 20) {
                  fontsize--;
               }
               document.getElementById(itemid).style.fontSize = fontsize + 'px';
            }
            while(document.getElementById(itemid).offsetHeight > 67) {
               fontsize--;
               document.getElementById(itemid).style.fontSize = fontsize + 'px';
            }
            if (fontsize > 30) {
               document.getElementById(itemid).style.fontSize = '30px';
            }
            if (fontsize < 7) {
               document.getElementById(itemid).style.fontSize = '7px';
            }
         }
      </script>";
      PluginMonitoringToolbox::loadLib();

      $this->getFromDB($id);
      echo '<div id="custom_date" style="display:none"></div>';
      echo '<div id="custom_time" style="display:none"></div>';

      echo '<script src="'.$CFG_GLPI["root_doc"].'/plugins/monitoring/lib/slider.js-14/js/jssor.slider.mini.js"></script>
<script>
    jQuery(document).ready(function ($) {
        //Define an array of slideshow transition code
        var _SlideshowTransitions = [
        {$Duration:0001,$Opacity:2}
        ];
        var options = {
            $AutoPlay: true,
            $AutoPlayInterval: '.$this->fields['duration'].'000,
            $SlideshowOptions: {
                    $Class: $JssorSlideshowRunner$,
                    $Transitions: _SlideshowTransitions,
                    $TransitionsOrder: 1,
                    $ShowLink: true
        }
        };
        var jssor_slider1 = new $JssorSlider$(\'slider1_container\', options);
    });
</script>';
      echo "<table class='tab_cadre'>";

      echo "<tr>";
      echo "<td>";

      $query = "SELECT * FROM `glpi_plugin_monitoring_sliders_items`
              WHERE `plugin_monitoring_sliders_id`='".$id."'";

      $result = $DB->query($query);
      $maxWidth = 0;
      $maxHeight = 0;
      $is_minemap = 0;
      while ($data=$DB->fetch_array($result)) {
         if ($data['itemtype'] == 'PluginMonitoringServicescatalog'
                 || $data['itemtype'] == 'PluginMonitoringComponentscatalog'
                 || $data['itemtype'] == 'PluginMonitoringCustomitem_Gauge'
                 || $data['itemtype'] == 'PluginMonitoringCustomitem_Counter') {
            if ($maxWidth < 180) {
               $maxWidth = 180;
            }
            if ($maxHeight < 180) {
               $maxHeight = 180;
            }
            if ($data['is_minemap'] == 1) {
               $is_minemap = 1;
            }
         } else if ($data['itemtype'] == 'PluginMonitoringService') {
            if ($maxWidth < 475) {
               $maxWidth = 475;
            }
            if ($maxHeight < 330) {
               $maxHeight = 330;
            }
         } else if ($data['itemtype'] == "PluginMapsMap") {
            if ($maxWidth < 950) {
               $maxWidth = 950;
            }
            if ($maxHeight < 800) {
               $maxHeight = 800;
            }
         } else {
            $itemtype = $data['itemtype'];
            $item = new $itemtype();
            $item->getFromDB($data['items_id']);
            if ($maxWidth < $item->fields['width']) {
               $maxWidth = $item->fields['width'];
            }
            if (isset($item->fields['height'])) {
               if ($maxHeight < $item->fields['width']) {
                  $maxHeight = $item->fields['height'];
               }
            }
         }
      }
      if ($is_minemap) {
         $maxHeight = '1500';
      }

      $pm = new PluginMonitoringComponentscatalog();
      echo '<div id="slider1_container" style="position: relative;
top: 0px; left: 0px; width: '.$maxWidth.'px; height: '.$maxHeight.'px;">
    <!-- Slides Container -->
    <div u="slides" style="cursor: move; position: absolute; overflow: hidden;
    left: 0px; top: 0px; width: '.$maxWidth.'px; height: '.$maxHeight.'px;">';

      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $itemtype = $data['itemtype'];
         $item = new $itemtype();
         if ($itemtype == "PluginMonitoringService") {
            echo '<div>';
            echo $item->showWidget($data['items_id'], $data['extra_infos']);
            echo '</div>';
         } else if ($itemtype == "PluginMonitoringWeathermap") {
            echo '<div>';
            echo '<div id="weathermap-'.$data['items_id'].'"></div>';
            echo '</div>';
         } else if ($itemtype == 'PluginMonitoringDisplayview') {
            echo '<div>';
            $pmDisplayview_item = new PluginMonitoringDisplayview_item();
            echo $pmDisplayview_item->view($data['items_id']);
            echo '</div>';
         } else if ($itemtype == "PluginMapsMap") {
            echo '<div>';
            echo '<div id="pluginmap"></div>';
            echo '</div>';
         } else {
            echo '<div>';
            echo $item->showWidget($data['items_id']);
            echo '</div>';
         }

      }
echo '    </div>
</div>';
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $itemtype = $data['itemtype'];
         $item = new $itemtype();
         // Ajax
         if ($itemtype == "PluginMonitoringService") {
            $pmComponent = new PluginMonitoringComponent();
            $item = new $itemtype();

            $item->getFromDB($data['items_id']);
            $pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']);
            $pmServicegraph = new PluginMonitoringServicegraph();
            $pmServicegraph->displayGraph($pmComponent->fields['graph_template'],
                                          "PluginMonitoringService",
                                          $data['items_id'],
                                          "0",
                                          $data['extra_infos'],
                                          "js");
         } else if($itemtype == "PluginMonitoringComponentscatalog") {
            $pmComponentscatalog = new PluginMonitoringComponentscatalog();
            $pmComponentscatalog->ajaxLoad($data['items_id'], $data['is_minemap']);
         } else if($itemtype == "PluginMonitoringServicescatalog") {
            $pmServicescatalog = new PluginMonitoringServicescatalog();
            $pmServicescatalog->ajaxLoad($data['items_id']);
         } else if($itemtype == "PluginMonitoringDisplayview") {

         } else if($itemtype == "PluginMonitoringCustomitem_Gauge") {
            $pmCustomitem_Gauge = new PluginMonitoringCustomitem_Gauge();
            $pmCustomitem_Gauge->ajaxLoad($data['items_id']);
         } else if($itemtype == "PluginMonitoringCustomitem_Counter") {
            $pmCustomitem_Counter = new PluginMonitoringCustomitem_Counter();
            $pmCustomitem_Counter->ajaxLoad($data['items_id']);
         }
         if ($itemtype == "PluginMonitoringWeathermap") {
            $sess_id = session_id();
            PluginMonitoringSecurity::updateSession();

            echo "<script type='text/javascript'>
            var mgr = new Ext.UpdateManager('weathermap-".$data['items_id']."');
            mgr.startAutoRefresh(50, \"".$CFG_GLPI["root_doc"].
                    "/plugins/monitoring/ajax/widgetWeathermap.php\","
                    . " \"id=".$data['items_id']."&extra_infos=".
                    $data['extra_infos']."&sess_id=".$sess_id.
                    "&glpiID=".$_SESSION['glpiID'].
                    "&plugin_monitoring_securekey=".$_SESSION['plugin_monitoring_securekey'].
                    "\", \"\", true);
            </script>";
         }
         if ($itemtype == "PluginMapsMap") {
            $sess_id = session_id();
            PluginMonitoringSecurity::updateSession();

            echo "<script type='text/javascript'>
            var mgr = new Ext.UpdateManager('pluginmap');
            mgr.startAutoRefresh(50, \"".$CFG_GLPI["root_doc"].
                    "/plugins/monitoring/ajax/widgetPluginmap.php\","
                    . " \"extra_infos=".
                    $data['extra_infos']."&sess_id=".$sess_id.
                    "&glpiID=".$_SESSION['glpiID'].
                    "&plugin_monitoring_securekey=".$_SESSION['plugin_monitoring_securekey'].
                    "\", \"\", true);
            </script>";
         }
      }
      echo "</td>";
      echo "</tr>";
      echo "</table>";
   }