/*
  Miscelleaneous functions used on kuul.dk
  Copyright 2010 by Jens Bjerrehuus <http://bjerrehuus.dk/blog/jens/>.
*/
var misc = {
  run : function()
  {
    /* Add class to <a> with inlined <img> to avoid <a> styling of images. */
    $("a:has(img)").addClass("img-in-a");
    
    /* Add class to all table cells that hold numbers; i.e. digits and punctuation only. */
    $("td:regex(^[\\d+/:,]+$)").addClass("number");

    /* Add a scrollbar to all scrollables on the page. */
    $('.scrollable').tinyscrollbar({scroll:true, wheel:10});
  },

  addEvent : function(obj, type, fn)
  {
    if (obj.addEventListener)
      obj.addEventListener(type, fn, false);
    else if (obj.attachEvent) {
      obj["e" + type + fn] = fn;
      obj[type + fn] = function() { obj["e" + type + fn]( window.event ); }
      obj.attachEvent("on" + type, obj[type + fn]);
    }
  }
};

misc.addEvent(window, 'load', misc.run);
