/******************************************************************************************************************************
*
* Obiectul de menuTab (are nevoie de fisierul CSS corespunzator acestei componente )
*
*******************************************************************************************************************************/
function MenuTab(idMenuTab,idPrincipal){
	this.htmlId=idMenuTab; /* id-ul div-ului cu copmponenta */
	
	this.htmlElem=document.getElementById(this.htmlId); /* div-ul ce contine componenta */
	this.htmlElem.style.visibility="visible";
	this.htmlMUL=this.htmlElem.getElementsByTagName("UL")[0]; /* UL cu meniul componentei */
	this.panels=new Array(); /* array cu toate panel-urile inregistrate in ordinea intalnita in arborele DOM */
	this.rPanels=new Array(); /* array asociativ intre id-urile panel-urilor si ordinea lor in arborele DOM */
	this.apasat=null;
	var els=this.htmlElem.getElementsByTagName("div");
	/* populare array-uri (vezi mai sus) */
	for (i=0;i<els.length;i++){
		if (els[i].className=="menuTabPanel"){
			this.panels[this.panels.length]=els[i];
			els[i].style.display="none";
			if (els[i].id){
				this.rPanels[els[i].id]=this.panels.length-1;
			}
		}
	}
/******************************************************************************************************************************
* Afisare un panel. Daca se primeste un id sau un numare de ordine pentru panel-ul initial
* se afiseaza acel panel, daca nu se afiseaza primul panel din arborele DOM
*******************************************************************************************************************************/
	if (typeof(idPrincipal)!="undefined"){
		this.displayPanel(idPrincipal);
	} else {
		this.displayPanel(0);
	}
}
function DetailTab(idMenuTab,idPrincipal){
	this.htmlId=idMenuTab; /* id-ul div-ului cu copmponenta */
	this.htmlElem=document.getElementById(this.htmlId); /* div-ul ce contine componenta */
/*	this.htmlElem.style.visibility="visible";*/
/*	this.htmlMUL=this.htmlElem.getElementsByTagName("UL")[0]; /* UL cu meniul componentei */
	this.panels=new Array(); /* array cu toate panel-urile inregistrate in ordinea intalnita in arborele DOM */
	this.rPanels=new Array(); /* array asociativ intre id-urile panel-urilor si ordinea lor in arborele DOM */
/*	this.apasat=null;*/
	var els=this.htmlElem.getElementsByTagName("div");
	/* populare array-uri (vezi mai sus) */
	for (i=0;i<els.length;i++){
		/*if (els[i].className=="menuTabPanel"){*/
			this.panels[this.panels.length]=els[i];
			els[i].style.display="none";
			if (els[i].id){
				this.rPanels[els[i].id]=this.panels.length-1;
			}
		/*}*/
	}
/******************************************************************************************************************************
* Afisare un panel. Daca se primeste un id sau un numare de ordine pentru panel-ul initial
* se afiseaza acel panel, daca nu se afiseaza primul panel din arborele DOM
*******************************************************************************************************************************/
	/*if (typeof(idPrincipal)!="undefined"){
		this.displayPanel(idPrincipal);
	} else {
		this.displayPanel(0);
	}  */
}
MenuTab.prototype.panels=null;
MenuTab.prototype.rPanels=null;
DetailTab.prototype.panels=null;
DetailTab.prototype.rPanels=null;
/******************************************************************************************************************************
* Functie de afisare a unui panel. Poate primi un ca idetnficator al panel-ului, ori numarul sau de ordine in
* arborele DOM, ori id-ul sau.
*******************************************************************************************************************************/
DetailTab.prototype.displayPanel=function(id){

	 if (typeof(id)!="number"){
		id=this.rPanels[id];
	 }
	 if (this.apasat!=null){
		this.panels[this.apasat].style.display="none";
		/*this.htmlMUL.getElementsByTagName("LI")[this.apasat].className=""; */
	}
	/*this.htmlMUL.getElementsByTagName("LI")[id].className="apasat";*/
	try{
        this.panels[id].style.display="block";
        this.apasat=id;
        }catch(Exp){
        }
	 
}
MenuTab.prototype.displayPanel=function(id){
	 if (typeof(id)!="number"){
		id=this.rPanels[id];
	 }
	
	 if (this.apasat!=null){
	 
		this.panels[this.apasat].style.display="none";
		this.htmlMUL.getElementsByTagName("LI")[this.apasat].className="tab_off";
	}
	this.htmlMUL.getElementsByTagName("LI")[id].className="tab_on";
	this.panels[id].style.display="block";
	this.apasat=id;

}