function Scroll()
{
	this.current_timeout;
	this.dir; //direcao
	//defino os valores padrao
	this.box_width = 372;
	this.box_width_item = 124;
	this.box_itens_name = "box_itens_galeria";
	this.anterior = '';
	this.proximo = ''
	this.move = true;
	this.left_;
	this.qtdeItensVitrine = 3;
}

Scroll.prototype.start_animation = function (mov)
{
	this.current_timeout = setTimeout("Scroll.anime()",50);
	this.dir = Math.round(mov);
}

Scroll.prototype.animation = function animation(mov)
{
	this.dir = Math.round(mov);
	anime();
}

Scroll.prototype.anime = function ()
{
	this.move = true;
	this.proximo = 'setaDir.gif';
	this.anterior= 'setaEsq.gif';
	
	var v = document.getElementById(this.box_itens_name);
	
	this.left_ = parseInt(v.style.left);
	
	v.style.left = this.get_position();
}

Scroll.prototype.get_position = function ()
{
	var left='';
	if(this.dir>0 && this.left_ >= 0)
	{
		this.move = false;
		left = '0px';
		this.anterior = 'setaEsqOff.gif';
	}
	if(this.dir<0 && this.left_ <= (this.box_width - this.box_width_item*this.qtdeItensVitrine)*-1)
	{
		this.move = false;
		left = ((this.box_width - this.box_width_item*this.qtdeItensVitrine)*-1)+'px';
		this.proximo = 'setaDirOff.gif';
	}
	document.getElementById("anterior").src = urlimg + this.anterior;
	document.getElementById("proximo").src = urlimg + this.proximo;
	if(this.move)
	{
		left = (this.left_ + this.dir) + 'px';
		this.current_timeout = setTimeout("Scroll.anime()",50);
	}
	return left;
}

Scroll.prototype.stop_animation =  function stop_animation()
{
	clearTimeout(this.current_timeout);
}

var Scroll = new Scroll()
