function Gallery(div) {
	
	//Settings
	this.delay = 7000; //7 seconds of the delay
	this.on_page = 4;
	
	//Protected	
	var _index = 0; //Current image
	var _int; //Auto play iterval
	
	//Cache
	var _me = this;
	var _div = div
	var _holder = div.find(".slides_wrapper");
	var _items = div.find(".slider_item");
	
	var _num_items = _items.length;
	var _on_page = 4;	
	var _num = Math.ceil(_num_items / this.on_page);//Total number of the images	
	var _w = 157;//The width of one item
	
	//Getter
	this.getIndex = function(){
		return _index;
	}
	this.getTotalNum = function(){
		return _num_items;
	}
	
	//Once images begin swap
	this.onSwap = function(index){
		//Override me
	}
	
	//Show next image	
	this.next = function(){
		
		//Get next image index
		++_index;
		if(_index >= _num){
			_index = 0;
		}
		
		//Scroll to the item
		this.show(_index);
	}
	
	//Show prev image	
	this.prev = function(){
		
		//Get prev image index
		--_index;
		if(_index < 0){
			_index = _num - 1;
		}
		
		//Scroll to the item
		this.show(_index);
	}
	
	//Show the item
	this.show = function(index){
		
		//Validate index
		if(index < 0 || index >= _num){
			return false;
		}
		_index = index;
		
		this.onSwap(index);
		
		//Calculate the position
		_holder.stop().animate({"left": -index * _w * this.on_page}, 700);
	}
	
	//Start autoplay
	this.startAutoplay = function(){
		clearInterval(_int);
		
		var me = this;
		_int = setInterval(function(){me.next()}, me.delay);
	}
	
	//Start autoplay
	this.stopAutoplay = function(){
		clearInterval(_int);
	}
}
