(function() {
  $(function() {
    var changeColor, colors, currentColorIndex, email, emailDomain, emailUsername, hideProfile, items, naturalChanging, nextColorName, setBackgroundColorClass, showProfile, showingProfile, timedColorChange;
    naturalChanging = true;
    showingProfile = false;
    currentColorIndex = 0;
    colors = ["yellow", "orange", "red", "magenta", "purple", "blue", "cyan", "green"];
    items = ["twitter", "dribbble", "github", "profile", "flickr", "linkedin", "facebook"];
    nextColorName = function() {
      if (currentColorIndex === colors.length - 1) {
        currentColorIndex = 0;
      } else {
        currentColorIndex++;
      }
      return "background-" + colors[currentColorIndex];
    };
    setBackgroundColorClass = function(className) {
      var colorName, _i, _j, _len, _len2;
      for (_i = 0, _len = colors.length; _i < _len; _i++) {
        colorName = colors[_i];
        $("body").removeClass("background-" + colorName);
      }
      for (_j = 0, _len2 = items.length; _j < _len2; _j++) {
        colorName = items[_j];
        $("body").removeClass("background-" + colorName);
      }
      return $("body").addClass(className);
    };
    changeColor = function(colorClass, fast, natural) {
      if (fast == null) {
        fast = false;
      }
      if (natural == null) {
        natural = false;
      }
      if (natural && !naturalChanging) {
        return true;
      }
      $("body").removeClass("quick-transition slow-transition");
      if (fast) {
        $("body").addClass("quick-transition");
      } else {
        $("body").addClass("slow-transition");
      }
      return setBackgroundColorClass(colorClass);
    };
    setBackgroundColorClass(nextColorName());
    $(".container-inner").append('<div class="tooltip"></div>');
    $(".tooltip").hide();
    $(".container-inner").append('<a href="#" class="close">Close</a>');
    $(".close").click(function(event) {
      event.preventDefault();
      if (showingProfile) {
        return hideProfile();
      }
    });
    emailUsername = "jonas";
    emailDomain = "lekevicius.com";
    email = "mailto:" + emailUsername + "@" + emailDomain;
    $("a.email").attr("href", email);
    timedColorChange = function() {
      var t;
      t = window.setTimeout(timedColorChange, 3000);
      return changeColor(nextColorName(), false, true);
    };
    timedColorChange();
    $(".links a, h1").hover(function() {
      var linkClass, tooltip;
      if (!showingProfile) {
        naturalChanging = false;
        linkClass = $(this).parent().attr("class");
        tooltip = $(this).data("tooltip");
        $(".tooltip").html(tooltip).show().css({
          top: "" + ($(this).position().top + $(this).height() + 5) + "px",
          left: "" + ($(this).position().left + ($(this).width() / 2) - 150) + "px"
        }).removeClass("hidden");
        changeColor("background-" + linkClass, true);
        return $(this).addClass("hovered");
      }
    }, function() {
      if (!showingProfile) {
        naturalChanging = true;
        $(this).removeClass("hovered");
        $(".tooltip").html("").addClass("hidden");
        return changeColor(nextColorName(), true);
      }
    });
    showProfile = function() {
      showingProfile = true;
      naturalChanging = false;
      $("h1").addClass("profile");
      $(".tooltip").html("");
      $(".intro, .close").addClass("visible");
      return $(".links li a, .tooltip").addClass("hidden");
    };
    hideProfile = function() {
      showingProfile = false;
      $("h1").removeClass("profile hovered");
      $(".intro, .close").removeClass("visible");
      $(".links li a, .tooltip").removeClass("hidden");
      naturalChanging = true;
      return changeColor(nextColorName(), true);
    };
    return $("h1").click(function(event) {
      event.preventDefault();
      if (!showingProfile) {
        return showProfile();
      }
    });
  });
}).call(this);

