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],'ak':[1,12],'al':[1,13],'d':[14],'da':[14,15],'dd':[14,16],'df':[14,17],'di':[14,18],'dl':[14,19],'ba':[14,20],'bb':[14,21],'bc':[14,22],'bd':[14,23],'be':[14,24],'bf':[14,25],'bg':[14,26],'bj':[14,27],'bk':[14,28],'c':[29],'ca':[29,30],'ga':[29,31],'gc':[29,32],'gf':[29,33],'gi':[29,34],'gj':[29,35],'f':[36],'fa':[36,37],'fg':[36,38],'fd':[36,39],'fe':[36,40],'ff':[36,41],'fb':[36,42],'fh':[36,43],'fi':[36,44],'fj':[36,45],'e':[46],'ea':[46,47],'eb':[46,48],'ec':[46,49],'ed':[46,50],'ee':[46,51],'ef':[46,52],'eg':[46,53],'eh':[46,54],'h':[55],'ha':[55,56],'hb':[55,57],'hc':[55,58],'hd':[55,59],'he':[55,60],'hf':[55,61],'hg':[55,62],'hi':[55,63],'hj':[55,64],'hk':[55,65],'hl':[55,66],'ib':[55,67],'ic':[55,68],'id':[55,69],'ie':[55,70],'ih':[55,70,71],'ii':[55,70,72],'ij':[55,70,73],'ik':[55,70,74],'ia':[75],'i':[76],'j':[77],'ja':[77,78],'jc':[77,79],'jb':[77,80],'k':[81],'kb':[81,82],'kc':[81,83],'l':[84],'lb':[84,85],'lc':[84,86]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Home','[marquee=behavior:scroll;direction:left;scrollamount:4][image=ht',1,0,'',''],[['aa','Welcome','Welcome',2,1,'',''],['ab','Our Staff Team','Our Staff Team',3,1,'',''],['ac','CSI','Crime Scene Kersland 2009',4,1,'',''],['ad','Home','[marquee=behavior:scroll;direction:left ]Welcome to Kersland![/m',5,0,'',''],['ae','The Curriculum','The Curriculum',6,1,'',''],['af','Learning and Teaching','Learning and Teaching',7,1,'',''],['ag','Our Staff Team New','Our Staff Team',8,1,'',''],['ah','CSI Kersland','ah',9,1,'',''],['ai','marquee pics','marquee pics',10,0,'',''],['aj','Subject Areas','Subject Areas',11,1,'',''],['ak','School Calendar 09 / 10','School Calendar 09 / 10',12,1,'',''],['al','Working With Parents','Working With Parents',13,1,'',''],],['d','Classes','Click on the numbered balloon or use the drop-down menu to acces',14,1,'',''],[['da','Room1','Room 1',15,1,'',''],['dd','Room 2','Room 2',16,1,'',''],['df','Room 3','Room 3',17,1,'',''],['di','Room 4','Room 4',18,1,'',''],['dl','Room 5','Room 5',19,1,'',''],['ba','Curriculum for Excellence','Curriculum for Excellence',20,1,'',''],['bb','Successful Learners','Watch the slideshow of us being Successful Learners.',21,0,'',''],['bc','Confident Individuals','Watch the slideshow of us being Confident Individuals.',22,0,'',''],['bd','Responsible Citizens','Watch the slideshow of us being Responsible Citizens.',23,0,'',''],['be','Effective Contributors','Watch the slideshow of us being Effective Contributors.',24,0,'',''],['bf','Working With Others','Working With Others.',25,1,'',''],['bg','General Info','General Info',26,1,'',''],['bj','bj','bj',27,1,'',''],['bk','bk','bk',28,1,'',''],],['c','Get Involved','Get Involved!',29,1,'',''],[['ca','How can you help?','How Can I Get Involved?',30,1,'',''],['ga','Room 6','Room 6',31,1,'',''],['gc','Room 7','Room 7',32,1,'',''],['gf','Room 8','Room 8',33,1,'',''],['gi','Room 9','Room 9',34,1,'',''],['gj','gj','gj',35,0,'',''],],['f','News Letters','Kersland Krack!',36,1,'',''],[['fa','Leavers Prom 2009','Leavers Prom 2007',37,0,'',''],['fg','April 2010','April 2010',38,1,'',''],['fd','October 2008','October 2008',39,1,'',''],['fe','December 08','December 08',40,1,'',''],['ff','Jan/ Feb 10','January/ February 2010 News',41,1,'',''],['fb','March 09','fb',42,1,'',''],['fh','June 09','fh',43,1,'',''],['fi','News Letter  October 2009','News Letter  October 2009',44,0,'',''],['fj','December 2009','December 2009',45,1,'',''],],['e','photo gallery post 2008','Click on the photos below to see more from these events',46,0,'',''],[['ea','Pupil-Eco Council','Pupil-Eco Council',47,1,'',''],['eb','Minutes','Minutes',48,1,'',''],['ec','What\'s New at Kersland?','What\'s New at Kersland?',49,1,'',''],['ed','Duke of Edinburgh Award','Duke of Edinburgh Award',50,1,'',''],['ee','Eco-School Award','Eco-School Award',51,1,'',''],['ef','Tes schools Award 2010','TES Schools Awards 2010',52,1,'',''],['eg','Inverclyde Sports Centre May 2010','Inverclyde Sports Centre May 2010',53,1,'',''],['eh','Here comes Summer!','Here comes Summer!',54,1,'',''],],['h','Photogallery menu','Click on the albums below to see different events from those yea',55,0,'',''],[['ha','photogallery pre 2008','Click on the photos below to see more from these events',56,0,'',''],['hb','BBQ','BBQ Beach Party 2007',57,0,'',''],['hc','Nativity 2008','Nativity 2008',58,0,'',''],['hd','Concert 2007','School Concert 2007',59,0,'',''],['he','Art Exhibition','Exhibition Art',60,0,'',''],['hf','Tree planting','Tree planting',61,0,'',''],['hg','Oscars','Oscars',62,0,'',''],['hi','Children in Need','Children in Need',63,0,'',''],['hj','Concert 2006','Concert 2006',64,0,'',''],['hk','Fund Raising','Fund Raising',65,0,'',''],['hl','Halloween','Happy Halloween',66,0,'',''],['ib','MUGA','MUGA (multi use games area)',67,0,'',''],['ic','In Aid Of Aidan','Fund Raising for Aidan',68,0,'',''],['id','OSCARS','Kersland topic',69,0,'',''],['ie','Alien Invasion 2009!!!!','Alien invasion',70,1,'',''],[['ih','ih','ih',71,0,'',''],['ii','ii','ii',72,0,'',''],['ij','ij','ij',73,0,'',''],['ik','ik','ik',74,0,'',''],]],['ia','Fashion Show','Braehead Fashion Show',75,0,'',''],['i','Fashion Show','Braehead Fashion Show',76,0,'',''],['j','fun activities','Click and show',77,1,'',''],[['ja','Artworks','Artworks',78,1,'',''],['jc','Rock and Roll','Rock and Roll',79,1,'',''],['jb','virtual tour',' A look around Kersland School',80,1,'',''],],['k','useful links','Useful links',81,1,'',''],[['kb','kb','kb',82,1,'',''],['kc','Handbook','School Handbook',83,1,'',''],],['l','Hot off the press','Hot off the press',84,1,'',''],[['lb','Quality Scotland Award','lb',85,1,'',''],['lc','The People\'s Millions 2006 winners','The People\'s Millions 2006 winners',86,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';
			}
	}
}

