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],'ag':[1,7],'ah':[1,8],'ai':[1,9],'aj':[1,10],'ak':[1,11],'al':[1,12],'am':[1,13],'an':[1,14],'ao':[1,15],'ap':[1,16],'b':[17],'ba':[17,18],'bb':[17,19],'bc':[17,20],'bd':[17,21],'be':[17,22],'bf':[17,23],'bg':[17,24],'bh':[17,25],'bi':[17,26],'bj':[17,27],'bk':[17,28],'bl':[17,29],'bm':[17,30],'bn':[17,31],'bo':[17,32],'c':[33],'ca':[33,34],'cb':[33,35],'cc':[33,36],'cd':[33,37],'ce':[33,38],'cf':[33,39],'cg':[33,40],'ch':[33,41],'ci':[33,42],'cj':[33,43],'cl':[33,44],'cm':[33,45],'co':[33,46],'d':[47],'da':[47,48],'db':[47,49],'de':[47,50],'df':[47,51],'dh':[47,52],'di':[47,53],'dk':[47,54],'e':[55],'ea':[55,56],'ed':[55,57],'ei':[55,58],'ej':[55,59],'ek':[55,60],'f':[61],'fc':[61,62],'fd':[61,63],'fe':[61,64],'g':[65],'ga':[65,66],'gb':[65,67],'gc':[65,68],'h':[69],'ha':[69,70],'hg':[69,71],'hi':[69,72],'hk':[69,73],'hm':[69,74],'i':[75],'id':[75,76],'if':[75,77],'ig':[75,78],'ii':[75,79],'io':[75,80],'ip':[75,81],'j':[82],'ja':[82,83],'jb':[82,84],'jc':[82,85],'jd':[82,86],'je':[82,87],'jf':[82,88],'jg':[82,89],'jh':[82,90],'ji':[82,91],'jj':[82,92],'jk':[82,93],'jl':[82,94],'jm':[82,95],'jn':[82,96],'jo':[82,97],'jp':[82,98],'o':[99],'p':[100]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Home','Welcome to our website',1,1,'',''],[['aa','Welcome','Welcome from the Headteacher',2,1,'',''],['ab','About our School','ab',3,1,'',''],['ac','Facilities','Facilities',4,1,'',''],['ad','Where to find us','ad',5,1,'',''],['ae','Around the Area','Around the Area',6,1,'',''],['ag','Management','Our School Management Team',7,1,'',''],['ah','Teaching staff','ah',8,1,'',''],['ai','Auxiliary Staff','ai',9,1,'',''],['aj','Visiting Specialists','Visiting Specialists',10,1,'',''],['ak','Nursery','Welcome to Cockenzie Nursery Class',11,1,'',''],['al','Starting School','Starting school',12,1,'',''],['am','Infants','am',13,1,'',''],['an','Middle School','an',14,1,'',''],['ao','Upper School','ao',15,1,'',''],['ap','Get in touch','ap',16,1,'',''],],['b','The Boring Stuff','b',17,1,'',''],[['ba','Holiday Dates','Holiday Dates 2009 - 2011',18,1,'',''],['bb','Calendar','Diary Dates 2009-2010',19,1,'',''],['bc','School Hours','The School Day',20,1,'',''],['bd','School Aims','School Aims',21,1,'',''],['be','Uniform','Uniform',22,1,'',''],['bf','School Rules','School Rules',23,1,'',''],['bg','Playground Rules','Playground Rules',24,1,'',''],['bh','Health & safety','Health & Safety',25,1,'',''],['bi','Anti-bullying','Anti-bullying',26,1,'',''],['bj','Equal Opps','Equal Opportunities',27,1,'',''],['bk','Learning Support','Support for Learning Policy',28,1,'',''],['bl','Learning and Teaching','Learning and Teaching Policy',29,1,'',''],['bm','Homework Policy','Homework Policy',30,1,'',''],['bn','Attendance','Attendance & Punctuality',31,1,'',''],['bo','Child Protection','Child Protection',32,1,'',''],],['c','Curriculum','Curriculum for Excellence',33,1,'',''],[['ca','Topic Web','Planned topics for this year',34,1,'',''],['cb','Language','Language',35,1,'',''],['cc','Mathematics','Mathematics',36,1,'',''],['cd','Environmental Studies','Environmental Studies',37,1,'',''],['ce','P.E','Physical Education',38,1,'',''],['cf','Expressive Arts','Expressive Arts',39,1,'',''],['cg','Modern Languages','French and Italian',40,1,'',''],['ch','R.M.E','Religious and Moral Education',41,1,'',''],['ci','P.S.D','Personal and Social Development',42,1,'',''],['cj','I.C.T','Information Communication Technology',43,1,'',''],['cl','Learning Support','Support for Pupils',44,1,'',''],['cm','Assessment','Assessments, Recording & Reporting',45,1,'',''],['co','Formative Assessment','What is Formative Assessment?',46,1,'',''],],['d','Kid\'s Zone','d',47,1,'',''],[['da','Homework Help','Homework Help',48,1,'',''],['db','Joke of the Day','db',49,1,'',''],['de','Art Gallery','de',50,1,'',''],['df','Fun Stuff','df',51,1,'',''],['dh','Gridclub','dh',52,1,'',''],['di','School Meals Survey','di',53,1,'',''],['dk','Cool Sites','Cool Sites for Kids',54,1,'',''],],['e','Parent\'s Zone','Parent\'s Zone',55,1,'',''],[['ea','E.S Homework','Homework Tasks P1-7',56,1,'',''],['ed','Today\'s happenings','ed',57,1,'',''],['ei','School Camp','Useful Information for Whithaugh Park',58,1,'',''],['ej','Gridclub','Gridclubs for Learning',59,1,'',''],['ek','Against Bullying','Against Bullying',60,1,'',''],],['f','School Community','f',61,1,'',''],[['fc','ECO Team','ECO Team',62,1,'',''],['fd','Active Schools Team','Active Schools Team',63,1,'',''],['fe','Health Promotion','Health Promoting School',64,1,'',''],],['g','Fundraising','',65,1,'',''],[['ga','Bounce for Benches','',66,1,'',''],['gb','Grounds for Fun','gb',67,1,'',''],['gc','Shoebox Appeal','The Goat Factor',68,1,'',''],],['h','School\'s Out!','Fun Activities',69,1,'',''],[['ha','After School Club','Cockenzie After School Club',70,1,'',''],['hg','French Trip','France 2008',71,1,'',''],['hi','School Camp','Whithaugh 2008',72,1,'',''],['hk','WOOSH!','WOOSH Programmes 2008-2009',73,1,'',''],['hm','Active Schools','',74,1,'',''],],['i','Celebrating Success','i',75,1,'',''],[['id','Assemblies','id',76,1,'',''],['if','2 stars and a wish','How are we doing as a school?',77,1,'',''],['ig','Burns Supper','P6 Burns Supper 2009',78,1,'',''],['ii','School Camp Display','School Camp Display',79,1,'',''],['io','feedback confirmation for school meals survey','Thank You',80,0,'',''],['ip','Feedback Confirmation for \'2 stars & a wish\'','Confirmation',81,0,'',''],],['j','Block 5 Homework','j',82,1,'',''],[['ja','P1 Reading','ja',83,1,'',''],['jb','P1 E.S','jb',84,1,'',''],['jc','P2 Reading','jc',85,1,'',''],['jd','P2 E.S','jd',86,1,'',''],['je','P3 Reading','je',87,1,'',''],['jf','P3 E.S','jf',88,1,'',''],['jg','P4 Reading','jg',89,1,'',''],['jh','P4 E.S','jh',90,1,'',''],['ji','P5 Reading','ji',91,1,'',''],['jj','P5 E.S','jj',92,1,'',''],['jk','P6 Reading','jk',93,1,'',''],['jl','P6 E.S','jl',94,1,'',''],['jm','P7 Reading','jm',95,1,'',''],['jn','P7 E.S','jn',96,1,'',''],['jo','Spelling','How to help your child with spelling',97,1,'',''],['jp','Maths','Maths is Fun!',98,1,'',''],],['o','Blog','Blog',99,1,'',''],['p','Downloads','Downloadable Files',100,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';
			}
	}
}

