﻿var BCErrorTimeout;

$(window).load(function() {
    $('#VidPop').bind('click', PopVideo);
    $('#VideoContainer a.close').bind('click', CloseVideo);
    brightcove.createExperiences();
    //setTimeout(PopVideo,1000);

});

function PopVideo() {
	BCErrorTimeout = setTimeout(showBCError,6000);
	$('#VideoContainer').fadeIn('fast');
}

function CloseVideo() {
	$('#VideoContainer').fadeOut('fast');
}

function showBCError() {
	$('#VideoContainer #Brightcove_Error').fadeIn();
}

var onTemplateLoaded = function(experienceID) {
	clearTimeout(BCErrorTimeout);
	bcExp			= brightcove.getExperience(experienceID);
	modPlayer	= bcExp.getModule(APIModules.VIDEO_PLAYER);
	if (experienceID=='Home_Experience') {
		modPlayer.addEventListener(BCMediaEvent.COMPLETE,CloseVideo);
	}
}
