var sImagesPath = "/imgs/Materna/";
//Argentina
var IdCapituloTusVideosEnMaterna = 1959;
var IdCapituloBeneficios = 1412;
var IdCapituloMomentosMaterna = 442;
var IdCapituloILactancia = 2353;
var IdCapituloConcursoNutrilonPremium = 2374;
//Chile
var IdCapituloTusVideosEnMaternaChile = 2149;
var IdCapituloBeneficiosChile = 2114;
var IdCapituloMaternaTVChile = 2286;
var beingLoadedNode;
var sCancelLoad = "Cargando...";
var timeOut = 60000;
var oXML;
var oSelNode;
var loadingNode;
function showLoadingNode(Node){
var oDiv;
oDIV = document.createElement("
");
oDIV = Node.appendChild(oDIV);
oDIV.innerText = sCancelLoad;
oDIV.onclick = cancelLoad;
}
function hideLoadingNode(Node){
try{
if (Node.childNodes.length>1){
oDIV = Node.childNodes(1);
Node.removeChild(oDIV);
}
}
catch(x){}
}
//This function builds tree.
//Parameter sourceNode is a XML source node, resultNode is a produced HTML node,
//expanded specifies whether display resultNode expanded or not.
function buildTree(sourceNode, resultNode, expanded){
var oLI, oUL, oIMG, oA, oNOBR, i, oNodeAttributes, nodeId, estilo, j, aux, bgcolor, ExtraMomentosMaterna;
var sIcon, sName, sNameLink, sHref, sHijos, sSrc, sFoto, branchlevel;
//Create container for child nodes
oUL = document.createElement("
");
oUL = resultNode.appendChild(oUL);
//if node expanded then display container
if (expanded=="true")
oUL.style.display="block";
else
oUL.style.display="none";
j=0;
//Run over nodes in XML source
for (i=0;i"));
oLI.id = nodeId;
sStyle = " STYLE= 'height:32px; text-align=right; MARGIN-BOTTOM:-5px ; MARGIN-LEFT: -" + Number(Number(0) + Number((40 * (branchlevel)))) + "px;'"
oNOBR = document.createElement(("- "));
oNOBR.id = "Li_" + nodeId;
oNOBR = oLI.appendChild(oNOBR);
//Leer cantidad de hijos
sHijos = ""
if (oNodeAttributes.getNamedItem("Hijos")!=null)
sHijos = oNodeAttributes.getNamedItem("Hijos").value;
sHref = ""
if (oNodeAttributes.getNamedItem("href")!=null)
sHref = oNodeAttributes.getNamedItem("href").value;
//Create action image
oIMG = document.createElement("
");
//If src attribute is not empty, add custom attribute to the result node
sSrc = "";
if (oNodeAttributes.getNamedItem("src")!=null)
sSrc = oNodeAttributes.getNamedItem("src").value;
oLI.setAttribute("src", sSrc);
oLI.setAttribute("branchlevel", branchlevel);
//If src attribute is not empty or amount of the child nodes is not equals zero
if (sSrc!="" || sourceNode.childNodes(i).childNodes.length>0){
//Sub nodes was not loaded and so not expanded
oLI.setAttribute("LoadedChildren", "false");
//Check is exists subtree
if (sourceNode.childNodes[i].children){
oLI.setAttribute("Expanded", "true");
}
else{
oLI.setAttribute("Expanded", "false");
oIMG.width = 0;
oIMG.height = 0;
}
}
oA = document.createElement("");
//Set event handler for node
oA.onclick = new Function("if (typeof(actionOnClick)!='undefined') {window.actionOnClick('" + nodeId + "',0,false);} else {window.parent.actionOnClick('" + nodeId + "',0,false);}");
sFoto = ""
if ((branchlevel==1) && (oNodeAttributes.getNamedItem("Foto")!=null))
sFoto = oNodeAttributes.getNamedItem("Foto").value;
if (sFoto=="") {
if (branchlevel==1) sFoto= sImagesPath + "bot_vacio.gif";
//Argentina
if ((branchlevel==1) && (nodeId==IdCapituloTusVideosEnMaterna)) sFoto= sImagesPath + "bot_ident04.gif";
if ((branchlevel==1) && (nodeId==IdCapituloBeneficios)) sFoto= sImagesPath + "bot_ident03.gif";
if ((branchlevel==1) && (nodeId==IdCapituloMomentosMaterna)) sFoto= sImagesPath + "bot_ident02.gif";
if ((branchlevel==1) && (nodeId==IdCapituloILactancia)) sFoto= sImagesPath + "bot_ident06.gif";
//Chile
if ((branchlevel==1) && (nodeId==IdCapituloTusVideosEnMaternaChile)) sFoto= sImagesPath + "bot_ident04.gif";
if ((branchlevel==1) && (nodeId==IdCapituloBeneficiosChile)) sFoto= sImagesPath + "bot_ident03.gif";
if ((branchlevel==1) && (nodeId==IdCapituloMaternaTVChile)) sFoto= sImagesPath + "bot_ident05.gif";
if ((branchlevel==1) && (estilo==1)) sFoto= sImagesPath + "bot_ident03.gif";
if ((branchlevel==1) && (nodeId==IdCapituloConcursoNutrilonPremium)) sFoto= sImagesPath + "bot_ident07.gif";
if (branchlevel==2) sFoto= sImagesPath + "bot_3n.gif";
if (branchlevel==3) sFoto= sImagesPath + "spacer.gif";
}
if (branchlevel!=3) AnchoFijo = "width=38"
ExtraMomentosMaterna=""
//Argentina
if (nodeId==IdCapituloTusVideosEnMaterna) ExtraMomentosMaterna="violeta"
if (nodeId==IdCapituloBeneficios) ExtraMomentosMaterna="rojo"
if (nodeId==IdCapituloMomentosMaterna) ExtraMomentosMaterna="azul"
if (nodeId==IdCapituloILactancia) ExtraMomentosMaterna="ilactancia"
if (nodeId==IdCapituloConcursoNutrilonPremium) ExtraMomentosMaterna="nutrilon"
//Chile
if (nodeId==IdCapituloTusVideosEnMaternaChile) ExtraMomentosMaterna="violeta"
if (nodeId==IdCapituloBeneficiosChile) ExtraMomentosMaterna="rojo"
if (nodeId==IdCapituloMaternaTVChile) ExtraMomentosMaterna="naranja"
//generico
if (estilo==1) ExtraMomentosMaterna="rojo"
if (nodeId==IdCapituloConcursoNutrilonPremium) ExtraMomentosMaterna="nutrilon"
if (sHijos==0)
//sNameLink=""
sNameLink=""
else
sNameLink=sName
if (branchlevel==3)
oA.innerHTML = "";
else
oA.innerHTML = "";
oA.className = "treenode"+branchlevel+ExtraMomentosMaterna;
oA = oNOBR.appendChild(oA);
oIMG = oNOBR.appendChild(oIMG);
//Create chapter icon image
oIMG = document.createElement("
");
oIMG = oNOBR.appendChild(oIMG);
oIMG.width = 0;
oIMG.height = 0;
//Assembly subtree //if (sourceNode.childNodes(i).childNodes.length>0) buildTree(sourceNode.childNodes(i), oLI, "false")
}
//Add custom attributes to resultNode which specifies whether node loaded children or not and whether is was expanded or not
resultNode.setAttribute("LoadedChildren", "true")
resultNode.setAttribute ("Expanded", expanded);
}
function actionOnClick(id,IdSinHijosSelect,activar){
var oNode = document.getElementById(id);
branchlevel = oNode.getAttribute("branchlevel");
//If node is already expanded we collapse it
if (oNode.getAttribute("Expanded")=="true"){
oNode.childNodes[1].style.display = "none";
oNode.childNodes[0].childNodes[0].alt = "+";
oNode.setAttribute ("Expanded", "false")
if ((activar) && (branchlevel==1)) eval("table"+id).style.color="#ffffff";
}
//If node is collapsed we expand it
else{
//Show minus icon
oNode.childNodes[0].childNodes[0].alt = "-";
if (activar)
{
if (branchlevel==1)
{
if (eval("document.all.SinHijos"+id)) eval("SinHijos"+id).style.color="#ccff00";
eval("table"+id).style.color="#ccff00";
}
else
if (branchlevel==3) eval("SinHijos"+id).style.color="#ffffff";
}
//If children nodes are already loaded, just expand it
if (oNode.getAttribute("LoadedChildren")=="true"){
oNode.childNodes[1].style.display = "block";
oNode.setAttribute ("Expanded", "true")
}
//Children nodes are not loaded yet, we need to load it
else{
//If the other nodes are loaded at the current time, we should stop it
if (beingLoadedNode!=null) hideBeingLoadedNode();
//Set new current being loaded node
beingLoadedNode = oNode;
//Show loading node
showBeingLoadedNode();
//loading subtree //buildTree(beingLoadedNode.parentNode, beingLoadedNode, "false");
oXml.load(beingLoadedNode.getAttribute("src"));
//processLoading(beingLoadedNode.getAttribute("src"));
}
}
}
//This function handles OnClick event on link
function nodeOnClick(){
var oNode
oNode = event.srcElement;
event.cancelBubble = true;
oSelNode = oNode.parentNode.parentNode;
}
//This function handles OnMouseOver event on link
function nodeOnMouseOver(){
var oNode
oNode = event.srcElement;
event.cancelBubble = true;
window.status = oNode.innerText;
}
//This function handles OnMouseOut event on link
function nodeOnMouseOut(){
var oNode
oNode = event.srcElement;
event.cancelBubble = true;
window.status = "";
}
//This function handles OnClick event on loading node
function cancelLoad(){
var oNode
oNode = event.srcElement;
hideLoadingNode(oNode.parentElement);
loadingNode = null;
}
function initPage(sRootTree, TextLoad){
if (TextLoad != null)
if (TextLoad != "")
sCancelLoad = TextLoad;
oSelNode = null;
beingLoadedNode = document.getElementById("Tree");
//set loadingNode to the tree container
loadingNode = document.all("Tree");
oXml = new ActiveXObject("Microsoft.XMLDOM");
//Change this property to false if you are working in synchronous mode
oXml.async = false;
//set handler for xml data loading event
oXml.onreadystatechange = onLoadXml;
//load root xml data source
oXml.load(sRootTree);
}
//This function parses and builds tree when XML data source has been loaded
function onLoadXml(){
//test if xml was fully loaded (COMPLETED(4))
if (oXml.readyState==4){
hideBeingLoadedNode (loadingNode);
//test if xml is well formed and contains other than documentElement nodes
if ((oXml.parseError.reason=="") && (oXml.documentElement.childNodes.length>0)){
//Building treeview starts with documentElement of XML and loading node
//We expand only one level of deep treeview, so we just pass "true" value in this call
buildTree(oXml.documentElement, beingLoadedNode, "true");
}
else
{
//If subtree loading have been failed, change action image to none and remove event handler
beingLoadedNode.childNodes(0).childNodes(0).onclick = null;
}
//Actions with loading node are finished, so set it to null
beingLoadedNode = null;
}
}
function hideBeingLoadedNode(){
if (beingLoadedNode.childNodes.length>1){
var oDIV = beingLoadedNode.childNodes[1];
beingLoadedNode.removeChild(oDIV);
}
}
function showBeingLoadedNode(){
var oDIV = beingLoadedNode.appendChild(document.createElement("div"));
var oA = oDIV.appendChild(document.createElement("a"));
oA.href = "#";
oA.onclick = cancelLoad;
var oText = oA.appendChild(document.createTextNode(sCancelLoad));
}
function processLoading(sTreeURL){
//window.tocLoader.location = sTreeURL;
//We will cancel loading of tree if it willn't have success during timeout
window.setTimeout("cancelLoadByTimeout('" + beingLoadedNode.id + "');", timeOut);
}