//this file stillr equires swfobject to be included to work
(function($) {
	
	$.rdPlayer = function(el, flashvars, params, options) {
      
		//we'll avoid scope issues, by using 'self' instead of 'this'
		// to reference this class from internal events and functions.
		var self = this;
	    
		// references to jQuery and DOM versions of element
		self.$el = $(el);
		self.el = el; 
	
		// Add a reverse reference to the DOM object
		self.$el.data("rdPlayer", self);
		  
		self.init = function() {
			self.flashvars = $.extend({},$.rdPlayer.flashvars, flashvars);
			self.params = $.extend({},$.rdPlayer.params, params);
			self.options = $.extend({},$.rdPlayer.options, options);
			self.attributes = {
					id : self.$el.attr('id')+"-player",
					name : self.$el.attr('id')+"-player"
			}
			swfobject.embedSWF("media/player-licensed.swf", self.$el.attr('id'), self.options.width, self.options.height, "9.0.0","expressInstall.swf", self.flashvars, self.params, self.attributes);
		};
		
		self.init();
	};
	
	$.rdPlayer.flashvars = {
		file : "",
		image : "images/screen.jpg",
		icons : "false",
		controlbar : "over",
		autostart : "false",
		stretching : "fill",
		aboutlink : "http://www.ResponsiveData.com/",
		abouttext : "Responsive Data"
	};
	
	$.rdPlayer.params = {
		allowfullscreen : "true",
		allowscriptaccess : "true",
		wmode : "opaque"
	};
	
	$.rdPlayer.options = {
		width: 314,
		height: 250
	}
	
	$.fn.rdPlayer = function(flashvars, params, options) {
		return this.each(function(i){		
			new $.rdPlayer(this, flashvars, params, options);
		});			
	};
	
})(jQuery);
