﻿/*

JQuery VideoPlayer Plugin v1.0
=============================================================
Author: Chris Kleckner
Last Updated: 12/4/2010  11:47 AM
=============================================================
This simple plugin projects an embeded object into the designated 
container for playing YouTube Videos.

*/

(function($) {

    // Plugin: YouTube Video Player
    $.fn.VideoPlayer = function(file, img, source) {

        // If no source provided then get first link as file
        if (file == null || file == undefined || file.length == 0) {
            file = $('#VideoPlaylist li:first a').attr('href');
        }

        if (source == null || source == undefined || source.lenght == 0) {
            if (file.indexOf('http://www.youtube.com/') != -1) {
                source = 'YouTube';
            } else {
                source = 'Flash';
            }
        }

        if (file.length > 0) {

            var swf = 'OriginalVideoPlayer.swf'
            if (source == 'YouTube') {
                swf = 'OriginalYoutubeVideoPlayer.swf';
            };

            var PayerHTML = '<object type="application/x-shockwave-flash" id="player1" allowscriptaccess="always" allowfullscreen="true" data="/Video/' + swf + '" bgcolor="#000000" width="560" height="360">'
                + ' <param name="movie" value="/video/' + swf + '" />'
                + '<param name="FlashVars" value="mediaPath=' + file + '&showStroke=false" />'
                + '</object>';

            this.html(PayerHTML);

        }

    }; // End: VideoPlayer Plugin

})(jQuery);

