/*
Require mootools.js
<script type="text/javascript" src="/amm/themes/shared/js/mootools.js"></script>
<script type="text/javascript" src="/amm/themes/shared/js/stick_nav.js"></script>

*** Menu structure ***

<div id="div_name_here">
	<ul>
		<li><a href="#">Link 1</a></li>
		<li><a href="#">Link 2</a></li>
		<li><a href="#">Link 3</a></li>
	</ul>
</div>

*** Call on load ***

<body onload="setCurrentLink('div_name_here')">


*/

var loc = location.href;

function setCurrentLink(div) {
	div = $(div);
	if (loc.match(/preview/) != null) {
		var activeLi = getCurrentLiPrev(div);
	} else var activeLi = getCurrentLi(div);
	
	if (activeLi != null) {
		//Do stuff to the current menu link. Change class identifier as necessary.
		activeLi.setAttribute('class', 'current');
	}
	
}

function getCurrentLi(div) {
	var cli;
	div.getElements('li').each(function(li, index) {
		a = li.getElement('a').href;
		if ((a.match(/\/[^/]+\/$/) != null) && loc.match(/\/[^/]+\/$/).pop() == a.match(/\/[^/]+\/$/).pop()) {
			cli = li;
			return
		}
	});
	return cli;
}

function getCurrentLiPrev(div) {
	var cli;
	id = loc.match(/content_id=\d*/).toString();
	div.getElements('li').each(function(li, index) {
		a = li.getElement('a').href.match(/content_id=\d*/);
		if ((a != null) && (id == a.toString())) {
			cli = li;
			return;
		}
	});
	if (cli != undefined) {
		return cli;
	} else {
		return div.getElement('li')
	}
}