/*
 * jQuery Slider Plugin
 * Copyright (c) 2016 Alvin So
 * Version: 1.32 (11-SEP-2017)
 */
(function($) {
	$.fn.extend({
		Slider: function(options, extra) {
			if(typeof(options) == 'object')
			{
				var setting = {
					slides: '> div',																//number of slides pre animate (string or jQuery object)
					maxSlide: 'auto',																//maximum number of slides pre animate (string or int or function)
					minSlide: 'auto',																//minimum number of slides pre animate (string or int or function)
					fixedSlide: 0,																	//fixed number of slides pre animate (int or function)
					slidesClass: '',																//class name for slides wrapper
					currentClass: 'current',														//class name for current slide
					prev: '.prev',																	//element to control previous (string or jQuery object)
					next: '.next',																	//element to control next (string or jQuery object)
					disableClass: 'disable',														//class name for control when it can't be clicked
					direction: 'horizontal',														//animate direction (horizontal or vertical)
					clickToSlide: false,															//slide to the clicked slide
					arrowControl: false,															//press ← and → to change slides
					mouseControl: false,															//scroll mouse wheel up and down to change slides
					swipeControl: false,															//swipe left and right to change slides
					swipeDistance: 100,																//swipe distance bigger than it will trigger swipe
					swipeByMouse: false,															//swipe support mouse drag
					timeout: 100,																	//time to update when slider resize
					autoPlay: 0,																	//millisecond for auto slide
					animateTime: 'normal',															//animation time (string or int)
					offset: 0,																		//slide distance offset
					autoMargin: true,																//margin between each slides
					minMargin: 0,																	//minimum margin between each slides when autoMargin enabled
					skipBoundary: 0,																//skip margin left and right of first and last slides when autoMargin enabled and slider longer than it (int or function)
					fixWidth: true,																	//slide distance base on first slide
					fadeOut: false,																	//animate in fadeout effect
					infiniteLoop: false,															//only available when fadeOut is false and slider having 2 or more slides
					dummySlide: false,																//only available when fadeOut is false and slider having 2 or more slides
					pager: '',																		//element to build pager (string or jQuery object)
					pagerTemplate: function(page, total_page) {										//pager template (string or function)
						return '<a href="#" />';		
					},
					pagerStopAutoPlay: true,														//stop autoplay when click pager
					beforeSlide: function(slider, slides, current_page, next_page, total_page) {},	//event before slide
					afterSlide: function(slider, slides, current_page, total_page) {},				//event after slide
					beforeResize: function(slider, slides, current_page, next_page, total_page) {},	//event before resize
					afterResize: function(slider, slides, current_page, total_page) {},				//event after resize
					afterInit: function(slider, slides, current_page, total_page) {}				//event after initiate
				};
				$.extend(true, setting, options);
				return this.each(function() {
					$.each($(this), function() {
						var _self = $(this);
						var _slides = $(setting.slides, _self);
						var _first = _slides.first();
						var _parent = _first.parent();
						var _prev = $(setting.prev, _self);
						var _next = $(setting.next, _self);
						var _pager = $(setting.pager, _self);
						var max = $(setting.slides, _self).length;
						var width = height = 0;
						var count = 1, total, auto_interval, resize_interval, animate = false;
						var infinite_loop = setting.infiniteLoop && ! setting.fadeOut && max >= 2;
						var dummy_slide = setting.dummySlide && ! setting.fadeOut && max >= 2;
						if(setting.fixWidth)
						{
							if(setting.direction == 'horizontal')
							{
								total = Math.ceil(max / Math.floor(_parent.width() / _first.outerWidth(true)));				
							}
							else
							{
								total = Math.ceil(max / Math.floor(_parent.height() / _first.outerHeight(true)));
							}					
						}
						else
						{
							if(setting.direction == 'horizontal')
							{
								var tmp_width = 0;
								$.each(_slides, function() {
									tmp_width += $(this).outerWidth(true);
								});
								total = Math.ceil(tmp_width / _parent.width());		
							}
							else
							{
								var tmp_height = 0;
								$.each(_slides, function() {
									tmp_height += $(this).outerHeight(true);
								});
								total = Math.ceil(tmp_height / _parent.height());		
							}
						}
						var updateClass = function() {
							if(setting.disableClass && ! setting.fadeOut && ! infinite_loop)
							{
								_prev.add(_next).removeClass(setting.disableClass);
								if(count <= 1)
								{
									_prev.addClass(setting.disableClass);
								}
								if(count >= total)
								{
									_next.addClass(setting.disableClass);
								}
							}
							if(setting.currentClass)
							{
								_parent.children().removeClass(setting.currentClass).filter(':not([data-dummy="true"]):eq(' + (count - 1) + ')').addClass(setting.currentClass);
							}
							if(setting.pager)
							{
								_pager.children().removeClass(setting.currentClass).eq(count - 1).addClass(setting.currentClass);
							}
						};
						var prevValue = function(obj, index) {
							var value = 0;
							if(setting.direction == 'horizontal')
							{
								$.each(obj.filter(':lt(' + index + ')'), function() {
									value += $(this).width() + setting.offset;
								});								
							}
							else
							{
								$.each(obj.filter(':lt(' + index + ')'), function() {
									value += $(this).height() + setting.offset;
								});
							}		
							return value;
						}
						var slideAnimate = function(new_count, direction) {
							if(! animate)
							{
								if(setting.fadeOut && _slides.length < 2)
								{
									return false;
								}
								animate = true;
								setting.beforeSlide(_self, _slides, count, new_count, total);
								var child = _parent.children();
								child.stop(true, true);
								if(setting.fadeOut)
								{
									child.hide().filter(':not([data-dummy="true"]):eq(' + (count - 1) + ')').show().fadeOut(setting.animateTime, function() {
										child.filter(':not([data-dummy="true"]):eq(' + (new_count - 1) + ')').fadeIn(setting.animateTime, function() {
											setting.afterSlide(_self, _slides, new_count, total);
											count = new_count;
											updateClass();
											animate = false;
										});
									});
								}
								else
								{
									var total_run = child.length;
									var base_value;
									if(infinite_loop && 
									   ((new_count == 1 && direction == 'next') || 
										(new_count == total && direction == 'prev')))
									{
										if(direction == 'next')
										{
											_parent.children(':not([data-dummy="true"]):last').insertBefore(_parent.children(':not([data-dummy="true"]):first'));
											if(setting.fixWidth)
											{
												child.css(setting.direction == 'horizontal' ? {
													left: '-' + ((dummy_slide ? 1 : 0) * (width + setting.offset)) + 'px'
												} : {
													top: '-' + ((dummy_slide ? 1 : 0) * (height + setting.offset)) + 'px'
												});
												
											}
											else
											{		
												child.css(setting.direction == 'horizontal' ? {
													left: '-' + prevValue(_parent.children(), (dummy_slide ? 1 : 0)) + 'px'
												} : {
													top: '-' + prevValue(_parent.children(), (dummy_slide ? 1 : 0)) + 'px'
												});	
											}
											base_value = dummy_slide ? 2 : 1;
										}
										else
										{
											_parent.children(':not([data-dummy="true"]):first').insertAfter(_parent.children(':not([data-dummy="true"]):last'));
											if(setting.fixWidth)
											{
												child.css(setting.direction == 'horizontal' ? {
													left: '-' + ((total - (dummy_slide ? 0 : 1)) * (width + setting.offset)) + 'px'
												} : {
													top: '-' + ((total - (dummy_slide ? 0 : 1)) * (height + setting.offset)) + 'px'
												});
												
											}
											else
											{		
												child.css(setting.direction == 'horizontal' ? {
													left: '-' + prevValue(_parent.children(), total - (dummy_slide ? 0 : 1)) + 'px'
												} : {
													top: '-' + prevValue(_parent.children(), total - (dummy_slide ? 0 : 1)) + 'px'
												});	
											}
											base_value = total - (dummy_slide ? 1 : 2);
										}
									}
									else
									{
										base_value = new_count - (dummy_slide ? 0 : 1);
									}
									if(setting.fixWidth)
									{
										child.animate(setting.direction == 'horizontal' ? {
											left: '-' + (base_value * (width + setting.offset)) + 'px'
										} : {
											top: '-' + (base_value * (height + setting.offset)) + 'px'
										}, setting.animateTime, function() {
											if(--total_run == 0)
											{
												count = new_count;
												if(infinite_loop && 
												   ((new_count == 1 && direction == 'next') || 
													(new_count == total && direction == 'prev')))
												{
													if(direction == 'next')
													{
														child.css(setting.direction == 'horizontal' ? {
															left: '-' + ((dummy_slide ? 1 : 0) * (width + setting.offset)) + 'px'
														} : {
															top: '-' + ((dummy_slide ? 1 : 0) * (height + setting.offset)) + 'px'
														});
														_parent.children(':not([data-dummy="true"]):first').insertAfter(_parent.children(':not([data-dummy="true"]):last'));
													}
													else
													{	
														child.css(setting.direction == 'horizontal' ? {
															left: '-' + ((total - (dummy_slide ? 0 : 1)) * (width + setting.offset)) + 'px'
														} : {
															top: '-' + ((total - (dummy_slide ? 0 : 1)) * (height + setting.offset)) + 'px'
														});
														_parent.children(':not([data-dummy="true"]):last').insertBefore(_parent.children(':not([data-dummy="true"]):first'));													
													}
												}
												updateClass();
												animate = false;
												setting.afterSlide(_self, _slides, count, total);
											}
										});
									}
									else
									{
										child.animate(setting.direction == 'horizontal' ? {
											left: '-' + prevValue(_parent.children(), base_value) + 'px'
										} : {
											top: '-' + prevValue(_parent.children(), base_value) + 'px'
										}, setting.animateTime, function() {
											if(--total_run == 0)
											{
												count = new_count;
												if(infinite_loop && 
												   ((new_count == 1 && direction == 'next') || 
													(new_count == total && direction == 'prev')))
												{
													if(direction == 'next')
													{
														child.css(setting.direction == 'horizontal' ? {
															left: '-' + prevValue(child, (dummy_slide ? 1 : 0)) + 'px'
														} : {
															top: '-' + prevValue(child, (dummy_slide ? 1 : 0)) + 'px'
														});	
														_parent.children(':not([data-dummy="true"]):first').insertAfter(_parent.children(':not([data-dummy="true"]):last'));
													}
													else
													{	
														child.css(setting.direction == 'horizontal' ? {
															left: '-' + prevValue(child, total - (dummy_slide ? 0 : 1)) + 'px'
														} : {
															top: '-' + prevValue(child, total - (dummy_slide ? 0 : 1)) + 'px'
														});
														_parent.children(':not([data-dummy="true"]):last').insertBefore(_parent.children(':not([data-dummy="true"]):first'));													
													}
												}
												updateClass();
												animate = false;
												setting.afterSlide(_self, _slides, count, total);
											}
										});
									}
								}
							}
						};
						var autoSlide = function() {
							if(setting.autoPlay > 0)
							{
								clearInterval(auto_interval);
								auto_interval = setInterval(function() {
									if(setting.autoPlay > 0)
									{
										if(count < total)
										{
											slideAnimate(count + 1, 'next');
										}
										else
										{
											slideAnimate(1, 'next');
										}
									}
									else
									{
										clearInterval(auto_interval);
									}
								}, setting.autoPlay);
							}
						};
						var prevSlide = function() {
							if(count > 1)
							{
								autoSlide();
								slideAnimate(count - 1, 'prev');
							}
							else if(setting.fadeOut || infinite_loop)
							{
								slideAnimate(total, 'prev');
							}
						}
						var nextSlide = function() {
							if(count < total)
							{
								autoSlide();
								slideAnimate(count + 1, 'next');
							}
							else if(setting.fadeOut || infinite_loop)
							{
								slideAnimate(1, 'next');
							}
						}
						_prev.click(function(e) {
							prevSlide();
							e.preventDefault();
						});
						_next.click(function(e) {
							nextSlide();
							e.preventDefault();
						});
						if(setting.arrowControl)
						{
							$(document).keydown(function(e) {
								if(e.which == 37)
								{
									prevSlide();
									e.preventDefault();
								}
								else if(e.which == 39)
								{
									nextSlide();
									e.preventDefault();
								}
							});
						}
						if(setting.mouseControl)
						{
							$(document).on('mousewheel', function(e) {
								if(e.originalEvent.wheelDelta / 120 > 0)
								{
									prevSlide();
								}
								else
								{
									nextSlide();
								}
							});
						}
						if(setting.swipeControl)
						{
							var pos = {
								startX: 0,
								startY: 0,
								endX: 0,
								endY: 0
							};
							var move = clicked = false;
							var start = function(e) {
								var event = 'touches' in e.originalEvent ? e.originalEvent.touches[0] : e.originalEvent;
								pos.startX = pos.endX = event.pageX;
								pos.startY = pos.endY = event.pageY;
								move = true;
								clicked = false;
							}
							var update = function(e) {
								if(move)
								{									
									var event = 'touches' in e.originalEvent ? e.originalEvent.touches[0] : e.originalEvent;
									pos.endX = event.pageX;
									pos.endY = event.pageY;
									e.preventDefault();
								}
							}
							var end = function(e) {
								if(move)
								{
									var diff_x = pos.endX - pos.startX;
									var diff_y = pos.endY - pos.startY;
									if(setting.direction == 'horizontal')
									{
										if(Math.abs(diff_x) > setting.swipeDistance)
										{							
											if(diff_x > 0)
											{
												prevSlide();
											}
											else
											{
												nextSlide();
											}
											e.preventDefault();
										}
										else if(e.type == 'touchend')
										{
											$('html, body').stop(true, true).animate({
												scrollTop: ($(document).scrollTop() + diff_y * -1) + 'px'
											}, 'fast', 'linear');
										}
										else
										{
											clicked = true;
										}
									}
									else if(setting.direction == 'vertical')
									{
										if(Math.abs(diff_y) > setting.swipeDistance)
										{												
											if(diff_y > 0)
											{
												prevSlide();
											}
											else
											{
												nextSlide();
											}
											e.preventDefault();
										}
										else if(e.type == 'touchend')
										{
											$('html, body').stop(true, true).animate({
												scrollLeft: ($(document).scrollLeft() + diff_x * -1) + 'px'
											}, 'fast', 'linear');
										}
										else
										{
											clicked = true;								
										}
									}
									move = false;
								}
							}
							_parent.bind({
								touchstart: start,
								touchmove: update,
								touchend: end
							});
							if(setting.swipeByMouse)
							{
								_parent.bind({
									mousedown: start,
									mousemove: update,
									mouseup: end
								});
								_slides.click(function(e) {
									if(! clicked)
									{										
										e.preventDefault();
									}
								});
							}
						}
						var resize = function() {
							if(_self.is(':visible'))
							{
								var parent_width = _parent.width();
								var parent_height = _parent.height();
								if((setting.direction == 'horizontal' && width != parent_width) || 
								   (setting.direction == 'vertical' && height != parent_height))
								{
									width = parent_width;
									height = parent_height;
									setting.beforeResize(_self, _slides, count, total);
									var extra_value = 0;
									if(setting.autoMargin)
									{
										if(setting.direction == 'horizontal')
										{
											_slides.css({
												marginLeft: setting.minMargin,
												marginRight: setting.minMargin
											});
										}
										else
										{
											_slides.css({
												marginTop: setting.minMargin,
												marginBottom: setting.minMargin
											});
										}
										var responsive_width = typeof(setting.skipBoundary) == 'function' ? setting.skipBoundary(_self, _slides) : setting.skipBoundary;
										var	skip_boundary = responsive_width && _self.width() > responsive_width;
										if(skip_boundary)
										{
											extra_value = setting.minMargin * 2;
										}
									}
									var max_slide = 1, min_slide = 1;
									var slide_width, slide_height;									
									if(setting.fixWidth)
									{
										slide_width = _first.outerWidth(true);
										slide_height = _first.outerHeight(true);
										if(setting.direction == 'horizontal')
										{
											max_slide = Math.floor((width + extra_value) / slide_width);					
										}
										else
										{
											max_slide = Math.floor((height + extra_value) / slide_height);
										}
									}
									if(setting.fixedSlide)
									{
										max_slide = min_slide = typeof(setting.fixedSlide) == 'function' ? setting.fixedSlide(_self, _slides) : setting.fixedSlide;
									}
									else
									{										
										if(setting.maxSlide != 'auto')
										{
											max_slide = Math.min(parseInt(typeof(setting.maxSlide) == 'function' ? setting.maxSlide(_self, _slides) : setting.maxSlide),  max_slide);
										}
										if(setting.minSlide != 'auto')
										{
											min_slide = Math.max(parseInt(typeof(setting.minSlide) == 'function' ? setting.minSlide(_self, _slides) : setting.minSlide),  max_slide);
										}
										max_slide = Math.max(min_slide, max_slide);
									}
									_parent.append(_slides).children().not(_slides).remove();
									if(setting.fixWidth)
									{
										$.each(_slides.filter(':nth-child(' + max_slide + 'n)'), function() {
											$(this).prevAll(':lt(' + (max_slide - 1) + ')').andSelf().wrapAll('<div' + (setting.slidesClass ? ' class="' + setting.slidesClass + '"' : '') + ' />');
										});
										_parent.children().filter(_slides).wrapAll('<div' + (setting.slidesClass ? ' class="' + setting.slidesClass + '"' : '') + ' />');
										_parent.children().css(setting.direction == 'horizontal' ? {
											position: 'relative',
											width: width + 'px'
										} : {
											position: 'relative',
											height: height + 'px'
										});
									}
									else
									{
										var tmp_count = 1;
										if(setting.direction == 'horizontal')
										{
											var tmp_width = skip_boundary ? extra_value : 0;
											$.each(_slides, function() {
												var tmp_slide_width = $(this).outerWidth(true);
												var tmp_total = tmp_width + tmp_slide_width;
												if(setting.autoMargin)
												{
													tmp_total += extra_value;
												}
												if(tmp_total > width || (setting.maxSlide != 'auto' && tmp_count >= max_slide))
												{
													$($(this).prevAll().filter(_slides).get().reverse()).wrapAll('<div' + (setting.slidesClass ? ' class="' + setting.slidesClass + '"' : '') + ' style="width: ' + tmp_width + 'px;" />');
													tmp_width = tmp_slide_width + (skip_boundary ? extra_value : 0);
													tmp_count = 1;
												}
												else
												{
													tmp_width = tmp_total;
													tmp_count++;
												}
											});
											_parent.children().filter(_slides).wrapAll('<div' + (setting.slidesClass ? ' class="' + setting.slidesClass + '"' : '') + ' style="width: ' + tmp_width + 'px;" />');
										}
										else
										{
											var tmp_height = skip_boundary ? extra_value : 0;
											$.each(_slides, function() {
												var tmp_slide_height = $(this).outerHeight(true);
												var tmp_total = tmp_height + tmp_slide_height;
												if(setting.autoMargin)
												{
													tmp_total += extra_value;
												}
												if(tmp_total > height || (setting.maxSlide != 'auto' && tmp_count >= max_slide))
												{
													$($(this).prevAll().filter(_slides).get().reverse()).wrapAll('<div' + (setting.slidesClass ? ' class="' + setting.slidesClass + '"' : '') + ' style="height: ' + tmp_height + 'px;" />');
													tmp_height = tmp_slide_height + (skip_boundary ? extra_value : 0);
													tmp_count = 1;
												}
												else
												{
													tmp_height = tmp_total;
													tmp_count++;
												}
											});
											_parent.children().filter(_slides).wrapAll('<div' + (setting.slidesClass ? ' class="' + setting.slidesClass + '"' : '') + ' style="height: ' + tmp_height + 'px;" />');
										}	
										_parent.children().css({
											position: 'relative'
										});									
									}
									total = _parent.children().length;
									count = Math.min(count, total);
									if(dummy_slide)
									{
										_parent.prepend(_parent.children(':last').clone().attr('data-dummy', true));
										var remain_width = parent_width - _parent.children(':last').outerWidth() - setting.offset;
										var tmp_count = 0;
										do {
											_parent.append(_parent.children(':not([data-dummy="true"])').eq(tmp_count++).clone().attr('data-dummy', true));
											remain_width -= _parent.children(':last').outerWidth() - setting.offset;
											tmp_count %= (total - 1);
										} while(remain_width > 0);	
									}
									if(! setting.fadeOut)
									{
										if(setting.fixWidth)
										{											
											_parent.children().css(setting.direction == 'horizontal' ? {
												left: '-' + ((count - (dummy_slide ? 0 : 1)) * (width + setting.offset)) + 'px'
											} : {
												top: '-' + ((count - (dummy_slide ? 0 : 1)) * (height + setting.offset)) + 'px'
											});
										}
										else
										{
											_parent.children().css(setting.direction == 'horizontal' ? {
												left: '-' + prevValue(_parent.children(), count - (dummy_slide ? 0 : 1)) + 'px'
											} : {
												top: '-' + prevValue(_parent.children(), count - (dummy_slide ? 0 : 1)) + 'px'
											});	
										}
									}
									else
									{
										_parent.children(':gt(0)').hide();
									}
									if(setting.autoMargin)
									{
										var margin = 0;
										if(setting.fixWidth)
										{
											var counted_slide = max_slide;
											if(skip_boundary) {
												counted_slide--;
											}
											var value1, value2;
											if(setting.direction == 'horizontal')
											{
												value1 = width;
												value2 = slide_width;
											}
											else
											{
												value1 = height;
												value2 = slide_height;											
											}
											margin = Math.floor((value1 - (max_slide * value2) + (skip_boundary ? extra_value : 0)) / counted_slide / 2 * 10) / 10 + setting.minMargin;
											if(margin > 0)
											{
												_slides.css(setting.direction == 'horizontal' ? {
													marginLeft: margin + 'px',
													marginRight: margin + 'px'
												} : {
													marginTop: margin + 'px',
													marginBottom: margin + 'px'
												});
											}
										}
										else
										{
											if(setting.direction == 'horizontal')
											{
												$.each(_parent.children(), function() {
													margin = Math.floor(($(this).width() - prevValue($(this).children(), $(this).children().length)) / $(this).children().length / 2 * 10) / 10;
													$(this).children().css({
														marginLeft: margin + 'px',
														marginRight: margin + 'px'
													});
												});
											}
											else
											{	
												$.each(_parent.children(), function() {
													margin = Math.floor(($(this).height() - prevValue($(this).children(), $(this).children().length)) / $(this).children().length / 2 * 10) / 10;
													$(this).children().css({
														marginTop: margin + 'px',
														marginBottom: margin + 'px'
													});
												});									
											}
										}
										if(skip_boundary)
										{
											$.each(_parent.children(), setting.direction == 'horizontal' ? function() {
												$(this).children(':first').css('marginLeft', 0);
												$(this).children(':last').css('marginRight', 0);
											} : function() {
												$(this).children(':first').css('marginTop', 0);
												$(this).children(':last').css('marginBottom', 0);
											});
										}
									}
									if(setting.clickToSlide)
									{
										_parent.children().click(function() {
											var index;
											if($(this).attr('data-dummy'))
											{
												index = ! $(this).index() ? total : 1;
											}
											else
											{												
												index = $(this).prevAll(':not([data-dummy="true"])').length + 1;
											}
											if(index != count)
											{
												slideAnimate(index, ($(this).index() + 1) > count ? 'next' : 'prev');
											}
										});
									}
									if(setting.pager)
									{
										_pager.children().remove();
										for(var i = 1; i <= total; i++)
										{
											_pager.append(typeof(setting.pagerTemplate) == 'function' ? setting.pagerTemplate(i, total) : setting.pagerTemplate).children(':last').click(function(e) {
												_self[0].page($(this).index() + 1);												
												if(setting.pagerStopAutoPlay)
												{
													_self[0].stop();
												}
												e.preventDefault();
											});
										}
									}
									updateClass();
									setting.afterResize(_self, _slides, count, total);
								}
							}
						}
						var auto_play = setting.autoPlay;
						_self[0].start = function() {
							setting.autoPlay = auto_play;
							autoSlide();
						};
						_self[0].stop = function() {
							setting.autoPlay = 0;
						};
						_self[0].prev = function() {
							prevSlide();
						};
						_self[0].next = function() {
							nextSlide();
						};
						_self[0].page = function(page) {
							if(count != page)
							{
								var old_count = count;
								var new_count = Math.min(page, total);
								if(new_count != old_count)
								{
									slideAnimate(new_count, new_count > old_count ? 'next' : 'prev');
								}
							}
						};
						_self[0].update = function() {
							width = height = 0;
						};
						_self[0].refresh = function() {
							updateClass();
						};
						_self[0].exec = function(extra) {
							extra(_self, _slides, count, total);
						};
						_self[0].destroy = function() {
							clearInterval(auto_interval);
							clearInterval(resize_interval);
							_parent.children().stop(true, true);
							_parent.append(_slides).children().not(_slides).remove();
							_pager.children().remove();
							_slides.css(setting.direction == 'horizontal' ? {
								marginLeft: '',
								marginRight: ''
							} : {
								marginTop: '',
								marginBottom: ''
							});
							_prev.add(_next).unbind('click').removeClass(setting.disableClass);
							if(setting.currentClass)
							{
								_parent.children().removeClass(setting.currentClass);
							}
							if(setting.swipeControl)
							{
								_parent.unbind('touchstart touchmove touchend');
								if(setting.swipeByMouse)
								{
									_parent.unbind('mousedown mousemove mouseup');
									_slides.unbind('click');
								}
							}
							_self[0].start = _self[0].stop = _self[0].page = _self[0].update = _self[0].refresh = _self[0].exec = _self[0].destroy = _self[0].init = undefined;
						};
						resize_interval = setInterval(resize, setting.timeout);
						resize();
						autoSlide();
						_self[0].init = true;
						setting.afterInit(_self, _slides, count, total);
					});
				});
			}
			else
			{
				return this.each(function() {
					if(this.init)
					{
						switch(options)
						{
							case 'start':
								this.start();
								break;
							case 'stop':
								this.stop();
								break;
							case 'prev':
								this.prev();
								break;
							case 'next':
								this.next();
								break;
							case 'page':
								this.page(extra);
								break;
							case 'update':
								this.update();
								break;
							case 'refresh':
								this.refresh();
								break;
							case 'exec':
								this.exec(extra);
								break;
							case 'destroy':
								this.destroy();
								break;
						}						
					}
				});
			}
		}
	});
})(jQuery);