$(document).ready(function() {
  
  $('ul.mixedlist').each(function(i,e) {
      $(e).wrap('<div class="'+$(e).attr('class')+'_container"/>');
      $(e).parent().css({
          position: 'relative',
          overflow: 'hidden',
          height: '300px'
      });
      if($('>li',e).length > 4) {
          limitListDisplay($('>li',e),4);
          setInterval(function() {newsScroller($(e))},6000);
      }
  });
});
function limitListDisplay(elements,n) {
  elements.each(function(i,e) {
    if(i>=n) {
      $(e).hide();
    }
  });
}
function newsScroller(container) {
    var n = 4;
    children = $('>li',container);
    //limitListDisplay(children,n);
    firstchild = children[0];
    $(firstchild).clone().appendTo(container).hide().removeClass('first');
	$(firstchild).animate({opacity:0},1200);
    container.css('position','relative').animate({
        top: -($(firstchild).outerHeight(true)+25)
    },1000,function() {
        container.css('top','0');
        $(children[1]).addClass('first');
        $(children[n]).fadeIn();
        $(firstchild).remove();
    });
}
