jQuery.fn.createScroller = function(opt){
	
	myOpt = jQuery.extend({delay:2000},opt);
	scroller = $(this);
	var inter;
	var anim = false;
	var current = 0;
		
	scroller.wrapInner('<div class="sdisplay"><div class="scnr"></div></div>');
	scroller.append('<div class="bbak"></div><div class="bnxt"></div>');
	var dWidth = scroller.find('.sdisplay').width();
	var tElement = scroller.find('.scrol').length;
	var moveWidth = dWidth+20;
	
	
	scroller.find('.scrol').width(dWidth);
	scroller.find('.scnr').width(dWidth*tElement+20*tElement+20);	
	var maxHeight = scroller.find('.scnr').height();

	scroller.find('.bbak').css('top', maxHeight/2-30+'px');
	scroller.find('.bnxt').css('top', maxHeight/2-30+'px');	
	
	scroller.find('.bbak').click(function(){
		moveRight();
	 });
	scroller.find('.bnxt').click(function(){
			moveLeft();
		
	 });
	
	resetInterval();	
	
	function moveLeft(){
		if(current<tElement-1 && !anim){
			 current++;
			 moveToblk(current);
		}else if(!anim){
			moveFirst();
		}
	}
	
	
	function moveRight(){
		if(current>0 && !anim){
		 current--;
         moveToblk(current);
		}		
	}	
	
	function moveFirst(){
		current = 0
		moveToblk(current);
	}
	
	function moveToblk(block){		
		resetInterval();
		var mWidth = -block*moveWidth;
		anim = true;
		scroller.find('.scnr').animate({marginLeft:mWidth+'px'}, onComplete);
		
	}	
	
	function resetInterval(){
		clearInterval(inter);
		inter = setInterval(moveLeft, myOpt.delay);
	}
	
	function onComplete(){
		anim = false;
	}
	
	
	
}

