function cScroller () {//states: 1 - down , -1 - up , -2 - right , 2 - left
	this.objects = {};
	this.speed = 10;

	this.init = function (objID,state) {
		var obj = {};
		obj.obj = document.getElementById(objID);
		obj.state = state;
		obj.timer = null;
		obj.maxVertScroll = parseInt(obj.obj.scrollHeight) - parseInt(obj.obj.offsetHeight);
		obj.maxHorizScroll = (parseInt(obj.obj.scrollWidth) - parseInt(obj.obj.offsetWidth));
		this.objects[objID] = obj;
	}

	this.down = function (id,timer) {
		if (this.objects[id] == undefined) {
			this.init(id,1);
		}
		var obj = this.objects[id];
		if (timer == undefined) {
			obj.state = 1;
		}

		if ((obj.maxVertScroll > obj.obj.scrollTop) && (obj.state == 1)) {
			obj.obj.scrollTop = (obj.obj.scrollTop + this.speed);
			obj.timer = setTimeout(this.down.bind(this,id,true),30);
		}

	}

	this.right = function (id,timer) {
		if (this.objects[id] == undefined) {
			this.init(id,-2);
		}
		var obj = this.objects[id];
		if (timer == undefined) {
			obj.state = -2;
		}

		if ((obj.maxHorizScroll > obj.obj.scrollLeft) && (obj.state == -2)) {
			obj.obj.scrollLeft = (parseInt(obj.obj.scrollLeft) + this.speed);
			obj.timer = setTimeout(this.right.bind(this,id,true),30);
		}

	}


	this.up = function (id,timer) {
		if (this.objects[id] == undefined) {
			this.init(id,-1);
		}
		var obj = this.objects[id];
		if (timer == undefined) {
			obj.state = -1;
		}

		if ((obj.obj.scrollTop > 0) && (obj.state == -1)) {
			obj.obj.scrollTop = (parseInt(obj.obj.scrollTop) - this.speed);
			if (obj.obj.scrollTop < 0) obj.obj.scrollTop = 0;
			obj.timer = setTimeout(this.up.bind(this,id,true),30);
		}
	}


	this.left = function (id,timer) {
		if (this.objects[id] == undefined) {
			this.init(id,2);
		}
		var obj = this.objects[id];
		if (timer == undefined) {
			obj.state = 2;
		}

		if ((obj.obj.scrollLeft > 0) && (obj.state == 2)) {
			obj.obj.scrollLeft = (parseInt(obj.obj.scrollLeft) - this.speed);
			if (obj.obj.scrollLeft < 0) obj.obj.scrollLeft = 0;
			obj.timer = setTimeout(this.left.bind(this,id,true),30);
		}
	}

	this.stop = function (id) {
		if (this.objects[id]) {
			clearTimeout(this.objects[id].timer);
			this.objects[id].state = 0;
		}
	}



}
