var edit_mode = "3";
var treecolor = "FFFFFFFF";
var dirty = false;
var site_nav_index = {'a':[1],'by':[1,2],'ay':[1,3],'aa':[1,4],'ab':[1,5],'ar':[1,6],'ac':[1,7],'ad':[1,8],'ae':[1,9],'af':[1,10],'ag':[1,11],'ai':[1,12],'al':[1,13],'an':[1,14],'ao':[1,15],'ap':[1,16],'au':[1,17],'av':[1,18],'ax':[1,19],'gv':[1,20],'gw':[1,21],'gx':[1,22],'gy':[1,23],'ka':[1,24],'kb':[1,25],'kc':[1,26],'kd':[1,27],'ke':[1,28],'kg':[1,29],'kh':[1,30],'nw':[1,31],'nx':[1,32],'p':[33],'pr':[33,34],'ps':[33,35],'pt':[33,36],'pu':[33,37],'pv':[33,38],'pw':[33,39],'px':[33,40],'py':[33,41],'ry':[33,42]};
var nav_path = site_nav_index[page];

function process_nav()
{
	var nav = [['a','Welcome','Welcome',1,1,'',''],[['by','Great courses for Summer 2010','Great courses for Summer 2010',2,1,'',''],['ay','Latest News','International Dry Stone Walling Course',3,1,'',''],['aa','What\'s it all about?','What\'s it all about?',4,1,'',''],['ab','Contact Us','Contact Us',5,1,'',''],['ar','Eco Centre','ar',6,1,'',''],['ac','What people have said','What people have said',7,1,'',''],['ad','Enquiries','Enquiries',8,1,'',''],['ae','Downloads','Downloads',9,1,'',''],['af','Walls for the Future - info','Walls for the Future',10,1,'',''],['ag','HBS - info','Heritage Building Skills',11,1,'',''],['ai','Courses 2010','Courses 2010',12,1,'',''],['al','Hedge laying  - dates','Hedge laying',13,1,'',''],['an','Walls for the Future - dates','Walls for the Future',14,1,'',''],['ao','WFTF L1 - Summer 2010','WFTF L1 - Summer 2010',15,0,'',''],['ap','Self Build Weekend','Self Build Weekend',16,1,'',''],['au','Booking Form','Booking Form',17,1,'',''],['av','WFTF Application Form','WFTF Application Form',18,1,'',''],['ax','WFTF confirmation','WFTF confirmation',19,0,'',''],['gv','DDCVS What we do','',20,0,'',''],['gw','DDCVS Who manages','',21,0,'',''],['gx','DDCVS Tng Opps','',22,0,'',''],['gy','DDCVS Feedback form','',23,0,'',''],['ka','Arts and Crafts','Arts and Crafts',24,1,'',''],['kb','Business and Careers','Business and Careers',25,1,'',''],['kc','Community / Voluntary','Community / Voluntary',26,1,'',''],['kd','Education and Training','Education and Training Opportunities',27,1,'',''],['ke','Land Based Skills','Land Based Skills',28,1,'',''],['kg','Environment','Environment',29,1,'',''],['kh','Miscellaneous','Miscellaneous',30,1,'',''],['nw','WFTF confirmation','',31,0,'',''],['nx','Confirmation','',32,0,'',''],],['p','Eco Centre','p',33,1,'',''],[['pr','8thFebruary2010','pr',34,0,'',''],['ps','7thJanuary2010','ps',35,0,'',''],['pt','6th January 2010','pt',36,0,'',''],['pu','15theJanuary2010','pu',37,0,'',''],['pv','3rdJanuary2010','pv',38,0,'',''],['pw','17thDecember2009','pw',39,0,'',''],['px','1stDecember2009','px',40,0,'',''],['py','25thNovember2009','py',41,0,'',''],['ry','_ry','HBS Fair confirmation',42,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';
			}
	}
}

