
/**
 * jquery videoPlayer
 *
 * @author HAAN <haan@fynskemedier.dk>
 *
 * @see Class
 */
(function($) {
	$.fn.videoPlayer = function(options) {
		if(options.width * 1 <= 0) {
			delete options.width;
		}
		if(options.height * 1 <= 0) {
			delete options.height;
		}

		var opt = $.extend({
			url : null,
			autostart : true,
			width : 685,
			height : 422,
			classid : 'CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'
		}, options);

		/** Build player **/
		if($.browser.msie) { // IE
			var player = $('<object />')
				.attr('classid', opt.classid)
				.attr('width', opt.width)
				.attr('height', opt.height)
				.attr('url', opt.url)
				.css({ 
					width : opt.width + 'px',
					height : opt.height + 'px'
				})
				.append($('<param />')
					.attr('name', 'autostart')
					.attr('value', opt.autostart)
				)
				.append($('<param />')
					.attr('name', 'uimode')
					.attr('value', 'none')
				)
				.append($('<param />')
					.attr('name', 'stretchtofit')
					.attr('value', 'true')
				);
		} else { // Anything else
			var player = $('<embed />')
				.attr('name', 'videoplayer')
				.attr('type', 'application/x-mplayer2')
				.attr('classid', opt.classid)
				.attr('src', opt.url)
				.attr('width', opt.width)
				.attr('autostart', opt.autostart)
				.attr('height', opt.height);
		}

		$(this).empty();
		$(this).append(player);
	}
})(jQuery);

