function flashCircles(){
  $('#1').fadeTo(500, 0, function(){
    $('#2').fadeTo(500, 0,function(){
      $('#1').fadeTo(500, 1,function(){
        $('#2').fadeTo(500, 1,function(){
          flashCircles();
        });
      });
    });
  });
}

function leftMenu(){
  $('#top_left_content li.menu-current > ul, #top_left_content li.menu-parent > ul').slideDown(500, function() {
    $(this).parent().addClass('current-expand');
  });
  $('#top_left_content li.menu-expand').mouseenter(function(evt) {
    var self = this;
    if ($(self).hasClass('current-expand')) return;
    $('#top_left_content li.menu-expand > ul').stop(true, true);
    $('#top_left_content li.menu-expand > ul').each(function() {
      if (self != this) {
        $(this).slideUp(500);
        $(this).parent().removeClass('current-expand');
      }
    });
    $('ul', self).slideDown(500, function() {
      $(this).parent().addClass('current-expand');
    });
  });
}

function fixHoverWidths(){
  $('#main_menu ul.menu-top').children("li").each(function() {
    if(!$(this).hasClass('menu-current')){
      $(this).addClass('menu-current');
      var width = $(this).width();
      $(this).css('width',width+1+'px');
      $(this).removeClass('menu-current');
    }
  });
  $('#footer_bg td').each(function(){
    $(this).width($(this).width());
    if($(this).children('a').length) {
      $(this).children('a:first').css('font-weight','bold');
      $(this).width($(this).width());
      $(this).children('a:first').attr('style', '');
    }
  })
}

function topMenuHover(){
  $('#main_menu ul > li').hover(function(){
    $('#main_menu ul > li.menu-parent').removeClass('menu-parent').addClass('menu-parent-nohover');
  }, function(){
    $('#main_menu ul > li.menu-parent-nohover').addClass('menu-parent').removeClass('menu-parent-nohover');
  });
}
      
$(window).load(function() {
  $("#background").fullBg();
});
      
$(document).ready(function(){
  leftMenu();
  flashCircles();
  fixHoverWidths();
  topMenuHover();
});
