var stopped=false;
	var first = 0;
	var last  = 0;
	var speed = 700;
	var pause = 3500;
	var interval;
	var tickerUlName='';

	function removeFirst(tickerName){
		if(tickerName)
			tickerUlName=tickerName;
		else
			tickerUlName='listticker';
		
		first = $('ul#'+tickerUlName+' li:first').html();
		$('ul#'+tickerUlName+' li:first')
		.animate({
			opacity: 0,
			height: 'toggle',
			marginTop:0,
			marginBottom:0,
			paddingTop:0,
			paddingBottom:0
		}, speed, function() {
		// Animation complete.
			$(this).remove();
		});

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




	function addFirst(){
		last = $('ul#'+tickerUlName+' li:last').html();
		first = '<li style="display:none;margin:0 0 0 8px;padding:0 12px 0 12px;">'+last+'</li>';
		$('ul#'+tickerUlName+'').prepend(first)
		$('ul#'+tickerUlName+' li:first')
		.animate({
			opacity: 1,
			height: 'toggle',
			paddingTop:12,
			paddingBottom:12
		}, speed,function(){removeLast();});
	}



	function removeLast(){
		$('ul#'+tickerUlName+' li:last').remove();
	}




	function toggleAnimation(){
		if(stopped)
			playAnimation();
		else
			stopAnimation()
	}
	
	function stopAnimation(){
		clearInterval(interval);
		stopped=true;
		$('#playBtn').html('<img src="images/wall-play.png" />');
		return false;
	}
	function playAnimation(){
		interval = setInterval(removeFirst, pause);
		stopped=false;
		$('#playBtn').html('<img src="images/wall-pause.png" />');
		return false;
	}
	
	
	function nextMessage(){
		removeFirst();
		stopAnimation();
		return false;
	}
	function previousMessage(){
		addFirst();
		stopAnimation();
		return false;
	}

