window.addEvent('domready', function() {
	if (Browser.Plugins.Flash.version < 9) return;
	var videoLink = $('corporate_video_link');
	var videoId = null;
	if (videoLink && (videoId = /v=([a-zA-Z0-9_-]+)$/.exec(videoLink.href)) && (videoId = videoId[1])) {
		videoLink.addEvent('click', function(e) {
			e.preventDefault();
			var videoSize = { width: 720, height : 435 };
			var videoPadding = { top : 16, right : 16, bottom : 40, left : 16 }
			var videoBorderSize = 30;
			var videoZIndex = 999;
			var closeVideo = function() {
				videoOverlay.dispose();
				videoPanel.dispose();
				videoContainer.dispose();
				delete videoPlayer;
			}
			var videoOverlay = new Element('div', {
				styles : {
					position : 'fixed',
					left : 0,
					top : 0,
					width : '100%',
					height : '100%',
					'background-color' : 'black',
					opacity : 0.7,
					'z-index' : videoZIndex + 0
				},
				events : {
					click : function() {
						closeVideo();
					}
				}
			}).inject(document.body, 'top');
			
			var panelSize = {
				width : videoSize.width + videoPadding.left + videoPadding.right,
				height : videoSize.height + videoPadding.top + videoPadding.bottom
			};
			var videoPanel = new Element('div', {
				styles : {
					position : 'fixed',
					left : '50%',
					top : '50%',
					width : videoSize.width + 'px',
					height : videoSize.height + 'px',
					'padding-top' : videoPadding.top + 'px',
					'padding-right' : videoPadding.right + 'px',
					'padding-bottom' : videoPadding.bottom + 'px',
					'padding-left' : videoPadding.left + 'px',
					'margin-left' : -Math.floor(panelSize.width / 2) + 'px',
					'margin-top' : -Math.floor(panelSize.height / 2) + 'px',
					'background-color' : 'white',
					'z-index' : videoZIndex + 1
				}
			}).inject(document.body, 'top');
			var closeButton = new Element('div', {
				text : 'Close \u00D7',
				styles : {
					'font-size' : '11px',
					position : 'absolute',
					bottom : '12px',
					right : '16px',
					cursor : 'pointer'
				},
				events : {
					click : function() {
						closeVideo();
					}
				}
			}).inject(videoPanel);
			var videoContainer = new Element('div', {
				styles : {
					width : videoSize.width + 'px',
					height : videoSize.height + 'px'
				}
			}).inject(videoPanel);
			var videoContainerCoordinates = videoContainer.getCoordinates();
			var videoPlayer = new Swiff('http://www.youtube.com/v/' + videoId + '?version=3&rel=0&showinfo=0&autoplay=1', {
				width : videoContainerCoordinates.width,
				height : videoContainerCoordinates.height,
				container : videoContainer,
				params: {
					wMode : 'opaque',
					allowFullScreen : 'true'
				}
			});
		});
	}
});
