var BlogScroller = {
timer   : 4, // second
display : 1000,  // how many items displayed
interval: null,
animation: 1000, //milisecond

init: function() {
	if (!BlogScroller.interval) {
		$("#blog_scroller .wrapper").mouseover(function(){
			BlogScroller.stopScroll();
		}).mouseout(function(){
			BlogScroller.startScroll();
		})
		BlogScroller.RatingUpdate();
		BlogScroller.startScroll();
	}
},

RatingUpdate: function(){
		$(".wrapper .headline:first").addClass("next");
		var blog_item  = $(".wrapper .next");
		var h = blog_item.height();
		blog_item.animate( { marginTop: -h, opacity: 0.4 }, BlogScroller.animation, function() {
		blog_item.css({ "opacity": 1, "marginTop": 9 });
		blog_item.appendTo("#blog_scroller .wrapper");
		blog_item.removeClass("next");
	});
},

startScroll: function() {
	if (!this.interval) {
		this.interval = setInterval("BlogScroller.RatingUpdate()", this.timer * 1000);
	}
},

stopScroll: function() {
	if (this.interval) {
			clearInterval(this.interval);
			this.interval = false;
		}
	}
};
$(BlogScroller.init);
