function console() {
	this.con = document.createElement("DIV");
		this.con.style.position = 'absolute';
		this.con.style.top = '100px';
		this.con.style.left = '800px';
		this.con.style.width = '100px';
		this.con.style.height = '300px';
		this.con.style.background = '#DDDDDD';
		this.con.style.overflow = 'scroll';
		this.con.innerHTML = '>';

	//document.body.appendChild(this.con);

	this.active = true;

	this.echo = function (text) {
		if (this.active) {
			var x = document.createElement("TEXT");
			x.innerHTML = text;
			this.con.appendChild(x);

			this.con.scrollTop = parseInt(this.con.scrollHeight) - parseInt(this.con.style.height) + 20;
		}
	}

	this.deactivate = function() {
		this.active = false;
		this.con.style.display = 'none';
	}

	this.activate = function() {
		this.active = true;
		this.con.style.display = 'block';
	}

}

var myconsole = new console();
	myconsole.deactivate();


/********************************************************************************************************************/
function Scroller(container_id) {
	this.container = document.getElementById( container_id + '_container');

	if (this.container == null) {
		//alert( container_id + ' NOT FOUND');
		this.container_height = 0;
		this.container_width = 0;
		this.container_scrollTop = 0;
		this.container_scrollLeft = 0;

		this.content = null;

		this.box = Array();
		this.arrow_on = Array();
		this.arrow_off = Array();
	} else {

		this.container_height = parseInt(this.container.style.height);
		this.container_width = parseInt(this.container.style.width);
		this.container_scrollTop = 0;
		this.container_scrollLeft = 0;

		this.content = document.getElementById( container_id + '_content');

		this.box = Array();
			this.box[3] = document.getElementById( container_id + '_left' );
			this.box[1] = document.getElementById( container_id + '_right' );
			this.box[2] = document.getElementById( container_id + '_up' );
			this.box[4] = document.getElementById( container_id + '_down' );

		this.arrow_on = Array();				this.arrow_off = Array();
			this.arrow_on[1] = function() {};		this.arrow_off[1] = function() {};
			this.arrow_on[2] = function() {};		this.arrow_off[2] = function() {};
			this.arrow_on[3] = function() {};		this.arrow_off[3] = function() {};
			this.arrow_on[4] = function() {};		this.arrow_off[4] = function() {};
	}

	//if (content)
	//	this.temp = Math.min( parseInt(content.style.height), parseInt(content.style.width) );
	//else
		this.temp = 800;

	this.speed_min = parseInt( this.temp / 16 );
	this.speed_max = parseInt( this.temp /  8 );

	this.acc_val = parseInt( this.speed_min / 1.6);
	this.acc_cnt = 1;

	this.speed_val = this.speed_min;
	this.speed_cnt = 0;
	//this.speed_frv = parseInt( 3000 / 1.6 / 2);
	this.speed_frv = 2000;

	this.timer = Array(0,0,0,0);

	this.accelerate = function() {
		if ( this.speed_val < this.speed_max ) {
			if ( this.speed_cnt < this.acc_cnt ) {
				this.speed_cnt ++;
			} else {
				this.speed_cnt = 0;
				this.speed_val = this.speed_val + this.acc_val;
				if (this.speed_val > this.speed_max)
					this.speed_val = this.speed_max;
			}
		}
	}

	this.scroll_timer = function(directie) {
		//var content_height = parseInt(content.style.height);
		//var content_width = parseInt(content.style.height);

		//alert('scroll timer - ' + directie);
		if (this.container == null)
			return;

		this.accelerate();

		myconsole.echo('<br />D / S : ' + directie + '/' + this.speed_val) ;

		switch(directie) {
			case 1 :
				var scroll_max = parseInt(this.container.scrollWidth) - parseInt(this.container.style.width);

				if (myconsole)
					myconsole.echo('<br />SL / S /SM: ' + this.container_scrollLeft + '/' + this.speed_val + '/' + scroll_max);
				if ( this.container_scrollLeft + this.speed_val < scroll_max )
					this.container.scrollLeft = this.container_scrollLeft = this.container_scrollLeft + this.speed_val;
				else {
					this.container.scrollLeft = this.container_scrollLeft = scroll_max;
					this.scroll_stop(1);
				}

			break;

			case 2 :
				myconsole.echo('<br />SU / S : ' + this.container_scrollTop + '/' + this.speed_val);

				if ( this.container_scrollTop - this.speed_val > 0 )
					this.container.scrollTop = this.container_scrollTop = this.container_scrollTop - this.speed_val;
				else {
					this.container.scrollTop = this.container_scrollTop = 0;
					this.scroll_stop(2);
				}

			break;
			case 3 :
				myconsole.echo('<br />SL / S : ' + this.container_scrollLeft + '/' + this.speed_val);

				if ( this.container_scrollLeft - this.speed_val > 0 )
					this.container.scrollLeft = this.container_scrollLeft = this.container_scrollLeft - this.speed_val;
				else {
					this.container.scrollLeft = this.container_scrollLeft = 0;
					this.scroll_stop(3);
				}

			break;

			case 4 :
				var scroll_max = parseInt(this.container.scrollHeight) - parseInt(this.container.style.height);

				if (myconsole)
					myconsole.echo('<br />SD / S /SM: ' + this.container_scrollTop + '/' + this.speed_val + '/' + scroll_max);
				if ( this.container_scrollTop + this.speed_val < scroll_max )
					this.container.scrollTop = this.container_scrollTop = this.container_scrollTop + this.speed_val;
				else {
					this.container.scrollTop = this.container_scrollTop = scroll_max;
					this.scroll_stop(4);
				}

			break;
		}

	}

	this.scroll_start = function(directie) {
		if (directie) {
			if (this.timer[directie])
				return;

			this.speed_val = this.speed_min;
			this.speed_cnt = 0;

			this.timer[directie] = setInterval("scrollers['"+container_id+"'].scroll_timer("+directie+")", this.speed_frv);
			this.arrow_on[directie]();
			//alert('scroll start - ' + 1);
		}
	}

	this.scroll_stop = function(directie) {
		if (directie) {
			clearInterval(this.timer[directie]);
			this.timer[directie] = 0;
			this.arrow_off[directie]();
		} else
			for(var i=1; i<5; i++) {
				clearInterval(this.timer[i]);
				this.timer[i] = 0;
				this.arrow_off[i]();
			}

		//alert('scroll stop - '+directie);
	}

	this.scroll_remap = function(container_id) {
		//this.scroll_stop();
		this.container = document.getElementById( container_id + '_container');

		if (this.container) {
			this.container_height = parseInt(this.container.style.height);
			this.container_width = parseInt(this.container.style.width);
			this.container_scrollTop = 0;
			this.container_scrollLeft = 0;

			this.content = document.getElementById( container_id + '_content');

			this.box[3] = document.getElementById( container_id + '_left' );
			this.box[1] = document.getElementById( container_id + '_right' );
			this.box[2] = document.getElementById( container_id + '_up' );
			this.box[4] = document.getElementById( container_id + '_down' );
		}
	}
}

var scrollers = new Object();