var as = 1;
var fontt;
var expo;

function addChilds(das,exps)
{
	var nam =das;
	expo = exps;

	if(das == "main")
	{
		var tdr = document.getElementById("main");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"index.php","Intro");
		addChil(fontt,"empezar.php","Empezar");
		addChil(fontt,"escribir.php",".escribir");
		addChil(fontt,"html-escribir.php","html etiquetas");
		addChil(fontt,"alerta.php","alerta");
	}
	else if(das == "vari")
	{
		var tdr = document.getElementById("vari");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"variable-tipos.php","Variable tipos");
		addChil(fontt,"string.php","String");
		addChil(fontt,"numbers.php","Number");
		addChil(fontt,"boolean.php","Boolean");
		addChil(fontt,"tipo-conversiones.php","Tipo Conversiones");
	}
	else if(das == "oper")
	{
		var tdr = document.getElementById("oper");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"operadores.php","Básico");
		addChil(fontt,"arithmetic-operadores.php","Aritmética");
		addChil(fontt,"logico-operadores.php","Logico");
		addChil(fontt,"comparacion.php","Comparación");
		addChil(fontt,"asignacion-operador.php","Asignación");
		addChil(fontt,"ternario.php","Ternario");
		addChil(fontt,"precedencia.php","Precedencia");
	}
	else if(das == "state")
	{
		var tdr = document.getElementById("state");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"if-funcion.php","if");
		addChil(fontt,"if-else.php","if else");
		addChil(fontt,"switch-case.php","switch case");
		addChil(fontt,"with-funcion.php","with");
	}
	else if(das == "loops")
	{
		var tdr = document.getElementById("loops");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"for-loop.php","for");
		addChil(fontt,"while-loop.php","while");
		addChil(fontt,"do-while-loop.php","do while");
		addChil(fontt,"break-funcion.php","break");
		addChil(fontt,"continue-funcion.php","continue");
	}
	else if(das == "funct")
	{
		var tdr = document.getElementById("funct");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"javascript-funcion.php","Funcion Basicos");
		addChil(fontt,"parametros.php","Parametros");
		addChil(fontt,"vuelta-valor.php","Vuelta Valor");
	}
	else if(das == "object")
	{
		var tdr = document.getElementById("object");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"string-funciones.php","Cadena");
		addChil(fontt,"date-funciones.php","Fecha");
		addChil(fontt,"math-funciones.php","Matemáticas");
		addChil(fontt,"number-objetos.php","Número");
		addChil(fontt,"mundial-funciones.php","Global");
	}
	else if(das == "arrays")
	{
		var tdr = document.getElementById("arrays");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"arrays.php","Array Básica");
		addChil(fontt,"dinamica-array.php","Dinámica Matriz");
		addChil(fontt,"array-tipos.php","Array Métodos");
	}
	else if(das == "bobject")
	{
		var tdr = document.getElementById("bobject");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"jerarquia.php","Jerarquia");
		addChil(fontt,"window-objetos.php","Ventana Objetos ");
		addChil(fontt,"documento-objetos.php","Documento Objetos");
		addChil(fontt,"historia-objeto.php","Historia Objetos");
		addChil(fontt,"navegador-objeto.php","Navegador Objetos");
	}
	else if(das == "form")
	{
		var tdr = document.getElementById("form");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"index.php","DOM y Eventos");
		addChil(fontt,"boton-eventos.php","Botón Objeto");
		addChil(fontt,"casilla-eventos.php","Checkbox Objeto");
		addChil(fontt,"radio-eventos.php","Radio Objeto");
		addChil(fontt,"texto-campo-events.php","Campo de texto");
		addChil(fontt,"texto-area-eventos.php","Objeto de texto");
		addChil(fontt,"seleccionar-eventos.php","Seleccionar objeto");
		addChil(fontt,"forma-objetos.php","Forma de objetos");
	}
}

function removeChilds(fontt)
{
	if(fontt != null)
	{
		while(fontt.hasChildNodes() && fontt.childNodes.length> 1)
		{	
		if(as > 1)
		{
		fontt.removeChild(fontt.lastChild);
		}
		as = as+1;
		}
	}
}

var love = "yes";
function addChil(parent,linkname,textname)
{
var breaka = document.createElement("br");
var divs= document.createElement("div");
var link = document.createElement("a");
link.setAttribute("href",ajss+expo+linkname);
link.style.color="#aa300a";
divs.style.marginLeft="8px";
divs.style.marginRight="4px";
divs.style.paddingLeft="3px";
divs.style.fontSize="12px";
divs.style.lineHeight="20px";
divs.style.border="0px green solid";

if(love == "yes")
{
divs.style.backgroundColor="#beefec";
love = "no";
}
else
{
divs.style.backgroundColor="#dfffdf";
love = "yes";
}
link.style.textDecoration="none";
//link.setAttribute("style","background-color: white;");

var name = document.createTextNode(textname);
//parent.appendChild(breaka);
parent.appendChild(divs);
divs.appendChild(link);
link.appendChild(name);
}

