var edit_mode = "3";
var treecolor = "FFFFFFFF";
var dirty = false;
var site_nav_index = {'a':[1],'aa':[2],'ab':[2,3],'ac':[2,4],'ad':[2,5],'ae':[2,6],'af':[2,7],'al':[2,8],'ag':[2,8,9],'ai':[2,10],'aj':[2,11],'ak':[2,12],'ah':[2,13],'b':[14],'ba':[14,15],'bb':[14,16],'bc':[14,17],'bd':[14,18],'c':[19],'ca':[19,20],'cb':[19,21],'cd':[19,22],'cc':[19,23],'ce':[19,24],'d':[25],'da':[25,26],'db':[25,27],'dc':[25,28],'di':[25,29],'ek':[25,30],'el':[25,31],'f':[32],'fa':[32,33],'fb':[32,34],'fc':[32,35],'fd':[32,36],'fe':[32,37],'ff':[32,38],'fg':[32,39],'fh':[32,40],'fk':[32,41],'g':[42],'gb':[42,43],'gc':[42,44],'h':[45],'ha':[45,46],'hb':[45,47],'hc':[45,48],'hd':[45,49],'he':[45,50],'hf':[45,51],'hg':[45,52],'hh':[45,53],'i':[54],'ia':[54,55],'ic':[54,56],'j':[57],'l':[58]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Home','[font=comic sans][colour=yellow][size=50]',1,1,'',''],['aa','Welcome','aa',2,1,'',''],[['ab','Tour the school','ab',3,1,'',''],['ac','Our Mission Statement','Mission Statement',4,1,'',''],['ad','Enterprise','Enterprise',5,1,'',''],['ae','Health Promoting School','ae',6,1,'',''],['af','Achievement and Awards','Raising Achievement',7,1,'',''],['al','Useful Links','Websites We Like',8,1,'',''],[['ag','Eco-Schools and Fairtrade','ag',9,1,'',''],],['ai','Inclusion','Links With Other Schools',10,1,'',''],['aj','Where To Find Us','Here We Are',11,1,'',''],['ak','Special Events','ak',12,1,'',''],['ah','School Calendar','ah',13,1,'',''],],['b','Primary','Welcome to the Primary Department',14,1,'',''],[['ba','Class 1','ba',15,1,'',''],['bb','Class 2','bb',16,1,'',''],['bc','Class 3','bc',17,1,'',''],['bd','Class 4','bd',18,1,'',''],],['c','Secondary','Welcome to the Secondary Department',19,1,'',''],[['ca','Class 6','ca',20,1,'',''],['cb','Class 7','cb',21,1,'',''],['cd','Class 8','cd',22,1,'',''],['cc','Class 9','cc',23,1,'',''],['ce','Class 10','Welcome to Class 10',24,1,'',''],],['d','Lismore Unit','Welcome to the Lismore Unit',25,1,'',''],[['da','Class 5','da',26,1,'',''],['db','Class 12','db',27,1,'',''],['dc','Class 12a','dc',28,1,'',''],['di','Practice Home','You have reached the website for',29,1,'',''],['ek','ek','ek',30,0,'',''],['el','slide show','el',31,0,'',''],],['f','Specialist Staff','People Who Help Us',32,1,'',''],[['fa','Medical Staff','fa',33,1,'',''],['fb','Physiotherapy Staff','fb',34,1,'',''],['fc','S and L Therapy','fc',35,1,'',''],['fd','Intensive Interaction','Intensive Interaction',36,1,'',''],['fe','Community PE','PE in the Community',37,1,'',''],['ff','Music','Making Music at Clippens',38,1,'',''],['fg','Swimming','Swimming',39,1,'',''],['fh','Aromatherapy','Theraputic',40,1,'',''],['fk','Untitled','',41,1,'',''],],['g','Parents','',42,1,'',''],[['gb','Recent and Future Events','gb',43,1,'',''],['gc','Parents\' Room','gc',44,1,'',''],],['h','Curriculum','h',45,1,'',''],[['ha','C&L','',46,1,'',''],['hb','PSD','',47,1,'',''],['hc','Mathematics','',48,1,'',''],['hd','Expressive Arts','',49,1,'',''],['he','Environmental Studies','',50,1,'',''],['hf','ICT','hf',51,1,'',''],['hg','RME','',52,1,'',''],['hh','National Qualifications','',53,1,'',''],],['i','Projects and Initiatives','i',54,1,'',''],[['ia','Cultural Education','Cultural Education in Clippens School',55,1,'',''],['ic','Tanzania School Links','Tanzania School Links',56,1,'',''],],['j','Staff Training','j',57,1,'',''],['l','Websites for children','Scroll down for more links',58,1,'',''],];
	_process_nav(nav, 0, '');
}

function _process_nav(nav, level, state)
{
	nav_div = document.getElementById('navblock');
	navigation = write_nav(nav, level, state);
	if (nav_div.hasChildNodes())
	{
		nav_div.removeChild(nav_div.childNodes[0]);
	}
	nav_div.appendChild(navigation);
}


function write_nav(nav, level, state)
{
	var navigation = document.createElement("ul");
	if (nav == 'undefined')
	{
		alert('Deary me, this isn\'t right!');
	}
	if (state == '' && nav_path.length >= (level + 1)) {navigation.style.display = "block";}
	navigation.className ='uln';
	for (var x = 0; x < nav.length; x++)
	{
		var item = nav[x];
		if (item && typeof(item[0]) == 'string')
		{
			if (typeof(nav[x+1]) != 'undefined' && typeof(nav[x+1][0]) != 'string' && typeof(nav[x+1][0]) != 'undefined')
			{
				var citem = write_nav_item(item, level, 'nf', state);
				if (citem != null)
				{
					x++;
					item = nav[x];
					if (nav[x - 1] != 'undefined' && nav[x-1][3] == nav_path[level] && item[4] != 0)
					{
						var child_nav = write_nav(item, level + 1, '');
						citem.appendChild(child_nav);
					}
					else
					{
						if (item[4] != 0)						{
							citem.appendChild(write_nav(item, level + 1, '_x'));
						}
					}
					navigation.appendChild(citem);
				}
			}
			else
			{
				citem = write_nav_item(item, level, 'np', state);
				if (citem != null)
				{
					navigation.appendChild(citem);
				}
			}
		}
	}
	return navigation;
}

function write_nav_item(item, level, navtype, state)
{
	var on_style = "";
	var list_on_style = "";
	var mode = 3;
	
	if (item[1] == '')
	{
		item[1] = 'Untitled';
	}
	if (item[3] == nav_path[level])	{
		on_style = " " + navtype;
		on_style += item[3] == nav_path[level] ? '_on' : '';

		list_on_style = " l" + navtype;
		list_on_style += item[3] == nav_path[level] ? '_on' : '';
	}
	else	{
		list_on_style = " l" + navtype;
		list_on_style += '_off';
	}
	if (item[4] == 0 && mode == 3)
	{
		on_style = '_hidden';
		list_on_style = '_hidden';
	}

	if (item[4] == 0 && mode == 3)
	{
		return null;
	}

	var nav_item = document.createElement("li");
	nav_item.setAttribute('id', "_" + item);
	//nav_item.setAttribute('class', "l" + navtype + list_on_style);
	nav_item.className = "l" + navtype + list_on_style;
	//if (level > 0 || navtype == 'np') {nav_item.style.display = "none";}

	div1 = document.createElement("div");
	div1.className = "nbg";

	div2 = document.createElement("div");
	//div2.setAttribute('class', navtype + on_style);
	div2.className = navtype + on_style;

// create disclosure
	if (navtype == 'nf')
	{
		d_b = document.createElement("a");
		d_b.setAttribute('name', '');
		d_b.setAttribute('onclick', 'disclose(this);');
		d_b.className="d_i";	// disclosure icon

		d_a = document.createElement("img");
		d_a.setAttribute('src', 'http://www.take2theweb.com/images/FIG.GIF');
		d_a.setAttribute('onclick', 'disclose(event);');
		d_a.onclick = disclose;
		d_a.setAttribute('height', '16');
		d_a.setAttribute('width', '16');
		d_a.className = 'nfi';
		//d_b.appendChild(d_a);
		div2.appendChild(d_a);
	}
	
//
	
	d_a = document.createElement("a");
	d_a.className = 'n_l';		// navigation link
	if (item[6] != undefined && item[6] != '')	{
		d_a.setAttribute('href', item[6]);
		d_a.setAttribute('target', '_top');
	}
	else
	{
		d_a.setAttribute('href', item[0] + '.html');
	}
	d_a.setAttribute('title', item[2]);
	d_a.setAttribute('alt', "This is a disclosure item");
	if (item[5] != '') {d_a.setAttribute('accesskey', item[5]);}
	
	d_a_txt = document.createTextNode(item[1]);
	
	d_a.appendChild(d_a_txt);
	div2.appendChild(d_a);
	div1.appendChild(div2);
	nav_item.appendChild(div1);
	return nav_item;
}

function disclose(e)
{
	if (!e) var e = window.event;
	e = e.target || e.srcElement;
	p = e.parentNode.parentNode.parentNode.lastChild;
	var state = p.style.display;
	switch(state)
	{
		case '':
		case null:
		case 'none':
			p.style.display='block';
			{
				e.className ='nfi_on';
			}
			break;
		default:
			p.style.display='none';
			{
				e.className ='nfi';
			}
	}
}

