/*
 * Author      : Hansaka Weerasingha
 * Description : News ticker related methods
 */

var first = 0;
var speed = 1000;
var pause = 5000;

function removeFirst(id){
    first = $('ul#'+id+' li:first').html();
    $('ul#'+id+' li:first')
    .animate({
        opacity: 0
    }, speed)
    .fadeOut('slow', function() {
        $(this).remove();
    });
    addLast(first, id);
}

function addLast(first, id){
    last = '<li style="display:none">'+first+'</li>';
    $('ul#'+id).append(last)
    $('ul#'+id+' li:last')
    .animate({
        opacity: 1
    }, speed)
    .fadeIn('slow')
}

function removeLast(id) {
    last = $('ul#'+id+' li:last').html();
    $('ul#'+id+' li:last')
    .animate({
        opacity: 0
    }, speed)
    .fadeOut('slow', function() {
        $(this).remove();
    });
    addFirst(last, id);
}

function addFirst(last, id){
    first = '<li style="display:none">'+last+'</li>';
    $('ul#'+id).prepend(first)
    $('ul#'+id+' li:first')
    .animate({
        opacity: 1
    }, speed)
    .fadeIn('slow')
}

