var galleryarray=new Array();var gallerywidths=new Array();galleryarray[0]="useruploads/images/scroller/an_australian_family_portrait_roller.jpg";gallerywidths[0]="166";galleryarray[1]="useruploads/images/scroller/bjumperroller.jpg";gallerywidths[1]="215";galleryarray[2]="useruploads/images/scroller/fashionroller.jpg";gallerywidths[2]="167";galleryarray[3]="useruploads/images/scroller/margarets_painting_roller.jpg";gallerywidths[3]="293";galleryarray[4]="useruploads/images/scroller/myerroller.jpg";gallerywidths[4]="146";galleryarray[5]="useruploads/images/scroller/nmartyroller.jpg";gallerywidths[5]="293";galleryarray[6]="useruploads/images/scroller/pirofamilyroller.jpg";gallerywidths[6]="164";galleryarray[7]="useruploads/images/scroller/pomiesroller.jpg";gallerywidths[7]="281";galleryarray[8]="useruploads/images/scroller/roosterroller.jpg";gallerywidths[8]="294"; $('.frame').empty(); $('#main-section').css('width','100%'); //setup var current = 0; var Interval; for(image in galleryarray) { $('.frame').append(""); //insert image $('.image').last().css({'left': current,'position':'absolute'}); //set position current = current + parseInt(gallerywidths[image]); //increment position } var length = current; function animate(){ for(image in galleryarray){ //get left var left = parseInt($('.image').eq(image).css('left')); //get width var width = parseInt(gallerywidths[image]); if(left == -(width)){ left = length - width; } left = left - 1; //set new left $('.image').eq(image).css('left',left); } } $('.frame').after(""); $(function() {//dom ready var speed = 50; //animate(); Interval = setInterval(" animate()", speed) $('#ff').mouseover(function(){ window.clearInterval(Interval); Interval = setInterval(" animate()", 10) }); $('#ff').mouseout(function(){ window.clearInterval(Interval); Interval = setInterval(" animate()", speed) }); })