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