/** 
 * @class TabbedPanel
 * @package TabbedPanel
 * @version 1.1
 * @author Frédéric LECOINTRE<frederic.lecointre@burnweb.net>
 * 
 */
TabbedPanel = function(sMenuId){
	this.id = sMenuId;
	this.dObj = null;
	this.tabs = Array();
	this.activeTab = null;
	this.panelWidth = null;
	this.panelHeight = null;
}//end function

/**
 *
 * @param integer iIndex
 * @return void
 */
TabbedPanel.prototype.initialize = function(iIndex){
	
	this.dObj = window.document.getElementById(this.id);
	
	if(this.dObj){
		var aTabs = this.dObj.getElementsByTagName('li');

		for (i = 0; i < aTabs.length; i++){
		
			aTabs[i].panel = window.document.getElementById(aTabs[i].id.replace(/^tab/, 'panel'));
			
			if(aTabs[i].panel){
				
				aTabs[i].style.display = 'block';
				aTabs[i].controller = this;
			
				if(this.panelWidth){
					aTabs[i].panel.style.width = this.panelWidth;
				}//end if
				
				if(this.panelWidth){
					aTabs[i].panel.style.height = this.panelHeight;
				}//end if
				
				aTabs[i].onmouseover = this.tabbedMenuOnmouseover;
				aTabs[i].onmouseout = this.tabbedMenuOnmouseout;
				aTabs[i].onmousedown = this.tabbedMenuOnmousedown;

				this.tabs[aTabs[i].id] = aTabs[i];			

			}//end if
			else{
				aTabs[i].style.display = 'none';
			}//end emse
			
		}//end for
		
		
		this.activate(this.tabs[aTabs[(iIndex && aTabs[iIndex] && aTabs[iIndex].panel) ? iIndex : 0].id]);
		
	}//end if
	else{
		alert('Unable to find  UL HTMLelement "' + this.id + '"');
	}//end else
	
}//end function

/**
 *
 * @param Object oTabMenu
 * @return void
 */
TabbedPanel.prototype.activate = function(oTabMenu){

	if(this.tabs[oTabMenu.id] != undefined){
	
		if(this.activeTab != null){
			this.deactivate(this.activeTab);
		}//end if
		
		oTabMenu.className = 'tabbedMenuOn';
		oTabMenu.panel.style.display = 'block';
		oTabMenu.panel.style.visibility = 'visible';
		
		this.activeTab = oTabMenu;
		
	}//end if
	
}//end function

/**
 *
 * @param Object oTabMenu
 * @return void
 */
TabbedPanel.prototype.deactivate = function(oTabMenu){

	if(this.tabs[oTabMenu.id] != undefined){
		oTabMenu.className = 'tabbedMenuOff';
		oTabMenu.panel.style.display = 'none';
		oTabMenu.panel.style.visibility = 'hidden';
	}//end if
	
}//end function

/**
 *
 * @param Event e
 * @return void
 */
TabbedPanel.prototype.tabbedMenuOnmouseover = function(e){
	
}//end function

/**
 *
 * @param Event e
 * @return void
 */
TabbedPanel.prototype.tabbedMenuOnmouseout = function(e){
	
}//end function


/**
 *
 * @param Event e
 * @return void
 */
TabbedPanel.prototype.tabbedMenuOnmousedown = function(e){
	this.controller.activate(this);
}//end function
