function Gallery(obj)
{
	var self = this;
	this.delay = obj.delay;
	this.cur = 0;
	this.count = $('#'+obj.element+' .item').length;
	if(obj.next)
		$('#'+obj.next).click(function(){self.next();return false;});
	if(obj.prev)
		$('#'+obj.prev).click(function(){self.prev();return false;});
	var parent = $('#'+obj.element);
	
	this.item = parent.find('.window')
	
	parent.height(this.item.height());
	
	this.pages = $('#'+obj.pages+' a');
	for(var i=0,len=this.pages.length;i<len;i++)
	{
		this.pages[i].id=i;
		this.pages[i].onclick = function(){
			self.show(this.id);
			return false
		};
	}
	this.slide()();
}
Gallery.prototype.next = function()
{
	if(this.cur<this.count-1)
		this.show(this.cur+1);
	return false;
}
Gallery.prototype.prev = function()
{
	if(this.cur>0)
		this.show(this.cur-1);
	return false;
}
Gallery.prototype.slide = function()
{
	var self = this;
	return function() {
		if(self.cur<self.count-1)
			self.show(self.cur+1);
		else
			self.show(0);
	}
}
Gallery.prototype.show = function(num)
{
	clearTimeout(this.t);
	this.cur = parseInt(num,10);
	for(var i=0,len=this.pages.length;i<len;i++)
		this.pages[i].className = '';
	if(this.pages[num])
		this.pages[num].className = 'active';
	//this.item[0].style.left=-(num)+'00%';
	$(this.item[0]).animate({left: '-'+num+'00%'}, 'fast');
	this.t = setTimeout(this.slide.call(this),this.delay*1000);
}
