jQuery.noConflict();
(function($) {		  
	jQuery(document).ready(function() 
	{	
		var scrollTempo = 3;
		var countNews = 1;
		var lenNews = $('.content .highlights .highlights_content .highlights_mover .highlights_container').size();
		if( lenNews > 1 )
		{
			$('.content .highlights .highlights_content .highlights_nav').css('visibility', 'visible');
			updateIndexNews();
			
		}
		
		var interval = setInterval(function () {getNextNews();}, 10000); 


		
		function getNextNews(){
			
			if( countNews >= lenNews )
			{
				countNews = 1;
			}else
			{
				countNews++;
			}
			updateIndexNews();
			gotoNews(countNews);
			return false;
			
		}
		
		function updateIndexNews()
		{
			$('.content .highlights .highlights_content .highlights_nav span.counter').html( countNews + "&nbsp;|&nbsp;" + lenNews );	
		}
		
		function gotoNews(nmbr)
		{
			var yPos = (nmbr-1) * -250;
			yPos += "px";
			$('.content .highlights .highlights_content .highlights_mover').stop().animate( {top: yPos}, 500 );	
		}
		// NEWS
		$('.content .highlights .highlights_content .highlights_nav a.highlights_up').click(function()
		{
			clearInterval(interval);
			if( countNews <= 1 )
			{
				countNews = lenNews;
			}else
			{
				countNews--;
			}
			updateIndexNews();	
			gotoNews(countNews);
			return false;
		});
		$('.content .highlights .highlights_content .highlights_nav a.highlights_down').click(function()
		{
			clearInterval(interval);
			getNextNews();
			return false;
		});	
		
		$('.content .offer .offer_content .offer_nav a.nav_up').mousedown(function(){
			//ivu = setInterval(scrollUp, 7, scrollTempo);
			ivu = setInterval( function() { scrollUp(scrollTempo); }, 7 );

		}).mouseup(function(){
			clearInterval(ivu);
		});
		
		$('.content .offer .offer_content .offer_nav a.nav_down').mousedown(function(){
			//ivd = setInterval(scrollDown, 7, scrollTempo);
			ivd = setInterval( function() { scrollDown(scrollTempo); }, 7 );
		}).mouseup(function(){
			clearInterval(ivd);
		});
		
		function scrollUp(tempo)
		{
			var temp = 	$('.content .offer .offer_content .offer_mover').scrollTop();																							
			$('.content .offer .offer_content .offer_mover').scrollTop(temp-tempo);
		}
		
		function scrollDown(tempo)
		{
			var temp = 	$('.content .offer .offer_content .offer_mover').scrollTop();																			  
			$('.content .offer .offer_content .offer_mover').scrollTop(temp+tempo);
		}
		
		$('.content .offer .offer_content').mousewheel(function(event, delta) 
		{
			if (delta > 0)
			{
				scrollUp(25);
			}else if (delta < 0)
			{
				scrollDown(25);
			}			
			event.stopPropagation();
			event.preventDefault();
		});

	});
})(jQuery);
