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],'ae':[1,6],'af':[1,7],'ag':[1,8],'ah':[1,9],'ai':[1,10],'aj':[1,11],'b':[12],'ba':[12,13],'bb':[12,14],'bc':[12,15],'bd':[12,16],'be':[12,17],'bf':[12,18],'bg':[12,19],'bh':[12,20],'bi':[12,21],'bj':[12,22],'bk':[12,23],'bl':[12,24],'bn':[12,25],'c':[26],'ca':[26,27],'cb':[26,28],'cc':[26,29],'cd':[26,30],'ce':[26,31],'cf':[26,32],'cg':[26,33],'ch':[26,34],'ci':[26,35],'cj':[26,36],'ck':[26,37],'cl':[26,38],'cm':[26,39],'cn':[26,40],'co':[26,41],'d':[42],'da':[42,43],'db':[42,44],'e':[45],'ea':[45,46],'eb':[45,47],'ec':[45,48],'ed':[45,49],'ee':[45,50],'ef':[45,51],'f':[52],'fa':[52,53],'fb':[52,54],'fc':[52,55],'g':[56],'ga':[56,57],'gb':[56,58],'gc':[56,59],'gd':[56,60],'h':[61],'i':[62],'ia':[62,63],'ib':[62,64],'j':[65],'ja':[65,66],'l':[67],'la':[67,68],'lb':[67,69],'lc':[67,70],'ld':[67,71],'le':[67,72],'m':[73],'n':[74],'o':[75]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Home','St Joseph\'s College',1,1,'',''],[['aa','History','History of the school',2,1,'',''],['ab','Aims','Aims of St Joseph\'s College',3,1,'',''],['ac','Denomination','Denominational Status',4,1,'',''],['ad','Population','The Population of St Joseph\'s College',5,1,'',''],['ae','Organisation','Organisation at St Joseph\'s',6,1,'',''],['af','Courses','Courses',7,1,'',''],['ag','S1 and S2','S1 and S2',8,0,'',''],['ah','S3 and S4','S3 and S4',9,0,'',''],['ai','S5 and S6','S5 and S6',10,0,'',''],['aj','Library','Library',11,1,'',''],],['b','Pupil Zone','Pupil Zone',12,1,'',''],[['ba','Pupil Council','The Pupil Council',13,1,'',''],['bb','Revision','Online Revision',14,1,'',''],['bc','SQA Exams 2008','SQA Exam Timetable 2008',15,1,'',''],['bd','Games','Games and Quizes',16,1,'',''],['be','S5 Options Form','S5 Options Form 2007-2008',17,1,'',''],['bf','S6 Option Form','S6 Option Form 2007-2008',18,1,'',''],['bg','Tobacco Policy','Tobacco Control Policy for Pupils',19,1,'',''],['bh','Discipline Policy','New Discipline Policy',20,1,'',''],['bi','Code of Conduct','CODE OF CONDUCT',21,0,'',''],['bj','School Rules','SCHOOL RULES',22,0,'',''],['bk','Routines','ROUTINES',23,0,'',''],['bl','Cyber Bullying','Cyber Bullying',24,1,'',''],['bn','Mobile Phones','Mobile Phone Policy',25,1,'',''],],['c','Parent Zone','Parent Zone',26,1,'',''],[['ca','Free Meals','Free School Meal Entitlement',27,1,'',''],['cb','Home Link Worker','Home Link Worker',28,1,'',''],['cc','Jubilee Forum','The Jubilee Forum',29,1,'',''],['cd','School Policies','School Policies',30,1,'',''],['ce','Special Needs','Facilities for Pupils with Special Needs',31,1,'',''],['cf','Pupil Support','Pupil Support',32,1,'',''],['cg','Links','Links',33,1,'',''],['ch','Discipline Policy','DISIPLINE POLICY',34,1,'',''],['ci','HMIe Reports','HMIe Reports',35,1,'',''],['cj','Exam Statistics','Exam Statistics',36,1,'',''],['ck','Music Lessons','Instrumental Instruction',37,1,'',''],['cl','RE','Religious Education And Observance',38,1,'',''],['cm','Term Dates','Term Dates',39,1,'',''],['cn','PSP Policy','PSP Policy',40,0,'',''],['co','Cyber Bullying','Cyber Bullying',41,1,'',''],],['d','Staff Zone','Staff Zone',42,1,'',''],[['da','Calendar','Calendar',43,1,'',''],['db','School Policies','School Policies',44,1,'',''],],['e','Latest News','Latest News',45,1,'',''],[['ea','School of the Week','SCIAFF\'s School of the Week',46,1,'',''],['eb','Coming Soon...','Coming Soon At St Joseph\'s',47,1,'',''],['ec','Science Comp','Salter\'s Glasgow University Challenge',48,1,'',''],['ed','Engineering Club','Engineering Club Formula Schools Challenge',49,1,'',''],['ee','Under 13s Football','Under 13s Football Success',50,1,'',''],['ef','Hayley Receives Cap','Hayley Receives Cap',51,1,'',''],],['f','School Trips','School Trips',52,1,'',''],[['fa','Hadrian\'s Wall 2009','Hadrian\'s Wall 2009',53,1,'',''],['fb','Belgian Trip 2009','Belgian Trip 2009',54,1,'',''],['fc','French Trip 2007','French Trip 2007',55,1,'',''],],['g','Departments','Departments',56,1,'',''],[['ga','Chemistry','Chemistry',57,1,'',''],['gb','Science','Science',58,1,'',''],['gc','English','English Department',59,1,'',''],['gd','Learning Support','Learning Support Department',60,1,'',''],],['h','College Links','School / College Links',61,1,'',''],['i','Sports','Sports',62,1,'',''],[['ia','Football','Football',63,1,'',''],['ib','Rugby','Rugby',64,1,'',''],],['j','Homework','Homework',65,1,'',''],[['ja','English Homework','English Department Homework',66,1,'',''],],['l','Parent Council','St Joseph\'s College Parent Council',67,1,'',''],[['la','Minutes','Minutes',68,1,'',''],['lb','Members','Members',69,1,'',''],['lc','Contact Us','lc',70,1,'',''],['ld','Constitution','Constitution',71,1,'',''],['le','Agendas','Agendas',72,1,'',''],],['m','Coming Soon...','Coming Soon at St Joseph\'s College',73,1,'',''],['n','The Eco Group','The Eco Group',74,1,'',''],['o','School Report','BBC SCHOOL REPORT 2010',75,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';
			}
	}
}

