jQuery.noConflict();

jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.10,
		direction: '-'
		}, 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).width();
				});

				/*alert(stripWidth);*/
				/*$strip.width(stripWidth);*/

				$strip.width(containerWidth);
				var defTiming   = stripWidth/settings.travelocity;
				var totalTravel = stripWidth+containerWidth;
				var direction   = settings.direction;
				
								
				function scrollnews(spazio, tempo, direction){

					$strip.animate(
							{left: direction + '='+ spazio}, 
							tempo, 
							"linear", 
							function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming, direction);}
							);
				}
				

				/*scrollnews(640, defTiming, direction);*/


				/* >>>> */
				jQuery('img#slidepg1L', $strip.parent().parent().parent().parent()).hover(
				function(){

				var offset = jQuery($strip).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime, '+');

				}
				,
				function(){
				jQuery($strip).stop();
				}
				);


				/* <<<< */				
				jQuery('img#slidepg1R', $strip.parent().parent().parent().parent()).hover(
				function(){

				var offset = jQuery($strip).offset();
			
				var residualSpace = /*offset.left +*/ stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime, '-');

				}
				,
				function(){
				jQuery($strip).stop();
				}
				);



				/* >>>> */
				jQuery('img#slidepg2L', $strip.parent().parent().parent().parent()).hover(
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime, '+');
				}
				,
				function(){
				jQuery($strip).stop();
				}
				);


				/* <<<< */				
				jQuery('img#slidepg2R', $strip.parent().parent().parent().parent()).hover(
				function(){
				var offset = jQuery($strip).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime, '-');
				}
				,
				function(){
				jQuery($strip).stop();
				}
				);



		});	
};

