
function ShowVideo(youtubeId) {
  var videoHtml = '<object width="600" height="364"><param name="movie" value="http://www.youtube.com/v/'+ youtubeId+ '&hl=en&fs=1&rel=0&border=1&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+ youtubeId+ '&hl=en&fs=1&rel=0&border=1&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="364"></embed></object>';

	document.getElementById('video').innerHTML = fixEmbeddedVideo(videoHtml);
	
  $.fancybox({
	  'padding' : 10,
		'transitionIn' : 'fade',
		'transitionOut' : 'fade',
		'speedIn' : 300,
  	'type' : 'inline',
		'href' : '#video',
  	'autoDimensions' : true,
  	'hideOnOverlayClick' : true,
  	'overlayOpacity' : 0.8,
  	'overlayColor' : '#000',
  	'showCloseButton' : true,
  	'onClosed' : function() {
  	   $('#video').html('');
  	}
  });
}

var fixEmbeddedVideo = function(embedCode) {
  if(embedCode && embedCode.toLowerCase().indexOf('classid') == -1) {
		var objPos = embedCode.toLowerCase().indexOf('object ') + 'object '.length;
		return embedCode.substr(0, objPos) + 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' + embedCode.substr(objPos);
	} else {
  	return embedCode;
	}
}

