﻿jQuery(function ($j) {
    $j('.teaser-link, #interview-link').click(function (e) {
			e.preventDefault();

			var wHeight = $j(window).height(),
				wWidth = $j(window).width(),
				ratio = 1280/720,
				videoHeight = Math.floor(wHeight * 0.9),
				videoWidth = Math.ceil(videoHeight * ratio);
				
			if (videoWidth > wWidth * 0.9) {
				videoWidth = Math.floor(wWidth * 0.9);
				videoHeight = Math.ceil(videoWidth / ratio);
			}

			var elem = this.id != 'interview-link' ? $j('#video-short') : $j('#video-interview');
			elem
				.attr('height', videoHeight)
				.attr('width', videoWidth)
				.find('embed')
					.attr('height', videoHeight)
					.attr('width', videoWidth);

			$j.fn.colorbox({
				inline: true,
				href: '#' + elem.attr('id'),
				onLoad: function () { videoRunning = true; },
				onClosed: function () { videoRunning = false; }
			});
			
			return false;
		});
});