var SEARCH_DEFAULT = "Search the blog...";
$(document).ready(function() {
  // SEARCH TOGGLE
  $("#s")[0].blur();
  $("#s")[0].value = SEARCH_DEFAULT;
  $("#s").focus(function() {
    if ($(this)[0].value == SEARCH_DEFAULT) {
      $(this).val("");
    };
  }).blur(function() {
    if ($(this)[0].value == "") {
      $(this).val(SEARCH_DEFAULT);
    };
  });
  
  // set archives-panel hover event for IE 6
  if(typeof ie6 != "undefined" && ie6) {
    $("#archives-dropdown").hover(
      function() {
        $("#archives-panel")[0].style.display = "block";
      },
      function() {
        $("#archives-panel")[0].style.display = "none";
      }
    )
  }
  
  var cat_split = Math.ceil($(".cat-item").length / 2);
  var j = 0;
  var k = 0;
  var IE = /*@cc_on!@*/false;
  var offset_y = (IE) ? 36 : 32;
  $(".cat-item").each(function(i) {
    if ((i + 1) > cat_split) {
      $(this).addClass('abs-pos');
      if ($(this).parent().hasClass("children")) {
        //$(this).css("top", function() { return k * 15 + 12 });
        $(this).css("top", function() { return k * 18 + 14 });
        k++
      } else {
        //$(this).css("top", function() { return j * 15 + 21 });
        $(this).css("top", function() { return j * 18 + offset_y });
        $(this).css("left", "12em");
      }
      j++;
    }
    if (i == $(".cat-item").length - 1) {
      $("#sidebar li.categories").fadeIn("fast");
    }
  });
  // toggle comments on/off
  $("#comment-toggle a").toggle(
    function() {
      $("#comments-wrap")[0].style.display = "block";
    },
    function() {
      $("#comments-wrap")[0].style.display = "none";
    }
  )
});
