$(document).ready(function(){
	
	var i = 0;
        var x = 0;
	var view_block = 0;
	var first_block_width = $("#slide ul").first().width();
	var text_scroller_int = '';
	var cloneElm = '';
	var step = 0;

	$("#slide").scrollLeft(i);
	var textScroller = {
		start: function(){
			text_scroller_int = setInterval(function(){
				i++;
				$("#slide").scrollLeft(i);
				
				var x = $("#slide ul").position();
				if(x.left < -(300 * step)){
					step++;
					if(step > 1){
						var cloneElm = $("#slide ul li").eq(step - 1).clone();
						$("#slide ul").append(cloneElm);
					}
				}
			}, 10);	
		},
		
		pause: function(){
			$('#slide').live('mouseover mouseout', function(event) {
				if (event.type == 'mouseover') {
					// do something on mouseover
					clearInterval(text_scroller_int);
				} else {
					// do something on mouseout
					textScroller.start();
				}
			});
		}
	};
	
	// auto start text scroller
	textScroller.start();
	textScroller.pause();
});
