

var yourDevKey = 'AI39si6Ws9wN5s8t7MlxgD08d3aj_C32L8yAKKkQ6LGER7Og6q3XOoc2_jvq55LcNqr8BOFDhRTC1osYIWjLJ-7jviT6P67d2g';
var np=0;

var glob_crtnewstate=-99;
var playv_viewer=0;
var fungames_TOC="";
var fungames_TOC2="";
var playv_timer=-1;
var playv_stimer=-1;
var playv_reloading=0;
var glob_gotstate1=0;
var glob_gotstate3=0;
var glob_playvtimercount=0;
var playv_trynum=0;
var glob_videostops=0;

var glob_init2=0;
var glob_init2_restarted=0;

var playv_startm=-1;
var playv_starts=-1;
var playv_starttimer=-1;

function bvideo_toggleBox(szDivID, iState) 
{
try {
if(document.layers)	   
{
document.layers[szDivID].visibility = iState ? "show" : "hide";
document.layers[szDivID].display = iState ? "block" : "none";
}
else if(document.getElementById)	  
{
var obj = document.getElementById(szDivID);
obj.style.visibility = iState ? "visible" : "hidden";
obj.style.display = iState ? "block" : "none";
}
else if(document.all)	
{
document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
document.all[szDivID].style.display = iState ? "block" : "none";
}
}
catch(e) {
}
}

function babyvideo_init(TOCU,TOCU2) {
var sw,sh,w,h,R;


playv_viewer=1;

R="";
sw=screen.width;
sh=screen.height;
w=sw-70;
h=sh-200;
np=0;
fungames_TOC=TOCU;
if (TOCU2!=null) {
fungames_TOC2=TOCU2;
}

var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
swfobject.embedSWF("http://gdata.youtube.com/apiplayer?key=" + yourDevKey + "&enablejsapi=1&playerapiid=ytplayer",
"ytapiplayer", w, h, "8", null, null, params, atts);

return R;
}

function babyvideo_init2(TOCU,w,h) {

glob_init2=1;
glob_init2_restarted=0;

playv_viewer=1;

R="";
np=0;

var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
swfobject.embedSWF("http://gdata.youtube.com/apiplayer?key=" + yourDevKey + "&enablejsapi=1&playerapiid=ytplayer",
"ytapiplayer", w, h, "8", null, null, params, atts);

return R;
}

function loadNewVideo(id, startSeconds) {
if (ytplayer) {
if (playv_startm==0) {
clearInterval(playv_starttimer);
playv_startm=-1;
}

if (startSeconds<1) {
startSeconds=1;
}

ytplayer.loadVideoById(id, startSeconds);

if (playv_viewer==1) {

if (startSeconds>0) {
playv_starts=startSeconds;
playv_startm=0;
playv_starttimer=setInterval("playv_checkstart()",250);
}
}
}
}

function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("myytplayer");

ytplayer.unMute();
if (glob_init2==1) {
ytplayer.setVolume(20);
} else {
ytplayer.setVolume(100);
}
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
ytplayer.addEventListener("onError", "onPlayerError");

NextVideo();
}

function updateHTML(elmId, value) {
document.getElementById(elmId).innerHTML = value;
}

function onytplayerStateChange(newState) {

glob_crtnewstate=newState;


if (playv_timer!=-1) {
if (newState==0) {
clearInterval(playv_timer);
playv_timer=-1;
}
else if (newState==1) {
glob_gotstate1=1;
clearInterval(playv_timer);
playv_timer=-1;
}
else if (newState==3) {
glob_gotstate3=1;
}
}

if (newState==5) {
doPlay();
}
else if (newState==0) {
if ((glob_init2==1)&&(glob_init2_restarted!=1)) {
if (ytplayer) {
var S1;
S1="<a href=\"http://www.edhelperbaby.com/edhelperbaby_fun_videos.htm\">"+
"<img border=0 src=\"http://www.edhelperbaby.com/clipart/videoprev0.jpg\"></a>";
ytplayer.style.visibility="hidden";
ytplayer.style.width="0px";
ytplayer.style.height="0px";
bvideo_toggleBox("ytapiplayer2",1);
updateHTML("ytapiplayer2",S1);

removeElement(ytplayer.parentNode,ytplayer);
}
}
else if (glob_gotstate1!=1) {
}
else if (np>0) {
if ((glob_init2!=1)&&(fungames_TOC2.length>0)) {
var H,xx;
H=fungames_TOC2+"&reload=1";
if (np<1) {
np=1;
}
for (xx=0;xx<np;xx++) {
H=H+"&done"+xx+"="+VID1[xx];
}
location.href=H;
} else {
NextVideo(1);
}
}
}
}

function onPlayerError(errorCode) {

NextVideo(1);
}

function doPlay() {
ytplayer.playVideo();
}

function NextVideo(WT) {
var L,s,F;

if (WT==1) {
ytplayer = document.getElementById("myytplayer");
if (ytplayer) {
ytplayer.stopVideo();
ytplayer.clearVideo();
}

ytplayer.unMute();
if (glob_init2==1) {
ytplayer.setVolume(20);
} else {
ytplayer.setVolume(100);
}
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
ytplayer.addEventListener("onError", "onPlayerError");
}

if (playv_stimer!=-1) {
clearInterval(playv_stimer);
playv_stimer=-1;
}
L=VID1.length;
if (L>np) {
F=VID1[np];
s=VID2[np];
if (VID3[np].length<1) {
glob_videostops=0;
} else {
glob_videostops=VID3[np];
}
np++;
loadNewVideo(F,s);

if (glob_videostops>0) {
playv_stimer=setInterval("playv_stimeron()",250);
}

glob_gotstate1=0;
glob_gotstate3=0;
glob_playvtimercount=0;
playv_timer=setInterval("playv_timeron()",500);
} else {
if (glob_init2==1) {
}
else if (fungames_TOC.length>4) {
location.href=fungames_TOC;
}
}
}

function playv_timeron() {
glob_playvtimercount++;
if (glob_playvtimercount>12) {
glob_init2_restarted=1;
playv_trynum++;
clearInterval(playv_timer);
playv_timer=-1;
np--;
NextVideo(1);
}
}

function playv_stimeron() {
var n;
n=ytplayer.getCurrentTime();
if (n>=1) {
if (n>=glob_videostops) {
clearInterval(playv_stimer);
ytplayer.stopVideo();
}
}
}

function playv_checkstart() {
var n;
if (playv_startm!=0) {
clearInterval(playv_starttimer);
playv_startm=-1;
} else {
n=ytplayer.getCurrentTime();
if (n==null) {
if ((glob_init2!=1)&&(fungames_TOC2.length>0)) {
var H,xx;
H=fungames_TOC2+"&reload=1";
if (np<1) {
np=1;
}
for (xx=0;xx<np-1;xx++) {
H=H+"&done"+xx+"="+VID1[xx];
}
location.href=H;
}
else if (fungames_TOC.length>4) {
location.href=fungames_TOC;
}
}
else if (n>=1) {
clearInterval(playv_starttimer);
playv_startm=-1;
if (n<playv_starts) {
ytplayer.seekTo(playv_starts,true);
}
}
}
}

function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}

