// Inline eXpandable Lists
//
// Please set the following variables to initiate.

// DIRECTIONS: step 1 --> Build your navigation using an unordered list (<ul> <li></li> </ul>). 
// All sub-lists will become drop-drop lists. To make sure this works correctly, be sure to 
// nest your lists correctly. (Sub list <ul>'s must go INSIDE the <li> tag!) For correct 
// list html visit http://www.w3schools.com/Html/html_lists.asp and notice the part about 
// nested lists.
//
// step 2 --> Make sure that all of your list items that are parents to a sub list are empty
// links (<a href="#"></a>). The functionality is applied to the empty links. If they are not
// there, users will not be able to expand/collapse the navigation.
//
// step 3 --> Link to the correct javascript files. There are two javascript files that are
// necessary to link to. They are "jq.js" and "jq-ixL.js". The first is the jQuery JS library
// the second is THIS FILE. Link the scripts using the <script> tag in the HEAD of your document.
// example: <script language="javascript" type="text/javascript" src="path/to/jq.js"></script>
//
// step 4 --> Configure ixL by customising the following variables. Each has a description:

// Enter a CSS selector for the lists that you want to be expandable. This should select an 
// unordered list tag (<ul>). (example: ul.expandList, ul#navigation).
var cssTarget="ul.ixL";

// Enter the CSS class name for closed list parent items. You can use this to make a menu 
// item that has sub items be styled differently. THIS GET APPLIED TO THE EMPTY LINK TAG!
var closedParent="closedParent";

// Enter the CSS class name for open list parent items. THIS GET APPLIED TO THE EMPTY LINK TAG!
var openParent="openParent";

// Enter the CSS class that is applied to the active menu item.
var currentClass="current";

// Slide effect on or off?
var effects="on";

// Should the lists begin open?
var startOpen="no";

// Should the nav open so that the linked to page is visible?
var openCurrent="yes";

//All done. Don't edit below this line.
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////

$(function() {	
	if (startOpen=="yes") {
		$(cssTarget).find('li ul').parent().children('a').addClass(openParent);
	} else {
		$(cssTarget).find('li ul').css('display','none');
		$(cssTarget).find('li ul').parent().children('a').addClass(closedParent);
	}
	$(cssTarget).find('li ul').parent().find('a:eq(0)').click(function(){ 
			$(this).parent().children('a').toggleClass(closedParent);
			$(this).parent().children('a').toggleClass(openParent);
		if (effects=="on") {
			$(this).nextAll('ul').slideToggle('fast');
		} else {
			$(this).nextAll('ul').toggle();
		}
	});
	if (openCurrent=='yes') {
		$('ul.ixL li a').each(function(index) {
			var currentLoc=window.location.href;
			if ($(this).attr('href')!='#') {
				if (currentLoc.indexOf($(this).attr('href'))>-1) {
					$(this).parents('ul').css('display','block');
					$(this).addClass(currentClass);
				}
			}
		});
	}
});