var RateTimer = new Object();

RateTimer.timer = null;
RateTimer.pointer = 1;
RateTimer.items = new Array();
RateTimer.buttons = new Array();

RateTimer.init = function() {
	 for(var i=0; i < this.buttons.length; i++) {
	 	$("#"+this.buttons[i]+" > a").mouseenter(function(){
	 		RateTimer.stop(); 
			for(var j=0; j < RateTimer.items.length; j++) {
				$("#"+RateTimer.items[j]).hide();
				$("#"+RateTimer.buttons[j]+" a").removeClass("active");
			}
			$(this).parent().next().show();
			$(this).addClass("active");
	 	});
	 	
	 	$("#"+this.buttons[i]+" > a").mouseleave(function(){
	 		RateTimer.start();
	 	});
	 }
	 RateTimer.start();
}

RateTimer.start = function() {	 
	 this.timer = window.setInterval("RateTimer.switchItem()",8000);
}

RateTimer.stop = function() {
    if(this.timer != null) {
        window.clearInterval(this.timer);
    }
    this.timer = null;
}

RateTimer.switchItem = function() {
	for(var i=0; i < this.items.length; i++) {
		
		$("#"+this.items[i]+"").hide();
		$("#"+this.buttons[i]+" a").removeClass("active");
	}
	$("#"+this.items[this.pointer]+"").fadeIn("slow");
	$("#"+this.buttons[this.pointer]+" a").addClass("active");
	
	this.pointer = (this.pointer+1)%this.items.length;
}

RateTimer.add = function(item,button) {
	this.items[this.items.length] = item;
	this.buttons[this.buttons.length] = button;
}