var edit_mode = "3";
var treecolor = "FFFFFFFF";
var dirty = false;
var site_nav_index = {'a':[1],'ac':[1,2],'ak':[1,3],'ab':[1,4],'eh':[5],'ei':[5,6],'ek':[5,7],'ej':[5,8],'el':[5,9],'ad':[10],'ga':[10,11],'ae':[10,12],'af':[10,13],'ai':[10,14],'al':[10,15],'f':[10,16],'ah':[10,17],'fa':[10,18],'fb':[10,19],'ge':[10,20],'gf':[10,21],'g':[10,22],'gd':[10,23],'df':[24],'dl':[24,25],'di':[24,26],'dh':[24,27],'dj':[24,28],'dk':[24,29],'c':[30],'ca':[30,31],'cb':[30,32],'l':[33],'j':[34],'ag':[35],'aj':[35,36],'h':[37],'ha':[37,38],'hb':[37,39],'hk':[37,40],'hc':[37,41],'hd':[37,42],'hl':[37,43],'hf':[37,44],'hh':[37,45],'hi':[37,46],'hj':[37,47],'gg':[48],'je':[48,49],'jf':[48,50],'e':[51],'ea':[51,52],'eb':[51,53],'ec':[51,54],'ed':[51,55],'fc':[56],'fd':[56,57],'ff':[56,58],'fg':[56,59],'fh':[56,60],'fi':[56,61],'fj':[56,62],'gi':[63],'gk':[63,64],'gj':[63,65],'kb':[66],'kc':[66,67],'kd':[66,67,68],'kf':[66,67,69],'kg':[66,67,70],'kh':[66,67,71],'ki':[66,67,72],'kk':[66,67,73],'b':[74],'bb':[74,75],'bh':[74,76],'bd':[74,77],'ba':[74,78],'bk':[74,79],'be':[74,80],'bj':[74,81],'bi':[74,82],'bl':[74,83],'bc':[74,84],'bf':[74,85],'bg':[74,86],'i':[87],'ii':[87,88],'d':[89],'dd':[89,90],'db':[89,91],'cd':[92],'ce':[92,93],'cf':[92,94],'cg':[92,95],'ch':[92,96],'ci':[92,97],'cj':[92,98],'jk':[99]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Home','a',1,1,'',''],[['ac','School History','ac',2,1,'',''],['ak','Location','ak',3,1,'',''],['ab','School Events','ab',4,1,'',''],],['eh','Staff','eh',5,1,'',''],[['ei','Senior Management Team','ei',6,1,'',''],['ek','Staff List','ek',7,1,'',''],['ej','Pupil Support','ej',8,1,'',''],['el','Welcome','el',9,1,'',''],],['ad','Parent Information','ad',10,1,'',''],[['ga','Latest Letters','ga',11,1,'',''],['ae','School Uniform','ae',12,1,'',''],['af','Attendance Policy','af',13,1,'',''],['ai','EMA','ai',14,1,'',''],['al','2009/2010 Handbook','al',15,1,'',''],['f','Newsletter','f',16,1,'',''],['ah','Policy on Parental Involvement','ah',17,1,'',''],['fa','Parent Council','fa',18,1,'',''],['fb','Behaviour Management Policy','fb',19,1,'',''],['ge','Aifl','ge',20,1,'',''],['gf','Curriculum for Excellence','gf',21,1,'',''],['g','Camera & Video Phones','g',22,1,'',''],['gd','Campus Officer','gd',23,1,'',''],],['df','Pupil Information','df',24,1,'',''],[['dl','Pupil Bulletin','dl',25,1,'',''],['di','S1 and S2','di',26,1,'',''],['dh','S3 and S4','dh',27,1,'',''],['dj','S5 and S6','dj',28,1,'',''],['dk','Clubs and Societies','dk',29,1,'',''],],['c','Art','c',30,1,'',''],[['ca','S1/S2','ca',31,1,'',''],['cb','S3/S4','cb',32,1,'',''],],['l','ICT Faculty','l',33,1,'',''],['j','English','j',34,1,'',''],['ag','Food Technology','ag',35,1,'',''],[['aj','aj','aj',36,1,'',''],],['h','Library','h',37,1,'',''],[['ha','About the Library','ha',38,1,'',''],['hb','Where to find things','hb',39,1,'',''],['hk','Scottish Authors','hk',40,1,'',''],['hc','Themed Booklists','hc',41,1,'',''],['hd','Good Reads 1','hd',42,1,'',''],['hl','Good Reads 2','hl',43,1,'',''],['hf','Look who\'s been caught reading!','hf',44,1,'',''],['hh','Top Reading Tips','hh',45,1,'',''],['hi','Graphic Novels','hi',46,1,'',''],['hj','Poetry Please!','hj',47,1,'',''],],['gg','Mathematics','gg',48,1,'',''],[['je','Higher Maths','Higher Revision Materials',49,1,'',''],['jf','Credit Maths','Revision Materials for Credit Maths',50,1,'',''],],['e','Modern Languages','e',51,1,'',''],[['ea','Resources and Materials','ea',52,1,'',''],['eb','Recommended Websites','eb',53,1,'',''],['ec','Culture and Events','ec',54,1,'',''],['ed','S1 German Penpal Letters','ed',55,1,'',''],],['fc','Music','fc',56,1,'',''],[['fd','About the Department','fd',57,1,'',''],['ff','Music in S3 & S4','Music in S3 & S4',58,1,'',''],['fg','Music in S5 & S6','Music in S5 & S6',59,1,'',''],['fh','Web Links','Web Links',60,1,'',''],['fi','Download Resources','Download Resources',61,1,'',''],['fj','Concept List',' [colour=black]\<b\>Concept List\</b\>[/colour]',62,1,'',''],],['gi','PE','gi',63,1,'',''],[['gk','Standard Grade S4','gk',64,1,'',''],['gj','Standand Grade S3','gj',65,1,'',''],],['kb','RME Dept','kb',66,1,'',''],[['kc','An intro to RME','kc',67,1,'',''],[['kd','ACE Reward','kd',68,1,'',''],['kf','S2 Course Outline','kf',69,1,'',''],['kg','S3/S4 Core Course Outline','kg',70,1,'',''],['kh','S3/S4 Intermediate Course','kh',71,1,'',''],['ki','Higher Philosophy','ki',72,1,'',''],['kk','Useful Links & Resources','kk',73,1,'',''],]],['b','Science','b',74,1,'',''],[['bb','Biology - Standard Grade','bb',75,1,'',''],['bh','Biology - Intermediate 1','bh',76,1,'',''],['bd','Biology - Intermediate 2','Biology',77,1,'',''],['ba','Biology - Higher','ba',78,1,'',''],['bk','Biotechnology','bk',79,1,'',''],['be','Physics - General Information','be',80,1,'',''],['bj','Physics - Intermediate 1','bj',81,1,'',''],['bi','Physics - Standard Grade','bi',82,1,'',''],['bl','Physics - Higher and Advanced Higher','Higher and Advanced Higher',83,1,'',''],['bc','Chemistry - Standard Grade','bc',84,1,'',''],['bf','Chemistry - Higher','bf',85,1,'',''],['bg','Chemistry 3','bg',86,1,'',''],],['i','Social Subjects','i',87,1,'',''],[['ii','Modern Studies','ii',88,1,'',''],],['d','Support for Learning','d',89,1,'',''],[['dd','Support Base','dd',90,1,'',''],['db','Useful Websites','db',91,1,'',''],],['cd','Technical','cd',92,1,'',''],[['ce','Subjects','ce',93,1,'',''],['cf','Resources Standard Grade Graphic Communication','cf',94,1,'',''],['cg','Resources Standard Grade Craft and Design','Standard Grade Craft and Design',95,1,'',''],['ch','Resources Intermediate 1 and 2 Graphic Communication','ch',96,1,'',''],['ci','Resources Higher Graphic Communcation','Resources Higher Graphic Communcation',97,1,'',''],['cj','Resources Higher Product Design','Resources Higher Product Design',98,1,'',''],],['jk','Online Grammarian Magazine','Online Grammarian Magazine',99,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';
			}
	}
}

