function _(str) {
	return document.getElementById(str);
}

var __TagObj__list = new Array();

function TagObj(id) {

	this.id = __TagObj__list.length;
	__TagObj__list.push(this);
	this.obj = _(id);

	////////////////////////////////////////////////////////////////////////////
	// visibility

	this.visible = true;
	this.visibleType = false;

	this.show = function() {
		this.obj.style.display = (this.visibleType?this.visibleType:'block');
		this.visible = true;
	}

	this.hide = function() {
		if (this.obj.style.display != 'none') {
			this.visibleType = this.obj.style.display;
			this.obj.style.display = 'none';
			this.visible = false;
		}
	}

	////////////////////////////////////////////////////////////////////////////
	// position / move

	this.x = 0;
	this.y = 0;
	this.fromx = 0;
	this.fromy = 0;
	this.targetx = 0;
	this.targety = 0;
	this.movesmooth = false;
	this.movesteps = 0;
	this.movestepsdone = 0;
	this.moverunner = false;

	this.setPos = function(x, y, nochange) {
		if (!nochange) {
			this.targetx = this.fromx = this.x = x;
			this.targety = this.fromy = this.y = y;
		}
		else {
			this.x = x;
			this.y = y;
		}
		this.obj.style.left = x+'px';
		this.obj.style.top = y+'px';
	}

	this.moveTo = function(x, y, t, s) {
		if (!(x==this.targetx && x==this.x && y==this.targety && y==this.y)) {
			this.fromx = this.x;
			this.fromy = this.y;
			this.targetx = x;
			this.targety = y;
			this.movesteps = Math.round(t/20);
			if (!this.movesteps)
				this.movesteps = 1;
			this.movestepsdone = 0;
			this.movesmooth = s ? true : false;

			if (!this.moverunner) {
				this.moverunner = true;
				this.runner();
			}
		}
	}

	this.runner = function() {
		if (this.moverunner) {
			var x = 0, y = 0;
			this.movestepsdone++;
			if (this.movestepsdone < this.movesteps) {
				if (this.movesmooth) {
					x = Math.round(this.fromx+(this.targetx-this.fromx)*(this.smoothpos(this.movestepsdone/this.movesteps)));
					y = Math.round(this.fromy+(this.targety-this.fromy)*(this.smoothpos(this.movestepsdone/this.movesteps)));
				}
				else {
					x = Math.round(this.fromx+(this.targetx-this.fromx)*(this.movestepsdone/this.movesteps));
					y = Math.round(this.fromy+(this.targety-this.fromy)*(this.movestepsdone/this.movesteps));
				}
			}
			else {
				x = this.targetx;
				y = this.targety;
				this.moverunner = false;
			}
			this.setPos(x, y, true);
			if (this.moverunner) {
				window.setTimeout('__TagObj__list['+this.id+'].runner();', 20);
			}
		}
	}

	this.smoothpos = function(perc) {
		return Math.cos(Math.PI+perc*Math.PI)/2+0.5;
	}

}

