CommentValidation = {
  init: function() {
    var forms = document.getElementsByTagName("form");

    for (var i = 0; i < forms.length; i++) {
      if (forms[i].className == "comment-form")
        forms[i].onsubmit = CommentValidation.is_valid;
    }
  },
  
  is_valid: function() {
    if (document.getElementById("comment_content").value == "") {
      alert("There's no point trying to submit a comment without any content. Add something and try again.");
      document.getElementById("comment_content").focus();
      return false;
    }
    if (document.getElementById("comment_name").value == "") {
      alert("You don't have to put in your real name, but something to set you apart from everyone else would be nice.");
      document.getElementById("comment_name").focus();
      return false;
    }
    if (document.getElementById("comment_email").value == "") {
      alert("Sorry, but we need an email for validation purposes. We won't spam it, or give it to anyone, but it's just a small step to weed out spam.");
      document.getElementById("comment_email").focus();
      return false;
    }
    
    return true;
  }
};

SideSizer = {
  init: function() {
    var sections = [];
    var divs = document.getElementById("secondary").getElementsByTagName("div");
    
    for (var i = 0; i < divs.length; i++) {
      if (divs[i].className == "side-section") {
        divs[i].style.height = "";
        sections.push(divs[i]);
      }
    }
    
    var sectionsSorted = 0;
    
    while (sectionsSorted < sections.length) {
      var maxHeight = 0;
      var currentTop = sections[sectionsSorted].offsetTop;
      
      for (var i = 0; i < sections.length; i++) {
        if (sections[i].offsetTop == currentTop && sections[i].offsetHeight > maxHeight)
          maxHeight = sections[i].offsetHeight;
      }
      
      maxHeight -= 18;

      for (var i = 0; i < sections.length; i++) {
        if (sections[i].offsetTop == currentTop) {
          sections[i].style.height = (maxHeight/14).toString() + "em";
          sectionsSorted++;
        }
      }
    }
  }
}

window.onload = function() {
  var login = document.getElementById("email");
  if (login) login.focus();
  
  CommentValidation.init();
  SideSizer.init();
}

window.onresize = function() {
  SideSizer.init();
}

_uacct = "UA-2475317-2";
if (window.urchinTracker) urchinTracker();