<!--

function fncScroll(){
	this.name =" topics";
	this.scrollSpeed = 20;
	this.pauseDelay = 5000;
	this.height = 10;
	this.top = 1;
	this.width = 615;
	this.scrollType = 1;//1:yoko 2:tate
	this.shuffleFlag = 0;	//0:no shuffle 1:shuffle

	this.moveCount = 0;
	this.topicCount = 0;
	this._topic = [];
	this.topic_length = 0;

	this.start = function(){
		if(this.shuffleFlag == 1){
			this._topic = this.shuffle(this._topic);
		}

		this.display();
		this.next();
	}

	this.display = function(){
document.write('<div id = "topic_box'+this.name+'" style="margin:0px;padding:0px;height:'+this.height+'px;width:'+this.width+'px;position:relative;overflow:hidden;">');
for(i =0;i < this.topic_length;i++){
	document.write('<div id="topic'+this.name+i+'" style="width:'+this.width+'px;position:absolute;display:none;">'+this._topic[i]+'</div>');
}
document.write('</div>');
	}

	this.add = function(){
		this._topic.push(arguments[0]);
		this.topic_length++;
	}

	this.shuffle = function(){
		arr = arguments[0];
		for( var i=0; i<arr.length; i++ ){
			backup = arr[i];
			rand = Math.floor( Math.random() * arr.length );

			arr[i] = arr[rand];
			arr[rand] = backup;
		}

		return arr;
	}

	this.next = function(){
		document.getElementById("topic"+this.name+this.topicCount).style.display ="block";
		switch(this.scrollType){
			case 1:
				document.getElementById("topic"+this.name+this.topicCount).style.left = this.width;
				this.moveCount = this.width;
				break;
			case 2:
				document.getElementById("topic"+this.name+this.topicCount).style.left = this.height;
				this.moveCount = this.height;
				break;
		}

		setTimeout(this.name+'.scroll()',this.scrollSpeed);
	}

	this.countUp = function(){
		document.getElementById("topic"+this.name+this.topicCount).style.display ="none";
		this.topicCount++;
		if(this.topic_length <= this.topicCount){
			this.topicCount = 0;
		}
		this.next();
	}
		

	this.scroll = function(){
		switch(this.scrollType){
			case 1:
				document.getElementById("topic"+this.name+this.topicCount).style.left = --this.moveCount;
				break;
			case 2:
				document.getElementById("topic"+this.name+this.topicCount).style.top = --this.moveCount;
				break;
		}
		if(this.moveCount < 0){
			this.setTime = setTimeout(this.name+'.countUp()',this.pauseDelay);
		}else{
			this.setTime = setTimeout(this.name+'.scroll()',this.scrollSpeed);
		}
	}

}

//-->
