(function($) {
    /* media options */
    var options = {
	    key:null,
	    playerFile:null		
	}
    
	$.fn.mediaPlayer = function(opts) {
		this.each(function() {
			
			if(opts) {
                $.extend(options, opts);
            }
       
			if(flowplayer && options.playerFile != null)
			{
			    /* clear container */
			    $(this).empty();
			    
			    if (options.key != null && options.key.length == 0)
			    {
			        options.key = null;
			    }
			    
			    /* Load flowplayer into container */
                flowplayer(this, options.playerFile, {
                    key:options.key,
                    
                    plugins: {
                        controls: {
                            /* control display */
                            autoHide: 'always',
                            borderRadius: '0',
                            backgroundColor: '#212121',
                            backgroundGradient: 'low',
                            opacity:0.7,
                            
                            sliderColor: '#000000',
                            sliderGradient: 'none',
                            
                            bufferColor: '#000000',
                            bufferGradient: 'none',
                            
                            progressColor: '#ffffff',
                            progressGradient: 'medium',
                            
                            buttonColor: '#a6a6a6',
                            buttonOverColor: '#919191',
                            timeColor: '#000000',
                            durationColor: '#525252',
                            
                            /* control visibility */
                            play:true,      
                            volume:true, 
                            mute:true,  
                            time:true,  
                            stop:false, 
                            playlist:false,  
                            fullscreen:false,
                            scrubber: true
                       }
                    },
                    
                    clip:{
                        autoPlay:false, 
                        autoBuffering:true /* shows the first frame of video when it loads */
                        }
                });
            }
		});
		return this;
	};
})(jQuery);

