(function ($) {
    $.fn.verticalSlideMenu = function (options) {
        var settings = {
            useAccordion: true,
            transitionSpeed: 'fast'
        };
        var options = $.extend(settings, options);
        return this.each(function () {
            var $menuAnchor = $(this).children('li').has('ul').children('a');
			var $anchor = $(this).children('li.selected:not(:has(ul))').addClass('no-submenu');
			//$(this).children('li.selected').siblings().children('ul').hide();
			$(this).children('li').children('ul').hide();
			$(this).children('li.selected').children('ul').show();
            switch (settings.useAccordion) {
            case (true):
                $(this).addClass('use-accordion-true');
                $menuAnchor.click(function () {
                    $(this).blur();
                    if (!$(this).parent().hasClass('selected')) {
                        $(this).parent().parent().children('li.selected').children('ul').slideUp(settings.transitionSpeed);
                        $(this).parent().parent().children('li.selected').removeClass('selected');
                        $(this).parent().children('ul').slideDown(settings.transitionSpeed);
                        $(this).parent().addClass('selected');
                    }
					$anchor.removeClass('no-submenu');
                    return false
                });
                break;
            case (false):
                $menuAnchor.click(function () {
                    $(this).blur();
                    if (!$(this).parent().hasClass('selected')) {
                        $(this).parent().children('ul').slideDown(settings.transitionSpeed);
                        $(this).parent().addClass('selected');
                    } else {
                        $(this).parent().children('ul').slideUp(settings.transitionSpeed);
                        $(this).parent().removeClass('selected');
                    }
					$anchor.removeClass('no-submenu');
                    return false
                });
                break;
            }
        });
    };
})(jQuery);
$(document).ready(function () {
    //$('.vertical-slide-menu').children('li:first-child').css('background-color', '#b3b3b3');
    $('.vertical-slide-menu').verticalSlideMenu();
});
