/*************************************************************************
*
* @description : Script for home header.
* 				 Opens the Brightcove video into an overlay
* 				 Overlay plugin used in the script is from flowplay, 
* 			     all documentation can be found here:
* 				 http://flowplayer.org/tools/demos/overlay/styling.html
*
* @author 		: Yannik Méthot
* @date			: November 2011
* @version		: V 1.0
* @revisions	:
* 
*************************************************************************/

var INTRALINKS = {};

$(document).ready(function(){
	
	var $overlay = $(".homevideo").prependTo("body").overlay({
		top: "center",

		left: "center",
		expose: { 
				// you might also consider a "transparent" color for the mask 
				color: '#002f52', 
				// load mask a little faster 
				loadSpeed: 200, 
				// highly transparent 
				opacity: 0.77 
			},
			closeOnClick: true, 
			api:true
	});	
	//var overlayAPI = $overlay.data('overlay');
	
	
	/* Function called from the flash. We have a
	* fallback URL if the overlay is not defined
	*/
	INTRALINKS.openVideo = function( fallback ){
		if($overlay){
			$overlay.load();	
		}else{
			window.location = fallback;	
		}
	}
	
	/* Function called from the flash. 
	* To track a page view
	*/
	INTRALINKS.trackFlashPageView = function( page ){
		pageTracker._trackPageview(page);
	}	
	
	/* Function called from the close button. 
	* Close the overlay
	*/
	$('.overlay-close').click(function(){
		$overlay.close();							   
	});
});

