//setup the global vars
var playing = false;
var VideoID = "";
var gabiID = "";
var loadedVid = 0;
var ytplayer = [];

function startVid(DivId){
	VideoID = ytVids[DivId];
	var params = { allowScriptAccess: "always" };
	var atts = { id: DivId };
	swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&amp;playerapiid=ytplayer", "ytapiplayer_" + DivId, "400", "300", "8", null, null, params, atts);
}

function clicker(DivId){
	if (playing){
		ytplayer[DivId].pauseVideo();
		playing = false;
	}else{
		ytplayer[DivId].playVideo();
		playing = true;
		
	}
}

function onYouTubePlayerReady(playerId) {
	ytplayer[loadedVid] = document.getElementById(loadedVid);
	//eval("document.getElementById('ytapiplayer_0').onclick = 'clicker(loadedVid)'");
	ytplayer[loadedVid].cueVideoById(VideoID);
	
	loadedVid++;
	if (ytVids[loadedVid]){
		startVid(loadedVid);
	}
}

//start with the first video
if (ytVids[0]){
	startVid(0);
}
