/*
 *	MxTabCntrl - Implements VB style tab control. The tabs have to implemented using MXDHTML class
 *	Author: Dmitry Rakovitsky
 */
 
// MxTabCntrl - inherits from MxDHTML
function MxTabCntrl(id) {
	this.init(id);
}
MxTabCntrl.prototype = new MxDHTML();
MxTabCntrl.superclass = MxDHTML.prototype;

// MxTabCntrl method: init - object initialization
MxTabCntrl.prototype.init = function( id ) {
	MxTabCntrl.superclass.init.call( this, false );
	
	this.id = id;
}


// MxTabCntrl method: showTab -  shows the object's DOM equivalant of the specified tab by id or type.
MxTabCntrl.prototype.showTab = function(id)
{
	if (id == null) {
		mxError("MxTabCntrl:showTab - missing id");
		return;
	}
	
	for (var i = 0; i < this.children.length; i++) 
		this.children[i].hide();

	var tab = this.getChild(id);			
	if ( tab == null ) {
		mxError('MxTabCntrl.showTab: Invalid option id. ' + this.id + '["' + id + '"]'); 
		return;
	}
	tab.show();
}	

// MxTabCntrl method: showTab -  shows the object's DOM equivalant of the specified tab by id or type.
MxTabCntrl.prototype.getActiveTabId = function()
{
	var activeTabId = -1;
	
	for (var i = 0; i < this.children.length; i++) {
		if (this.children[i].hidden == false) {
			activeTabId = this.children[i].id;
			break;
		}
	}
	
	return activeTabId;
}
