
var panorama = {
	interval: 0,
	speed: 0,
	position: 0,
	left: true,
	element: null,

	init: function (id) {
		this.interval = 0;
		this.speed = 0;
		this.position = 0;
		this.left = true;
		this.element = null;
	
		if (this.interval)
			clearInterval(this.interval);
			
		this.element = document.getElementById(id);
		this.element.onmousemove = function (e) {
			panorama.left = false;
			if (!e)
				e = event;
			panorama.speed = ((e.clientX - panorama.element.offsetLeft) - (panorama.element.clientWidth / 2)) / (panorama.element.clientWidth / 35);
		};
		
		this.interval = setInterval(function () {
			if (panorama.left && (panorama.speed > 0.001 || panorama.speed < -0.001)) {
				panorama.speed = panorama.speed / 1.2;
			}
		
			panorama.position -= panorama.speed;
			panorama.element.style.backgroundPosition = panorama.position + "px 0";
		}, 30);
		
		this.element.onmouseout = function () {
			panorama.left = true;
		};
	}
};

