function Gallery(div) {
	
	//Settings
	this.delay = 2000; //5 seconds of the delay
	
	//Protected	
	var _index = 0; //Current image
	var _int; //Auto play iterval
	
	//Cache
	var _me = this;
	var _div = div
	var _holder = div;
	var _items = div.find(".item");
	var _num = _items.length;//Total number of the images
	var _w = _items.eq(0).css("width").replace("px", "") * 1;//The width of one item
	var _h = _items.eq(0).css("height").replace("px", "") * 1;//The width of one item
	
	//How actually to swap the items
	this.doSwap = function(next_index, current_index){
		//Override me
	}
	
	//Show next image	
	this.next = function(){
		
		//Get next image index
		var current_index = _index;
		++_index;
		if(_index >= _num){
			_index = 0;
		}
		
		//Scroll to the item
		this.show(_index, current_index, "next");
	}
	
	//Show prev image	
	this.prev = function(){
		
		//Get next image index
		var current_index = _index;
		--_index;
		if(_index < 0){
			_index = _num - 1;
		}
		
		//Scroll to the item
		this.show(_index, current_index, "prev");
	}
	
	//Show the item
	this.show = function(index, current_index, type){
		
		//Validate index
		if(index < 0 || index >= _num){
			return false;
		}
		if(current_index == undefined){
			current_index = _index;
		}
		
		//Validate index again
		if(index == current_index){
			return false;
		}
		_index = index;
		
		this.doSwap(index, current_index, type);
	}
	
	//Start autoplay
	this.startAutoplay = function(){
		clearInterval(_int);
		
		var me = this;
		_int = setInterval(function(){me.next()}, me.delay);
	}
	
	//Start autoplay
	this.stopAutoplay = function(){
		clearInterval(_int);
	}
	
	//Holder getter
	this.getHolder = function(){
		return _holder;
	}
	
	//Items getter
	this.getItems = function(){
		return _items;
	}
	
	//Slide width getter
	this.getSlideWidth = function(){
		return _w;
	}
	
	//Slide height getter
	this.getSlideHeight = function(){
		return _h;
	}
}
