function KickerPages() { this.value = 0; } var mySlide = new Array( 'http://c.americanapparel.net/storefront/headers/men/collaredshirts/1.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/11.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/2.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/29.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/410men-collaredshirts1.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/410men-collaredshirts2.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/410men-collaredshirts20.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/410men-collaredshirts29.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/collaredshirts1_410.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/collaredshirts_410.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/flannel.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/men-collaredshirts2.jpg' ,'http://c.americanapparel.net/storefront/headers/men/collaredshirts/men-collaredshirts3.jpg' ); var myInterval = 0; var myIntervalPause = 0; var myTimeout = 0; var myAPI; function ScrollThroughmyPages(){ myAPI.next(500); RestartmyInterval(); } function AutoScroll() { randArray(mySlide); for(var x = 0; x < mySlide.length; x++) if (x <=0) document.getElementById('myItems').innerHTML += ''; else document.getElementById('myItems').innerHTML += ''; $(function() { $("#myScrollable").myScrollable({horizontal:true}); }); if (document.getElementById('myScrollable') != null) { myAPI = $("#myScrollable").myScrollable(); myTotal = myAPI.getStatus().total; if (myTotal <= 1) { $('DIV.myNext').hide(); $('DIV.myPrev').hide(); } RestartmyInterval(); } } function RestartmyInterval() { LoadImgs(); myPause = 5000; CancelmyInterval(); myInterval = setInterval('ScrollThroughmyPages()',myPause); } function PausemyInterval(){ LoadImgs(); CancelmyInterval(); clearTimeout(myTimeout); myTimeout = setTimeout('RestartmyInterval()',5000); } function CancelmyInterval(){ LoadImgs(); clearInterval(myInterval); } function LoadImgs(){ myIndex = myAPI.getStatus().index; LoadImg(myIndex - 1); LoadImg(myIndex); LoadImg(myIndex + 1); } function LoadImg(index){ Item = document.getElementById('myItem' + index); if ( Item != null ){ if (mySlide[index] != null && Item.src != mySlide[index]) { Item.src = mySlide[index]; } } } function randArray(o){ for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); return o; } window.onload=AutoScroll;