function mussumize(input) {
	var sentences = input.toString().split(' ');
	var output = [];
	$.each(sentences, function(i, item) {
		var word = '';
		var last = '';
		if(item.length > 3) {
			last = item.substring(item.length - 1);
			switch(last) {
				case '.':
				case ',':
				case ':':
				case '/':
				case '\\':
				case '|':
				case '"':
				case "'":
				case "!":
				case "?":
				case ")":
				case "(":
				case "[":
				case "]":
						word = mussumize(item.substring(0, item.length - 1));
					break;
				case 'a':
				case 'e':
				case 'i':
				case 'o':
				case 'u':
					switch(item.substring(item.length - 2, item.length - 1)) {
						case 'c':
							word = item.substring(0, item.length - 2) + 'quis';
							break;
						case 'a':
						case 'e':
						case 'i':
						case 'o':
						case 'u':
							word = item.substring(0, item.length - 1) + 'zis';
							break;
						case 'q':
						case 'g':
							word = item.substring(0, item.length - 1) + 'uis';
							break;
						default:
							word = item.substring(0, item.length - 1) + 'is';
							break;
					}
					break;
				default:
					word = item + 'zis';
					break;
			}
		} else {
			word = item;
		}
		output.push(word);
	});
	result = output.join(' ');
	return result.replace(/  /,' ').toLowerCase();
}

$(document).ready(function(){
	$('form').submit(function(){
		$('ul').addClass('loading');
		$('li').each(function(i, item){
			$(this).fadeIn(i * 200, function(){
				$(this).fadeOut(200, function(){
					$(this).remove();
				});
			});
		});
		var username = $('input#user').val();
		var url = "http://twitter.com/statuses/user_timeline.json?screen_name=" + username + "&count=10&callback=?";
		$.getJSON(url, function(data){
			var $li;
			$.each(data, function(i, item){
				$li = $('<li>' + item.text + '</li>');
				$li.appendTo('ul');
			})
			$('ul li').each(function(i){
				$(this).text(mussumize($(this).text()));
			});
			$('ul').removeClass('loading');
		});
		return false;
	})
});