Event.observe(window,"load",initializeLogoRotation,false);
function initializeLogoRotation(){
logo_rotator=new imageRotator();
Event.observe(logo_rotator.element,"mouseover",function(e){
logo_rotator.start();
},false);
Event.observe(logo_rotator.element,"mouseout",function(e){
logo_rotator.stop();
},false);
logo_rotator.rotateForInterval(logo_rotator.auto_rotation_length);
}
function imageRotator(){
this.current=2;
this.min=0;
this.max=15;
this.per_row=4;
this.w=45;
this.h=45;
this.interval=100;
this.auto_rotation_length=1000;
this.varname="logo_rotator";
this.element=$("xlogo");
this.interval_id=false;
this.timeout_id=false;
this.x=0;
this.y=0;
}
imageRotator.prototype.rotate=function(){
this.current=this.pickRandom();
this.row=Math.floor(this.current/this.per_row);
this.col=this.current%this.per_row;
this.x=this.col*this.w;
this.y=this.row*this.h;
Element.setStyle(this.element,{backgroundPosition:"-"+this.x+"px -"+this.y+"px"});
};
imageRotator.prototype.start=function(){
clearTimeout(this.timeout_id);
interval_code=this.varname+".rotateForInterval("+this.auto_rotation_length+")";
this.interval_id=window.setInterval(interval_code,this.interval);
};
imageRotator.prototype.stop=function(){
window.clearInterval(this.interval_id);
};
imageRotator.prototype.rotateForInterval=function(_3){
clearTimeout(this.timeout_id);
if(_3<0){
return;
}
this.rotate();
interval_code=this.varname+".rotateForInterval("+(_3-this.interval)+")";
this.timeout_id=window.setTimeout(interval_code,this.interval);
};
imageRotator.prototype.pickRandom=function(){
next_logo=this.current;
while(next_logo==this.current){
next_logo=Math.floor(Math.random()*(this.max+1));
}
return next_logo;
};

