$(document).ready(function(){
    var sSel = 'a[href^="http://www.youtube.com/watch"]:not(.dont-embed)';
        sSel += ',a[href^="http://youtube.com/watch"]:not(.dont-embed)';
        sSel += ',a[href^="http://www.youtube.com/view_play_list"]:not(.dont-embed)';
        sSel += ',a[href^="http://youtube.com/view_play_list"]:not(.dont-embed)';
    $(sSel).each( function(){

        if($(this).hasClass('smaller-video')) {
          nWidth  = 400
          nHeight = 245
        } else if($(this).hasClass('trust-video')) {
          nWidth  = 354
          nHeight = 213
        } else if($(this).hasClass('news-story')) {
          nWidth  = 440
          nHeight = 270
        } else {
          nWidth  = 480
          nHeight = 295
        }
        $(this).flash(
          { width: nWidth, height: nHeight, wmode: 'transparent' },
          { version: 8 },
          function(htmlOptions) {

              // first check for playlist
              if($(this).attr('href').match('view_play_list')) {
                bPlaylist = true
                // aMatches = /p=(.+?)(&|$)/i.exec($(this).attr('href'))
                aMatches = /[\?|&]p=([^&]+)/i.exec($(this).attr('href'))
                href = aMatches[1]
              } else {
                bPlaylist = false
                // aMatches = /v=(.+?)(&|$)/i.exec($(this).attr('href'))
                aMatches = /[\?|&]v=([^&]+)/i.exec($(this).attr('href'))
                href = aMatches[1]
              }
              if(bPlaylist) {
                htmlOptions.src = "http://youtube.com/p/" + href;
              } else {
                htmlOptions.src = "http://youtube.com/v/" + href;
              }
              $(this).parent().css("text-align","center")
              $(this).css("display","block")
              $(this).css("text-align","center")
              $(this).before($.fn.flash.transform(htmlOptions));
          }
        );
    })
});