function ImageListSelection(position,count) { count = "number" == typeof count ? count : window.g_Gallery.pageCount; var selection = window.curGallery.imageList.slice(position,position+count); window.curGallery.container.list.innerHTML = ""; selection.forEach( function (e,i) { var element = elementPlace("#ImageList",e,"thumbnail","li"); element.innerHTML = e; element.style.backgroundImage = "url("+window.api_url+"?i!"+e+"!"+window.curGallery.Name+"!thumb)"; element.style.backgroundRepeat = "no-repeat"; element.style.backgroundPosition = "center center"; element.onclick = function () { initImage(window.curGallery.Position+i,window.curGallery.Name); }; element.innerHTML = e; }); }