$.noConflict(); //with the edit of the line below, allows for multiple versions of jQuery on the same page

//$(document).ready(function() {
 jQuery(document).ready(function($){

      function addMega(){
        $(this).addClass("hovering");
            $(this).css('background-color','#f5a305');
        }

      function removeMega(){
       $(this).removeClass("hovering");
       $(this).removeClass("showmenu");
           $(this).css('background-color','#F58105');
        }

    var megaConfig = {
         interval: 200,  //milliseconds before dropdown displays
         sensitivity: 1,
         over: addMega,
         timeout: 200,  // milliseconds before menu disappears
         out: removeMega
    };
    
    
 

    $('li.topmenuitem').hoverIntent(megaConfig)//shows menu 
  
  //disables redirect in the top leve anchor tag only for JS users  
  $("#menu li:has(ul.submenu)").hover(function () {
     $(this).children("a").click(function () {
        return false;
     });
     
     

 });



  
// THESE BLOCKS OF CODE ARE TO PROVIDE MENU FUNCTIONALITY TO KEYBOARD USERS 
    
   $('li.topmenuitem > a').focus(function () { 
         $(this).parent('.topmenuitem').css('background-color', '#f5a305');  
         $(this).parent().addClass('showmenu'); //reference the parent which is the li, not the anchor  
    });

    //   might be able to use focusout out here instead of .lastitem 
    $('.lastitem').blur(function() {   
        $('#navcontainer > ul li').removeClass('showmenu');
        $('.topmenuitem').css('background-color','#F58105');
    });
    
        
    //THESE FUNCTION CALLS BELOW ARE NECESSARY TO CALL BECAUSE OF THEIR SPECIFIC POSITIONS SET IN THE CSS  
    $('li.counselor a').focus(function () {
       $(this).parent('.topmenuitem').css('background-color', '#f5a305');  
       $(this).parent().addClass('showcounselor');    
    });

    $('li.parents a').focus(function () {
       $(this).parent('.topmenuitem').css('background-color', '#f5a305');  
       $(this).parent().addClass('showparents');   
    });

    $('li.about a').focus(function () {
       $(this).parent('.topmenuitem').css('background-color', '#f5a305');  
       $(this).parent().addClass('showabout');    
     });
});  //closes main function all


