function MMapTypeControl(MOptions) {
	MOptions = MOptions ? MOptions : {};
	this.parent = MOptions.container ? MOptions.container : null;
	this.direction = MOptions.direction ? MOptions.direction : 'H';
	this.validValues = MOptions.validValues ? MOptions.validValues : [];
	this.maxRes = 0;
	this.position = MOptions.position ? MOptions.position : new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(5, 5));
}

MMapTypeControl.prototype = new GControl();

MMapTypeControl.prototype.initialize = function(map) {
	var that = this;
	this.map = map;

	GEvent.addListener(map, "addmaptype", function(type) {that.mapAddType(type)});
	GEvent.addListener(map, "removemaptype", function(type) {that.mapRemoveType(type)});
	GEvent.addListener(map, "maptypechanged", function(o,n) {that.mapTypeChanged()});

	var container = document.createElement('div');
	this.container = container;
	var oUL = document.createElement('ul');
	oUL.id = 'MMTT_UL';
	container.appendChild(oUL);

	oUL.setAttribute('style','list-style-type:none;');

	var mapTypes = this.map.getMapTypes();
	for (var  n = 0 ; n < mapTypes.length ; n++ ) {
		var label = mapTypes[n].getName();
		if (this.direction == 'V' || n == 0) {
			var oRow = document.createElement('span');
			oUL.appendChild(oRow);
			oRow.id = 'MMTR_'+n;

		}
		var oLI = this.createButton(that,n,label);
	oLI.innerHTML+=" ";  // oLI replaces oCell

		oRow.appendChild(oLI);
	}

	if (this.parent) {
		this.parent.appendChild(container);
	}
	else {
		this.map.getContainer().appendChild(container);
	}

//	this.mapTypeChanged();

	return container;
}

MMapTypeControl.prototype.getDefaultPosition = function() {
	if (this.parent) {
		return null;
	}
	return this.position;
}


MMapTypeControl.prototype.createButton = function(that,n,label) {
	var oLI = document.createElement('li');
	oLI.id = 'MMTC_'+n;
	label = label.replace('&nbsp;');
	oLI.innerHTML = label;
	this.setStyle(oLI);
	GEvent.addDomListener(oLI, "click", function() {that.setMapType(n)});
	return oLI;
}

MMapTypeControl.prototype.setMapType = function(n) {
	this.map.setMapType(this.map.getMapTypes()[n]);
}

MMapTypeControl.prototype.mapTypeChanged = function() {
	var mapTypes = this.map.getMapTypes();
	var currentMapType = this.map.getCurrentMapType();

	for (var n = 0; n < mapTypes.length ; n++ ) {
		var oLI = document.getElementById('MMTC_'+n); //Cell
		if (oLI) {
			this.setStyle(oLI);
			if (currentMapType == mapTypes[n]) {
				this.setStyleSel(oLI);
			}
		}
	}
}



MMapTypeControl.prototype.mapAddType = function(type) {
	var mapTypes = this.map.getMapTypes();
	var ix = mapTypes.length-1;
	var label = mapTypes[ix].getName();

		var oRow = document.getElementById('MMTR_0');
	var oLI = this.createButton(this,ix,label);
	oRow.appendChild(oLI);

};

MMapTypeControl.prototype.mapRemoveType = function(type) {
}
////////// Styles /////////////////////

MMapTypeControl.prototype.setCommon = function(obj) {
  obj.style.textDecoration = 'none';
  obj.style.border = '0px solid black';
  obj.style.cursor = 'pointer';
}

MMapTypeControl.prototype.setStyle = function(obj) {
	this.setCommon(obj);
	obj.style.backgroundPosition = '0em 0em';
}
MMapTypeControl.prototype.setStyleSel = function(obj) {
	this.setCommon(obj);
	obj.style.backgroundPosition = '0em -1em';
}
MMapTypeControl.prototype.setStyle2 = function(obj) {
	this.setCommon(obj);
	obj.style.backgroundPosition = '0em 0em';
	}



MMapTypeControl.prototype.show = function () {
	this.container.style.display = '';
}

MMapTypeControl.prototype.hide = function () {
	this.container.style.display = 'none';
}

MMapTypeControl.prototype.toggle = function () {
	this.container.style.display = this.container.style.display == '' ? 'none' : '';
}
