function $() {
	if (arguments.length == 1) return get$(arguments[0]);
	var elements = [];
	$c(arguments).each(function(el){
		elements.push(get$(el));
	});
	return elements;
	function get$(el){
		if (typeof el == 'string') el = document.getElementById(el);
		return el;
	}
}


function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


function nav() {

	eval("$('nav_about').onmouseover = function() {return navShow('nav_about');}");
	eval("$('nav_about').onmouseout = function() {return navHide('nav_about');}");

	var hrefsFirst = $('nav_about').getElementsByTagName('A');
	for (var i=0; i < hrefsFirst.length; i++)
	{
		 eval("hrefsFirst[i].onfocus = function() {return navShow('nav_about');}");
		 eval("hrefsFirst[i].onblur = function() {return navHide('nav_about');}"); 
	}

	eval("$('nav_gallery').onmouseover = function() {return navShow('nav_gallery');}");
	eval("$('nav_gallery').onmouseout = function() {return navHide('nav_gallery');}");

	var hrefsSecond = $('nav_gallery').getElementsByTagName('A');
	for (var j=0; j < hrefsSecond.length; j++)
	{
		 eval("hrefsSecond[j].onfocus = function() {return navShow('nav_gallery');}");
		 eval("hrefsSecond[j].onblur = function() {return navHide('nav_gallery');}"); 
	}

	eval("$('nav_thoughts').onmouseover = function() {return navShow('nav_thoughts');}");
	eval("$('nav_thoughts').onmouseout = function() {return navHide('nav_thoughts');}");

	var hrefsSecond = $('nav_thoughts').getElementsByTagName('A');
	for (var j=0; j < hrefsSecond.length; j++)
	{
		 eval("hrefsSecond[j].onfocus = function() {return navShow('nav_thoughts');}");
		 eval("hrefsSecond[j].onblur = function() {return navHide('nav_thoughts');}"); 
	}

	eval("$('nav_resources').childNodes[0].onfocus = function() {return navColor('nav_resources');}"); 
	eval("$('nav_resources').onmouseover = function() {return navColor('nav_resources');}");
	eval("$('nav_resources').childNodes[0].onblur = function() {return navUnColor('nav_resources');}"); 
	eval("$('nav_resources').onmouseout = function() {return navUnColor('nav_resources');}");

	if ($('galleryTOC'))
	{
			var hrefs = $('galleryTOC').getElementsByTagName('A');
			for (var k=0; k < hrefs.length; k++)
			{
				 eval("hrefs[k].onclick = function() {return galleryPoint("+k+");}");
			}
	}


	var gals = getElementsByClass('galleryContent',document,'DIV');
	for (var l=0; l < gals.length; l++)
	{
		 gals[l].id = 'galleryContent'+l;
	}
	
	galleryStep=0
	galleryTotal=gals.length-1

	if (navigator.appVersion.indexOf("MSIE")!=-1){
	document.execCommand("BackgroundImageCache",false,true)
	}
}

window.onload = nav;

function navColor(id) {
	$(id).style.backgroundColor = '#9acdff';
}

function navUnColor(id) {
	$(id).style.backgroundColor = 'transparent';
}

function navShow(id) {
	$(id).style.backgroundColor = '#9acdff';
	$(id+'_sub').style.left = "0";
}

function navHide(id) {
	$(id).style.backgroundColor = 'transparent';
	$(id+'_sub').style.left = "-1000em";
}

 	
function galleryPoint(id) {

	galleryClose();

	$('galleryContent'+id).style.display = 'block';
	
	galleryStep=id
}

function galleryTOC() {

	galleryClose();

	$('galleryTOC').style.display='block';
}

function next() {

	if (galleryStep<galleryTotal) {
	galleryStep++
	}
	else
	{
	galleryStep=0
	}

	galleryClose();

	$('galleryContent'+galleryStep).style.display='';

}

function previous() {

	if (galleryStep == 0) {
	galleryStep=galleryTotal
	}
	else
	{
	galleryStep--
	}

	galleryClose();

	$('galleryContent'+galleryStep).style.display='';

}

function galleryClose() {
	var gals = getElementsByClass('galleryContent',document,'DIV');
	for (var i=0; i < gals.length; i++)
	{
		 gals[i].style.display = 'none';
	}
	$('galleryTOC').style.display='none';
}