var nsInterval;
var currentNews = 1;
var allNews = 0;

function initNews()
{

    $('.news').each( function( i ) {
       allNews++;
    });

    $('.news-container-in').css( 'width', ( allNews * 530 ) + 'px');
    $('.news-container-in').removeClass( 'no-display' );
    nsInterval    = setTimeout( "scrollNews()", 5000 );
}



function viewNews( nLp )
{
    clearTimeout( nsInterval );
    var nPosition   = ( nLp - 1 ) * 530 * -1;
    $('.news-container-in').animate({
        left: nPosition + 'px'
      }, 750, function() {
        // Animation complete.
      });

      $('.navigator a').removeClass('current');
      $('#news-button-' + nLp).addClass('current');
      currentNews = nLp;

      nsInterval    = setTimeout( "scrollNews()", 5000 );
}

function scrollNews()
{
    currentNews++;
    if( currentNews > allNews )
    {
        currentNews = 1;
    }
    viewNews( currentNews );
}
