var tl;
function onLoad() {
  var eventSource = new BlogEventSource();
  var theme = Timeline.getDefaultTheme();
  // theme.event.label.width = 200; // px
  var date = "Fri Aug 6 2006 13:00:00 GMT+0100"
  var bandInfos = [
    Timeline.createBandInfo({
        eventSource:    eventSource,
        width:          "80%", 
        intervalUnit:   Timeline.DateTime.WEEK, 
        intervalPixels: 100,
        theme:          theme,
        date:           date
    }),
    Timeline.createBandInfo({
        eventSource:    eventSource,
        showEventText:  false,
        trackHeight:    0.8,
        trackGap:       0.2,
        width:          "10%", 
        intervalUnit:   Timeline.DateTime.MONTH, 
        intervalPixels: 200,
        date:           date
    }),
    Timeline.createBandInfo({
        eventSource:    eventSource,
        showEventText:  false,
        trackHeight:    0.8,
        trackGap:       0.1,
        width:          "10%",
        intervalUnit:   Timeline.DateTime.YEAR, 
        intervalPixels: 200,
        date:           date
    })
  ];
  bandInfos[1].syncWith = 0;
  bandInfos[1].highlight = true;
  bandInfos[2].syncWith = 0;
  bandInfos[2].highlight = true;
  tl = Timeline.create(document.getElementById("timeline"), bandInfos);
  // Timeline.loadJSON("wp_drnicwilliams.js", function(xml, url) { eventSource.loadJSON(xml, url); });
  Timeline.loadJSON(dataURL(), function(xml, url) { eventSource.loadJSON(xml, url); });
}

var resizeTimerID = null;
function onResize() {
    if (resizeTimerID == null) {
        resizeTimerID = window.setTimeout(function() {
            resizeTimerID = null;
            tl.layout();
        }, 500);
    }
}

function dataURL() {
  return "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?format=json&table=wp_posts&" +
  "post_status=publish&field=ID&field=post_title&field=post_date_gmt&field=post_modified_gmt&" +
  "field=guid&field=comment_count";
}

$('cant_see_timeline').hide();