function diggwb(obj) {
  if (!$) setTimeout(function() { diggwb(obj); }, 200); 
  $('#digg-widget-container ul').html('');
  var tpl = function() {
    if (this.thumbnail == undefined) {
      return [
              'li', {}, [
                         'a', { 'href': this.href+'?OTC-widget', 'class': 'digg-count', 'target': '_blank' }, this.diggs+' <span>diggs</span>',
                         'h3', {}, [
                                    'a', { 'href': this.href+'?OTC-widget', 'target': '_blank' }, this.title
                                   ],
                         'p', {}, this.description
                        ]
             ];
    } else {
      return [
              'li', {}, [
                         'a', { 'href': this.href+'?OTC-widget', 'class': 'digg-count', 'target': '_blank' }, this.diggs+' <span>diggs</span>',
                         'h3', {}, [
                                    'a', { 'href': this.href+'?OTC-widget', 'target': '_blank'  }, [
                                           'img', {'src': this.thumbnail.src, 'alt': '', 'width': '30', 'height': '30', 'class': 'digg-thumbnail'}, '',
                                           'span', {}, this.title
                                          ]
                                   ],
                         'p', {}, this.description
                        ]
             ];
    }
  };
  if(!obj) {
    $('#digg-widget-container ul').html('We were unable to retrieve matching stories from Digg. Please refresh the page to try again.');
  }
  if(!obj.stories || obj.stories.length == 0) {
    $('#digg-widget-container ul').html('Currently, there are no recent stories of this type on Digg.');
  }
  if (obj.stories) {
    for (var i = 0 ; i < obj.stories.length ; i++) {
      if(obj.stories[i].diggs > 10000) {
        obj.stories[i].diggs = Math.floor(obj.stories[i].diggs/1000)+'K+';
      }
      $('#digg-widget-container ul').tplAppend(obj.stories[i], tpl);
    }                 
  }
}
