function TextPane( ) {
	this.init( );
}

TextPane.prototype.init = function( ) {
	this.width = 0;
	this.height = 0;
	this.marginTop = 0;
	this.marginRight = 0;
	this.marginBottom = 0;
	this.marginLeft = 0;
	this.content = "";
	this.rng = null;
	this.el = null;
	this.htmlFrag = "";
}

TextPane.prototype.setWidth = function( val ) {
	this.width = val;
}
TextPane.prototype.setHeight = function( val ) {
	this.height = val;
}
TextPane.prototype.setMarginTop = function( val ) {
	this.marginTop = val;
}
TextPane.prototype.setMarginRight = function( val ) {
	this.marginRight = val;
}
TextPane.prototype.setMarginBottom = function( val ) {
	this.marginBottom = val;
}
TextPane.prototype.setMarginLeft = function( val ) {
	this.marginLeft = val;
}
TextPane.prototype.setMargin = function( top, right, bottom, left ) {
	this.setMarginTop( top );
	this.setMarginRight( right );
	this.setMarginBottom( bottom );
	this.setMarginLeft( left );	
}
TextPane.prototype.setContent = function( val ) {
	this.content = val;
	//if IE 4+
	if (document.all) {
		dcontent.style.display = (this.content == null || this.content == '' || this.content == ' ') ? 'none' : 'block';
		dcontent.innerHTML=this.content;
	}
	//else if NS 6 (supports new DOM)
	else if (document.getElementById) {
		this.rng = document.createRange();
		this.el = document.getElementById("dcontent");
		this.el.style.display = (this.content == null || this.content == '' || this.content == ' ') ? 'none' : 'block';
		this.rng.setStartBefore(this.el);
		this.htmlFrag = this.rng.createContextualFragment(this.content);
		while (this.el.hasChildNodes())
			this.el.removeChild(this.el.lastChild);
		this.el.appendChild(this.htmlFrag);
	}
}
TextPane.prototype.draw = function( ) {
	var trueWidth = this.width - this.marginLeft - this.marginRight;
	var trueHeight = this.height - this.marginTop - this.marginBottom;
	var tpcStyles = '<style type="text/css">.textPaneContainer {	width:'+this.width+'px;';
	tpcStyles += (this.height != 0) ? ' height:'+this.height+'px;' : '';
	tpcStyles += ' padding:'+this.marginTop+'px '+this.marginRight+'px '+this.marginBottom+'px '+this.marginLeft+'px;';
	tpcStyles += ' voice-family: "\"}\""; voice-family:inherit; width:'+trueWidth+'px;';
	tpcStyles += (this.height != 0) ? ' height:'+trueHeight+'px;' : '';
	tpcStyles += '} html>body .textPaneContainer { width:'+trueWidth+'px;';
	tpcStyles += (this.height != 0) ? ' height:'+trueHeight+'px;' : '';
	tpcStyles += '}</style>';

	var tpStyles = ' style="width:'+trueWidth+'px;';
	tpStyles += (this.height != 0) ? ' height:'+trueHeight+'px"' : '"';
	var out = tpcStyles;
	out += '<div class="textPaneContainer"><div id="dcontent" class="textPane"'+tpStyles+'></div></div>';
	document.write(out);
	return (true);
}

