var NewsTicker = (function(){
	function constructor(obj){
		this.obj = obj;
		this.lis;
		this.news = [];
		this.autoScrollTime = 6000;
		this.interval;
		this.init();
	}
	constructor.prototype.init = function(){
		this.lis = this.obj.getElementsByTagName('li');
		for(var k=0;k<this.lis.length;k++){
			this.news.push(this.lis[k]);
			this.lis[k].controller = this;
			this.lis[k].style.zIndex = this.lis.length-k;
		}
		startInterval(this);
	}
	
	function startInterval(instance){
		instance.interval = setInterval(function(){instance.swap();},instance.autoScrollTime);
	}
	
	constructor.prototype.swap = function(){
		if(this.interval){
			clearInterval(this.interval);
			this.interval = null;
		}
		this.news[0].tween = new Tween(this.news[0],"clip",0,900,500,'rect(0 900px 34px ','px)',"easeSin",true);
		
		this.news[0].tween.onTweenFinished = function(){
			this.obj.style.clip = "rect(0 900px 34px 0px)";
			for(var k=0;k<this.obj.controller.news.length;k++){
				this.obj.controller.news[k].style.zIndex = this.obj.controller.news.length-k;
			}
			this.stop();
		}
		this.news[0].tween.play();
		
		this.news.push(this.news.shift());
		//this.news[0].style.zIndex = 4;
		startInterval(this,this.autoScrollTime);
	}
	
	return constructor;
})();