
/* funcion para mostrar ocultar */
function ExpandirOContraerById(pIdElement) {
	if (!CogerObjById(pIdElement)) return false;
	if (!document.getElementById(pIdElement).style) return false;
	if (!document.getElementById(pIdElement).style.display) return false;
	if (document.getElementById(pIdElement).style.display == "block") {
		document.getElementById(pIdElement).style.display = "none";
	} else {
		document.getElementById(pIdElement).style.display = "block";
	}
}
/* funcion para mostrar */
function ExpandirById(pIdElement) {
	if (!CogerObjById(pIdElement)) return false;
	if (!document.getElementById(pIdElement).style) return false;
	if (!document.getElementById(pIdElement).style.display) return false;
	if (document.getElementById(pIdElement).style.display == "none") {
		document.getElementById(pIdElement).style.display = "block";
	}
}
/* funcion para ocultar */
function ContraerById(pIdElement) {
	if (!CogerObjById(pIdElement)) return false;
	if (!document.getElementById(pIdElement).style) return false;
	if (!document.getElementById(pIdElement).style.display) return false;
	if (document.getElementById(pIdElement).style.display == "block") {
		document.getElementById(pIdElement).style.display = "none";
	}
}

function CogerObjById(pIdElement) {
	if (!document.getElementById) return null;
	return document.getElementById(pIdElement);
}

function ExpandirCapaGrupo(pNombreCapa, pIndice) {
	var i = 0;
	var iMax = GetMaxDivById(pNombreCapa + "%i");
	
	QuitarFoco();
	
	for (i = 1; i <= iMax; i++) {
		if (i == pIndice) {
			ExpandirById(pNombreCapa + i);
		} else {
			ContraerById(pNombreCapa + i);
		}
	}
	document.location = "#" + pNombreCapa + pIndice;
}

function GetMaxDivById(pIdRegExp) {
	var i = 1;
	while (document.getElementById(pIdRegExp.replace("%i", i))) i++;
	return (i - 1);
}

function QuitarFoco() {
	if (!window.document.body) return false;
	if (!window.document.body.focus) return false;
	
	window.document.body.focus();
	return true;
}

