function slideJS(constructorName,lstart, loop, speed, pr_step, divContent, divSquare,maxHeight,maxWidth) {
	try {
		this.constructorName = constructorName;
		this.lstart = lstart;
		this.loop = loop;
		this.speed = speed;
		this.pr_step = pr_step;
		this.timer;
		this.maxHeight = maxHeight;
		this.maxWidth = maxWidth;
		this.ObjSlide = eval("document.all."+divContent);
		this.ObjSlide.style.top=this.lstart;
		this.differenza = Math.abs(parseInt(this.maxHeight)-parseInt(this.ObjSlide.scrollHeight));
		this.differenzaOrr = Math.abs(parseInt(this.maxWidth)-parseInt(this.ObjSlide.scrollWidth));
		this.senso;
		this.senso = 0;
	} catch(e){
		riportaErrore("slideJS",e);
	}
}

//definizione dei prototype
slideJS.prototype.vaisu = vaisu;
slideJS.prototype.vaigiu = vaigiu;
slideJS.prototype.vaiasinistra = vaiasinistra;
slideJS.prototype.vaiadestra = vaiadestra;
slideJS.prototype.stop = stop;
slideJS.prototype.wheelControl = wheelControl;
slideJS.prototype.resetPosition = resetPosition;


function resetPosition(){
	this.ObjSlide.style.top=this.lstart;
}

function vaisu(vel){
	try {
		this.loop=true;
		if(parseInt(this.ObjSlide.style.top)<0){
			this.ObjSlide.style.top = parseInt(this.ObjSlide.style.top) + this.pr_step;
			if (this.loop) this.timer = setTimeout(this.constructorName+".vaisu("+vel+")",this.speed);
		}
	} catch(e){
		riportaErrore("slideJS-vaisu",e);
	}
}

function vaigiu(vel){
	try {
		this.loop=true;
		//Nel caso in cui il contenuto è + grande del riquadro
		if (parseInt(this.maxHeight) < parseInt(this.ObjSlide.scrollHeight))
		if((parseInt(this.ObjSlide.style.top) > -this.ObjSlide.scrollHeight) &&  Math.abs(parseInt(this.ObjSlide.style.top)) < this.differenza){
			this.ObjSlide.style.top = parseInt(this.ObjSlide.style.top)-this.pr_step;
			if (this.loop) this.timer = setTimeout(this.constructorName+".vaigiu("+vel+")",this.speed);
		}
	} catch(e){
		riportaErrore("slideJS-vaigiu",e);
	}
}

function vaiasinistra(vel){
	try {
		this.loop=true;
		if(parseInt(this.ObjSlide.style.left)<0){
			this.ObjSlide.style.left = parseInt(this.ObjSlide.style.left) + this.pr_step;
			if (this.loop) this.timer = setTimeout(this.constructorName+".vaiasinistra("+vel+")",this.speed);
		}
	} catch(e){
		riportaErrore("slideJS-vaiasinistra",e);
	}
}

function vaiadestra(vel){
	try {
		this.loop=true;
		//Nel caso in cui il contenuto è + grande del riquadro
		if (parseInt(this.maxWidth) < parseInt(this.ObjSlide.scrollWidth))
		if((parseInt(this.ObjSlide.style.left) > -this.ObjSlide.scrollWidth) &&  Math.abs(parseInt(this.ObjSlide.style.left)) < this.differenzaOrr){
			this.ObjSlide.style.left = parseInt(this.ObjSlide.style.left)-this.pr_step;
			if (this.loop) this.timer = setTimeout(this.constructorName+".vaiadestra("+vel+")",this.speed);
		}
	} catch(e){
		riportaErrore("slideJS-vaiadestra",e);
	}
}

function stop(){
	try {
		this.loop=false;
		if(this.timer) clearTimeout(this.timer);
	} catch(e){
		riportaErrore("slideJS-stop",e);
	}
}

function wheelControl(){
	try {
		if (event.wheelDelta >= 120) {
			tmp = this.pr_step
			this.pr_step = 5
			if (this.senso==1){
				this.vaiasinistra(1);
			}else{
				this.vaisu(1);
			}
			this.pr_step = tmp
			this.stop();
		}else if (event.wheelDelta <= -120){
			tmp = this.pr_step
			this.pr_step = 5
			if (this.senso==1){
				this.vaiadestra(1);
			}else{
				this.vaigiu(1);
			}
			this.pr_step = tmp
			this.stop();
		}
	} catch(e) {
		riportaErrore("slideJS-wheelControl",e);
	}
}

function riportaErrore(posizione, errore){
	try {
		//Se il browser supporta la scrittura
		if (window.print){
			if(document.all.errorJSimg)
			var r = '';
			for (var p in errore) r += p + ': ' + errore[p] + '<br>';
			document.all.errorJSimg.src = "/include/errorJSimg.asp?posizione="+posizione+"&errore="+r;
		}
	}
	catch (e){
	}
}