(function($) {

/**
 * Chainable method for converting elements into rich media.
 *
 * @param options
 
 $('yourdiv').media({ 
	width:     360, 
	height:    400, 
	bgColor:	'#1B1A18',
	src:       	'/swf/box_home_v3.swf',
	flashvars: 	{'filetocall':'/corexml/home_box.php'},
	caption:   false
});
*/
$.fn.media = function(options) {
	var opt = $.extend({
		expInstall	: 'http://www.rtl.it/swf/support/expressInstall.swf',
		src			: '',
		width		: 300,
		height		: 300,
		flashvars 	: {	},
		params		: {
			menu: "false"
		},
		attributes 	: {
			id: "myDynamicContent",
			name: "myDynamicContent",
			bgcolor		: '#1B1A18'
		},
		caption	: false
	}, options);
		
	return this.each(function() {
		var $this 			= $(this);
		var $d				= $('<div></div>').attr({id:($($this).attr('id')+'_div')}).appendTo($(this));
		var $o				= $.extend(
								{
									attributes : { 
										id : ($($this).attr('id')+'_swf'),
										name : ($($this).attr('id')+'_swf'),
										bgcolor : opt.bgColor
									},
									params		: {
										bgcolor : opt.bgColor
									}
								},
								opt);
		
		swfobject.embedSWF($o.src, $($d).attr('id'), $o.width, $o.height, "9.0.0",$o.expInstall, $o.flashvars, $o.params, $o.attributes);
	});
};

})(jQuery);
