$("#textwrapper").css({"display":"block"});
var scrollwidth = $("#textwidth").width();
$("#textwrapper").remove();
var scrollwrapperwidth = $("#scrollwrapper").width();
if(scrollwidth < scrollwrapperwidth) scrollwidth = scrollwrapperwidth;
var noappend = 0;
$("#scrollcontent").css({"width":scrollwidth});
$("#firstcontent").css({"width":scrollwidth});
var appending = scrollwrapperwidth-scrollwidth;

function animatetext(rate){			
	var starttime = new Date();
	var dist = scrollwidth+parseFloat($("#scrollcontent").css("left"));
	if(!rate)rate = 1;
	var duration = Math.abs(dist/(rate/100));
	$("#scrollcontent").animate({"left":"-"+scrollwidth},{
		step: function() {							
			if(parseFloat($("#scrollcontent").css("left"))< parseFloat(appending) && !noappend){
				noappend = 1;
				$("#scrollcontent").css({"width":scrollwidth+scrollwidth});							
				$("#scrollcontent").append("<span style=\'float:left; text-align:left; width:"+scrollwidth+"px;\'>"+$("#scrollcontent").children(":first").html()+"</span>");
			}
		},
		duration: duration,
		easing: "linear",
		complete:function(){			
			$("#scrollcontent").children(":first").remove();
			$("#scrollcontent").css({"left":0});
			$("#scrollcontent").css({"width":scrollwidth});			
			noappend=0;
			animatetext(6);
		}
	});
}
$("#scrollcontent").mouseover(function(e){
	$("#scrollcontent").stop();
});
$("#scrollcontent").mouseout(function(e){
	animatetext(6);
});

var scrollheight = $("#textup").height();

function scrolltextup(speed){
	$("#textup").animate({"top":"-=20"},{
		duration: speed,
		easing: "linear",
		complete:function(){					
			$("#textup").children(":last").after("<div style='line-height:20px;'>"+$("#textup").children(":first").html()+"</div>");
			var fcheight = parseInt($("#textup").css("top"));
			if($("#textup").children(":first").height() <= (parseInt($("#textup").css("top"))*-1)){
				$("#textup").children(":first").remove();
				$("#textup").css({"top":0});
			}
			setTimeout("scrolltextup(3000)", 500);
		}
	});
}

$(document).ready(function(){
	if(scrollheight>20)
		setTimeout("scrolltextup(3000)", 600);
	animatetext(6);
});