var videoPreviewFotos=new Array(), index=0, youtubeId, ctime;


function showPopupWithHtml(videoKey, w, h){
    x = screen.availWidth/2-w/2;
    y = screen.availHeight/2-h/2;
    var popupWindow = window.open(
    		'http://images.vesseltracker.com/images/video_popup.html?youtube_id='+videoKey,'','width='+w+',height='+h+',left='+x+',top='+y+',screenX='+x+',screenY='+y);
}

function showVideoPreview(s){
	youtubeId=s;
	var url="http://i.ytimg.com/vi/"+youtubeId+"/";
	
	videoPreviewFotos[0]=url+"1.jpg";
	videoPreviewFotos[1]=url+"2.jpg";
	videoPreviewFotos[2]=url+"3.jpg";
	
	startPreview();
}

function startPreview() {
	document.images[youtubeId].src = videoPreviewFotos[index];
	if (index > 1) {
		index = 0;
	} else {
		index = index + 1;
	}
	ctime=setTimeout(startPreview, 1000);
}

function stopPreview(){
	clearTimeout(ctime);
}