var edit_mode = "3";
var treecolor = "FFFFFFFF";
var dirty = false;
var site_nav_index = {'a':[1],'cd':[2],'cc':[2,3],'aa':[2,4],'c':[2,5],'ab':[2,6],'ac':[2,7],'ca':[2,8],'ad':[2,9],'cb':[2,9,10],'ae':[2,9,11],'ag':[2,9,12],'ah':[2,9,13],'ai':[2,9,14],'aj':[2,9,15],'ak':[2,9,16],'al':[2,9,17],'l':[2,18],'la':[2,18,19],'lb':[2,18,20],'lc':[2,18,21],'d':[22],'da':[22,23],'db':[22,24],'dc':[22,25],'dd':[22,26],'de':[22,27],'eg':[22,28],'eb':[22,29],'df':[22,30],'dg':[22,31],'dh':[22,32],'di':[22,33],'bi':[22,34],'fh':[22,35],'bk':[22,36],'fj':[22,37],'ea':[22,38],'bj':[22,39],'dk':[22,40],'dl':[22,41],'bf':[22,42],'fg':[22,43],'ec':[22,44],'ed':[22,45],'bl':[22,46],'ee':[22,47],'ef':[22,48],'eh':[22,49],'el':[22,50],'fc':[22,51],'cl':[22,52],'bg':[22,53],'ei':[22,54],'bd':[22,55],'f':[56],'fb':[56,57],'b':[56,58],'fa':[56,59],'af':[56,60],'dj':[56,61],'lh':[56,62],'lj':[56,63],'lk':[56,64],'fd':[65],'fk':[65,66],'fl':[65,67],'gj':[65,68],'fe':[65,69],'e':[65,70],'g':[71],'ga':[71,72],'gc':[71,72,73],'gd':[71,72,74],'h':[75],'ha':[75,76],'hd':[75,77],'he':[75,78],'hf':[75,79],'hg':[75,80],'hh':[75,81],'i':[82],'ia':[82,83],'ib':[82,84],'id':[82,85],'ic':[82,86],'if':[82,87],'ig':[82,88],'j':[89],'ja':[89,90],'jb':[89,91],'jc':[89,92],'jd':[89,93],'je':[89,94],'jf':[89,95],'jg':[89,96],'k':[97],'ka':[97,,98],'kb':[97,,99],'kc':[97,,100],'ke':[97,,101],'ll':[102],'kk':[102,103],'kj':[102,103,104]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Front Page','a',1,1,'',''],['cd','Site Map','Site Map',2,1,'',''],[['cc','School Improvement Plan','cc',3,0,'',''],['aa','Renfrew Town','aa',4,0,'',''],['c','Getting in Touch','c',5,0,'',''],['ab','Aims','ab',6,0,'',''],['ac','School Prayer','ac',7,0,'',''],['ca','Help us improve','ca',8,0,'',''],['ad','How we work','ad',9,0,'',''],[['cb','Liturgy Group','Liturgy Group',10,0,'',''],['ae','Holidays','School Holidays',11,0,'',''],['ag','School Rules','ag',12,0,'',''],['ah','Uniform/PE Kit','ah',13,0,'',''],['ai','Registration','ai',14,0,'',''],['aj','House Councils','aj',15,0,'',''],['ak','Policies','ak',16,0,'',''],['al','Standards','al',17,0,'',''],],['l','Calendar (including Holidays)','Calendar of Events 2010-2011',18,0,'',''],[['la','Discos','Dates of Discos',19,0,'',''],['lb','Parents\' Evenings','Dates of Parents\' Evenings',20,0,'',''],['lc','Reports','Dates of Reports',21,0,'',''],]],['d','Curriculum','What we teach',22,0,'',''],[['da','Art and Design','Welcome to Art and Design',23,0,'',''],['db','Biology','Welcome to the Biology Department',24,0,'',''],['dc','Chemistry','\<b\>\<font color=&quot;Blue&quot;\>Welcome to the Chemistry Departm',25,0,'',''],['dd','Classics','Classics',26,0,'',''],['de','English','Welcome to the English Department',27,0,'',''],['eg','English for Speakers of Other Languagers (ESOL)','English for Speakers of Other Languagers (ESOL)',28,0,'',''],['eb','French','French',29,0,'',''],['df','Geography','Welcome to Geography',30,0,'',''],['dg','History','Welcome to History',31,0,'',''],['dh','HE','Welcome to Home Economics',32,0,'',''],['di','ict','Welcome to the ICT Department',33,0,'',''],['bi','ICT','ICT',34,0,'',''],['fh','ICT','ICT',35,0,'',''],['bk','Italian','Italian',36,0,'',''],['fj','Languages','Welcome to the Languages Department',37,0,'',''],['ea','Mathematics','Welcome to the Mathematics Department',38,0,'',''],['bj','Maths 2','bj',39,0,'',''],['dk','Media Studies','Media Studies',40,0,'',''],['dl','Modern Studies','Welcome to Modern Studies',41,0,'',''],['bf','Modern Studies 2','Curricular Events in Modern Studies',42,0,'',''],['fg','Mod Studs','Useful links for Modern Studies',43,0,'',''],['ec','Music','Welcome to the Music Department',44,0,'',''],['ed','PE','Welcome to the Physical Education Department',45,0,'',''],['bl','Music 2','',46,0,'',''],['ee','Physics','Welcome to the Physics Department',47,0,'',''],['ef','Psychology','Welcome to Psychology!',48,0,'',''],['eh','RE','Welcome to the Religious Education Department',49,0,'',''],['el','RE 2','el',50,0,'',''],['fc','SE','\<b\>SOCIAL EDUCATION\</b\>',51,0,'',''],['cl','Social Subjects','Welcome to Social Subjects',52,0,'',''],['bg','SVS','Welcome to S.V.S.',53,0,'',''],['ei','TECH','Welcome to the Technical Education Department',54,0,'',''],['bd','XL Club','Welcome to XL Club',55,0,'',''],],['f','Pupil Support','Pupil Support',56,0,'',''],[['fb','Careers','\<b\>CAREERS INFORMATION\</b\>',57,0,'',''],['b','Home School Link','Home School Link',58,0,'',''],['fa','Pastoral Team','fa',59,0,'',''],['af','Pastoral Support','Pastoral Support',60,0,'',''],['dj','Support for Learning','Welcome to Support for Learning',61,0,'',''],['lh','WW1','First World War Festival',62,0,'',''],['lj','lj','PARENTAL QUESTIONNAIRE 2008',63,0,'',''],['lk','lk','Trinity - A Celebration',64,0,'',''],],['fd','Library','Welcome to the Library Resource Centre',65,1,'',''],[['fk','Library 2','Library investigations',66,1,'',''],['fl','Library 3','All about books',67,1,'',''],['gj','Library 4','Personal Study Lists',68,0,'',''],['fe','Book reviews','Book Reviews',69,0,'',''],['e','e','Deleted Page',70,0,'',''],],['g','News and Events','This Month\'s Quick News',71,0,'',''],[['ga','Newsletters','Newsletters',72,1,'',''],[['gc','Summary Improvement Plan 2008/09','SUMMARY IMPROVEMENT PLAN 2008/09',73,1,'',''],['gd','APD Partnership Work - Trip to India','CITIZENSHIP NEWSLETTER - MARCH 2007',74,1,'',''],]],['h','Pupil pages','Pupil Pages',75,0,'',''],[['ha','Pupil Councils','Our School\'s Pupil Council',76,0,'',''],['hd','School Trips','SCHOOL TRIPS ARE COOL!!',77,1,'',''],['he','The Links','The Cool Pupil Links',78,0,'',''],['hf','Homework','Homework Helper',79,0,'',''],['hg','Charity Events','\<font color=&quot;green&quot;\> Charity Events',80,1,'',''],['hh','The School Houses','The School Houses',81,1,'',''],],['i','Useful Links','USEFUL LINKS TO OUTSIDE SITES',82,0,'',''],[['ia','Educational Organisations','Educational Organisations',83,0,'',''],['ib','Universities/Colleges','University and College Web Sites',84,0,'',''],['id','Careers and Learning','Careers and Learning',85,0,'',''],['ic','Search Engines','Popular Search Engines',86,1,'',''],['if','Teacher Tutorials','Tutorials',87,0,'',''],['ig','Parent Page','Parent Page',88,0,'',''],],['j','Parent and Carer Information','Parent and Carer Information',89,0,'',''],[['ja','Parent Forum','Parent Forum',90,0,'',''],['jb','Parent Forum Members','Members of Trinity High Parent Forum',91,0,'',''],['jc','Meeting Dates','Dates of Parent Forum Meetings',92,0,'',''],['jd','PTA','Parent Teacher Association',93,0,'',''],['je','PTA Committee','Committee of Trinity High Parent Teacher Association',94,0,'',''],['jf','PTA Meeting Dates','Dates of PTA Meetings',95,0,'',''],['jg','PTA Events','PTA Events',96,0,'',''],],['k','Special Events','Special Events/Visits',97,0,'',''],[[['ka','HMIe','Trinity High HMIe Report',98,1,'',''],['kb','School Show','',99,1,'',''],['kc','Sciafathon','Sciafathon',100,1,'',''],['ke','ACE DAY','ACE DAY',101,1,'',''],]],['ll','Trinity High School Review','School Review',102,0,'',''],[['kk','kk','kk',103,0,'',''],[['kj','S1 Anti-bullying seminar','kj',104,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';
			}
	}
}

