﻿// Plugin created by Brock Nusser - http://mlamenu.blogspot.com/

$(function () {
	var collapse = new Boolean();
	//setup - all values in pixels
	var navWidth = 180;
	var ulIndent = 0;
	collapse = true;
	//end setup
	
	
	
	//Required Section
    var slideSpeed = 'normal'; // 'slow', 'normal', 'fast', or miliseconds 
	$('#nav a').each(function () {
        var thisHref = $(this).attr('href')
		if ((window.location.pathname.indexOf(thisHref) == 0) || (window.location.pathname.indexOf('/' + thisHref) == 0)) {
            $(this).addClass('Current');
        }
    });
    
	$('.Current').parent('li').children('ul').show();
    $('.Current').parents('ul').show();
    
    $('#nav a').click(function () {
        if ($(this).parent('li').children('ul').html() != null) {
			if(collapse){$(this).parent('li').parent('ul').children('li').children('ul').hide(slideSpeed);}
            if ($(this).parent('li').children('ul').css('display') == "block") {
                $(this).parent('li').children('ul').hide(slideSpeed);
            } else {
                $(this).parent('li').children('ul').show(slideSpeed);
            }
            return false;
        }
	
    });

    $('#nav li').click(function () {
        if ($(this).children('a').length == 0) {
            if ($(this).children('ul').html() != null) {
                $(this).parent('ul').children('li').children('ul').hide(slideSpeed);
                if ($(this).children('ul').css('display') == "block") {
                    $(this).children('ul').hide(slideSpeed);
                } else {
                    $(this).children('ul').show(slideSpeed);
                }
            }
        } 
    });
	//End Required Section
});
