$home = jQuery.noConflict();
var video_home;

$home(document).ready(function() 
{
	if($home('#video_home').length > 0){
		video_home = VideoJS.setup("video_home");
		video_home.play();

		setTimeout("showControls()", 1000);
		setTimeout("hideControls()", 2000);
		
		$home(".pop-out").click(function() { 
			video_home.pause();
			popOut();
		});
	}else if($home('#mpl').length > 0){
		video_home = document.getElementById('mpl');
		
		$home(".pop-out").click(function() { 
			video_home.sendEvent("STOP", "true");
			popOut();
		});
	}
	
});

function showControls() {
	$home('.vjs-controls li').show();
}
function hideControls() {
	if(video_home && video_home.hideController) video_home.hideController();
}

function popOut() {
	var width		= 600;
	var height		= 325;
	var left		= (screen.width/2)-(width/2);
	var top			= ((screen.height/2)-(height/2))-100;
	var videodoc	= $home(".pop-out").attr("videodoc");
	var opts		= "width="+width+",";
		opts		= opts+"height="+height+",";
		opts		= opts+"scrollbars=no,";
		opts		= opts+"toolbar=no,";
		opts		= opts+"location=no,";
		opts		= opts+"top="+top+",";
		opts		= opts+"left="+left;

	window.open(
		"/assets/video-popout", 
		"Video", 
		opts
		);
}
