$.fn.typewriter = function(opt) {
  var typeone = function(self, text, content) {
    if (text.length > 0) {
      var next = text.match(/(\s*(<[^>]*>)?)*(&.*?;|.?)/)[0];
      text = text.substr(next.length);
      $(self).html(content+next);
      setTimeout(function(){
        typeone(self, text, content+next);
				typesound();
      }, opt['delay']);
    }
  }
  this.each(function() {
    opt = opt || { 'delay': 100 };
    $(this).height($(this).height());
    $(this).width($(this).width());
    typeone(this, $(this).html(), '');
		
  });
}

months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

function typesound() {
	num = Math.ceil((Math.random()*30)/10);
	$.sound.play("/mp3s/key" + num + ".mp3");
}

function cloneToJournalBody() {
	$("#journal_body").html( $("#tweet_body").val() );
	typesound();
	$("#char_count").html($("#journal_body").html().length);
}
