﻿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","简介");
		addChil(fontt,"howto.php","开始");
		addChil(fontt,"write.php",".写");
		addChil(fontt,"html-write.php","HTML标记");
		addChil(fontt,"alert.php","警报");
	}
	else if(das == "vari")
	{
		var tdr = document.getElementById("vari");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"types.php","类型");
		addChil(fontt,"string.php","字符串");
		addChil(fontt,"numbers.php","编号");
		addChil(fontt,"boolean.php","布尔");
		addChil(fontt,"type-conversions.php","类型转换");
	}
	else if(das == "oper")
	{
		var tdr = document.getElementById("oper");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"operators.php","基础知识");
		addChil(fontt,"arithmetic-operator.php","算术");
		addChil(fontt,"logical-operator.php","逻辑");
		addChil(fontt,"comparison.php","比较");
		addChil(fontt,"assignment-operator.php","转让");
		addChil(fontt,"ternary.php","三元");
		addChil(fontt,"precedence.php","优先");
	}
	else if(das == "state")
	{
		var tdr = document.getElementById("state");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"if-statement.php","if陈述");
		addChil(fontt,"if-else.php","ifelse陈述 ");
		addChil(fontt,"switch-case.php","switchcase陈述");
		addChil(fontt,"with-statement.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","	dowhile环");
		addChil(fontt,"break-statement.php","break陈述");
		addChil(fontt,"continue-statement.php","continue陈述");
	}
	else if(das == "funct")
	{
		var tdr = document.getElementById("funct");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"javascript-function.php","基础知识");
		addChil(fontt,"parameter.php","参数");
		addChil(fontt,"return-value.php","返回值");
	}
	else if(das == "object")
	{
		var tdr = document.getElementById("object");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"string-functions.php","字符串");
		addChil(fontt,"date-methods.php","日期");
		addChil(fontt,"math-methods.php","数学");
		addChil(fontt,"number-objects.php","编号");
		addChil(fontt,"global-functions.php","全球");
	}
	else if(das == "arrays")
	{
		var tdr = document.getElementById("arrays");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"arrays.php","阵列基本法");
		addChil(fontt,"dynamic-array.php","动态数组");
		addChil(fontt,"array-methods.php","阵列方法");
	}
	else if(das == "bobject")
	{
		var tdr = document.getElementById("bobject");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"hierarchy.php","层次");
		addChil(fontt,"window-object.php","窗口对象");
		addChil(fontt,"document-object.php","文件对象");
		addChil(fontt,"history-object.php","历史对象");
		addChil(fontt,"navigator-object.php","领航员对象");
	}
	else if(das == "form")
	{
		var tdr = document.getElementById("form");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"index.php","的DOM及活动");
		addChil(fontt,"button-events.php","按钮对象");
		addChil(fontt,"checkbox-events.php","复选框对象");
		addChil(fontt,"radio-events.php","广播对象");
		addChil(fontt,"textfield-events.php","文本字段对象");
		addChil(fontt,"textarea-events.php","文本区对象");
		addChil(fontt,"select-events.php","选择对象");
		addChil(fontt,"form-object.php","表单对象");
	}
}

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);
}

