function TextPane(
		html,		// the source text in HTML form
		ix,			// central x coord
		iy,			// central y coord
		iw,			// container width
		ih			// container height
	) {
	
	this.pw = vpw/100;
	this.ph = vph/100;
	ix *= this.pw;
	iy *= this.ph;
	iw *= this.pw;
	ih *= this.ph;
	
	this.orientation = -1;
	this.html =		html;
	this.zoom =		Math.sqrt((vpw*vpw)+(vph*vph));
	this.ix =		ix;
	this.iy = 		iy;
	this.iz = 		this.zoom;
	this.iw = 		iw;
	this.ih =		ih;
	this.icx=		Math.floor(iw / 2);
	this.icy=		Math.floor(ih / 2);
	this.xpiv =		-1;
	this.xrot = 	0;
	this.ypiv =		-1;
	this.yrot = 	0;
	this.ebod =		document.getElementById("core");
	this.dive =		[null];
	this.queue = 	[null];
	this.stable =	false;
	this.zfactor =	2;
	this.uid = 		Math.floor(Math.random()*10000000);
	this.reverse =	false;
	this.prepared = false;
	this.opacity =	1.0;
	this.overflow = "hidden";
}
function textpane_getClass() { return "TextPane"; }
function textpane_setup() {
	this.numslices = 1;
	this.half = 0.5;

	var i = 0;
	this.dive[i] = document.createElement("div");
	this.dive[i].id = "dive"+this.uid+"_"+i;
	this.dive[i].style.position = "absolute";
	this.dive[i].style.left = "-1000px";
	this.dive[i].style.top = "-1000px";
	this.dive[i].style.left = this.ix+"px";
	this.dive[i].style.top = this.iy+"px";
	this.dive[i].style.width = this.iw+"px";
	this.dive[i].style.height = this.ih+"px";
	this.dive[i].style.overflow = this.overflow;
	this.dive[i].style.backgroundColor = "transparent";
	this.dive[i].style.zIndex = "240";
	this.dive[i].className = "pane";

	var inner = document.createElement("div");
	inner.style.width = this.iw+"px";
	inner.style.height = this.ih+"px";
	inner.style.fontSize = Math.floor(this.zoom/90)+"px";
	inner.innerHTML = this.html
	this.dive[i].appendChild(inner);

	this.ebod.appendChild( this.dive[i] );
	this.prepared = true;
}

function textpane_run3d() {
	if (!this.prepared) this.setup();
	var i = 0;
	this.dive[i].style.left = ""+((this.pw*this.ix)-this.icx)+"px";
	this.dive[i].style.top= ""+((this.ph*this.iy)-this.icy)+"px";
	this.dive[i].style.width = ""+Math.floor(this.iw)+"px";
	this.dive[i].style.height = ""+Math.floor(this.ih)+"px";
	this.dive[i].style.overflow = this.overflow;
	setOpacity(this.dive[i],this.opacity*100);
	
	if ((this.queue!=null) && (this.queue[0]!=null)) {
		var finished = false;
		var i = -1;
		while (++i < this.queue.length) {
			if (this.queue[i] != null) {
				if (this.queue[i].getType()=="DelayTask") {
					if (i==0) {
						this.queue[i].finish();
					} else {
						i = this.queue.length;
					}
				} else if (this.queue[i].getType()=="WaitTask") {
					this.queue[i].advance();
					if (this.queue[i].isFinished()) finished = true;
					i = this.queue.length;
				} else if (this.queue[i].getType()=="XOrientationTask") {
					this.orientation = 1;
					this.queue[i].finish();
				} else if (this.queue[i].getType()=="YOrientationTask") {
					this.orientation = 0;
					this.queue[i].finish();
				} else if (this.queue[i].getType()=="MoveTask") {
					this.ix = this.queue[i].getX();
					this.iy = this.queue[i].getY();
					this.queue[i].advance();
					if (this.queue[i].isFinished()) finished = true;
				} else if (this.queue[i].getType()=="FadeTask") {
					this.opacity = this.queue[i].getO();
					this.queue[i].advance();
					if (this.queue[i].isFinished()) finished = true;
				} else if (this.queue[i].getType()=="HideTask") {
					this.opacity = 0;
					this.queue[i].finish();
					finished = true;
				} else if (this.queue[i].getType()=="JumpTask") {
					this.ix = this.queue[i].getX();
					this.iy = this.queue[i].getY();
					this.queue[i].finish();
					finished = true;
				} else if (this.queue[i].getType()=="LiftTask") {
					this.queue[i].finish(); finished = true; // Not Supported
				} else if (this.queue[i].getType()=="ElevatedMoveTask") {
					this.queue[i].finish(); finished = true; // Not Supported
				} else if (this.queue[i].getType()=="BounceTask") {
					this.queue[i].finish(); finished = true; // Not Supported
				} else if (this.queue[i].getType()=="DropTask") {
					this.queue[i].finish(); finished = true; // Not Supported
				} else if (this.queue[i].getType()=="YSpinTask") {
					this.queue[i].finish(); finished = true; // Not Supported
				} else if (this.queue[i].getType()=="XSpinTask") {
					this.queue[i].finish(); finished = true; // Not Supported
				} else if (this.queue[i].getType()=="XSpinReplaceTask") {
					this.queue[i].finish(); finished = true; // Not Supported
				} else if (this.queue[i].getType()=="YSpinReplaceTask") {
					this.queue[i].finish(); finished = true; // Not Supported
				} else {
					this.queue[i].finish();
					finished = true;
				}
			}
		}
		if (finished) {
			i = -1;
			var n = 0;
			var q2 = [null];
			while (++i < this.queue.length) {
				if (!this.queue[i].isFinished()) q2[n++] = this.queue[i];
			}
			this.queue = q2;
		}
	} else {
		this.stable = true;
	}
}
function textpane_offX(e) {
	var x = 0;
	while (e!=null) {
		x = x + e.offsetLeft;
		e = e.offsetParent;
	}
	return x;
}
function textpane_offY(e) {
	var y = 0;
	while (e!=null) {
		y = y + e.offsetTop;
		e = e.offsetParent;
	}
	return y;
}
function textpane_getScreenX(x,y,z) {
	return ( (x / z) * this.zoom);
}
function textpane_getScreenY(x,y,z) {
	return ( (y / z) * this.zoom);
}
function textpane_getScreenWidth(z) {
	return this.iw
}
function textpane_getScreenHeight(z) {
	return this.ih
}
function textpane_setStrip(i,basex,basey,x,y,z) {} // not supported
function textpane_isStable() {
	return this.stable;
}
function textpane_addTask(task) {
	if ((this.queue==null) || (this.queue[0]==null)) {
		this.queue[0] = task;
	} else {
		this.queue[this.queue.length] = task;
	}
}
function textpane_runQueue() {
	if ((this.queue==null) || (this.queue[0]==null)) return;
	if (!this.prepared) this.setup();
	var i = -1;
	while (++i < this.queue.length) {
		this.queue[i].start();
	}
	this.stable = false;
}
function textpane_getUID() {return this.uid; }
function textpane_getBaseZ() {return this.zoom; }
function textpane_getCurrentX() { return this.ix; }
function textpane_getCurrentY() { return this.iy; }
function textpane_getCurrentZ() { return this.iz; }
function textpane_getCurrentOrientation() { return this.orientation; }
function textpane_getOpacity() { return this.opacity; }
function textpane_setOpacity(o) { this.opacity = o; }
function textpane_centerPivot() { this.xpiv = 0; this.ypiv = 0; }
function textpane_leftPivot() { this.ypiv = 1; }
function textpane_rightPivot() { this.ypiv = 2; }
function textpane_topPivot() { this.xpiv = 1; }
function textpane_bottomPivot() { this.xpiv = 2; }
function textpane_orient(o) {} // not supported
function textpane_rolloverX( src ) {} // not supported
function textpane_getQueueLength() {
	return this.queue.length;
}
function textpane_setOverflow(o) {
	this.overflow = o;
}

TextPane.prototype.setup = textpane_setup;
TextPane.prototype.getClass = textpane_getClass;
TextPane.prototype.run = textpane_run3d;
TextPane.prototype.offX = textpane_offX
TextPane.prototype.offY = textpane_offY
TextPane.prototype.getScreenX = textpane_getScreenX;
TextPane.prototype.getScreenY = textpane_getScreenY;
TextPane.prototype.getScreenWidth = textpane_getScreenWidth;
TextPane.prototype.getScreenHeight = textpane_getScreenHeight;
TextPane.prototype.setStrip = textpane_setStrip;
TextPane.prototype.isStable =pane_isStable;
TextPane.prototype.addTask = textpane_addTask;
TextPane.prototype.runQueue = textpane_runQueue;
TextPane.prototype.getUID = textpane_getUID;
TextPane.prototype.getBaseZ = textpane_getBaseZ;
TextPane.prototype.getCurrentX = textpane_getCurrentX;
TextPane.prototype.getCurrentY = textpane_getCurrentY;
TextPane.prototype.getCurrentZ = textpane_getCurrentZ;
TextPane.prototype.x = textpane_getCurrentX;
TextPane.prototype.y = textpane_getCurrentY;
TextPane.prototype.z = textpane_getCurrentZ;TextPane.prototype.getCurrentOrientation = textpane_getCurrentOrientation;
TextPane.prototype.centerPivot = textpane_centerPivot;
TextPane.prototype.leftPivot = textpane_leftPivot;
TextPane.prototype.rightPivot = textpane_rightPivot;
TextPane.prototype.topPivot = textpane_topPivot;
TextPane.prototype.bottomPivot = textpane_bottomPivot;
TextPane.prototype.orient = textpane_orient;
TextPane.prototype.rolloverX = textpane_rolloverX;
TextPane.prototype.getQueueLength = textpane_getQueueLength;
TextPane.prototype.getOpacity = textpane_getOpacity;
TextPane.prototype.setOverflow = textpane_setOverflow;
