var isAdPlaying = false;
var q = '';		//Setup the query string variable so that we can deep link into a video

getURLVars();

//When the page is loaded, create the instance of the video player
$(document).ready(function(){
	cvp_loadVideoPlayer('MicrositeRightRail', '288', '162', 'videoPlayer', true);
});

//Update the title and headline div's
function cvp_updateMetadata(vId, headlinEl, descEl) {
	var jsonText = TURNERPLAYER.getVideoEntry(vId);
	var videoObj = eval( '(' + jsonText + ')' );
	document.getElementById(headlinEl).innerHTML = videoObj.headline;
	document.getElementById(descEl).innerHTML = videoObj.description;
}

/*** CVP JS Callback Functions ***/
//video player is loaded and ready to play
function onPlayerReady() {
	if (q != '') {
		microPlay(q);
	} else {
		cvp_enqueueVideos();
	}
}

//video has started playing
function onVideoPlayerPlay(videoId) {
	cvp_updateMetadata(videoId, 'videoHeadline', 'videoDescription');
}

//preroll has started
function onAdStarted(response)  {
    isAdPlaying = true;
}

//preroll has ended
function onAdFinished(response) {
	isAdPlaying = false;
}

//
//preroll url when return false, don't play preroll
function onAdPrerollUrl(videoId, adUrl) 
{	//no preroll ads on wgc pages
		return false;	//returning false here achieves that

}