jsn_b = 'http://westonwisconsin.org/';
jsn_b2 = 'http://www.westonwisconsin.org/';

/*

Glossary:

a	anchor element
i	iterator
o	object from jsn_a
p	parent object (type o)
t	element type
ul	unordered list element

*/

// Get element by id
function jsn_i (i) { return document.getElementById(i); }

// Create element
function jsn_c (t) { return document.createElement(t); }

// Check whether defined
function jsn_d (v) { return (typeof(v) != 'undefined' && v); }

// Recursively attach anchors to object nodes and create show/hide functions
function jsn_n (o,a,p)
{
	o.a = a;
	o.p = p;

	if (jsn_d(o.s) && o.s.length > 0)
	{
		o.ul = jsn_c('ul');

		for (var i = 0; i < o.s.length; i++)
		{
			var l = jsn_c('li');
			var ca = jsn_c('a');

			ca.href = o.s[i].u;
			ca.innerHTML = o.s[i].n;
			ca.id = o.a.id+'_'+i;

			l.appendChild(ca);

			jsn_n(o.s[i],ca,o);

			o.ul.appendChild(l);
		}
		
		o.a.parentNode.appendChild(o.ul);

		o.a.parentNode.onmouseover = jsn_show;
		o.a.parentNode.onmouseout = jsn_hide;
	}

	o.a.o = o;
}

jsn_show = function() {
	this.className += ' show';
};

jsn_hide = function() {
	this.className = '';
};

var jsn_p = {'ul':jsn_i('nav')};
var jsn_h = jsn_p.ul.getElementsByTagName('a');

for (var i = 0; i < jsn_a.length; i++)
{
	for (var j = 0; j < jsn_h.length; j++)
	{
		if (jsn_h[j].href == jsn_b+jsn_a[i].n+'/' || jsn_h[j].href == jsn_b2+jsn_a[i].n+'/')
		{
			
			jsn_h[j].id = jsn_a[i].n;
			jsn_n(jsn_a[i],jsn_h[j],jsn_p);
		}
	}
}

