//------------------------------------------------------------------------------
// jquery.mim.js - JQuery Funktionen
//------------------------------------------------------------------------------
$(window).load( function() {
  if($("#mnav ul li").find("ul.munavRechts").length > 0)
  {
  var ulNormalWidth = $("#mnav ul li ul.munavRechts").width();
  var ulNormalTop = $("#mnav ul li ul.munavRechts").css('top');
  }
  
  $(this).find("ul.munavRechts").hide();  
  
  $('#mnav ul li:has("ul.munavRechts")').bind('mouseenter',function() {
    $(this).find("ul.munavRechts").css( { 'width':'0px', 'display':'block' } );
    $(this).addClass("hover");
    
    var ulOffsetTop = $(this).find("ul.munavRechts").offset().top;
    var ulHeight = $(this).find("ul.munavRechts").height();
    var scrollTop = $(window).scrollTop();
    var windowHeight = $(window).height();
    ulHoeheGesamt = ulOffsetTop + ulHeight;    
    posHeight = scrollTop + windowHeight;    
    if(ulHoeheGesamt > posHeight) {    
      ulNachOben = -1*(ulHoeheGesamt - posHeight);
      $(this).find("ul.munavRechts").css( { 'top': ulNachOben-2 } );
    }
          
    $(this).find("ul.munavRechts").animate( { 'width':ulNormalWidth } ,0 );
  });
  
  $('#mnav ul li:has("ul.munavRechts")').bind('mouseleave',function() {
      $(this).find("ul.munavRechts").animate( { 'width':'0' },0, function() {
        $(this).css( { 'display':'none' , 'top':ulNormalTop } );
      });      
      $(this).removeClass("hover");
  });    
//------------------------------------------------------------------------------
});

