function Slideshow(idx) {  this.slides = new Array; this.curIdx = -1; this.isA = true; this.idx = idx; }Slideshow.prototype = { constructor : Slideshow, addSlide : function(img, caption) {  this.slides.push( {  src : 'url(' + img + ')', 'caption' : caption }); }, start : function() {  var a = document.getElementById('slideshow_body_a' + this.idx); var b = document.getElementById('slideshow_body_b' + this.idx); var self = this; var imgA = this.getNextImage(); var imgB = this.getNextImage(); a.style.backgroundImage = imgA.src; b.style.backgroundImage = imgB.src; $('./p', a).setInnerHTML(imgA.caption); $('./p', b).setInnerHTML(imgB.caption); setTimeout(function() {  self.animate(); }, 5000); }, animate : function() {  var self = this; if(this.isA) {  $('id("slideshow_body_a' + this.idx + '")').fadeOut(2000).each( function(node) {  var img = self.getNextImage(); node.style.backgroundImage = img.src; $('./p', node).setInnerHTML(img.caption); }); $('id("slideshow_body_b' + this.idx + '")').fadeIn(2000); } else {  $('id("slideshow_body_b' + this.idx + '")').fadeOut(2000).each( function(node) {  var img = self.getNextImage(); node.style.backgroundImage = img.src; $('./p', node).setInnerHTML(img.caption); }); $('id("slideshow_body_a' + this.idx + '")').fadeIn(2000); } this.isA = !this.isA; setTimeout(function() {  self.animate(); }, 10000); }, getNextImage : function() {  if(++this.curIdx == this.slides.length) this.curIdx = 0; return this.slides[this.curIdx]; }};