jQuery.fn.vScroller = function(opt){
	
	var myOpt = jQuery.extend({delay:3000}, opt);
	var vScroller = $(this);
	var inter;
	var anim = false;
	var current = 0;
	var pcurrent = 0;
	var maxBlock = vScroller.find('.fblock').length;
	
	vScroller.wrapInner('<div class="vdisplay"><div class="vcnr"></div></div>');
	var dHeight = vScroller.find('.vdisplay').height();
	var tElement = vScroller.find('.fblock').length;
	var moveheight = dHeight;
	
	createFnav();
	vScroller.find('.fdnav li').click(function(){
		  var idx = vScroller.find('.fdnav li').index($(this));
		  moveToblk(idx);
    });	
	
	vScroller.find('.fblock').height(dHeight);
	vScroller.find('.vcnr').height(dHeight*tElement+20*tElement+20);	
	var maxHeight = vScroller.find('.vcnr').height();

	
	resetInterval();	
	
	function moveTop(){
		if(current<tElement-1 && !anim){
			 current++;
			 moveToblk(current);
		}else if(!anim){
			moveFirst();
		}
	}
	
	
	function moveBottom(){
		if(current>0 && !anim){
		 current--;
         moveToblk(current);
		}		
	}	
	
	function moveFirst(){
		current = 0
		moveToblk(current);
	}
	
	function moveToblk(block){		
		resetInterval();
		current = block;
		var mheight = -block*moveheight;
		anim = true;
		vScroller.find('.vcnr').animate({marginTop:mheight+'px'}, onComplete);
		vScroller.find('.fdnav li').eq(pcurrent).removeClass('active');
		vScroller.find('.fdnav li').eq(current).addClass('active');
		pcurrent = current;
		
	}	
	
	function resetInterval(){
		clearInterval(inter);
		inter = setInterval(moveTop, myOpt.delay);
	}
	
	function onComplete(){
		anim = false;
	}
	
	function createFnav(){
		vScroller.append('<div class="fdnav"><ul></ul></div>');
		for(var i=0; i<maxBlock; i++){
			vScroller.find('.fdnav ul').append('<li>'+(i+1)+'</li>');
		}
		vScroller.find('.fdnav li:first').addClass('active');
	}
	
}