get = function (id)
{
	return document.getElementById(id) || false;
}
blockEvent = function (event)
{
	event = event || window.event;
	if(event.stopPropagation) event.stopPropagation();
	else event.cancelBubble = true;
	if(event.preventDefault) event.preventDefault();
	else event.returnValue = false;
}

window.activeId = false;

showId = function (id)
{
	if (window.activeId)
	{
		get('link-' + window.activeId).className = 'passive';
		get(window.activeId).className = 'hidden';
	}
	window.activeId = id;
	get('link-' + id).className = 'active';
	get(id).className = 'visible';
}

setClickFunc = function (id)
{
	return function (e)
	{
		blockEvent(e);
		showId(id);
	}
}

window.onload = function ()
{
	document.body.className = 'js';
	if (get('links'))
	{
		var links = get('links').getElementsByTagName('A');
		for (var i = 0; i < links.length; i++)
		{
			var id = links[i].href.split('#')[1];
			if (get(id))
			{
				links[i].id = 'link-' + id;
				get('link-' + id).className = 'passive';
				get(id).className = 'hidden';
				links[i].onclick = setClickFunc(id);
			}
		}
		if (document.location.hash && get(document.location.hash.replace('#', '')))
		{
			showId(document.location.hash.replace('#', ''));
		}
		else
		{
			showId(links[0].href.split('#')[1]);
		}
	}
}