/*******************************************************************
 ** Frontend HTML5 Video
 ******************************************************************/
(function ($) { // protect the protector

$.widget( "ui.frontendVideo", {

    _init: function () {
    var self = this;
        var video = self.element;

        // Do not initialize if iPhone
        var agent = navigator.userAgent.toLowerCase();
        if( !agent.match(/iPhone/i) ) {
            
            // override default options with caller supplied jwplayer params
            var playerOptions = $.extend( 
                {},
                self.options.default_jwplayer_params,
                self.options.jwplayer_params || {} 
            );
    
            jwplayer( self.element[0] ).setup( playerOptions );
        }
        
        return;
    }, // _init

    destroy: function () {
    var self = this;

        jwplayer( self.element[0] ).remove();

    $.widget.prototype.destroy.apply( this, arguments );
    } // destroy

}); // $.widget

$.extend( $.ui.frontendVideo, { 
    version: "1.0",
    defaults: {
        default_jwplayer_params : {
            flashplayer: '/javascript/ruby/jwplayer/player.swf',
            skin: '/images/ruby/flash/five/five.xml'
        }
    }
});

})(jQuery); // function($)



