/**
 *	Menu 'Accordion'
 *	Show/hide menu areas absed on current page and make them slide all nice like
 *
 *
 *	@copyright: Work Communications :: http://www.workcomms.com/
 *
 *	@written: 27/08/2008
 *	@edited: 22/10/2008
 *
 *	Contents
 *
 *	onload
 *	activateBox
 *
 */
 
 /* On load */
 $(document).ready(function(){

 	$('#menu').accordion({
 	 	active: false, 
    	header: '.head', 
    	navigation: true, 
    	event: 'click', 
   	 	fillSpace: false  
   });
	
	/* Activate 'box' */
	activateBox();
 });
 
 function activateBox(){
 		/* Get URL page name e.g. page.html */
	 	var url = window.location.href;
		var urlElements = url.split("/");
	 	var page = urlElements[(urlElements.length-1)];
		
		/* Highlight activate side panel boxes */
	 	$('.box p.more a').each(
			function(){
				if($(this).attr('href') == page){
					$(this).parent().parent().addClass('selected');
				}
			}
		);
		
		/* No do the same for active submneu items */
		$('#menu li ul li a').each(
			function(){
				if($(this).attr('href') == page){
					$(this).addClass('current');
				}
			}
		);
 }