﻿/*JQuery Custom Accordian
*/

$(document).ready(function() {
  
 var path = location.pathname.substring(0); //Get path of current page
 var quickLaunchID = "#ctl00_PlaceHolderMain_QuickLaunchNavigationManager";


$(quickLaunchID + ' li:has(ul)').children('ul').hide();

  var path = location.pathname.substring(0); //Get path of current page
   var selectedLink =  $(quickLaunchID + ' a[href$="' + path + '"]'); //Get selected Link
   if ( path )
   {
    $(selectedLink).closest('ul').show();
     $(selectedLink).parent().children('ul').show();
    $(selectedLink).css('color','navy');
   }

	$(quickLaunchID + ' li:has(ul)').hoverIntent(function(){
		$(this).find('ul').slideDown('fast');
		},function(){selectedItem($(this),path,quickLaunchID)
		});
			
});

function selectedItem(thisUL,path,iD)
{
	var selectedLink = $(iD + ' a[href$="' + path + '"]').parent();//Get parent Li if root item		
	var selectedSubLink = $(iD + ' a[href$="' + path + '"]').closest('ul').parent(); //Get parent Li if sub item
	if($(selectedSubLink).get(0) != $(thisUL).get(0) && (selectedLink).get(0) != $(thisUL).get(0)) //If the hovered Li is not equal to Li of the current page or parent Li of the current page Slide Up
	{
		$(thisUL).find('ul').slideUp('fast'); 
	}
}

