<script language="javascript" src="../plugins/balanced/scripts.js"></script> 
 <script language="javascript">
-        window.onload = function(event) {
-                applyOptimalImagesSize();
+        var thumbsize = <?php echo THUMB_SIZE ?>;
+       window.onload = function(event) {
+                applyOptimalImagesSize(thumbsize);
         }
         window.onresize = function(event) {
-                applyOptimalImagesSize();
+                applyOptimalImagesSize(thumbsize);
         }
 </script>
 
-function applyOptimalImagesSize()\r
+/*Copyright (C) 2013  Baptiste Clement\r
+\r
+This program is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 3 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+*/\r
+\r
+function applyOptimalImagesSize(bestHeight)\r
 {\r
-       var divimages = document.getElementsByClassName("image");\r
+       var divimages = document.getElementsByClassName("image imagepreview");\r
        var images = new Array();\r
        for(var i = 0 ; i < divimages.length ; ++i)\r
        {\r
                images.push(divimages[i].children[0].children[0]);\r
        }\r
-       var bestHeight = parseInt(document.getElementById("thumbsize").textContent);\r
        var newHList = getOptimalHeights(images, bestHeight);\r
        for( var i = 0 ; i < images.length ; ++i)\r
        {\r
        return sizes;\r
 }\r
 \r
-\r
-\r
-\r
 //Renvoi un tableau de tableau, correspondant au découpage du tableau d'entrée découpé par tranche de MAX\r
 function splitTab(tab, max)\r
 {\r