(function() {
  (function($) {
    var prop, scroll, setup;
    if ($ == null) {
      $ = jQuery;
    }
    $.fn.ticker = function() {
      return this.each(function() {
        if ($(this).children('article').size() > 1) {
          return setup(this);
        }
      });
    };
    prop = {
      height: null
    };
    setup = function(el) {
      prop.element = $(el);
      prop.height = prop.element.height();
      $(el).append('<div class="actions">\
				<a href="#" class="prev" data-direction="up">prev</a>\
				<a href="#" class="next" data-direction="down">next</a>\
			</div>');
      return $(el).find('.actions a').bind('click', scroll);
    };
    return scroll = function(ev) {
      var dir, el;
      ev.preventDefault();
      el = ev.target;
      dir = $(el).attr('data-direction');
      switch (dir) {
        case "down":
          return prop.element.children('article:first').animate({
            marginTop: prop.height * -1
          }, 800, function() {
            return $(this).detach().appendTo(prop.element).removeAttr('style');
          });
        default:
          prop.element.children('article:last').detach().prependTo(prop.element).css({
            marginTop: prop.height * -1
          });
          return prop.element.children('article:first').animate({
            marginTop: 0
          }, 800, function() {
            return $(this).detach().prependTo(prop.element).removeAttr('style');
          });
      }
    };
  })($);
  $(function() {
    return $('#news').ticker();
  });
}).call(this);

