﻿function ShowVideo(videoLink) {    
    var youtubeVideoParam = GetQueryParam(videoLink, "v");
    
    if (null == youtubeVideoParam)
        return;

    var xScreenSize = 730;
    var yScreenSize = 450;

    
    var html = '<object height="' + yScreenSize + '" width="' + xScreenSize + '" class="FirstChild LastChild">' +
                   '<param value="http://www.youtube.com/v/' + youtubeVideoParam + '&rel=0&color1=0x333333&color2=0x002877&border=0&fs=1&autoplay=1&ap=%2526fmt%3D22" name="movie" class="FirstChild"/>' +
                   '<param value="true" name="allowFullScreen"/>' +
                   '<embed height="' + yScreenSize + '" width="' + xScreenSize + '" allowfullscreen="true" type="application/x-shockwave-flash" src="http://www.youtube.com/v/' + youtubeVideoParam + '&rel=0&color1=0x333333&color2=0x002877&border=0&fs=1&autoplay=1&ap=%2526fmt%3D22" class="LastChild"/>' +
               '</object>';
                   
    ShowTickBox(xScreenSize + 6, yScreenSize + 16, html);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
function ShowTickBox(width, height, html) {
    var btnID = 'showVideoButton';
    var alt = '#TB_inline?height=' + height + '&amp;width=' + width + '&amp;inlineId=tickBoxPanel';    
    $('#' + btnID).attr("alt", alt);
    $('#tickBoxPanel').html(html);
    $('#' + btnID).click();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
function GetQueryParam(searchString, parameter){
    var p = escape(unescape(parameter));
    var regex = new RegExp("[?&]" + p + "(?:=([^&]*))?","i");
    var match = regex.exec(searchString);
    var value = null;
    if( match != null ){
        value = match[1];
    }
    return value;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------