var menuItem="";
var oldMenuItem="";


itemMenu = function(idObj)
{
	if (idObj == null)
	{
		idObj = menuItem;
	}
	cITEM_ROOT = "c";
	cITEM_DOC = "d";
	cCSSITEMON = "itemSelected";
	cCSSITEMOFF = "noItemSelected";
	cCSSDOCON = "itemSelected";
	cCSSDOCOFF = "noItemSelected";
	cCSSLISTON = "showList";
	cCSSLISTOFF = "noShowList";
	this.tipo = idObj.substr(0,1);
	this.id = idObj.substr(1,name.length);
	this.name = idObj;
	if (this.tipo == cITEM_DOC)
	{
		this.oNodoDoc = document.getElementById(this.name);
		this.srchParentNode();
	}else{
		this.oNodo = document.getElementById(this.name);
		this.oNodoList = document.getElementById(this.name+"_nodo");
	}
	this.optSelected = document.getElementById("optSelected");
}

itemMenu.prototype.chgClassItem = function()
{
	if (this.oNodo != null)
	{
		this.oNodo.className = (this.oNodo.className == cCSSITEMON) ? cCSSITEMOFF : cCSSITEMON;
	}
}
	
itemMenu.prototype.chgClassItemDoc = function()
{
	if (this.oNodoDoc != null)
	{
		this.oNodoDoc.className = (this.oNodoDoc.className == cCSSDOCON) ? cCSSDOCOFF : cCSSDOCON;
	}
}
	
itemMenu.prototype.optShowItem = function()
{
	if (this.oNodoList != null)
	{
		this.oNodoList.className = (this.oNodoList.className == cCSSLISTON) ? cCSSLISTOFF : cCSSLISTON;
	}
}
	
itemMenu.prototype.showHideItems = function(objName)
{
	this.optShowItem();
	this.chgClassItem();
	oldMenuItem = this.name;
	/* SOLO ADMIN
	if (this.oNodo != null)
	{
		this.optSelected.value = this.oNodo.id;
	}else{
		this.optSelected.value = this.name;
	}
	execOptSelected();
	*/
}
	
itemMenu.prototype.srchParentNode = function()
{
	srchParent = this.oNodoDoc.parentNode.parentNode;
	this.oNodoList = srchParent;
	this.oNodo = document.getElementById(srchParent.id.substr(0,srchParent.id.indexOf('_')));
}
	
itemMenu.prototype.init = function()
{
	if (this.tipo == cITEM_DOC)
	{
		this.chgClassItemDoc();
	}
	this.showHideItems(menuItem);
}



function showItemMenu(objName)
{
	oItemMenu = new itemMenu(oldMenuItem);
	oItemMenu.showHideItems();
	menuItem = objName;
	oItemMenu = new itemMenu();
	oItemMenu.showHideItems();
}

function initTree()
{
	// quit if this function has already been called
    if (arguments.callee.done) return;

    // flag this function so we don't do the same thing twice
    arguments.callee.done = true;
	//Buscar dom el fichero
	oItemMenu = new itemMenu()
	obj = oItemMenu.init();
}

/** INICIALIZADOR DEL NAVEGADOR **/

/* for Mozilla */
if (document.addEventListener) {
   document.addEventListener("DOMContentLoaded", initTree, null);
}


/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
   document.write("<script defer src=common/ie_tree_onload.js><"+"/script>");
/*@end @*/

/* for other browsers */
window.onload = initTree;


