(function($){

	$(document).ready(function(){

		var overlayDIV = $('#overlay');
		var videoDIV   = $('#calendar-video-highlight');

		this.showVideo = function(videoLink){

			// On prend la taille de bottom-div qui est à la taille réelle du contenu
			// alors que body ne l'est pas
			overlayDIV.height($(document.body).height());
			videoDIV.height(videoDIV.height());

			if (overlayDIV.css('display') == 'none') {

				$(overlayDIV).fadeTo(300, .6, function(){

					$(videoDIV).css({
						'position': 'absolute',
						'visibility': 'hidden',
						'display': 'block',
						'left': '50%',
						'top': '40%',
						'margin-left': - videoDIV.width() / 2,
						'margin-top': - videoDIV.height() / 2,
						'visibility': ''
					});

					$(videoDIV).fadeIn(500, function(){

						$('#calendar-video-content').html('<object width="425" height="344" type="application/x-shockwave-flash" data="' + videoLink + '"><param name="movie" value="' + videoLink + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent" /><embed src="' + videoLink + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="425" height="344"></embed></object>');

						var closeBtn = $('#calendar-video-close-btn');

						closeBtn.hover(
							function(){ $(this).fadeTo(300, 0.5) }, 
							function(){ $(this).fadeTo(300, 1.0) }
						);

						closeBtn.click(function(){
							$(overlayDIV).fadeOut(300);
							$(videoDIV).fadeOut(300);
						});
					});
				});
			}

			else {
				$(videoDIV).fadeOut(500, function(){
					$(videoDIV).fadeIn(500);
				});
			}
		};
		
		this.hideVideo = function(){
			$(videoDIV).fadeOut(200, function(){
				$(videoDIV).fadeOut(200);
			});
		};
		
	});
	
})(jQuery);

