var itemsPerPage = 9, ci = itemsPerPage-1, total = 0, minLeft =0, maxLeft = 0, left = 0, speed = 5000; var obj, s, w, st, items; function ShowImages(){ slideInit(); } function slideInit(){ obj = jQuery('#showImageItems'); items = jQuery('#showImageItems > .Item'); total = s = items.length; w = jQuery('.Item').width(); if (total > itemsPerPage){ // Reset width for slider obj.css('width',w*s+'px'); // Set margin left min when click next button minLeft = -w*itemsPerPage*(total%itemsPerPage==0?parseInt(total/itemsPerPage):parseInt(total/itemsPerPage)+1); maxLeft = -w*itemsPerPage; // Set slide continuos jQuery(obj).append(jQuery('#showImageItems div.Item:lt('+(itemsPerPage-s%itemsPerPage)+')').clone()); for(var i=0;i total-1) curInd = 0; obj.append(items.eq(curInd).clone()); } obj.css('margin-left',left+(w*itemsPerPage)+'px'); if(ci>total) ci=ci%total; } } function adjustPrev(){ ci-=itemsPerPage; if(left==0){ jQuery('#showImageItems div.Item:gt('+(s-itemsPerPage-1)+')').remove(); var curInd = ci - itemsPerPage; if(curInd < 0) curInd = total + curInd; for(var i=0;i