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],'ae':[1,5],'af':[1,6],'ag':[1,7],'ah':[1,8],'ai':[1,9],'al':[1,10],'b':[11],'ba':[11,12],'bb':[11,13],'bc':[11,14],'bd':[11,15],'be':[11,16],'bf':[11,17],'bk':[11,18],'bg':[11,19],'bh':[11,20],'bi':[11,21],'bj':[11,22],'c':[23],'ca':[23,24],'cb':[23,25],'cc':[23,26],'cd':[23,27],'ce':[23,28],'cf':[23,29],'cg':[23,30],'ch':[23,31],'ci':[23,32],'cj':[23,33],'d':[34],'da':[34,35],'db':[34,36],'dc':[34,37],'dd':[34,38],'de':[34,39],'df':[34,40],'e':[41],'ea':[41,42],'eb':[41,43],'ec':[41,44],'ed':[41,45],'ee':[41,46],'ef':[41,47],'f':[48],'fa':[48,49],'fb':[48,50],'fc':[48,51],'fd':[48,52],'fe':[48,53],'fg':[48,54],'fh':[48,55],'g':[56],'gb':[56,57],'ga':[56,58],'gj':[56,59],'gk':[56,60],'gf':[56,61],'h':[62],'ha':[62,63],'hb':[62,64],'i':[65],'k':[66],'l':[67]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Home','\<marquee width=&quot;75%&quot; height=&quot;10&quot; behaviour=&',1,1,'',''],[['aa','Welcome','WELCOME',2,1,'',''],['ab','Aims and Values','ab',3,1,'',''],['ac','Uniform','UNIFORM',4,1,'',''],['ae','Calendar of Events','\<font color=&quot;red&quot;\>Calendar of Events 2009/10\</font\>',5,1,'',''],['af','Staff','Staff',6,1,'',''],['ag','Holidays','Holidays',7,1,'',''],['ah','HMIe Report','ah',8,1,'',''],['ai','Emergency Closures','Emergency Closures',9,1,'',''],['al','Scotland\'s Homecoming','Scotland\'s Homecoming',10,1,'',''],],['b','Classes','\<b\>\<font color=&quot;red&quot;\>Click on a balloon below to find',11,1,'',''],[['ba','Primary 1','Primary 1',12,1,'',''],['bb','Primary 1/2','Primary 1/2',13,1,'',''],['bc','Primary 2/3','Primary 2/3',14,1,'',''],['bd','Primary 3','Primary 3',15,1,'',''],['be','Primary 4','Primary 4',16,1,'',''],['bf','Primary 4/5','Primary 4/5',17,1,'',''],['bk','Primary 5/6','P5/6',18,1,'',''],['bg','Primary 6/7','Primary 6/7',19,1,'',''],['bh','Primary 7','Primary 7',20,1,'',''],['bi','Learning Centre','Learning Centre',21,1,'',''],['bj','Gallery','Gallery',22,1,'',''],],['c','Nursery','NURSERY',23,1,'',''],[['ca','Day to Day Info','Day to Day Information',24,1,'',''],['cb','Our Aims','OUR AIMS',25,1,'',''],['cc','Behaviour','Behaviour',26,1,'',''],['cd','What We Provide','What We Provide',27,1,'',''],['ce','Parent Info','Parent Information',28,1,'',''],['cf','Parents as Partners','Parents as Partners',29,1,'',''],['cg','Transition to P1','Transition to Primary 1',30,1,'',''],['ch','Gallery','Nursery Art Gallery',31,1,'',''],['ci','HMIe Report','Care Commission & HMIe Report',32,1,'',''],['cj','Our Wormery','\<font color =&quot;red&quot;\> O\</font\>\<font color =&quot;green&q',33,1,'',''],],['d','Policies','SCHOOL POLICIES',34,1,'',''],[['da','Curriculum','Curriculum',35,1,'',''],['db','National Assessments','National Assessments',36,1,'',''],['dc','Behaviour','Behaviour and Discipline',37,1,'',''],['dd','Learning and Teaching','Learning and Teaching',38,1,'',''],['de','Support for Pupils','Support for Pupils',39,1,'',''],['df','Nursery','Nursery',40,1,'',''],],['e','School Assoc','SCHOOL ASSOCIATIONS',41,1,'',''],[['ea','Parent Council','Lochmaben Parent Council',42,1,'',''],['eb','L.S.A.','Lochmaben School Association',43,1,'',''],['ec','SNAG','School Nutrition Action Group',44,1,'',''],['ed','Charity','Charity',45,1,'',''],['ee','Pupil Council','Lochmaben School Council',46,1,'',''],['ef','ECO','Eco School Committee',47,1,'',''],],['f','After School Clubs','AFTER SCHOOL CLUBS',48,1,'',''],[['fa','Drama Club','Drama Club',49,1,'',''],['fb','Pop Lacrosse Club','Pop Lacrosse Club',50,1,'',''],['fc','Football Club','Football Club',51,1,'',''],['fd','Swimming Club','Swimming Club',52,1,'',''],['fe','Scripture Union','Scripture Union',53,1,'',''],['fg','Keep Fit Club','Keep Fit Club',54,1,'',''],['fh','Lochmaben Playcare','Lochmaben Playcare',55,1,'',''],],['g','Newsletters','Read All About It!!',56,1,'',''],[['gb','June 2010','gb',57,1,'',''],['ga','April 2010','ga',58,1,'',''],['gj','March 2010','gj',59,1,'',''],['gk','January 2010','gk',60,1,'',''],['gf','December 2009','gf',61,1,'',''],],['h','School Meals','School Meals',62,1,'',''],[['ha','Two Course Menu','Two Course Menu',63,1,'',''],['hb','Take 4 Health','Take 4 Health',64,1,'',''],],['i','Links','Helpful Sites',65,1,'',''],['k','Contact Us','Contact Us',66,1,'',''],['l','Slideshow','l',67,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';
			}
	}
}

