
function getNavigatorType() {
	if ( navigator.appName == "Microsoft Internet Explorer" )
		return 1;
	else if ( navigator.appName == "Netscape" )
		return 2;
	else
		return 0;
}

var nv = new Object();
nv.Scroll = function() {
	this.version = "0.2";
	this.name = "NvScroll";
	this.divId = "";
	this.item = new Array();
	this.itemcount = 0;
	this.currentspeed = 0;
	this.scrollspeed = 200;
	this.pausedelay = 1000;
	this.pausemouseover = false;
	this.stop = false;
	this.height = 100;
	this.width = 100;
	this.stopHeight=0;
	this.i=0;
	this.reloadData = 0;
	this.scrollHeight = 1;
	this.tid1=0;
	this.tid2=0;
	this.tid3=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;
		tid1=setTimeout(this.name+'.scroll()',this.currentspeed);
		window.setTimeout(this.name+".stop = false", this.pausedelay);
	},
	display : function () {
		var htmlCode;
		if(getNavigatorType()=="1")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(); " class="font12_w">';
		else if(getNavigatorType()=="2")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(); " class="font12_w">';
		else htmlCode = '<div id="'+this.name+'" style="height:'+this.height+'; width:'+this.width+'; position:relative; overflow:hidden; " OnMouseOver="'+this.name+'.onmouseover(); " OnMouseOut="'+this.name+'.onmouseout(); " class="font12_w">';
		for(var i = 0; i < this.itemcount; i++) {
			htmlCode += '<div id="'+this.name+'item'+i+'"style="left:0px; width:'+this.width+'; position:absolute; top:'+(this.height*i)+'px; " class="font12_w">';
			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) - this.scrollHeight) + "px";
				
				if(parseInt(obj.top) <= this.height * (-1)){
					obj.top = (this.height * (this.itemcount-1)) + "px";
				}
				if(parseInt(obj.top) == this.height){
					this.currentspeed = this.pausedelay;
					this.i = i;     
				}
			}
		}
		tid2=window.setTimeout(this.name+".scroll()",this.currentspeed);
	},
	scroll_down : function () {
		isEnd = 0;
		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) + this.scrollHeight) + "px";
				
				if(parseInt(obj.top) > this.height * (this.itemcount -1)){
					obj.top = ((this.height * (-1))+1) + "px";
				}
				if(parseInt(obj.top) == this.height){
					this.currentspeed = this.pausedelay;
					this.i = i;
					isEnd = 1;
				}
			}
		}
		if(isEnd == 1){
			tid2=window.setTimeout(this.name+".scroll()",this.currentspeed);
		}else{
			tid2=window.setTimeout(this.name+".scroll_down()",this.currentspeed);
		}
	},
	next : function() {
		this.stop = false;
		clearTimeout(tid1);
		clearTimeout(tid2);
		this.scroll();
	},
	prev : function() {
		this.stop = false;
		clearTimeout(tid1);
		clearTimeout(tid2);
		this.scroll_down();
	},
	onmouseover : function () {},
	onmouseout : function () {}
}
nv.Ranking = function(){
	this.nvscroll = new nv.Scroll();
	this.nvscroll.name = "";
	this.nvscroll.name = "quicknewstop.nvscroll";
	this.nvscroll.height = 17;
	this.nvscroll.width = 449;
	this.nvscroll.scrollspeed = 1;
	this.nvscroll.pausedelay = 3000;
	this.nvscroll.pausemouseover = true;
}
nv.Ranking.prototype = {
	init : function(){
		this.nvscroll.setDivId("list");
		
		this.nvscroll.onmouseover = function() {
			if ( this.pausemouseover ) {
				this.stop = true;
			}
		}
		
		this.nvscroll.onmouseout = function() {
			if ( this.pausemouseover ) {
				this.stop = false;
			}
		}
	},
	add : function(text){
		this.nvscroll.add(text);
	},
	start : function(){
		this.init();
		this.nvscroll.start();
	},
	onmouseover : function(){
		this.nvscroll.onmouseover();
	},
	onmouseout : function(){
		this.nvscroll.onmouseout();
	},
	next : function() {
		this.nvscroll.next();
	},
	prev : function() {
		this.nvscroll.prev();
	},
	unext : function () {
		this.onmouseover();
		this.next();
		window.setTimeout(this.name+".onmouseout()",this.nvscroll.pausedelay);
	},
	uprev : function () {
		this.onmouseover();
		this.prev();
		window.setTimeout(this.name+".onmouseout()",this.nvscroll.pausedelay);
	}
}
