var edit_mode = "3";
var treecolor = "FFFFFFFF";
var dirty = false;
var site_nav_index = {'a':[1],'k':[1,2],'aa':[1,3],'ab':[1,4],'ac':[1,5],'ad':[1,6],'af':[1,7],'ae':[1,8],'ag':[1,9],'ah':[1,10],'ai':[1,11],'ak':[1,12],'aj':[13],'al':[13,14],'am':[13,15],'e':[13,16],'ea':[13,17],'eb':[13,18],'ec':[13,19],'ed':[13,20],'ee':[13,21],'ef':[13,22],'an':[13,23],'ao':[13,24],'ap':[13,25],'b':[13,26],'ba':[13,27],'bb':[13,28],'be':[29],'bf':[29,30],'bg':[29,31],'bh':[29,32],'bi':[29,33],'bk':[29,34],'bl':[29,35],'bm':[29,36],'bn':[29,37],'c':[38],'ca':[38,39],'cb':[38,40],'cc':[38,41],'cd':[38,42],'ce':[38,43],'cf':[38,44],'cg':[38,45],'cl':[38,46],'cm':[38,47],'cn':[38,48],'co':[38,49],'cp':[38,50],'d':[38,51],'da':[38,52],'db':[38,53],'dc':[38,54],'f':[55],'fa':[55,56],'fb':[55,57],'fc':[55,58],'fd':[55,59],'fe':[55,60],'ff':[55,61],'fi':[55,62],'fg':[55,63],'fh':[55,64],'fj':[55,65],'fk':[55,66],'fl':[55,67],'fm':[55,68],'fn':[55,69],'fo':[55,70],'fp':[55,71],'g':[72],'ga':[72,73],'pn':[72,74],'po':[72,75],'pp':[72,76]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Home','a',1,1,'',''],[['k','Staying Safe','Staying Safe on the Internet',2,1,'',''],['aa','School Prospectus and Significant Documentation','Acklam Whin Primary School Prospectus and Significant Documentat',3,1,'',''],['ab','School Reception and Office','School Reception and Office',4,1,'',''],['ac','School Diary','School Diary',5,1,'',''],['ad','The Latest Ofsted Report','Acklam Whin\'s Latest Ofsted Report: 2008',6,1,'',''],['af','Head Teacher\'s Message','Head Teacher\'s Message',7,1,'',''],['ae','Key Stage 2 SAT Results','Key Stage 2 SAT Results',8,1,'',''],['ag','Assessment','Assessing children\'s learning and progress.',9,1,'',''],['ah','Letters & Forms','Latest Letters & Forms[br][br]',10,1,'',''],['ai','The Whinbush','What is a Whinbush?',11,1,'',''],['ak','Contact Us','Contact Us',12,1,'',''],],['aj','Children','Children\'s Zone',13,1,'',''],[['al','My Class','My Class',14,1,'',''],['am','My Learning','My Learning',15,1,'',''],['e','Literacy links','My Learning - Literacy',16,0,'',''],['ea','Maths links','My Learning - Maths',17,0,'',''],['eb','Science links','My Learning - Science',18,0,'',''],['ec','History Links','My Learning - History',19,0,'',''],['ed','Geography links','My Learning - Geography',20,0,'',''],['ee','Art & D&T links','My Learning - Art and D&T',21,0,'',''],['ef','Search Engines','My Learning - Search Engines',22,0,'',''],['an','Lunch Menu','What\'s for lunch this week?[br][br]',23,1,'',''],['ao','Our Gallery','Our Gallery',24,1,'',''],['ap','School Council','ap',25,1,'',''],['b','Achievements','Achievements',26,1,'',''],['ba','Memory Box','Memory Box',27,1,'',''],['bb','Football Club','Football Club',28,1,'',''],],['be','Parents','Parents\' Zone',29,1,'',''],[['bf','Home Learning Helper','Home Learning Helper',30,1,'',''],['bg','Events','[u]Events[/u]',31,1,'',''],['bh','Meet Our Staff','Meet Our Staff',32,1,'',''],['bi','E-Safety','E-Safety',33,1,'',''],['bk','Pupil Progress','The main thing is.........Learning.',34,1,'',''],['bl','AWPFA','AWPFA',35,1,'',''],['bm','Extra-Curricular','Extra-Curricular',36,1,'',''],['bn','Parent Support','Parent Support Advisor',37,1,'',''],],['c','Governors','Governors\' Zone',38,1,'',''],[['ca','Governor Involvement','Governor Involvement',39,1,'',''],['cb','Training','Middlesbrough Council Governor Training',40,1,'',''],['cc','Minutes','Governing Body Minutes',41,1,'',''],['cd','Statistics','Key Stage 2 SAT Results',42,1,'',''],['ce','Events','Events',43,1,'',''],['cf','Links','Useful Websites for Governors',44,1,'',''],['cg','School Profile','Acklam Whin\'s School Profile',45,1,'',''],['cl','Nursery','Nursery',46,0,'',''],['cm','Reception','Reception',47,0,'',''],['cn','Year 1','Year 1',48,0,'',''],['co','Year 2','                     [size=36]Year 2[/size]',49,0,'',''],['cp','Year 3','Year 3',50,0,'',''],['d','Year 4','[colour=3333FF]Year 4[/colour]',51,0,'',''],['da','Year 5','Year 5',52,0,'',''],['db','Year 6','[colour=3300FF]Year 6[/colour]',53,0,'',''],['dc','Every Child Matters','dc',54,1,'',''],],['f','Extra Pages: Parents','[u]Maths[/u]',55,0,'',''],[['fa','Maths Facts','                     Maths Facts',56,1,'',''],['fb','Maths Methods','Maths Methods',57,1,'',''],['fc','Solving Problems','                    Solving Problems',58,1,'',''],['fd','Real Life Maths','Real Life Maths',59,1,'',''],['fe','Maths Glossary','                    Maths Glossary',60,1,'',''],['ff','Maths Resources','Maths Resources',61,1,'',''],['fi','Literacy','                         [u]Literacy[/u',62,1,'',''],['fg','Spelling','                    Spelling',63,1,'',''],['fh','Reading','                    Reading',64,1,'',''],['fj','Handwriting','                    Handwriting',65,1,'',''],['fk','Writing','                    Writing',66,1,'',''],['fl','Literacy Resources','                    Literacy Resources',67,1,'',''],['fm','Literacy Glossary','                    Literacy Glossary',68,1,'',''],['fn','MGrid','                  Middlesbrough Grid',69,1,'',''],['fo','Miss Quinn','[i]Remembering Miss Quinn[/i] ',70,1,'',''],['fp','Mr Newark','[i]Remembering Mr Newark[/i]',71,1,'',''],],['g','Extra Pages: Parents','Digital Media Week',72,0,'',''],[['ga','Digital Media Vote','Vote for your Favourite Project!',73,1,'',''],['pn','Feedback thankyou','pn',74,0,'',''],['po','Feedback','po',75,0,'',''],['pp','Search','pp',76,0,'',''],]];
	_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';
			}
	}
}

