function MTextControl(MOptions) {
	MOptions = MOptions ? MOptions : {};
	this.position = MOptions.position ? MOptions.position : new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(5, 3));
	this.width = MOptions.width ? MOptions.width : 150;
	this.height = MOptions.height ? MOptions.height : false;

}

MTextControl.prototype = new GControl(true,false);

MTextControl.prototype.initialize = function(map) {
	this.map = map;
	var that = this;


	if( window.getComputedStyle ) {
		var style = window.getComputedStyle(document.body, '');
	} else if( document.body.currentStyle ) {
		var style = document.body.currentStyle;
	}

	this.container = document.createElement('div');
	this.container.style.padding = '20px';
	this.container.style.display = 'none';
	this.container.style.width = this.width + 'px';


	this.topTable = document.createElement('TABLE');
	this.container.appendChild(this.topTable);
	this.topTable.style.display = 'none';

	this.topTable.setAttribute('cellSpacing','0');
	this.topTable.setAttribute('cellPadding','0');
	this.topTable.setAttribute('width','100%');
	this.topTable.style.backgroundColor = style.backgroundColor;

	var tBody = document.createElement('TBODY');
	this.topTable.appendChild(tBody);
	var tRow = document.createElement('TR');
	tBody.appendChild(tRow);

	this.titleCell = document.createElement('TD');
	tRow.appendChild(this.titleCell);
	this.minCell = document.createElement('TD');
	tRow.appendChild(this.minCell);
	
	
	this.titleDiv =  document.createElement('div');
	this.titleCell.appendChild(this.titleDiv);
	this.titleDiv.innerHTML = 'Title';
	this.titleDiv.style.color = style.color;
	this.titleDiv.style.padding = '5px';
	this.titleDiv.style.border = '1px solid ' + style.color;
	this.titleDiv.style.font = 'bold 12px verdana';
	this.titleDiv.style.textAlign = 'left';

	this.minCell.innerHTML = '[Minimize]';
	this.minCell.style.width = '80px';
	this.minCell.style.textAlign = 'center';
	this.minCell.style.cursor = 'pointer';
	this.minCell.style.backgroundColor = '#860000';
	this.minCell.onclick = function() {that.toggle()};






	this.innerDiv =  document.createElement('div');
	this.container.appendChild(this.innerDiv);
	this.innerDiv.style.padding = '2px';
	this.innerDiv.style.border = '1px solid ' + style.color;
	this.innerDiv.style.backgroundColor = style.backgroundColor;
	this.innerDiv.style.textAlign = 'left';

	this.map.getContainer().appendChild(this.container);

	if (this.height) {
		this.innerDiv.style.height = this.height + 'px';
		this.innerDiv.style.overflow = 'auto';
	}


	GEvent.addDomListener(this.container, "DOMMouseScroll", function (ev) {try{ev.stopPropagation()}catch(e){event.cancelBubble=true}});
	GEvent.addDomListener(this.container, "mousewheel", function (ev) {try{ev.stopPropagation()}catch(e){event.cancelBubble=true}}); 


	return this.container;
}

MTextControl.prototype.getDefaultPosition = function() {
	return this.position;
}
MTextControl.prototype.setTitle = function(text) {
	this.titleDiv.innerHTML = text;
	this.topTable.style.display = '';
}

MTextControl.prototype.setText1 = function(text) {
	this.innerDiv.innerHTML = text;
	this.show();
}

MTextControl.prototype.show = function() {
	this.container.style.display = '';
}

MTextControl.prototype.hide = function() {
	this.container.style.display = 'none';
}

MTextControl.prototype.toggle = function() {
	this.innerDiv.style.display = this.innerDiv.style.display == 'none' ? '' : 'none';
	this.minCell.innerHTML = this.innerDiv.style.display == 'none' ? '[Maximize]' : '[Minimize]';
}


function setObjOpacity(obj,tx) {
  if(typeof(obj.style.filter)=='string'){obj.style.filter='alpha(opacity:'+tx+')';}
  if(typeof(obj.style.KHTMLOpacity)=='string'){obj.style.KHTMLOpacity=tx/100;}
  if(typeof(obj.style.MozOpacity)=='string'){obj.style.MozOpacity=tx/100;}
  if(typeof(obj.style.opacity)=='string'){obj.style.opacity=tx/100;}

}

