var speed=5;
var crossobj = $('content');
var contentheight = 0;

// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 124;

var isAdPlaying = false;

function ResizeWindow(width,height) {
		var w = width - document.body.clientWidth;
		var h = height - document.body.clientHeight;
		window.resizeBy(w,h);
}
		
function OpenWindowMax( aURL, aWinName ) {
   var wOpen;
   var sOptions;

   sOptions = 'location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes';
   sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
   sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString();
   sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

   wOpen = window.open( '', aWinName, sOptions );
   wOpen.location = aURL;
   wOpen.focus();
   wOpen.moveTo( 0, 0 );
   wOpen.resizeTo( screen.availWidth, screen.availHeight );
   //return wOpen;
}

//video player is loaded and ready to play
function onPlayerReady() {
	cvp_enqueueVideos();
}

//video has started playing
function onVideoPlayerPlay(videoId) {
	cvp_updateHeadlineAndDescription(videoId, 'vHeadline', 'vDescription');
}

//just before a preroll starts, return false to cancel preroll
function onAdPrerollUrl(videoId, adUrl) {
	//return false;
}

//create list of videos with linked thumbnails and title
function buildVideoList() {
	var len = playlist.length;
	var container = $('content');
	container.innerHTML = '';
	var videoList = '';
	
	for(var i=0; i<=len-1; i++) {		
		videoList += '<div class="pgaScrollDiv">';
		videoList += '<a href="#" onclick="playVideo(\''+playlist[i].url+'\')"><img src="'+playlist[i].thumbnail+'" border="0"/></a>';
		videoList += '<h4><a href="#" onclick="playVideo(\''+playlist[i].url+'\')">'+playlist[i].title+'</a></h4>';
		videoList += '<p>'+playlist[i].description+'</p>';
		videoList += '</div><div class="pgaClear"></div>';
	}
	
	container.innerHTML = videoList;
	getcontent_height();
}

//play selected video
function playVideo(vId) {
	cvp_playVideo(vId);
}

function movedown() {
	if(parseInt(crossobj.style.top)>=(contentheight*(-1)+60)) {
		crossobj.style.top=parseInt(crossobj.style.top)-speed+"px";
	}
	movedownvar=setTimeout("movedown()",20);
}

function moveup() {
	if(parseInt(crossobj.style.top)<=0) {
		crossobj.style.top=parseInt(crossobj.style.top)+speed+"px";
	}
	moveupvar=setTimeout("moveup()",20);
}

function getcontent_height() {
	contentheight=crossobj.offsetHeight;
}
