//////////////////////////////////////////////////////////////////////////////////////////////////
/*  sLnews v1.0 - 3:09 PM 26/03/2007

*/
//////////////////////////////////////////////////////////////////////////////////////////////////
// init options - edit these for your purposes
//////////////////////////////////////////////////////////////////////////////////////////////////
window.addEvent('domready', function(){
var newsTick = new sLnewsTicker();
});
//////////////////////////////////////////////////////////////////////////////////////////////////
// class - no editing below this line
//////////////////////////////////////////////////////////////////////////////////////////////////
var sLnewsTicker = new Class({
	options:{
		newsContainer:'newsticker-feed-feed', // the container div to update with results
		url:'/ajax/newsfeed.php', // the url of the php file providing the html output
		introDur: 750, // the duration of the first fade / height "drop" effect
		newsDivHeight: 250, // the height od the "drop" effect.
		downDur:100000, // the duration of the down scrolling
		upDur: 25000, // the duration of the up scrolling		
		scrollPerPx: 1
	},
	
	initialize:function(options){
		this.setOptions(options);
		this.loadNews(options)
		this.scroller();
	},
	setOptions:function(options){
		this.options = Object.extend( this.options, options || {} );
	},
	scroller:function(options){
			
		this.scrollerDown();
		
		$(this.options.newsContainer).addEvent('mouseover',function(){
			try{ this.newsScroll.stop(); }catch(e){}
		}.bind(this));

		$(this.options.newsContainer).addEvent('mouseout',function(){
				try{ this.scrollerDown(); }catch(e){}
		}.bind(this));
	},
	
	scrollerDown:function(){
		this.newsScroll = new Fx.Scroll(this.options.newsContainer,{
			duration: this.options.downDur,
			transition: Fx.Transitions.linear,
			onStart: function(){
                this.options.duration = Math.abs(this.to[1]-this.from[1])*150;                               
            },
			onComplete: function(){
				$(this.options.newsContainer).scrollTo(0,0);
				this.newsScroll.toBottom();
			}.bind(this)					
			
		});
		this.newsScroll.toBottom();
	},
	loadNews:function(){			
		var chld = $(this.options.newsContainer).getChildren();
		$each( chld, function(){
			chld.clone().injectInside( $(this.options.newsContainer) )
		},this);
	}
});

