
// $Id$

/**
 * This function looks for swfobject class items and loads them
 * as swfobjects. 
 */
Drupal.behaviors.swfobjectInit = function (context) {
  $('.swfobject:not(.swfobjectInit-processed)', context).addClass('swfobjectInit-processed').each(function () {
    var config = Drupal.settings.swfobject_api['files'][$(this).attr('id')];
    swfobject.embedSWF(config.url, $(this).attr('id'), config.width, config.height, config.version, config.express_redirect, config.flashVars, config.params, config.attributes);
  });
};
;
$(function() {
  if ($(document.body).hasClass('collage')) {
    $().bind('collage:end', load_channel);
  } else {
    load_channel();
  }
  
  function load_channel() {
    var feed_url = 'http://gdata.youtube.com/feeds/api/users/lobsterapparel/uploads?callback=?';
    $.getJSON(feed_url, {
      alt: 'jsonc',
      v: 2
    }, function(rs) {
      if (rs == undefined || !rs.data.items) {
        return;
      }
      var video = rs.data.items[0];
      if (!video || !video.id) {
        return;
      }
      swfobject.embedSWF(
        'http://www.youtube.com/v/' + video.id, 
        'youtube-channel', 
        '260', 
        '217', 
        '8');
    });
  }
});;

