function init_slider(slide_width){
	$(function(){
		$('#banner-slider').wsslider(slide_width);
	});
}

(function($){
	$.fn.wsslider = function(slide_width){
		var $this = $(this),
			$slide_holder = $this.find('#banner-frame ul')
			$switcher = $this.find('.switcher'),
			slide_total = $slide_holder.children().length,
			slider_interval = null;
		var current_frame = 0;
		$this.find('.link-next').click(function(e){
			e.preventDefault();
			gotoSlide(current_frame + 1);
			return false;
		});
		$this.find('.link-prev').click(function(e){
			e.preventDefault();
			gotoSlide(current_frame - 1);
			return false;
		});
		$switcher.children().click(function(e){
			e.preventDefault();
			gotoSlide($(this).index());
			return false;
		}).first().addClass('active');
		function gotoSlide(slide) {
			current_frame = slide;
			if (current_frame >= slide_total) current_frame = 0;
			else if (current_frame < 0) current_frame = slide_total - 1;

			$switcher.children().removeClass('active').eq(current_frame).addClass('active');
			$slide_holder.animate({'margin-left': '-' + (current_frame * slide_width) + 'px'});
		}
		slider_interval = setInterval(function(){
			gotoSlide(current_frame + 1);
		}, 5000);
	}
})(jQuery);
