// JavaScript Document
var fVideo;
var vidCont;
var fun;


window.onload= function ()
{		
		//console.log("ASDFSDFSDF");
		vidCont = document.createElement("div");
		vidCont.style.width = "1280px";
		vidCont.style.height = "720px";
		vidCont.style.position = "absolute";
		vidCont.style.top = "0px";
		vidCont.style.left = "0px";
		vidCont.style.backgroundImage = "url('Assets/images/loader.gif')";
		vidCont.style.backgroundPosition = "center";
		vidCont.style.backgroundRepeat = "no-repeat";
		fVideo = document.createElement("video");
		fVideo.style.position = "absolute";
		fVideo.style.top = "0px";
		fVideo.style.left = "0px";
		fVideo.style.height = "720px";
		fVideo.style.width = "1280px";
		document.body.appendChild(vidCont);
		vidCont.appendChild(fVideo);
		vidCont.style.zIndex = -1;
		
		startIntro();
}

var feedbackVid = {
		
	playCorrectFeedback: function (func)
	{
		fun = func;
		//console.log("Correct............");
		fVideo.src = "Assets/videos/Feedback_Right.mp4";
		playVideo();
	},


	playWrongFeedback: function (func)
	{
		fun = func;
		//console.log("Wrong............");
		//vidCont.style.backgroundImage = 'none';
		//vidCont.style.zIndex = 200;
		fVideo.style.zIndex = 200;
		fVideo.src = "Assets/videos/Feedback_Wrong.mp4";
		playVideo();
	},
};

function playVideo()
{
	fVideo.play();	
	fVideo.addEventListener("ended", onVideoEnd);

}

function onVideoEnd()
{
	fVideo.style.zIndex = -1;
	fVideo.removeEventListener("ended", onVideoEnd);
	fVideo.src = "";
	try{
		fun();
	}catch(Err)
	{
		console.log("Error:  ", Err);
	}
}

