var newsticker_interval = window.setInterval(function() {forward_newsticker();}, 5000);
var newsticker_animation_in_progress = false;

function forward_newsticker(duration, reverse) {
	if (typeof duration == "undefined") var duration = 1500;
	if (typeof reverse == "undefined") var reverse = true;
	if (newsticker_animation_in_progress) return;
	rest_newsticker();
	newsticker_animation_in_progress = true;
	if (reverse)
	{
		jQuery("#right_part_newsticker .news:first").animate
		(
			{
				marginTop: "-130px"
			},
			{
				duration: duration,
				complete: function() {
					jQuery("#right_part_newsticker .news:first").insertAfter(jQuery("#right_part_newsticker .news:last"));
					rest_newsticker();
				},
				queue: true
			}
		);
	} else {
	
		jQuery("#right_part_newsticker .news:last").css("margin-top", "-130px").insertBefore("#right_part_newsticker .news:first").animate
		(
			{
				marginTop: "0px"
			},
			{
				duration: duration,
				complete: rest_newsticker,
				queue: true
			}
		);
	}
}

function rest_newsticker() {
	jQuery("#right_part_newsticker .news").stop().css("margin-top", "0px");
	window.clearInterval(newsticker_interval);
	newsticker_interval = window.setInterval(function() {forward_newsticker();}, 5000);
	newsticker_animation_in_progress = false;
}

function fastforward_newsticker() {
	forward_newsticker(300, false);
}
function fastreverse_newsticker() {
	forward_newsticker(300, true);
}


