jQuery.fn.bxSlider = function(options){
	var defaults = {
		mode: 'slide',
		speed: 500,
		auto: false,
		pause: 2500
	};
	options = $.extend(defaults, options);

	var $this = $(this);
	var current = 0;
	var child_count = $this.children().size();
	var i = 0;
	var j = 0;
	var k = 0;

	function fade(direction){
		if(direction == 'next'){
			var last_before_switch = child_count - 1;
			var start_over = 0;
			var incr = k + 1;
		}else if(direction == 'prev'){
			var last_before_switch = 0;
			var start_over = child_count -1;
			var incr = k - 1;
		}		
		if(k == last_before_switch){
			$this.children().eq(k).slideUp();
			$this.children().eq(start_over).slideDown(options.speed, function(){
				k = start_over;
			});
		}else{
			$this.children().eq(k).slideUp();
			$this.children().eq(incr).slideDown(options.speed, function(){
				k = incr;
			});
		}		
	}

	$this.parent().css({
		'overflow' : 'hidden',
		'position' : 'relative'
	});
	$this.children().css({		
		'position' : 'absolute',
		'listStyle' : 'none',
		'display' : 'none'	
	});
	$this.children(':first').css({
		'display' : 'block'
	});
	
	$t = setInterval(function(){fade('next');}, options.pause);

	return {
		fade: fade,
		clearTwitInterval: function() { clearInterval($t); },
	    restoreTwitInterval: function() { $t = setInterval(function(){fade('next');}, options.pause); }
	}
}
