var edit_mode = "3";
var treecolor = "FFFFFFFF";
var dirty = false;
var site_nav_index = {'a':[1],'co':[1,2],'eb':[1,3],'ef':[1,4],'ei':[1,5],'ej':[1,6],'ek':[1,7],'el':[1,8],'em':[1,9],'en':[1,10],'ep':[1,11],'go':[1,12],'gp':[1,13],'ho':[1,14],'i':[15],'ia':[15,16],'ib':[15,17],'ic':[15,18],'id':[15,19],'lb':[15,20],'lc':[15,21],'ld':[15,22],'le':[15,23],'lf':[15,24],'lg':[15,25],'lh':[15,26],'li':[15,27],'lj':[15,28],'lk':[15,29],'ll':[15,30],'lm':[15,31],'ln':[15,32],'lo':[15,33],'mb':[15,34],'mc':[15,35],'md':[15,36],'na':[15,37],'nb':[15,38],'nc':[15,39],'nd':[15,40],'ne':[15,41],'nf':[15,42],'ng':[15,43],'nh':[15,44],'ni':[15,45],'nj':[15,46],'nk':[15,47],'nl':[15,48],'nm':[15,49],'nn':[15,50],'no':[15,51],'np':[15,52],'pb':[15,53],'pc':[15,54],'pd':[15,55],'pe':[15,56],'pk':[15,57],'pl':[15,58]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Home','a',1,1,'',''],[['co','Thailand','IM goes to Thailand',2,0,'',''],['eb','SNG Collaborative','SchoolNet Global Collaborative',3,0,'',''],['ef','Web Community','',4,0,'',''],['ei','Portfolio','',5,0,'',''],['ej','Pepper','The Pepper & Poppy Club',6,0,'',''],['ek','Sponsorship','Sponsorship',7,0,'',''],['el','test','image test',8,0,'',''],['em','_em','',9,0,'',''],['en','Grandma','',10,0,'',''],['ep','Student Voice','',11,0,'',''],['go','SuperClubsPLUS','Independent Research on SuperClubsPLUS',12,0,'',''],['gp','SchoolNet','DfES Evaluation of SchoolNet Global',13,0,'',''],['ho','Press Archive','What the Press Say',14,0,'',''],],['i','Press Hidden','What the Press Say',15,0,'',''],[['ia','Press Hidden 2','What the Press Say',16,0,'',''],['ib','Press Hidden 3','What the Press Say',17,0,'',''],['ic','Press hidden 4','What the Press Say',18,0,'',''],['id','Connected','What the Press Say',19,0,'',''],['lb','Kids','Kids Take Over',20,1,'',''],['lc','SCP Australia','SuperClubsPlus Australia Launch \<br/\>',21,1,'',''],['ld','iPhone','Mobile Communities',22,0,'',''],['le','Parents evening','Parents evening',23,1,'',''],['lf','BETT 08','The Big Issue at BETT',24,1,'',''],['lg','Mobile upgrade','',25,0,'',''],['lh','Parent Speaks','A Parent Speaks Out',26,0,'',''],['li','Schoolzone','',27,0,'',''],['lj','Parents Safety Guide','Safety Guide for Parents',28,0,'',''],['lk','Gem Awards','Gem Awards Launched',29,1,'',''],['ll','OWZ Evaluation','',30,0,'',''],['lm','Kids Lit 09','Kids Lit 09',31,1,'',''],['ln','Prof. Heppell','Prof. Heppell Joins IM',32,1,'',''],['lo','Forensic','IM and Forensic',33,1,'',''],['mb','Thank You','Thank you for your enquiry',34,0,'',''],['mc','Order','Order Research Report',35,0,'',''],['md','Thank You','Thank you for your order',36,0,'',''],['na','SchoolNet FactFiles','SchoolNet Global FactFile Downloads',37,1,'',''],['nb','Take2theweb','',38,1,'',''],['nc','MSC','Download Millennium Schools FactFiles',39,0,'',''],['nd','Community in My Pocket','',40,1,'',''],['ne','My Mobile','',41,1,'',''],['nf','Emily Connected','Emily Connected',42,1,'',''],['ng','Cyberbullying','',43,1,'',''],['nh','Posters','IM posters',44,1,'',''],['ni','Research','Research Programme',45,0,'',''],['nj','Sponsors','Research & Sponsorship',46,0,'',''],['nk','My Safety','',47,1,'',''],['nl','Poland','IM in Poland',48,0,'',''],['nm','Family Learning','nm',49,1,'',''],['nn','Evaluations','',50,1,'',''],['no','Learning Files','',51,1,'',''],['np','LiF Presentation','np',52,0,'',''],['pb','Giant Leap','International Video Conferencing in SchoolNet Global',53,0,'',''],['pc','Sustainability','The Sustainability Project - SchoolNetGlobal',54,0,'',''],['pd','My Country','FactFile: The My Country Project',55,0,'',''],['pe','My Culture','My Culture Project in SchoolNetGlobal',56,0,'',''],['pk','Citizenship','Exploring Citizenship with SchoolNet Global',57,0,'',''],['pl','International','The International Dimension',58,0,'',''],]];
	_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';
			}
	}
}

