﻿var gVhxMoviePlayer;
var gVhxPreventUnloadLoop = 0;
var gVhxPreventResumeLoop = 0;
var gVhxPreventChangeLoop = 0;
var gVhxActiveVideoDescription;

function unloadVideoTab(){
	try{
		gVhxMoviePlayer.Unload();
	}catch(er){
		if(gVhxPreventUnloadLoop <= 50)
			setTimeout("unloadVideoTab()", 50);
		++gVhxPreventUnloadLoop;
	}
}

function resumeVideo(){
	try{
		gVhxMoviePlayer.PlayVideo();
	}catch(er){
		if(gVhxPreventResumeLoop <= 50)
			setTimeout("resumeVideo()", 500);
		++gVhxPreventResumeLoop;
	}
}

function changeVideo(vid){
    try{
		gVhxMoviePlayer.PlayVideo(vid);
	}catch(er){
		if(gVhxPreventChangeLoop <= 50)
			setTimeout("changeVideo('" + vid + "')", 50);
		++gVhxPreventChangeLoop;
	}
}

function initializeVideo(movieName) {
	if ($.browser.msie != -1)
	{
        gVhxMoviePlayer = gO(movieName);
    } else {
        gVhxMoviePlayer = window.document[movieName];
    }
}

var changeCallbackEmbeddedVideo = function()
{
	var video = arguments[1];
	var ad = arguments[0];
	if(video && video.Provider == "306")
	{
		hideFlashPrerollInfo();
	}
	refreshCompanionAdsWithLightningCast(ad);
};
