function Fader(id){
this.id=id;
this.images=document.getElementById(id).getElementsByTagName("span");
this.counter=0;
this.images[0].style.opacity="100";
this.images[0].style.filter="alpha(opacity=100)";
this.images[0].style.display="block";
this.fade=function(step){
var fader=this;
step=step || 0;
var t=this.images[this.counter];
t.style.display="block";
t.style.opacity=step/100;
t.style.filter="alpha(opacity="+step+")";
step=step+1;
if(step<=100) window.setTimeout(function(){fader.fade(step);},1);
else window.setTimeout(function(){fader.next();},3000);
};
this.next=function (){
this.counter++;
var i=this.images;
if(!(this.counter<i.length)){
if((this.images.length-2)>0){
i[i.length-2].style.opacity="0";
i[i.length-2].style.filter="alpha(opacity=0)";
i[i.length-2].style.display="none";
}
if((i.length-1)>0) {
i[i.length-1].style.opacity="0";
i[i.length-1].style.filter="alpha(opacity=0)";
i[i.length-1].style.display="none";
}
this.counter=0;
this.fade();
}
else if(this.counter<i.length){
if(this.counter>1){
if((this.counter+2)>0){
i[this.counter-2].style.opacity="0";
i[this.counter-2].style.filter="alpha(opacity=0)";
i[this.counter-2].style.display="none";
}
}
this.fade();
}
};
}
