jQuery.fn.banners = function( options ){
	var $this = $(this);
	var $nav = $(options.nav);
	var numbers = new Array('one', 'two', 'three', 'four', 'five');
	var delay = options.delay || 5000;
	var restart = options.restart || 1000;
	var animateT = options.animateTime || 1000;
	var currPos = 0;
	var size = $this.find('img').size();
	var auto;
	var restartT;
	
	init();
	setAuto();
	
	function init(){
		for(i=0; i<size; i++){
			$nav.append('<a class="number_'+numbers[i]+'">'+(i+1)+'</a>');
		}
		
		$this.find('img:not(:eq(0))').css({opacity: 0, zIndex: 10});
		$this.find('img:eq(0)').css({opacity: 1, zIndex: 50});
		$nav.children().removeClass('curr_number');
		$nav.children().eq(0).addClass('curr_number');
		
		$this.hover(function(){
			clearTimeout(restartT);
			clearInterval(auto);
		}, function(){
			restartT = setTimeout(function(){
				setAuto();
			}, restart);
		});
		
		$nav.children().css('cursor', 'pointer').click(function(){
			var ind = $nav.children().index( $(this) );
			changeBan(ind);
			return false;
		});
	}
	
	function setAuto(){
		auto = setInterval(function(){
			if (currPos < (size-1)){
				currPos++;
			}else{
				currPos = 0;
			}
			changeBan( currPos );
		}, delay);
	}
	
	function changeBan( ind ){
		$nav.children().removeClass('curr_number');
		$nav.children().eq(ind).addClass('curr_number');
		$this.find('img:not(:eq('+ind+'))').animate({opacity: 0, zIndex: 10}, {queue: false, duration: animateT});
		$this.find('img:eq('+ind+')').animate({opacity: 1, zIndex: 50}, {queue: false, duration: (animateT+1500)});
	}
	
}
