/**
 * Simple Ticker script.
 *
 * Usage:
 *   ticker.apply("#myticker", {speed:2000, effect:"slide"});
 *
 * Inspired by Alex Fish' List Ticker. Thank you!
 */
var ticker;
(function($) {
	ticker = {
		defaults: {speed: 4000, effect: "fade"},

		apply: function(selector, options) {
			options = $.extend(this.defaults, options);

			$(selector).each(function() {
				var $this = $(this),
						$list = $this.children();
				$list.not(":first").hide();

        $this.hover(function() {
          $this.data.hovered = true;
        }, function() {
          $this.data.hovered = false;
        });

				setInterval(function() {
				  if ($this.data.hovered === true) {
				    return;
				  }

				  $list = $this.children();
					$list.not(":first").hide();
					var first = $list.eq(0),
							second = $list.eq(1);

					if (options.effect === "slide"){
						first.slideUp();
						second.slideDown(function(){
							first.remove().appendTo($this);
						});
					} else {
						first.fadeOut(function(){
							second.fadeIn();
							first.remove().appendTo($this);
						});
					}
				}, options.speed);
			});
		}
	};
}(jQuery));

