$(function() {
	var ch = 0;
	var item = 0;
	var items = $('#caption li').length;
	var time = 1000;
	var delay = 28;
	var wait = 3000
	
	$('#showCaption').css('width', ($('#caption').width() + 20));
		
	function tickInterval() {
		if(item < items) {
			var text = $('#caption li:eq('+item+')').text();
			type(text);
			text = null;
			var tick = setTimeout(tickInterval, time);
		} else {
			clearTimeout(tick);
		}
	}
	
	function type(text) {
		time = delay;
		$('#showCaption').html(text.substr(0, ch++));
		if(ch > text.length) {
			item++;
			ch = 0;
			time = wait;
		}	
	}
	
	var tick = setTimeout(tickInterval, time);
});

