$(document).ready(function() {

  new SpotLight; // doesn't run in IE
  new Archive;
  
  $.fn.tipsta.defaults.anchor = "#flooring";
  $("#map_books").tipsta({ y: -15 });
  $("#map_camera").tipsta({ y: 15 });
  $("#map_macbook").tipsta({ x: -45, y: -15 });
  $("#map_iphone").tipsta({ y: 15 });

  if ($.browser.msie) {
    $("#query").attr("maxlength", 25);
  }
    
  function bindEvents() {
    $("span.comment").hover(
      function() { // mouse enter
        $(this).append($("<span><a href=''>&nbsp;comments</a></span>"));
      },
      function() { // mouse exit
        $(this).find("span:last").remove();
      }
    );
    
    
    $("pre.bash").hover(
      function() {
        $(this).animate(
          { width: '870px' },
          200,
          'easeOutQuad'
        );
      },
      function() {
       if (this.clientWidth > 700) {
          $(this).animate(
            { width: '100%' },
            200,
            'easeOutQuad'
          );
        }
      }
    );
    
    var q = $("#query");
    var hint = "search weblog";
    q.attr("value", hint);
    q.focus(function(e) {
      if (this.value == hint) {
        this.value = "";
        $(this).addClass("hint");
      }
    });
    q.blur(function(e) {
      if (this.value.length == 0) {
        $(this).removeClass("hint");
        $(this).attr("value", hint);
      }
    });
  }
  
  bindEvents();
  prettyPrint();
    
});
