$(document).ready(function(){
	// get body id
	var _BID = bodyid.replace('m','').split('-');
	
	// get all UL that have a trigger A before and wrap them in hider DIV
	$('ul[@id="navigation"] a + ul').wrap('<div class="hider"></div>')
			
	// get all hider DIVs
	.find('..').hide()
	
	// add class of closed to parent LI
	.find('..').addClass('closed')
	
	// add onclick functionality to necessary As
	.find('a:eq(0)').click( function(e)
	{
		// close all subs
		$('../../li/div//div:visible', this).hide()
		.find('..').removeClass('opened').addClass('closed');
		
		// close all at same depth
		$('../../li/div:visible', this).slideUp(300)
		.find('..').removeClass('opened').addClass('closed');
		
		// open selected
		$('../div:hidden:eq(0)', this).slideDown(500)
		.find('..') .removeClass('closed').addClass('opened');
		
		e.stopPropagation();
		e.preventDefault();
		return false;
	});
	
	// open and highlight current page
	openMenu(_BID, $('#navigation'));
});
//openMenu([3,0],$('#nav'));
// recursive function to open unlimited depths
openMenu = function(_BID, _OBJ, _ITR)
{
	var _ITR = !_ITR ? 0 : _ITR;

	var _CUR = _OBJ.find('> li:eq('+ ( _BID[_ITR] - 1 ) +')')

	.removeClass('closed')
	.addClass('selected')

	if(_ITR < _BID.length - 1 && _BID[_ITR+1] > 0)
	{
		_CUR.addClass('opened')
		.find('div:hidden:eq(0)')
		.show()
		.find('> ul');

		openMenu(_BID, _CUR, ++_ITR);
	}
}

// fix for mac ie
Array.prototype.push = function(v)
{
    this[this.length] = v;
    return this.length;
}