$(function() {
    $('a.video_link').bind('click', function() {
        //Read the value of the object/embed markup, transform it into standard HTML, insert it into the DOM.
        var videoMarkup = $('span.video_markup', this).text();
        videoMarkup = videoMarkup.replace ('&quot;', '"');
        videoMarkup = videoMarkup.replace ('&amp;', '&');
        videoMarkup = videoMarkup.replace('&lt;', '<');
        videoMarkup = videoMarkup.replace('&gt;', '>');

        var playerListContext = $(this).parent().parent();
        
        $('div.video_container', playerListContext).html(videoMarkup);
        
        $('div.video_wrapper', playerListContext).show();

        //This is a hack to force the page to reflow in IE.
        $('div.player_listing').css('margin', '0px');
        $('div.player_listing').css('margin', '0px 0px 25px 0px');
        
        /*Center the video.  This method is a little strange, but it takes into account that the browser 
          may be using the the object tag (Opera)the embed tag (IE), or both (FireFox). */        
        var flashObjectWidth = $('object, embed', playerListContext).width();                
        $('div.video_container', playerListContext).css('padding-left', ((500 - flashObjectWidth) / 2) + 'px');

        return false;
    });
});