window.onload = onloadContainer;

function onloadContainer() {
	initToggleCategories();
	
}
function initToggleCategories() {
	// Hide the container with all toggleable elements 
	document.getElementById('contentPool').style.display = 'none';
	// var as = document.getElementById('thebuttons').getElementsByTagName('a');
	var as = document.getElementsByTagName('a');
	toggle(as[0]);
	for (var i = 0; i < as.length; i++) {
		as[i].onclick = function() {;
			toggle(this);
			return false;
		}
	}
}

function toggle(l) {
	// Setting location to place content
	var content = document.getElementById('content');
	// Checking for existing content element and removing it if it exists
	var oldClone = document.getElementById('cloneDIV');
	if (oldClone != null){content.removeChild(oldClone);}
	// retrieve the catagory name
	var cat_name = l.href.match(/#(\w.+)/)[1];
	var clone = document.getElementById(cat_name).cloneNode(true);
	clone.setAttribute('id', 'cloneDIV');	
	document.getElementById('content').appendChild(clone);
	if (cat_name == 'location')
		{
		document.getElementById('map').style.display = 'block';
		load();
		}
	else
		{
		if (document.getElementById('map').style.display == 'block')
			{
			document.getElementById('map').style.display = 'none';		
			GUnload();
			}
		}
}

function directtoggle(h) {
	var content = document.getElementById('content');
	var oldClone = document.getElementById('cloneDIV');
	if (oldClone != null){content.removeChild(oldClone);}
	var clone = document.getElementById(h).cloneNode(true);
	clone.setAttribute('id', 'cloneDIV');
	document.getElementById('content').appendChild(clone);
}

