(function($){

$.fullscreen = function(opts) {
	
	defaults = {
		swf:	'/templates/nw/swf/FullScreenVideoPlayer.swf',
		time:	0,
		x:		217,
		y:		145,
		width:	644,
		height:	420,
		flashvars:''
	}
	
	
	
	opts = $.extend(defaults,opts);
	
	var mask = $('<div><div class="overlayMask"></div><iframe class="overlayMask" /></div>');
	var win = $('<div class="overlayWindow"><a class="overlayClose" href="#"><img src="/images/nw/buttons/close.png"></a><div id="fullscreen_flash"></div</div>');
	
	
	$(document.body).append(mask);
	$(document.body).append(win);
	
	mask.find('.overlayMask').css({
		width:$(window).width()+'px',
		height:$(document).height()+'px'
	});
	
	win.find('.overlayClose')
			.click(function(){
				win.hide('fast',function(){
					win.remove();
					mask.remove();
				});
				return false;
			})
			.hide();
	
	win.css({
			left:Math.round(($(window).width()-opts.width)/2) + 'px',
			top:Math.round($(window).scrollTop()+($(window).height()-opts.height)/2) + 'px',
			width:opts.width+'px',
			height:opts.height+'px'
		})
	.hide()
	.show('fast',function(){
			win.find('.overlayClose').show();
			var f = new HW.Flash();
			f.width = opts.width;
			f.height = opts.height;
			f.src = [8,opts.swf];
			f.flashvars = opts.flashvars;
			f.load('fullscreen_flash');
		});

	
}

})(jQuery)