var nv = new Object();
nv.Ranking = function(){
	this.nvscroll = new nv.Scroll();
	this.nvscroll.name = "";
	this.nvscroll.name = "quicknewstop.nvscroll";
	this.nvscroll.height = 18;
	this.nvscroll.width = 520;
	this.nvscroll.scrollspeed = 1;
	this.nvscroll.pausedelay = 2000;
	this.nvscroll.pausemouseover = true;
}
nv.Ranking.prototype = {
	init : function(){
		this.nvscroll.setDivId("roll_list");
	},

	add : function(text){
		this.nvscroll.add(text);
	},
	start : function(){
		this.init();
		this.nvscroll.start();
	}
}
nv.Scroll = function() {
	this.version = "0.2";
	this.name = "NvScroll";
	this.divId = "";
	this.item = new Array();
	this.itemcount = 0;
	this.currentspeed = 0;
	this.scrollspeed = 50;
	this.pausedelay = 1000;
	this.pausemouseover = false;
	this.stop = false;
	this.height = 18;
	this.width = 520;
	this.stopHeight=0;
	this.i=0;
	this.reloadData = 0;
}
nv.Scroll.prototype = {
	 add : function (text) {
		   this.item[this.itemcount] = text;
		   this.itemcount = this.itemcount + 1;
	 },
	 setDivId : function(name) {
			this.divId = name
	 },
	 start : function () {
		   if ( this.itemcount == 1 ) {
			this.add(this.item[0]);
		   }
		   this.display();
		   this.currentspeed = this.scrollspeed;
		   this.stop = true;
		   setTimeout(this.name+'.scroll()',this.currentspeed);
		   window.setTimeout(this.name+".stop = false", this.pausedelay);
	 },
	 display : function () {
		   var htmlCode;
		   htmlCode = '<div id="'+this.name+'" style="height:'+this.height+'px; width:'+this.width+'px; position:relative; overflow:hidden; " OnMouseOver="'+this.name+'.onmouseover(); " OnMouseOut="'+this.name+'.onmouseout(); ">';
		   for(var i = 0; i < this.itemcount; i++) {
		   htmlCode += '<div id="'+this.name+'item'+i+'"style="left:0px; width:'+this.width+'px; position:absolute; top:'+(this.height*i)+'px; ">';
		   htmlCode += this.item[i];
		   htmlCode += '</div>';
		   }
		   htmlCode += '</div>';
		   document.getElementById(this.divId).innerHTML=htmlCode;
	 },
	 scroll : function () {
		   this.currentspeed = this.scrollspeed;
		   if ( !this.stop ) 
		   {
						for (var i = 0; i < this.itemcount; i++) 
						{
									 obj = document.getElementById(this.name+'item'+i).style;
									 obj.top = (parseInt(obj.top) - 1)+"px" ;

									 if ( parseInt(obj.top) <= this.height * (-1) ) obj.top = this.height * (this.itemcount-1);
									 if ( parseInt(obj.top) == 0 ) 
									 {
												  this.currentspeed = this.pausedelay;
												  this.i = i;
									 }
						}
		   }
		   window.setTimeout(this.name+".scroll()",this.currentspeed);
	 },
	 onmouseover : function () {this.stop=true;},
	 onmouseout : function () {this.stop=false;}
}
