﻿var pnlPreview
function ShowYouTubePanel(inTagId, inMovieUrl)
{
    //Get the movie ID from the url
    var key = 'v';
    var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
    var qs = regex.exec(inMovieUrl);
    var movieId = qs[1];
    pnlPreview = new YAHOO.widget.Panel("previewPanel", {close:true, visible:true, context:[inTagId,'tr','bl']}); 
    pnlPreview.setHeader('Preview');
    pnlPreview.setBody('<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/' + movieId + '&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/' + movieId + '&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>');
    pnlPreview.hideEvent.subscribe(CloseYouTubePanel);
    pnlPreview.render('YouTubeContainer');
}

function CloseYouTubePanel()
{
    pnlPreview.setBody();
    pnlPreview.hide();
}
