function Scroller(id){
	var completeID = id+"_scroller";
	this.id = completeID;
	this.conteiner = document.getElementById(id);
	this.photos = this.conteiner.getElementsByTagName("ul")[0];
	var images = this.photos.getElementsByTagName("li");
	var imageW = images[0].offsetWidth;
	var buttW = 42;
	var totalW = imageW*images.length;
	this.width = this.conteiner.offsetWidth-(buttW*2);
	this.height = this.conteiner.offsetHeight;
	this.photos.style.width = totalW+"px";	// per IE devo assegnare anche il totale larghezza
	if(this.width<totalW){
		this.photos.style.position = "absolute";	// se non lo faccio da codice lo scorrimento nn funge
		this.photos.style.top = "25px";				// se non lo faccio da codice lo scorrimento nn funge
		this.photos.style.left = "0px";
		this.blockWidth = this.photos.offsetWidth;
		this.blockHeight = this.photos.offsetHeight;
		var buttons = this.conteiner.getElementsByTagName("a");
		for(var i=0,img;i<buttons.length;i++){
			if(buttons[i].target){
				buttons[i].onclick = function(){
											window[completeID].move(this.target,imageW*2);
											return false;
								 		}
			}
		}
	}else{
		this.photos.style.position = "relative";	// se non lo faccio da codice lo scorrimento nn funge
		this.photos.style.top = "0px";				// se non lo faccio da codice lo scorrimento nn funge
		this.photos.style.left = "0px";
		this.photos.style.marginLeft = "auto";
		this.photos.style.marginRight = "auto";
	}
	this.move = function(direction,hMany){
					moveBlock(this.id,direction,hMany);
				}
	return window[this.id] = this;
}

function setCurrentMover(id,direction,hMany){
	window.currentMover = {id:id,
						   direction:direction,
						   hMany:hMany,
						   obj:window[id]};
	clearTimeout(window.scrollerTimeID); // se non fosse stato annullato
	return window.currentMover;
}
function getCurrentMover(){
	return window.currentMover;
}

function moveBlock(id,direction,hMany){
	var myMover = setCurrentMover(id,direction,hMany);
	var obj = myMover.obj;
	if(obj){
		var left = parseInt(obj.photos.style.left,10);
		var max;
		var moveTo = 0;
		switch(myMover.direction){
			//case "left":
			case "right":
				max = -(obj.blockWidth - obj.width);
				moveTo = left - myMover.hMany;
				if(moveTo<max)
					moveTo = max;
				myMover.moveTo = moveTo;
				_moveLeft();
			break;
			//case "right":
			case "left":
				max = 0;
				moveTo = left + myMover.hMany;
				if(moveTo>max)
					moveTo = max;
				myMover.moveTo = moveTo;
				_moveRight();
			break;
		}
	}
}

function _moveLeft(){
	var myMover = getCurrentMover();
	if(myMover){
		var left = parseInt(myMover.obj.photos.style.left,10);
		if(left>myMover.moveTo){
			myMover.obj.photos.style.left = (left-10)+"px";
			window.scrollerTimeID = setTimeout("_moveLeft()",1);
		}else
			clearTimeout(window.scrollerTimeID);
	}
}

function _moveRight(){
	var myMover = getCurrentMover();
	if(myMover){
		var left = parseInt(myMover.obj.photos.style.left,10);
		if(left<myMover.moveTo){
			myMover.obj.photos.style.left = (left+10)+"px";
			window.scrollerTimeID = setTimeout("_moveRight()",1);
		}else
			clearTimeout(window.scrollerTimeID);
	}
}
