window.ImgFlipper=function(img_id) {
    this.img_id=img_id;
    this.frames=[];
    this.current=0;
}
window.ImgFlipper.prototype.add=function(url) {
    this.frames.push(url);
}
window.ImgFlipper.prototype.flip=function() {
    if (this.frames.length>1) {
       this.current=(this.current+1)%this.frames.length;
       document.getElementById(this.img_id).src=this.frames[this.current];
    }
}

window.img_flippers={}

window.addFlip=function(img_id,url) {
    flipper=window.img_flippers[img_id];
    if (typeof(flipper)=='undefined') {
        flipper=new ImgFlipper(img_id);
        window.img_flippers[img_id]=flipper
    }
    flipper.add(url);
}
window.doFlip=function() {
    for (f in window.img_flippers) {
        window.img_flippers[f].flip()
    }
    setTimeout('window.doFlip()',2000);
}
