var as = 1;
var fontt;
var expo;
var nav_val;
function addChilds(das,exps)
{
	var nam =das;
	expo = exps;
  nav_val=$('#'+das+' .topics1').html();
nav_lik=$('#'+das+' a').attr('href');        
	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,"howto.php","Begin");
		addChil(fontt,"write.php",".write");
		addChil(fontt,"html-write.php","html tags");
		addChil(fontt,"alert.php","alert");
	}
	else if(das == "vari")
	{
		var tdr = document.getElementById("vari");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"types.php","Types");
		addChil(fontt,"string.php","String");
		addChil(fontt,"numbers.php","Number");
		addChil(fontt,"boolean.php","Boolean");
		addChil(fontt,"type-conversions.php","Type Conversion");
	}
	else if(das == "oper")
	{
		var tdr = document.getElementById("oper");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"operators.php","Basics");
		addChil(fontt,"arithmetic-operator.php","Arithmetic");
		addChil(fontt,"logical-operator.php","Logical");
		addChil(fontt,"comparison.php","Comparision");
		addChil(fontt,"assignment-operator.php","Assignment");
		addChil(fontt,"ternary.php","Ternary");
		addChil(fontt,"precedence.php","Precedence");
	}
	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","if else");
		addChil(fontt,"switch-case.php","switch case");
		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","do while");
		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","Basics");
		addChil(fontt,"parameter.php","Parameters");
		addChil(fontt,"return-value.php","Return Value");
	}
	else if(das == "object")
	{
		var tdr = document.getElementById("object");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"string-functions.php","String");
		addChil(fontt,"date-methods.php","Date");
		addChil(fontt,"math-methods.php","Math");
		addChil(fontt,"number-objects.php","Number");
		addChil(fontt,"global-functions.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 Basic");
		addChil(fontt,"dynamic-array.php","Dynamic Array");
		addChil(fontt,"array-methods.php","Array Methods");
		addChil(fontt,"js-concat-array.php","concat()");
		addChil(fontt,"js-pop-array.php","pop()");
		addChil(fontt,"js-push-array.php","push()");
		addChil(fontt,"js-shift-array.php","shift()");
		addChil(fontt,"js-unshift-array.php","unshift()");
		addChil(fontt,"js-slice-array.php","slice()");
		addChil(fontt,"js-splice-array.php","splice()");
	}
	else if(das == "cookies")
	{
		var tdr = document.getElementById("cookies");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"cookie-introduction.php","Cookies");
		addChil(fontt,"cookie-parameters.php","Cookie Parameters");
		addChil(fontt,"cookie-functions.php","Cookie functions");
		addChil(fontt,"setcookie.php","setcookie()");
		addChil(fontt,"getcookie.php","getcookie()");
		addChil(fontt,"deletecookie.php","deletecookie()");
	}

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

		addChil(fontt,"style-object.php","Style Object");
		addChil(fontt,"style-object-background.php","Background");
		addChil(fontt,"border-margin-properties.php","Border & Margin");
		addChil(fontt,"dom-layout.php","Dom Layout");
		addChil(fontt,"dom-list-style-property.php","List style");
		addChil(fontt,"dom-misc-property.php","Misc Property");
		addChil(fontt,"dom-position-property.php","Position Property");
		addChil(fontt,"dom-print-property.php","Print property");	
		addChil(fontt,"dom-table-property.php","Table Properties");
		addChil(fontt,"dom-text-property.php","Text Property");
		addChil(fontt,"dom-standard-properties.php","Standard Properties");
	}

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

		addChil(fontt,"hierarchy.php","Hierarchy");
		addChil(fontt,"window-object.php","Window Object");
		addChil(fontt,"document-object.php","Document Object");
		addChil(fontt,"history-object.php","History Object");
		addChil(fontt,"navigator-object.php","Navigator Object");
	}
	else if(das == "form")
	{
		var tdr = document.getElementById("form");
		removeChilds(fontt);
		fontt = tdr.getElementsByTagName('font').item(0);
		removeChilds(fontt);

		addChil(fontt,"index.php","DOM & Events");
		addChil(fontt,"button-events.php","Button Object");
		addChil(fontt,"checkbox-events.php","Checkbox Object");
		addChil(fontt,"radio-events.php","Radio Object");
		addChil(fontt,"textfield-events.php","Text Field");
		addChil(fontt,"textarea-events.php","Textarea Object");
		addChil(fontt,"select-events.php","Select Object");
		addChil(fontt,"form-object.php","Form Object");
	}
}

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


