
jQuery(document).ready(function($){

	$("#mainNav").superfish({
	hoverClass:    'sfHover',          // the class applied to hovered list items 
    pathClass:     'current_page_itema', // the class you have applied to list items that lead to the current page 
    pathLevels:    1,                  // the number of levels of submenus that remain open or are restored using pathClass 
    delay:         500,                // the delay in milliseconds that the mouse can remain outside a submenu without it closing 
    animation:     {opacity:'show'},   // an object equivalent to first parameter of jQuery’s .animate() method 
    speed:         'normal',           // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method 
    autoArrows:    false,               // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance 
    dropShadows:   true,               // completely disable drop shadows by setting this to false 
    disableHI:     false,              // set to true to disable hoverIntent detection 
    onInit:        function(){},       // callback function fires once Superfish is initialised – 'this' is the containing ul 
    onBeforeShow:  function(){},       // callback function fires just before reveal animation begins – 'this' is the ul about to open 
    onShow:        function(){},       // callback function fires once reveal animation completed – 'this' is the opened ul 
    onHide:        function(){}        // callback function fires after a sub-menu has closed – 'this' is the ul that just closed 
	});
});		

			

				
				jQuery(document).ready(function($){
	
					/**
					 * 1. show parent and child of current 
					 * 2. add the +/- signs to the links
					 * 3. remove the link function from the +/-
					 * 4. add the open and close effect
					 */
					
					// show first ul
					$('.sidebar ul .current_page_item > ul:first, .sidebar ul .current_page_ancestor > ul').show().parent('li').addClass('openMenu');
					
					// add +/-
					$('.sidebar ul li').each(function(){
						
						var thisLi = $(this),
							liUl = thisLi.find('ul');
						// if the li has an ul
						if(liUl.length > 0){
							thisLi.addClass('hasSubMenu');
							// if the menu is open else
							if(thisLi.hasClass('openMenu')){
							
								// add the -2 to the current page else add -1
								if(thisLi.hasClass('current_page_item')){
									thisLi
										.find('a:first')
										.prepend('<span class="mipl minus2" />');
								}else{
									thisLi
										.find('a:first')
										.prepend('<span class="mipl minus1" />');
								}
							}else{
								thisLi
									.find('a:first')
									.prepend('<span class="mipl plus1" />');
							}
						}
					});
					
					// remove the link on +/-
					$('.sidebar ul a .mipl').each(function(){
						var orgUrl = $(this).parent().attr('href');
						$(this).hover(function(){
							$(this).parent().attr('href', '#menu');
						}, function(){
							$(this).parent().attr('href', orgUrl);
						});
					});
					
					// the function
					$('.sidebar ul a .mipl').click(function(){
						
						var parent = $(this).parent().parent();
						
						// slideUp if is open
						if(parent.hasClass('openMenu')){
							parent
								.removeClass('openMenu')
								.find('ul:first')
								.slideUp();
								
							if($(this).hasClass('minus2'))
								$(this).removeClass('minus2').addClass('plus2');
							else
								$(this).removeClass('minus1').addClass('plus1');
						}else{
							
							parent.siblings().removeClass('openMenu').find('ul').slideUp( function(){
								
								$(this).parent().find('.mipl').each(function(){
									if($(this).hasClass('minus2') || $(this).hasClass('minus1')){
										if($(this).hasClass('minus2'))
											$(this).removeClass('minus2').addClass('plus2');
										else
											$(this).removeClass('minus1').addClass('plus1');
									}
								})
								
							});
							
							parent.addClass('openMenu').find('ul:first').slideDown();
							
							
							if($(this).hasClass('plus2'))
								$(this).removeClass('plus2').addClass('minus2');
							else
								$(this).removeClass('plus1').addClass('minus1');
						}
						return false;
						
					});

				});	// end jQuery
				
			jQuery(document).ready(function($){
				$(".page-template-page-sidebar-x2-php .ps_undermeny ul li:has(ul)").hover(function(){
					$(this).addClass("sfhover");
				}, function(){
					$(this).removeClass("sfhover");
				});
			});