

function youtubePlayVideo(video_id) {
	var w = 700; var h = 400;

	$$('#divYouTubeVidFrame').destroy();

	var divFrame = new Element('div', {
		id: 'divYouTubeVidFrame',
		styles: {
			'position': 'absolute',
			'display': 'block',
			'opacity': 0,
			'width': w,
			'height': h + 10,
			'opacity': 0,
			'border': 'none',
			'z-index': 100,
			'top': ( $(document.body).getHeight() / 2 ) - (h / 2) + $(document.body).getScroll().y,
			'left': ($(document.body).getWidth() / 2) - (w / 2)
		}
	}).inject($(document.body));

	var divLabel = new Element('div');
	divLabel.setStyles({
		'text-align': 'right',
		'font-weight': 'bold',
		'font-size': '1.5em'
	});
	divLabel.addClass('controls');
	divLabel.innerHTML = '<a href="javascript:youtubeVideoClose()" style="color:white;">Close X</a>';
	divLabel.inject(divFrame);
	youtubePositionVid();

	var divGuts = new Element('div');
	divGuts.id = 'divYouTubeVidContainer';
	divGuts.inject(divFrame);

	swfobject.embedSWF( 'http://www.youtube.com/v/'+video_id+'&hl=en_US&fs=1&hd=1', 'divYouTubeVidContainer', w, h, '8', '', {  }, { quality: 'high', allowFullScreen: 'true', allowscriptaccess: 'always' }, { id: 'myMov' } );

	setTimeout(function() {
		if(!window.youtubeOverlay) window.youtubeOverlay = new OverlayDiv({ color: '#000000', opacity: 0.5, close_on_click: false });
		window.youtubeOverlay.show()
		setTimeout(function() {
			$('divYouTubeVidFrame').setStyle('opacity', 1);
		}, 900);
	}, 300);


}

function youtubeVideoClose() {
	try {
		$$('#divYouTubeVidFrame').destroy();
		window.youtubeOverlay.hide();
	} catch(e) {};
}

function youtubePositionVid() {
	var divFrame = $('divYouTubeVidFrame');
	if(divFrame) {
		divFrame.setStyles({
			'top': ( $(document.body).getHeight() / 2 ) - (divFrame.getHeight() / 2) + $(document.body).getScroll().y,
			'left': ($(document.body).getWidth() / 2) - (divFrame.getWidth() / 2)
		});
	}
}





