$(document).ready(function(){
  var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
  if ($("#container").height() < $("#main").height()) {
    $("#container").height($("#main").height() + 120);
  }
  $(".profile .picture a img").fadeOut(600, function (){
    $(".profile .picture a img").css('opacity', 1);
    $(".profile .picture a img").fadeIn(3000, function (){
      if ($(".recent_buzz").length) {
        $(".recent_buzz").fadeIn(3000, function () {
          $(".see-all-your-buzz").fadeIn(1000, function (){
            $(".group-my-buzz").fadeIn(2000, function () {
              if (!isIE6) $(".user-block-buddy-list").slideDown(2000, function () {
                if ($("#container").height() < $("#main").height()) {
                  $("#container").height($("#main").height() + 120);
                }
                buddy_list = $(".user-block-buddy-list").offset();
                group = $(".group-my-buzz").offset();
                interests = $(".user-block-interests").offset();
                group_offset = parseInt(group.top+$(".group-my-buzz").height() - interests.top + 20);
                buddy_offset = parseInt(buddy_list.top+$(".user-block-buddy-list").height() - interests.top + 20);
                if (group_offset > buddy_offset) {
                  move_offset = group_offset;
                } else {
                  move_offset = buddy_offset;
                }
                move_offset_string = move_offset + "px 0 0 0";

                if ($("#locale").val() == 'en') {
                  if (navigator.appName == "Microsoft Internet Explorer") {
                    $(".user-block-interests").css('margin', move_offset_string);
                  } else {
                    $(".user-block-interests").animate({
                      "margin": move_offset_string
                    }, 1500);
                  }
                }
              });
            });
          });
        });
      } else {
        $(".group-my-buzz").fadeIn(2000, function () {
          $(".user-block-buddy-list").slideDown(2000, function () {
            if ($("#container").height() < $("#main").height()) {
              $("#container").height($("#main").height() + 120);
            }
            buddy_list = $(".user-block-buddy-list").offset();
            interests = $(".user-block-interests").offset();
            allowed_height = buddy_list.top + $(".user-block-buddy-list").height();
            if (allowed_height > interests.top) {
              move_offset = parseInt(buddy_list.top+$(".user-block-buddy-list").height() - interests.top + 10);
              move_offset_string = move_offset + "px 0 0 0";
              if (navigator.appName == "Microsoft Internet Explorer") {
                $(".user-block-interests").css('margin', move_offset_string);
              } else {
                $(".user-block-interests").animate({
                  "margin": move_offset_string
                }, 1500);
              }
            }
          });
        });
        if ($('.profile .node').css('top') == '-150px') {
          $(".user-block-interests").animate({
            "margin": "-150px 0 0 0"
          }, 1500);
        }
      }
    });
  });
})