/*
 * 
 *
 */
 

  
  (function ($) {
    
  
  	$(document).ready(
  		function()
  		{
  			var slider = $('#slideWrapper');
  			
  			document.moveNext = function ()
			{
				if (slider.data('moving')) return;

				var firstItem = $('#slideWrapper div.newsItem').get(0);
				slider.data('moving',true).animate(
					{ top: -firstItem.offsetHeight },2000, 'linear',
					function () {
				 		//move fist to last & reset offset
						slider.data('moving',false).append(firstItem).css( { top: '0px' } ) ;
				  	}
				 );
			};

  		
  		
  			$('#pushBottom').click( 
  				function () {
  					clearInterval(document.moveInt);
  					document.moveNext();
  				}
  			);
  			
  			
  			
  			$('#pushTop').click(
  				function ()
  				{
  					if (document.moveInt) clearInterval(document.moveInt);
  					if (slider.data('moving')) return;
  				
 					var lastItem = $('#slideWrapper div.newsItem').get(2);
 					
 					slider
 						.data('moving',true)
 						.prepend(lastItem)
 						.css( { top: -lastItem.offsetHeight+"px" } )
						.animate( 
							{ top: 0 },2000, 'linear',
							function () {
								slider.data('moving',false);
							}
						);
  				}
  			);
  		
			
			if (document.moveInt) clearInterval(document.moveInt);
			document.moveInt = setInterval( "document.moveNext()", 7000) ;
  		}

  	);
  

  
   })(jQuery);
  
  
