
//This is a very handy function written by Simon Willison:
//http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


//LOAD EVENTS
addLoadEvent(setAnchorTarget);
addLoadEvent(setCategoryMenu);


function setAnchorTarget()
	{
	var anchors = document.getElementsByTagName('a');
	for (i=0; i<anchors.length; i++)
		{
		if (anchors[i].className == 'external-link' || anchors[i].className == 'new-window')
			{
			anchors[i].target = '_blank';
			}
		}
	}


function setCategoryMenu()
	{
	if (document.getElementById)
		{
		var menu = 	document.getElementById('cat-menu');
		var current = document.getElementById('currentCat');
		if (menu)
			{
			menu.className = 'hideItems';
			//current.getElementsByTagName('a')[0].href = 'javascript:showHideMenu();';
			current.firstChild.href = 'javascript:showHideMenu();';
			}
		}
	}

function hideMenu() {
	document.write('<style type="text/css"> .hideonload { display:none; } </style>');	
}


function showHideMenu()
	{
	var menu = 	document.getElementById('cat-menu');
	if (menu.className == 'hideItems')
		{
		menu.className = 'showItems';	
		}
	else
		{
		menu.className = 'hideItems';
		}
	}