// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

jQuery(document).ready(function() {
  jQuery('div[data-youtubevideo]').each(function(index, e) {
    var playerid= e.id;
    url = jQuery(e).data('youtubevideo') + '&enablejsapi=1&playerapiid=' + playerid;
    var params = { allowScriptAccess: "always" };
    var atts = { id: playerid};
    var width= e.getAttribute("width") || "500";
    var height = e.getAttribute("height") || "400";
    swfobject.embedSWF(url, e.id, width, height, "9.0.0", null, null, params, atts);

    try{
      function yt_callback(category,action,label,value){
        _gaq.push(['_trackEvent',category,action,label,value]);
      }
      var ytTracker = new YoutubeTracker(false, yt_callback, true);
    }catch(e){}
  });
});

