/* For WC3 Dom Level 2 compliant browsers */

if (document.getElementsByClassName)
{
	var page_item_list = document.getElementsByClassName("page_item");
	
	for (var x = 0; x < page_item_list.length; x++)
	{
		page_item_list.item(x).addEventListener("click", li_redirect, true);
	}	
}
/* And for others (read: IE) */
else
{
	var li_list = document.getElementsByTagName('li');
	
	for (var x = 0; x < li_list.length; x++)
	{
		if (li_list.item(x).className.match("page_item") != null)
		{
			li_list.item(x).attachEvent("onclick", li_redirect);
			
			/* Add hover effect hack for non-current list items */
			if (li_list.item(x).className.match("current_page_item") == null)
			{
				li_list.item(x).attachEvent("onmouseover", li_mouseover);
				li_list.item(x).attachEvent("onmouseout", li_mouseout);
			}
		}
	}
}
/* IE li:hover hack */
function li_mouseover()
{
	/* Workaround in order for function not to operate on child elements */
	if (!event.srcElement.href) 
	{
		event.srcElement.className = 'page_item current_page_item';
	}
}

function li_mouseout()
{
	if (!event.toElement.href && !event.srcElement.parentElement.className.match('page_item'))
	{
		event.srcElement.className = 'page_item';
	}
}

function li_redirect() 
{

	if (!this.childNodes)
	{
		element = event.srcElement;
	}
	else
	{
		element = this;
	}

	 for (i = 0; i < element.childNodes.length; i++) {
			
		var str = new String(element.childNodes[i]);

		if (str.match('http\:\/\/') != null)
		{
			window.location.href = str;
		}
	 }
}


