function ScrollScreen() {
	this.init();
}

ScrollScreen.prototype = {
	moveInterval : null,
	finalX : null,
	finalY : null,
	ease : 10,
	self : null,
	
	prevX : null,
	prevY : null,
	
	init : function() {
		//console.log('ScrollScreen initialized');
	},
	
	scrollIt : function(thisFinalX,thisFinalY,interval) {
		if(this.moveInterval) clearInterval(this.moveInterval);
		this.finalX = thisFinalX < 0 ? 0 : thisFinalX;
		this.finalY = thisFinalY < 0 ? 0 : thisFinalY;
		self = this;
		this.moveInterval = setInterval(this.moveIt,interval);
	},
	
	moveIt : function() {
		self.xpos = $(window).scrollLeft();
		self.ypos = $(window).scrollTop();
		
		if (self.xpos == self.finalX && self.ypos == self.finalY){
			clearInterval(self.moveInterval);
			self.moveInterval = null;
			//console.log('DONE Scrollin');
			return true;
		}
		
		if (self.xpos < self.finalX) {
			var dist = Math.ceil((self.finalX - self.xpos)  /  self.ease);
			self.xpos = self.xpos + dist;
		}
		if (self.xpos > self.finalX) {
			var dist = Math.ceil((self.xpos - self.finalX) / self.ease);
			self.xpos = self.xpos - dist;
		}
		if (self.ypos < self.finalY) {
			var dist = Math.ceil((self.finalY - self.ypos) / self.ease);
			self.ypos = self.ypos + dist;
		}
		if (self.ypos > self.finalY) {
			var dist = Math.ceil((self.ypos - self.finalY) / self.ease);
			self.ypos = self.ypos - dist;
		}
		
		if (self.xpos === self.prevX && self.ypos === self.prevY){
			clearInterval(self.moveInterval);
			self.moveInterval = null;
			//console.log('DONE Scrollin');
			return true;
		}
		
		self.prevX = self.xpos;
		self.prevY = self.ypos;
		
		window.scrollTo(self.xpos,self.ypos);
	}
};
