/*!
 * liScroll 1.0
 * Examples and documentation at: 
 * http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html
 * 2007-2010 Gian Carlo Mingati
 * Version: 1.0.2 (30-MARCH-2009)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires:
 * jQuery v1.2.x or later
 * 
 */


jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.05
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("newsticker")
				var stripWidth = 0;
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.find("li").each(function(i){
				stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar
				});
				$strip.width(stripWidth);			
				var totalTravel = stripWidth+containerWidth;
				var defTiming = totalTravel/settings.travelocity;	// thanks to Scott Waye		
				function scrollnews(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(function(){
				//jQuery(this).stop();
				},
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime);
				});			
		});	
};

//CONTINUOUS NEWS TICKER
//
//Pinquin.nl
//Date: 2010-12-14
//Version: 0.3
//Jquery version: 1.4.4
//
/*Changes
 * Stop toegevoegd
 * Stop functie verbeterd
 */
//jQuery("#newsstream_content").ticker({step: '30', speed: '500', marginNext: '10'});

( function(jQuery) {
	var defaults, first, last;
	jQuery.fn.ticker = function(options) {	
		defaults = { step: '30', speed: 500, marginNext: 10 };//Standaard waarden
		var options = jQuery.extend( defaults, options );
			return this.each( function() {
			var h = 0;
			var newsticker = jQuery(this);
			jQuery(newsticker).children().each( function( i, n ) {//Zet alle newsitems op de start positie
				jQuery(n).css({left: h + "px"});
				h += (parseInt( defaults.marginNext ) + jQuery(n).width());
			});
			jQuery(newsticker).css("width", h + "px");
			jQuery( jQuery(newsticker).children()[jQuery(newsticker).children().length - 1] ).addClass('last_tickeritem');
			start();//Start de newsticker

			function ticker(item) {
				jQuery(item).animate( { left: '-=' + defaults.step}, parseInt( defaults.speed ), 'linear', function() {
					if( jQuery(this).position()['left'] + jQuery(this).width() < 0 ) {
						last = jQuery(".last_tickeritem").removeClass('last_tickeritem');
						first = jQuery(this).addClass('last_tickeritem').css({ left: Math.round( jQuery(last).position()['left'] + jQuery(last).width() + parseInt( defaults.marginNext ) ) + "px"}).remove();
						jQuery(newsticker).append( jQuery(first) );
						ticker( jQuery(first) );
					} else ticker( jQuery(this) );
				});
			}
			
			//jQuery(newsticker).parent().hover( function() { jQuery(this).children().children().stop(); }, function() { start(); });
			function start() { jQuery(newsticker).children().each( function( i, n ) { ticker(jQuery(n)); }); }
			
		});
	};
} )( jQuery );
