function gallery(base, id, prev, next){
	this.base = $(base);
	this.id   = $(id);
	this.prev = $(prev);
	this.next = $(next);
	this.interval;
	this.activeImg;
	this.width = 544;
	Event.add(this.prev, "mouseover", createMethodReference(this, "leftOver"));
	Event.add(this.next, "mouseover", createMethodReference(this, "rightOver"));
	Event.add(this.prev, "mouseout", createMethodReference(this, "clearOver"));
	Event.add(this.next, "mouseout", createMethodReference(this, "clearOver"));
	Event.add(this.prev, "click", createMethodReference(this, "Click"));
	Event.add(this.next, "click", createMethodReference(this, "Click"));
	
	this.baseImg = this.base.getElementsByTagName("IMG")[0];
	
	this.images = this.id.getElementsByTagName("IMG");
	for(var i in this.images){
		if(this.images[i].tagName == "IMG"){
			if(this.images[i].parentNode.className == "active"){
				this.activeImg = this.images[i].parentNode;
			}
			
			this.images[i].onclick = function(me, el){
				return function(e){
					me.clickImg.call(me, el);
					Event.stop();
					e = fixEvent(e);
					e.stopPropagation();
					e.preventDefault();
				}
			}(this, this.images[i]);
		}
	}
}

gallery.prototype.Click = function(e){
	e = fixEvent(e);
	e.stopPropagation();
	e.preventDefault();
}

gallery.prototype.clickImg = function(el){
	this.baseImg.src = el.lang;
	if(this.activeImg) this.activeImg.className = "pasive";
	this.activeImg = el.parentNode;
	this.activeImg.className = "active";
}

gallery.prototype.rightOver = function(e){
	clearInterval(this.interval);
	this.interval = setInterval(createMethodReference(this, "rightInterval"), 35);
	this.active();
}

gallery.prototype.rightInterval = function(){
	var leftInt = parseInt(this.id.style.left);
	if(leftInt > -this.id.offsetWidth+this.width){
		this.id.style.left = leftInt - 15 + "px";
	}else{
		clearInterval(this.interval);
		this.id.style.left = -this.id.offsetWidth+this.width + "px";
		this.next.className = "next pasive";
	}
}

gallery.prototype.leftOver = function(){
	clearInterval(this.interval);
	this.interval = setInterval(createMethodReference(this, "leftInterval"), 35);
	this.active();
}

gallery.prototype.leftInterval = function(){
	var leftInt = parseInt(this.id.style.left);
	if(leftInt < 0){
		this.id.style.left = leftInt + 15 + "px";
	}else{
		clearInterval(this.interval);
		this.id.style.left = 0;
		this.prev.className = "prev pasive";
	}
}

gallery.prototype.clearOver = function(){
	clearInterval(this.interval);
}

gallery.prototype.active = function(){
	this.prev.className = "prev";
	this.next.className = "next";
}
