var edit_mode = "3";
var treecolor = "FFFFFFFF";
var dirty = false;
var site_nav_index = {'a':[1],'aa':[1,2],'ab':[1,3],'ac':[1,4],'ad':[1,5],'b':[6],'ba':[6,7],'bf':[6,8],'be':[6,9],'bc':[6,10],'bb':[6,11],'bd':[6,12],'c':[13],'cg':[13,14],'cc':[13,15],'ce':[13,16],'cf':[13,17],'cb':[13,18],'pt':[13,19],'d':[20],'da':[20,21],'db':[20,21,22],'de':[20,23],'di':[20,24],'dm':[20,25],'dq':[20,26],'kd':[20,26,27],'bm':[20,28],'bq':[20,29],'hh':[20,30],'hk':[20,30,31],'n':[20,32],'hl':[20,33],'hp':[20,34],'ll':[20,34,35],'hq':[20,34,36],'hr':[20,34,37],'hs':[20,34,38],'lm':[20,34,39],'ln':[20,34,40],'lp':[20,34,41],'nh':[20,42],'ht':[20,43],'gl':[20,44],'gp':[20,45],'gt':[20,46],'fs':[20,47],'ih':[20,48],'il':[20,49],'ob':[20,50],'e':[51],'eb':[51,52],'ea':[51,53],'eg':[51,54],'ef':[51,55],'ec':[51,56],'eh':[51,57],'eq':[51,58],'er':[51,58,59],'es':[51,58,60],'f':[61],'fi':[61,62],'fm':[61,63],'oq':[61,64],'fj':[61,65],'os':[61,66],'fk':[61,67],'ot':[68],'at':[68,69],'an':[68,70],'ao':[68,71],'p':[68,72],'fo':[68,73],'ch':[68,74],'fh':[68,75],'ei':[76],'em':[76,77],'el':[76,78],'ek':[76,79],'en':[76,80],'pm':[76,81],'pn':[76,81,82],'pq':[76,83],'po':[76,83,84],'hg':[76,83,85],'ps':[76,83,86],'pj':[76,83,87],'fb':[76,83,88],'pb':[76,83,89],'pc':[76,83,90],'pd':[76,83,91],'fa':[76,83,92],'ph':[76,83,93],'fc':[76,83,94],'pe':[76,83,95],'pi':[76,83,96],'pf':[76,83,97],'pg':[76,83,98],'g':[99],'ga':[99,100],'gc':[99,101],'ha':[99,102],'hc':[99,103],'pl':[104]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Home','a',1,1,'',''],[['aa','Headteacher','Welcome to Marr College.',2,1,'',''],['ab','Captains','Welcome from School Captains',3,1,'',''],['ac','Parent Council','ac',4,1,'',''],['ad','Contact us','Contact us',5,1,'',''],],['b','Our School','Our School',6,1,'',''],[['ba','Values and Aims','Values and Aims',7,1,'',''],['bf','Catchment','bf',8,1,'',''],['be','History','History',9,1,'',''],['bc','Location','Location',10,1,'',''],['bb','HMIE Reports','HMIE Inspection Reports',11,1,'',''],['bd','News','News',12,1,'',''],],['c','Our Staff','Our Staff',13,1,'',''],[['cg','Campus Cop','Campus Cop - PC Simpson',14,1,'',''],['cc','Guidance','The Guidance Structure',15,1,'',''],['ce','Janitorial','Janitorial',16,1,'',''],['cf','Support Staff','Support Staff',17,1,'',''],['cb','Teaching Staff','Teaching Staff',18,1,'',''],['pt','SMT','SMT',19,1,'',''],],['d','Departments','d',20,1,'',''],[['da','Art','da',21,1,'',''],[['db','Art Club','db',22,1,'',''],],['de','Biology','de',23,1,'',''],['di','Business Education','di',24,1,'',''],['dm','Chemistry','dm',25,1,'',''],['dq','Computing','dq',26,1,'',''],[['kd','Higher','Higher Computing',27,1,'',''],],['bm','Design & Tech','bm',28,1,'',''],['bq','English','bq',29,1,'',''],['hh','Geography','hh',30,1,'',''],[['hk','SG','SG',31,1,'',''],],['n','Guidance','n',32,1,'',''],['hl','History','hl',33,1,'',''],['hp','Home Economics','hp',34,1,'',''],[['ll','Examination News','Examination News',35,1,'',''],['hq','S1','S1 Home Economics',36,1,'',''],['hr','S2','S2 Home Economics',37,1,'',''],['hs','Recipes','Recipes',38,1,'',''],['lm','More Recipes','More Recipes',39,1,'',''],['ln','Photos','Photos',40,1,'',''],['lp','Int 2 Hospitality','lp',41,1,'',''],],['nh','Library','nh',42,1,'',''],['ht','Mathematics','ht',43,1,'',''],['gl','Mod Languages','gl',44,1,'',''],['gp','Music','gp',45,1,'',''],['gt','PE','gt',46,1,'',''],['fs','Physics','fs',47,1,'',''],['ih','RMPS','ih',48,1,'',''],['il','Support','il',49,1,'',''],['ob','Science','Science',50,1,'',''],],['e','Pupil Zone','Pupil Zone',51,1,'',''],[['eb','Assemblies','Assemblies',52,1,'',''],['ea','Conduct','ea',53,1,'',''],['eg','Dress Code','School Dress Code',54,1,'',''],['ef','Duke of Ed','ef',55,1,'',''],['ec','Houses','Houses',56,1,'',''],['eh','Study Support','Supported Study',57,1,'',''],['eq','Clubs','Clubs',58,1,'',''],[['er','Computer','er',59,1,'',''],['es','Debating','Debating Club',60,1,'',''],]],['f','Parent Zone','Parent Zone',61,1,'',''],[['fi','Standards and Quality Report','fi',62,1,'',''],['fm','Calendar','Calendar',63,1,'',''],['oq','Enterprise','Enterprise in Education',64,1,'',''],['fj','Holidays','fj',65,1,'',''],['os','Letters','os',66,1,'',''],['fk','Parent Council','fk',67,1,'',''],],['ot','School Info','School Information',68,1,'',''],[['at','Exams','Examinations Information',69,1,'',''],['an','Handbook','School Handbook',70,1,'',''],['ao','Newslink','Newslink',71,1,'',''],['p','Press Report','Press Report',72,1,'',''],['fo','Provisional Reports dates','Provisional Reporting dates',73,1,'',''],['ch','School Hours','ch',74,1,'',''],['fh','Uniform','Uniform & Equipment',75,1,'',''],],['ei','Sports','Sports',76,1,'',''],[['em','News','News',77,1,'',''],['el','Football','Football',78,1,'',''],['ek','Rugby','Rugby',79,1,'',''],['en','Volleyball','Volleyball',80,1,'',''],['pm','pm','pm',81,0,'',''],[['pn','pn','News',82,0,'',''],],['pq','Sports Photographs','Sports Photographs',83,1,'',''],[['po','Athletics','Athletics',84,1,'',''],['hg','Badminton','Badminton',85,1,'',''],['ps','Basketball','Basketball',86,1,'',''],['pj','Cricket','Cricket',87,1,'',''],['fb','Dancing','Dancing',88,1,'',''],['pb','Football','Football',89,1,'',''],['pc','Golf','Golf',90,1,'',''],['pd','Hockey','Hockey',91,1,'',''],['fa','Netball','Netball',92,1,'',''],['ph','Internationalists','Internationalists',93,1,'',''],['fc','Orienteering','Orienteering',94,1,'',''],['pe','Rugby','Rugby',95,1,'',''],['pi','Swimming','Swimming',96,1,'',''],['pf','Tennis','Tennis',97,1,'',''],['pg','Volleyball','Volleyball',98,1,'',''],]],['g','Events','Events',99,1,'',''],[['ga','Christmas','ga',100,1,'',''],['gc','Trips','Trips',101,1,'',''],['ha','Chaplains','Chaplains',102,1,'',''],['hc','Councillors','Councillors',103,1,'',''],],['pl','SQA','pl',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';
			}
	}
}

