/*
pirean.newsTicker.js
Created prior to 01.11.2010
Updated on 17.01.2012

Description:
	Displays the news ticker, and keeps it ticking over.

Requirements:
	jQuery

Changelog:
	2012.01.17 - Converted script to CoffeeScript and rewrote to more concise code (BSL)
	2011.02.02 - Started commenting/documenting external javascript files by Ben Leveritt (BSL)
	2010.11.01 - Created by Simon Hagger (SH)
*/
var pauseRotate, rotateNews, startRotate, ticker;

ticker = null;

$(function() {
  $('ul.newsList li:first-child').fadeIn('slow');
  $('ul.newsList li').hover(function() {
    pauseRotate();
  }, function() {
    startRotate();
  });
});

pauseRotate = function() {
  window.clearInterval(ticker);
};

startRotate = function() {
  ticker = window.setInterval(rotateNews, 4000);
};

rotateNews = function() {
  $('ul.newsList li:first-child').fadeOut('slow', function() {
    $(this).appendTo($('ul.newsList'));
    $('ul.newsList li:first-child').fadeIn('slow');
  });
};

