Simple fading slideshow hogging cpu
I've got a fairly simple slideshow object which takes an array of images and rotates through them, with a fade between each picture. But it seems to use a fair amount of cpu, especially on IE, a little less so on firefox. Any ideas on how to optimise this? Is the object too self-referencial? Are the function calls maybe too static?
Cheers
function picSlideShow(elementID, picArray)
{
var self=this;
this.id = elementID;
this.picArray = picArray;
this.pointer=0;
this.fadeOutPeriod=500;
this.fadeInPeriod=500;
this.holdPeriod=3500;
this.length=picArray.length;
this.waitBeforeFadeOut=function(){window.setTimeout(function(){self.runSlideShow()},this.holdPeriod);}
this.runSlideShow=function(){$('#'+this.id).fadeOut(this.fadeOutPeriod, function(){self.nextPic();});}
this.nextPic=function()
{
this.pointer++;
if(this.pointer>=this.length)this.pointer=0;
$('#'+this.id).attr('src',this.picArray[this.pointer]);
$('#'+this.id).fadeIn(this.fadeInPeriod,function(){self.waitBeforeFadeOut();})
}
for(a=1,b=picArray.length; a<b; a++) {preloadImage(this.picArray[a]);}
}
$(document).ready(function(){
slide = new picSlideShow('slideshow1',new Array("/images/dailydeal/weeklydeals_mop_margin.jpg","/images/dailydeal/weeklydeals_teasmade_margin.jpg"))
slide.waitBeforeFadeOut();
});