function link_popups()
{
	$('footnotes').style.display = 'none';
	links = $('agenda').getElementsByTagName('a');

	for(i=0; i < links.length; i++)
	{
		links[i].onclick = function() { show_details(this.hash); return false; }
	}

	// add our show/hide div
	var popup = document.createElement('DIV');
	var pop_top = document.createElement('DIV');
	var pop_body = document.createElement('DIV');
	var pop_bottom = document.createElement('DIV');
	popup.id = 'agenda_pop';
	pop_top.id = 'agenda_pop_top';
	pop_body.id = 'agenda_pop_body';
	pop_bottom.id = 'agenda_pop_bottom';
	popup.onclick = function() { hide_details(this); }
	popup.appendChild(pop_top);
	popup.appendChild(pop_body);
	popup.appendChild(pop_bottom);
	popup.style.display = 'none';
	center_object_to_window(popup);
	document.body.appendChild(popup);
}

Event.observe(window,'load',link_popups,false);

function show_details(hash)
{
	tgt = $(hash.replace(/#/,''));

	pop = $('agenda_pop');
	pop_content = $('agenda_pop_body');
	pop_content.innerHTML = tgt.innerHTML + '<p class="close">[x] close</p>';
	pop.style.visibility = 'hidden';
	pop.style.display = 'block';
	center_object_to_window(pop);
	pop.style.visibility = 'visible';
}

function hide_details(obj)
{
	obj.style.display = 'none';
}

function center_object_to_window(obj)
{
	var scroll = get_page_scroll();
	var win = get_window_size();
    obj.style.top = Math.round((win.height/2) - (obj.offsetHeight/2) + scroll.yScroll) + 'px';
    obj.style.left = Math.round((win.width/2) - (obj.offsetWidth/2)) + 'px';
}

// get the page scroll position
function get_page_scroll()
{
	var x, y;
	if(window.pageYOffset && window.pageYOffset)
	{
		// Safari & FireFox
		x = window.pageXOffset;
		y = window.pageYOffset;
	}
	else if(window.scrollY && window.scrollX)
	{
		// Safari & FireFox
		x = window.scrollX;
		y = window.scrollY;
	}
	else
	{
		// FireFox, IE6 & IE7
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	
	return {xScroll: x, yScroll: y};
}

// get the navigator window height and width
function get_window_size()
{
	var x, y;
	if(window.innerHeight && window.innerWidth)
	{
		// most newer browsers
		x = window.innerWidth;
		y = window.innerHeight;
	}
	else if(document.documentElement.clientHeight && document.documentElement.clientWidth)
	{
		// most browsers, but most importantly to get the window size in IE6 Strict
		// most other browsers will return document height which can be smaller or larger than the window
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else
	{
		// IE 4, 5 & 6 Quirks
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	
	return {width: x, height: y};
}