$(document).ready(function(){
  if($('.item-content').length > 0){
    $('a.MoveMenu').each(function(){
      $(this).click(function(){
        return MenuSwitch($(this));
      });
    });
      
    setTimeout(function(){
      if(!bDontFold){
        CheckActiveMenu();
      }
    }, 500);
  }
  
  if($('.submenu').length > 0){
    $('.submenu').each(function(){
      if($('ul', $(this)).length < 1){
        $(this).css('height','0px');
        $(this).css('line-height','0px');
        $(this).css('font-size','0px');
        $(this).css('overflow','hidden');
      }
    });
  }
});

function MenuSwitch(ClickedElement){
  var ContentDivElement    = $('.item-content');
  var Url = ClickedElement.attr('href');
  
  if(ClickedElement.hasClass('MoveMenuSub')){
    window.location.href = Url;
  } else {
    ContentDivElement.slideUp('slow', function(){
      
      window.location = Url;
    });
  }
  return false;
}

function CheckActiveMenu(){
  var ContentDivElement    = $('.item-content');
  var ContentElementHeight = ContentDivElement[0].scrollHeight;  
  ContentDivElement.animate({'height': ContentElementHeight + 'px'}); 
  return true;  
}
