var edit_mode = "3";
var treecolor = "FFFFFFFF";
var dirty = false;
var site_nav_index = {'a':[1],'aa':[1,2],'dl':[1,3],'ai':[1,4],'aj':[1,5],'ak':[1,6],'al':[1,7],'ad':[1,8],'af':[1,9],'b':[10],'bb':[10,11],'ba':[10,12],'bc':[10,13],'bd':[10,14],'c':[15],'ca':[15,16],'cb':[15,17],'cd':[15,18],'ce':[15,19],'cf':[15,20],'ch':[15,21],'cj':[15,22],'cg':[15,23],'d':[24],'da':[24,25],'db':[24,26],'dc':[24,27],'dd':[24,28],'de':[24,29],'di':[24,30],'dj':[24,31],'cl':[24,32],'e':[33],'ha':[33,34],'gl':[33,35],'jd':[33,36],'ci':[33,37],'ea':[33,38],'eb':[33,39],'ec':[33,40],'h':[33,41],'ed':[33,42],'ee':[33,43],'eg':[33,44],'eh':[33,45],'ei':[33,46],'ek':[33,47],'ef':[33,48],'ej':[33,49],'l':[33,50],'dh':[33,51],'dg':[33,52],'hc':[53],'hd':[53,54],'he':[53,55],'hb':[53,56],'hf':[53,57],'hg':[53,58],'hh':[53,59],'el':[53,60],'hi':[53,61],'f':[53,62],'hj':[53,63],'fg':[53,64],'gf':[65],'gb':[65,66],'ga':[65,67],'gc':[65,68],'gd':[65,69],'ge':[65,70],'il':[65,71],'dk':[72],'jj':[72,73],'le':[72,74],'la':[72,75],'lc':[72,76],'ld':[72,77],'lf':[72,78],'lg':[72,79],'lh':[72,80],'li':[72,81],'lj':[72,82],'lk':[72,83],'lb':[72,84],'fh':[72,85],'fi':[72,86],'ic':[72,87],'k':[72,88],'jk':[89],'jl':[89,90],'ig':[91],'id':[91,92],'ie':[91,93],'if':[91,94],'j':[95],'hl':[95,96],'fk':[95,97],'fb':[95,98],'gg':[95,99],'gh':[95,100],'ja':[95,101],'ll':[95,102],'jb':[95,103],'fa':[95,104],'hk':[95,105],'g':[95,106],'kc':[95,107],'ji':[108],'kb':[108,,109],'kd':[108,,110],'kk':[108,,111],'fd':[108,,112],'jf':[108,,113],'jg':[108,,114],'jh':[108,,115],'gj':[116],'je':[116,117],'gi':[116,118],'gk':[116,119],'jc':[116,120],'fj':[121],'i':[121,122],'ia':[121,123],'fl':[121,124],'fc':[121,125],'ih':[121,126],'ib':[121,127],'ik':[121,128],'ij':[121,129],'ka':[130]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Welcome','Welcome',1,1,'',''],[['aa','Latest News','Latest News',2,1,'',''],['dl','Dr Sophia and Mr Tahir 2009 Visit','Dr Sophia and Mr Tahir 2009 Visit',3,0,'',''],['ai','Absence & Attendance','Absence & Attendance',4,1,'',''],['aj','Adverse Weather','Adverse Weather Warnings',5,1,'',''],['ak','School Handbook','School Handbook 2010',6,1,'',''],['al','Contact Us','Contact Us',7,1,'',''],['ad','Transport','Transport',8,1,'',''],['af','School Dates','School Calendar - 09/10',9,1,'',''],],['b','Nursery','Nursery',10,1,'',''],[['bb','Nursery News','Nursery News',11,1,'',''],['ba','Our Topics','Caterpillars, food and health.',12,1,'',''],['bc','Chrismas Bazaar','Christmas Bazaar',13,1,'',''],['bd','St Andrew\'s Celebration','St Andrew\'s Celebration',14,1,'',''],],['c','P1-2','Hello',15,1,'',''],[['ca','Critical Skills','ca',16,1,'',''],['cb','Rotting Food','Rotting Food',17,1,'',''],['cd','Houses and Homes','Houses',18,1,'',''],['ce','Houses and Homes Presentation','Four of our class made up this PowerPoint Presentation.  Enjoy!',19,1,'',''],['cf','Ballyheerin Slideshow','Scoil Choluim, Ballyheerin',20,1,'',''],['ch','Star Writers','Star Writers',21,1,'',''],['cj','Voices of the World','Voices of the World',22,1,'',''],['cg','What\'s the time Mr Wolf?','What\'s the time Mr Wolf?',23,1,'',''],],['d','P3-4-5','P3-4-5',24,1,'',''],[['da','Scotland','Scotland',25,1,'',''],['db','European Handwriting','European Handwriting',26,1,'',''],['dc','Victorians','Victorians',27,1,'',''],['dd','Money Matters','Money Matters',28,1,'',''],['de','Transport','Transport',29,1,'',''],['di','Duff House Art','This is A Display Of Our Duff House Art',30,1,'',''],['dj','Superclubs','Superclubs',31,1,'',''],['cl','Tattie-Bogle Kidz','Tattie-Bogle Kidz',32,1,'',''],],['e','P6-7','P6-7',33,1,'',''],[['ha','Latest News','Latest News',34,1,'',''],['gl','Ancient Egypt 2010','gl',35,1,'',''],['jd','Global Citizens out and about','Global Citizens out and about',36,1,'',''],['ci','Chinese Moon Festival','Chinese Moon Festival',37,1,'',''],['ea','St Thomas Radio?','St Thomas Radio?',38,1,'',''],['eb','Good Books','How to relax with a good book!',39,1,'',''],['ec','Soap City','Soap City',40,0,'',''],['h','Bubbly Dubbly Soap','Bubbly Dubbly Soap',41,0,'',''],['ed','World War Two','World War Two',42,1,'',''],['ee','Polish Art Project','Polish Art Project',43,1,'',''],['eg','Voices of the World','Voices of the World',44,1,'',''],['eh','Squeaky Clean Challenge','Squeaky Clean Challenge',45,1,'',''],['ei','Countries of the World','Countries of The World',46,1,'',''],['ek','Sammy comes to school!','Sammy comes to school!',47,1,'',''],['ef','The Mistle Thrush','The Mistle Thrush',48,1,'',''],['ej','The Crested Tit','The Crested Tit',49,1,'',''],['l','Pupils\' Page','Pupils\' Page',50,1,'',''],['dh','I Can Animate','I Can Animate',51,1,'',''],['dg','Monkey Bubbles','Monkey Bubbles',52,0,'',''],],['hc','Curriculum for Excellence','Curriculum for Excellence',53,1,'',''],[['hd','ICT','ICT',54,1,'',''],['he','Science','Science',55,1,'',''],['hb','Language','Language',56,1,'',''],['hf','Mathematics','Mathematics',57,1,'',''],['hg','Environmental Studies','Environmental Studies',58,1,'',''],['hh','Expressive Arts','Expressive Arts',59,1,'',''],['el','Sport','Sport',60,1,'',''],['hi','Support for Learning','Support for Learning',61,1,'',''],['f','Religious Observance','Religious Observance',62,1,'',''],['hj','P.S.D.','Personal & Social Development',63,1,'',''],['fg','R.E.','R.E.',64,1,'',''],],['gf','Health','Health',65,1,'',''],[['gb','Our Committee','Our Committee',66,1,'',''],['ga','7-Stage Process','Health Promoting School 7-stage process.',67,1,'',''],['gc','Healthy Eating','Healthy Eating',68,1,'',''],['gd','Drugs','Drugs',69,1,'',''],['ge','Physical Health','Physical Health',70,1,'',''],['il','Promoting Health Slideshow','Promoting Health Day',71,1,'',''],],['dk','Global/International','St Thomas goes Global',72,1,'',''],[['jj','International Policy','International Policy for St Thomas RC School, Keith,Moray',73,1,'',''],['le','Confucius Classrooms','Confucius Classrooms',74,1,'',''],['la','Planet Partners','Planet Partners',75,1,'',''],['lc','Places of Worship','Places of Worship',76,1,'',''],['ld','Music','Pakistani Music',77,1,'',''],['lf','Voices of the World','Voices of the World',78,0,'',''],['lg','Hello Goodbye','Hello Goodbye Assembly',79,1,'',''],['lh','Poetry','Poetry',80,1,'',''],['li','Video Conference','Video Conference',81,1,'',''],['lj','Ms. Francis\' Diary','Ms. Francis\' Diary',82,1,'',''],['lk','Lahore Lyceum','Lahore Lyceum',83,1,'',''],['lb','Partnership Agreement','Partnership Agreement',84,1,'',''],['fh','Farhat\'s First Visit to Keith','Farhat\'s First Visit to Keith',85,1,'',''],['fi','Mr Farrell\'s Travels','Mr Farrell\'s Travels',86,1,'',''],['ic','World Time','World Time',87,1,'',''],['k','Postcards from Pakistan !','Postcards from Pakistan !',88,1,'',''],],['jk','Pupils\' Pages','Pupils\' Pages',89,1,'',''],[['jl','Planet Partners','Planet Partners',90,1,'',''],],['ig','Enterprise','[marquee=behavior:scroll;direction:up] Enterprise[/marquee]',91,1,'',''],[['id','Duff House Art','Duff House Art',92,1,'',''],['ie','Our visit to Duff House in pictures','Our visit to Duff House in pictures',93,1,'',''],['if','Kids\' Enterprise','Kids\' Enterprise',94,1,'',''],],['j','Eco-Schools','Eco-Schools',95,1,'',''],[['hl','Eco Code','Eco Code',96,1,'',''],['fk','Happy Hippos','Happy Hippos',97,1,'',''],['fb','Recycle Less !','Recycle Less !',98,1,'',''],['gg','Water','Water Water Everywhere!',99,1,'',''],['gh','Mural','Indoor Mural',100,1,'',''],['ja','Litter','Litter Campaign',101,1,'',''],['ll','Sensory Garden','Sensory Garden',102,1,'',''],['jb','Rowanbank','Rowanbank Eco Workshop',103,1,'',''],['fa','Global Handprint Blog Connection','Global Handprint',104,1,'',''],['hk','Turbine Project','Turbine Project',105,1,'',''],['g','Your Moray Your Environment','Your Moray Your Environment Award',106,1,'',''],['kc','Eco Action Plans','Eco Action Plans',107,1,'',''],],['ji','ACE Afternoons','ACE Afternoons',108,1,'',''],[[['kb','Thank you','Thank you',109,0,'',''],['kd','Bubble Makers','Bubble Makers',110,0,'',''],['kk','German Comenius Visit','German Comenius Visit',111,0,'',''],['fd','Comenius School Group','Comenius School Group',112,1,'',''],['jf','EcoSchool Group','EcoSchool Group',113,1,'',''],['jg','Healthy School Group','Healthy School Group',114,1,'',''],['jh','Enterprise School Group','Enterprise School Group',115,1,'',''],]],['gj','Pupil Council','Pupil Council',116,1,'',''],[['je','Pupil Council Minutes','Pupil Council Minutes',117,1,'',''],['gi','Constitution','Constitution',118,1,'',''],['gk','Library Review','Library Review',119,1,'',''],['jc','Recycool','Recycool',120,1,'',''],],['fj','Parents & Carers','Parents & Carers',121,1,'',''],[['i','Parent Council','Parent Council',122,1,'',''],['ia','Constitution','Constitution',123,1,'',''],['fl','Minutes','Minutes',124,1,'',''],['fc','Events','Events',125,1,'',''],['ih','Medicines','Medicines',126,1,'',''],['ib','Health & Safety','Health & Safety',127,1,'',''],['ik','Homework Help','Homework Help',128,1,'',''],['ij','Contact Us','Contact Us',129,1,'',''],],['ka','Links','Links',130,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';
			}
	}
}

