var VerbMonster = {};
var Utils = {};
Utils.Path = " ";
var resId = 0, questionId = 0, startTime = 0, scoredMarks = 0, totalMarks = 5, label = "word", level = 1,
scoreFlag = false, nextButtonClick = 0,sellIndex = 0,sampleOptionArray = [];
$(document).ready(function () {
    $(".se-pre-con").fadeOut("slow");
    if ((navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i))&& !(window.location.href.includes('http')))
        Utils.mobileDeviceFlag = true;
    /* if (Utils.mobileDeviceFlag)
        Utils.Path = Android.getMediaPath("Verb Monster"); */
    setTimeout(function () { VerbMonster.Initilize(); }, 200);
});
VerbMonster.Initilize = function () {
	document.title = VerbMonster.hardcodedData.title;
    VerbMonster.setImages(); //function that set all the images 
	document.getElementById("homeDiv").style.visibility = "hidden";
	document.getElementById("verbDiv").style.visibility = "hidden";
    document.getElementById("gamePage").style.display = "none";
    document.getElementById("endPage").style.display = "none";
	document.getElementById("verbListPage").style.display = "none";
    VerbMonster.variableInitilization(); //function to declare and initilize all variable
    VerbMonster.createAcknowledgementDivs(); //function to create acknowledgement Div
}
VerbMonster.setImages = function() //set all images
{
	    document.body.style.backgroundImage = Utils.Path + "url('images/skin/coverPage.png')";
		document.getElementById("homeImg").src = Utils.Path + "images/skin/home.png";
		document.getElementById("logoImg").src = Utils.Path + "images/skin/logo.png";
		document.getElementById("playImg").src=Utils.Path+"images/skin/play.png";
		document.getElementById("nextImg").src = Utils.Path + "images/skin/next.png";
	    document.getElementById("goNextImg").src = Utils.Path + "images/skin/go.png";
		document.getElementById("soundImg").src = Utils.Path + "images/skin/sound.png";
	    document.getElementById("playAgain").src=Utils.Path+"images/skin/replay.png";
	    document.getElementById("creditImg").src=Utils.Path+"images/skin/credits.png";
		document.getElementById("skipImg").src = Utils.Path+"images/skin/skip.png";
		document.getElementById("verbDiv").style.backgroundImage=Utils.Path+"url('images/skin/titleblock.png')";
	    document.getElementById("outerVerbList").style.backgroundImage=Utils.Path+"url('images/skin/swimimgTank.png')";
		document.getElementById("verbListType").innerHTML = VerbMonster.hardcodedData.label;
}
VerbMonster.variableInitilization = function() // all variable initilize
  {
	  VerbMonster.total_no_of_verb = 0; //total number of verbs to show at verblist
	  VerbMonster.selectedVerb=0; //store selected verb from verblist
	  VerbMonster.rightAnsCnt=0; //number of right answer
	  VerbMonster.id = 0 ; //contain id of selected sell
	  VerbMonster.currentQues = 0;//Verb from verb Array
	  VerbMonster.pronounsIndex =0 ;//slected pronouns
	  VerbMonster.ans; //selected sell id
	  VerbMonster.wrongTimer; //wrong ans timer
	  VerbMonster.highlightedCell; //contains info of clicked sell
	  VerbMonster.ansData; //contain answers
	  VerbMonster.quesArray=[]; // contains ques
	  VerbMonster.idArray=[]; //contains id of selected sell
	  VerbMonster.optionsArray=[]; //contains options
	  VerbMonster.randomOptionArray = [];//randomly selcted 5 option 
	  VerbMonster.tensArray= ["Present","Past","Future"]; 
	  VerbMonster.verbArray = []; //total verb that are showing
	  VerbMonster.pronounsRandomArray = [];//includes three options
	  VerbMonster.jsonObj ={ };
	  VerbMonster.practicePageFlag = false;
      VerbMonster.flag = false; // learning pag
	  VerbMonster.clickedSell=false; // sell is clicked or not
	  VerbMonster.nextClicked=false; // next button is clicked or not
	  VerbMonster.homeFlag = false;
	  VerbMonster.sliderFlag = false;
 } 
VerbMonster.playGame = function()
{
    document.body.style.backgroundImage = Utils.Path + "url('images/skin/bg.png')";
    document.getElementById("coverPage").style.display="none";
    document.getElementById("homeDiv").style.visibility = "visible";
	document.getElementById("verbListPage").style.display = "block";
	VerbMonster.verbArray = populate(VerbMonster.data,VerbMonster.verbArray,20);
	VerbMonster.showVerb(); 
}
VerbMonster.showVerb = function()  //fuunction that shows the verb list to select 
  {
	document.getElementById("verbDiv").style.visibility = "hidden";
	for(var i=0;i< VerbMonster.verbArray.length;i++)
	{
		 var currentQues = VerbMonster.verbArray[i];
		 var verbListDiv = document.createElement("div");
		 verbListDiv.setAttribute("id","verbListDivId"+i);
		 verbListDiv.setAttribute("class"," verbDivClass nopadding col-sm-6 col-xs-6 col-md-6 col-lg-6");
		 verbListDiv.setAttribute("onclick", "VerbMonster.selectVerb(this.id)");
		 $(verbListDiv).data("verbIndex",currentQues);
		 document.getElementById("verbList").appendChild(verbListDiv);
		 //radio button
		 var radioButtonDiv = document.createElement("INPUT");
		 radioButtonDiv.setAttribute("id","radioButtonId"+i);
		 radioButtonDiv.setAttribute("class","nopadding radioButtonClass checkmark col-sm-4 col-xs-4 col-md-4 col-lg-4");
		 radioButtonDiv.setAttribute("type", "radio");
		 radioButtonDiv.setAttribute("name", "verbs");
		// radioButtonDiv.setAttribute("onclick", "VerbMonster.selectVerb(this.id)");
		 $(radioButtonDiv).data("verbIndex",currentQues);
		 document.getElementById("verbListDivId"+i).appendChild(radioButtonDiv);
		var verbDiv = document.createElement("div");
		verbDiv.setAttribute("id","verbDiv"+i);
		verbDiv.setAttribute("class","nopadding verbClass col-sm-6 col-lg-6 col-md-6 col-xs-6");
		$(verbDiv).text();
		document.getElementById("verbListDivId"+i).appendChild(verbDiv);
		$(verbDiv).text(VerbMonster.data[currentQues].langVerb);
    }
    $("#radioButtonId0").prop("checked", true);
	VerbMonster.selectedVerb=$("#radioButtonId0").data("verbIndex"); 
	VerbMonster.showText();
 }
  VerbMonster.selectVerb  = function(clicked_id) //function to select verb from list
    {
		var childArr = $("#" + clicked_id).children();
		console.log(childArr);
		var childID = childArr[0];
		$(childID).prop("checked", true);
		VerbMonster.selectedVerb = $("#" + clicked_id).data("verbIndex");
		console.log(VerbMonster.selectedVerb);
	  /*  VerbMonster.selectedVerb = $("#"+clicked_id).data("verbIndex");
	   console.log(VerbMonster.selectedVerb); */
	   document.getElementById("selectedVerbText").innerHTML=" ";
	   VerbMonster.showText();
	}
	VerbMonster.showText = function(){
		var i=0,textSpan;
		for(i=0;i<2;i++){
	     	textSpan = document.createElement("span");
	    	textSpan.setAttribute("id","spanTextId"+i);
	    	textSpan.setAttribute("class","nopadding textSpanClass");
			if(i==1)
				textSpan.innerHTML = VerbMonster.hardcodedData.verbConfirmText;
			else
				textSpan.innerHTML = VerbMonster.data[VerbMonster.selectedVerb].langVerb; 
				  $("#spanTextId0").addClass("animated zoomIn");
		
				document.getElementById("selectedVerbText").appendChild(textSpan);
		}

	}
  VerbMonster.showPracticePage = function() //function that show the practicePage
   {
	document.getElementById("verbDiv").style.visibility = "visible";
   	 VerbMonster.homeFlag = true;
	  VerbMonster.quesArray=[];
	  VerbMonster.optionsArray=[];
	  document.getElementById("soundButton").style.visibility="hidden";
	  document.getElementById("skipSlider").style.display = "block";
	  document.getElementById("verbListPage").style.display = "none";
	  document.getElementById("gamePage").style.display="block";
	  VerbMonster.quesArray.push(VerbMonster.data[VerbMonster.selectedVerb]);
	  document.getElementById("verbDiv").innerHTML = VerbMonster.data[VerbMonster.selectedVerb].langVerb; 
	  if(VerbMonster.practicePageFlag)
	  {
		  document.getElementById("nextButton").style.display = "block";
		   document.getElementById("skipSlider").style.display = "none";
		   document.getElementById("optionsDiv").style.display="block";
	     	 VerbMonster.flag=true;
	  }
	  else
	  {
		document.getElementById("nextButton").style.display = "none";
		document.getElementById("skipButton").style.display = "block";
		document.getElementById("optionsDiv").style.display="none";
	    VerbMonster.flag=false;
	  }
	   document.getElementById("optionsDiv").style.backgroundImage=Utils.Path+"url('images/skin/waterTenk.png')";
   	   document.getElementById("tenseChart").innerHTML="";	
	   document.getElementById("VerbHeading").innerHTML="";
	   if(!VerbMonster.sliderFlag)
	   document.getElementById("outerSliderDiv").innerHTML=" ";
	   if(!VerbMonster.sliderFlag)
	   VerbMonster.createSlider();
        VerbMonster.tenseDiv();
		VerbMonster.learningPage();
}
VerbMonster.tenseDiv = function() //function that set the learning chart
{
	VerbMonster.jsonObj = { };
	VerbMonster.optionsArray=[];
	VerbMonster.idArray = [];
    var queTense='',randomTensesArray = [],currentTense='',randNo=0,number=0,k=0,sellIndex=0;
	randNo=Math.floor(Math.random()*2); //male or female 0 =male and 1=female
  for(var i=0;i<3;i++)
  {
	 var tenseDiv = document.createElement("div");
	 tenseDiv.setAttribute("id","tenseDiv"+i);
	 tenseDiv.setAttribute("class","verbHeadingClass nopadding col-sm-4 col-lg-4 col-md-4 col-xs-4");
	 document.getElementById('VerbHeading').appendChild(tenseDiv);
	 $(tenseDiv).text(VerbMonster.tensDataArray_h[i]);
  }
	 for(var i=0;i<3;i++)
	{
		var currentTense = VerbMonster.data[VerbMonster.selectedVerb].firstPerson[i].tense;
		randomTensesArray = [];
		while(randomTensesArray.length < 3)
		{
		   number = Math.floor(Math.random()*3);
		   if(randomTensesArray.indexOf(number)== -1)
				randomTensesArray.push(number);
		}
	    var tenseDiv = document.createElement("div");
		tenseDiv.setAttribute("id","rowDiv"+i);
		tenseDiv.setAttribute("class"," nopadding col-sm-4 col-lg-4 col-md-4 col-xs-4");
		document.getElementById('tenseChart').appendChild(tenseDiv);
		for(var j=0;j<3;j++)
		{
			if(randNo == 0)
			{
			  if(VerbMonster.pronounsIndex == 0){
			     if(j==0)
			 		queTense=VerbMonster.quesArray[0].firstPerson[i].male;
			 	 else if(j==1)
				    queTense=VerbMonster.quesArray[0].firstPerson[i].male;
             	  else
				    queTense=VerbMonster.quesArray[0].firstPerson[i].male;
			  }
			  else if(VerbMonster.pronounsIndex == 1)
			  {
				if(j==0)
			 		queTense=VerbMonster.quesArray[0].secondPerson[i].male;
			 	 else if(j==1)
				    queTense=VerbMonster.quesArray[0].secondPerson[i].male;
             	 else
				    queTense=VerbMonster.quesArray[0].secondPerson[i].male;
			  }
			  else{
				if(j==0)
				   queTense=VerbMonster.quesArray[0].thirdPerson[i].male;
			    else if(j==1)
			      queTense=VerbMonster.quesArray[0].thirdPerson[i].male;
			    else
			      queTense=VerbMonster.quesArray[0].thirdPerson[i].male;
			  }
		    }
		   else
		   {
			if(VerbMonster.pronounsIndex == 0){
				if(j==0)
					queTense=VerbMonster.quesArray[0].firstPerson[i].female;
				 else if(j==1)
				   queTense=VerbMonster.quesArray[0].firstPerson[i].female;
				  else
				   queTense=VerbMonster.quesArray[0].firstPerson[i].female;
			 }
			 else if(VerbMonster.pronounsIndex == 1)
			 {
			   if(j==0)
					queTense=VerbMonster.quesArray[0].secondPerson[i].female;
				 else if(j==1)
				   queTense=VerbMonster.quesArray[0].secondPerson[i].female;
				 else
				   queTense=VerbMonster.quesArray[0].secondPerson[i].female;
			 }
			 else{
			   if(j==0)
				  queTense=VerbMonster.quesArray[0].thirdPerson[i].female;
			   else if(j==1)
				  queTense=VerbMonster.quesArray[0].thirdPerson[i].female;
			   else
				  queTense=VerbMonster.quesArray[0].thirdPerson[i].female;
			 }
			}
	 		var tenseDiv = document.createElement("div");
			tenseDiv.setAttribute("id","tenseTypeDiv"+i+""+j);
			tenseDiv.setAttribute("class","sentenceDiv style col-sm-12 col-lg-12 col-md-12 col-xs-12 col-sm-offset-0 col-lg-offset-0 col-md-offset-0 col-xs-offset-0");
			tenseDiv.setAttribute("onclick","VerbMonster.playTense(this.id)");
			tenseDiv.setAttribute("data","off");
			document.getElementById("rowDiv"+i).appendChild(tenseDiv);
			document.getElementById("tenseTypeDiv"+i+""+j).style.backgroundImage=Utils.Path+"url('images/skin/block.png')";

			var tenseDiv = document.createElement("div");
			tenseDiv.setAttribute("id","langDiv"+i+""+j+""+k);
			tenseDiv.setAttribute("sellIndex",sellIndex);
			sellIndex++;
			tenseDiv.setAttribute("class","divStyle nopadding col-sm-12 col-lg-12 col-md-12 col-xs-12");
			document.getElementById("tenseTypeDiv"+i+""+j).appendChild(tenseDiv);
			VerbMonster.idArray.push(tenseDiv.getAttribute("id"));
			 $(tenseDiv).text(queTense[randomTensesArray[j]]);

             if(VerbMonster.flag==false)
				{
					$(tenseDiv).text(queTense[randomTensesArray[j]]);
					$(tenseDiv).data("data",queTense[randomTensesArray[j]]);
					$(tenseDiv).data("clickedTense",currentTense);
					sampleOptionArray.push(queTense[randomTensesArray[j]]);
					VerbMonster.optionsArray.push(queTense[randomTensesArray[j]]);
				}
		}
			VerbMonster.jsonObj[currentTense] = sampleOptionArray;
			sampleOptionArray = [];
	}
}
VerbMonster.createSlider = function() //to create toggle switch
{
	VerbMonster.sliderFlag = true;
    var toggleDiv,selectorDiv,toggleSpan;
      for(var k=0;k<3;k++)
		{
			toggleDiv = document.createElement("div");
			toggleDiv.setAttribute("id","toggleDivId"+k);
			toggleDiv.setAttribute("class","nopadding toggleClass col-sm-4 col-xs-4 col-md-4 col-lg-4");
			toggleDiv.setAttribute("onclick","VerbMonster.change_pronouns(this.id)");
			toggleDiv.style.opacity = 0.3;
			toggleDiv.innerHTML = VerbMonster.pronounsArray[k];
			document.getElementById("outerSliderDiv").appendChild(toggleDiv);
        }
		selectorDiv = document.createElement("div");
		selectorDiv.setAttribute("id","selectorId");
		selectorDiv.setAttribute("class","selectorClass");
		document.getElementById("outerSliderDiv").appendChild(selectorDiv);
		selectorDiv.style.width = toggleDiv.clientWidth+"px";
		selectorDiv.style.backgroundColor = VerbMonster.colorArray[0];
		selectorDiv.innerHTML = document.getElementById("toggleDivId0").innerHTML;
		selectorDiv.style.left = 0;
		var currentPronoun = selectorDiv.innerHTML;
		VerbMonster.pronounsIndex = VerbMonster.pronounsArray.indexOf(currentPronoun);
}	
VerbMonster.change_pronouns = function(object_id)//changing pronouns
 {
	 var currentPronoun , i,selector;
	 currentPronoun = document.getElementById(object_id).innerHTML;
	 console.log(currentPronoun);
	 selector = document.getElementById("selectorId");
	 for(i=0;i<3;i++)
	 {
		 if(currentPronoun == VerbMonster.pronounsArray[i])
		 {
			selector.style.width = document.getElementById(object_id).clientWidth+"px";
			selector.style.backgroundColor = VerbMonster.colorArray[i];
			selector.innerHTML = document.getElementById(object_id).innerHTML;
			break;
		 }
	 }
		 if(i==0)
			 selector.style.left = 0;
		 else if(i==1)
			selector.style.left = document.getElementById(object_id).offsetWidth+"px";
		 
		 else
				selector.style.left = document.getElementById(object_id).clientWidth+document.getElementById(object_id).clientWidth+1+"px";

				VerbMonster.pronounsIndex = VerbMonster.pronounsArray.indexOf(currentPronoun);
				document.getElementById("tenseChart").innerHTML = " ";
				document.getElementById('VerbHeading').innerHTML=" ";
				VerbMonster.tenseDiv();
				VerbMonster.learningPage();
}
VerbMonster.playTense=function(object)//listen tense 
{
	VerbMonster.clickedSell=true;
	document.getElementById("playSound").pause();
	clearTimeout(VerbMonster.instructionTimer);
	$("#optionsDiv").css({'pointer-events':'auto'});
	$(".sentenceDiv").removeClass("highLight");
	if(VerbMonster.flag==true)	//game page select cell to solve
	{
		$("#"+object).addClass("highLight");
		$("#optionsDiv").css({'pointer-events':'auto'});
	    VerbMonster.ans=$($("#"+object).children()[0]).prop('id');
		VerbMonster.ansData = $($("#"+object).children()[0]).data("clickedTense")
        VerbMonster.highlightedCell=$("#"+object).prop('id');
	}
}
VerbMonster.learningPage=function()
 {
	VerbMonster.nextClicked=false;
	VerbMonster.homeFlag = true;
	d = new Date();  //date object
	startTime = d.getDate() + "-" + (d.getMonth() + 1) + "-" + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();  //to get the current date
	VerbMonster.clickedSell=false;
	scoredMarks = 0;
	VerbMonster.tensArray= ["Present","Past","Future"];
	document.getElementById("optionsDiv").innerHTML="" ; 
		VerbMonster.createOptions();
	label=word=VerbMonster.quesArray[0].langVerb;
	totalNos=VerbMonster.verbArray.length;
	questionId=VerbMonster.quesArray[0].questionId;
	$("#optionsDiv").css({'pointer-events':'none'});
	$("#next").removeClass("blink_me");
	$("#soundButton").css({'pointer-events':'auto'});
 }
VerbMonster.createOptions=function() //function that create 5 option
{
	VerbMonster.randomOptionArray = populate(VerbMonster.optionsArray,VerbMonster.randomOptionArray,5);
   for(var i=0;i<VerbMonster.randomOptionArray.length;i++)
	{
		var num = VerbMonster.randomOptionArray[i];
		var optionDiv = document.createElement("Div");
		optionDiv.setAttribute("id","optionDiv"+i);
		optionDiv.setAttribute("class","noppadding options col-sm-4 col-lg-4 col-md-4 col-xs-4");
		document.getElementById('optionsDiv').appendChild(optionDiv);
		optionDiv.setAttribute("onclick","VerbMonster.checkAnswer(this.id)");
		$(optionDiv).text(VerbMonster.optionsArray[num]);
		$(optionDiv).data("optionSound",VerbMonster.optionsArray[num].audio);
	}
}
VerbMonster.skipPractice = function()
 {
	 var clicked_index = 0;
	document.getElementById("skipSlider").style.display = "none";
	document.getElementById("soundButton").style.visibility="visible";
	 $(".sentenceDiv").removeClass("highLight");
	 if(nextButtonClick==0)
		getDuration(Utils.Path + 'sounds/instruction/' +VerbMonster.hardcodedData.instruction2);
	   VerbMonster.flag=true;
	document.getElementById("nextButton").style.display="block";
	document.getElementById("playSound").pause();
	document.getElementById("optionsDiv").style.display="block";
	$("#optionsDiv").css({'pointer-events':'none'});
	for(var i=0;i<VerbMonster.randomOptionArray.length;i++)
	{
		var number = VerbMonster.randomOptionArray[i]; 
		 for(var j=0;j<9;j++)
		 {
			clicked_index =document.getElementById(VerbMonster.idArray[j]).getAttribute('sellIndex');
			if(number ==clicked_index)
			{
				$("#"+VerbMonster.idArray[j]).css({"border-bottom": "3px dotted","height":"6.2vh"});
				$("#"+VerbMonster.idArray[j]).addClass("selctedSellClass");
				$("#"+VerbMonster.idArray[j]).text("");
			 	break;
			}
		}
	}
	 for(var i=0;i<9;i++)
	 {
		 if($("#"+VerbMonster.idArray[i]).hasClass("selctedSellClass")){
			continue;
		 }
		 else{
			 $("#"+VerbMonster.idArray[i]).parent().css('pointer-events','none');
			  $("#"+VerbMonster.idArray[i]).parent().removeClass("highLight");
		 }
	 }
	 	$(".Div").removeClass("highLight");	
 }
VerbMonster.playInstruction = function(){//play instruction
	document.getElementById('playSound').src=Utils.Path+'sounds/instruction/'+ VerbMonster.hardcodedData.instruction2;
	document.getElementById('playSound').play();
}
function getDuration(src) {
	var duration = 0;
	$('#playSound').on("loadedmetadata", function () {
		duration = $('#playSound').prop('duration');
		$('#playSound').unbind("loadedmetadata");
		VerbMonster.playNextSound(duration);
	});
	$('#playSound').prop('src', src);
}
VerbMonster.playNextSound = function (duration)//function for instruction
{
	document.getElementById('playSound').play();
	if (VerbMonster.instructionTimer) {
		clearTimeout(VerbMonster.instructionTimer);
		VerbMonster.instructionTimer = null;
	}
	VerbMonster.instructionTimer = setTimeout(function () {
	}, duration * 1000);
}
VerbMonster.checkAnswer=function(obj)//function to check answer
{
	VerbMonster.id = obj
	clearTimeout(VerbMonster.wrongTimer);
	scoreFlag = true;
	$(".pulse").removeClass("animated pulse");
	document.getElementById("playSound").pause(); 
	var selectedText=document.getElementById(obj).innerHTML;
	$("#"+VerbMonster.ans).text(selectedText);
	$("#optionsDiv").css({'pointer-events':'none'});
	$("#tenseChart").css({'pointer-events':'none'});
	if(VerbMonster.ansData == "Present"){
	   if(VerbMonster.jsonObj.Present.includes(selectedText) == true)
	       VerbMonster.correctAns();
	   else
		   VerbMonster.wrongAns();
	}
	else if(VerbMonster.ansData == "Past"){
       if(VerbMonster.jsonObj.Past.includes(selectedText) == true)
	        VerbMonster.correctAns();
	   else
		   VerbMonster.wrongAns();
	}
	else{
		  if(VerbMonster.jsonObj.Future.includes(selectedText) == true)
	          VerbMonster.correctAns();
	      else
		      VerbMonster.wrongAns();
	   }

    if (VerbMonster.Timer) {
		clearTimeout(VerbMonster.Timer);
		VerbMonster.Timer = null;
	}
	VerbMonster.Timer = setTimeout(function () {
		$("#tenseChart").css({'pointer-events':'auto'});
	}, 800);
	document.getElementById("playSound").play(); 
}

VerbMonster.correctAns = function()////when ans is correct
{
	var optionSound=$("#"+VerbMonster.id ).data("optionSound");
		VerbMonster.rightAnsCnt++;
		if(VerbMonster.rightAnsCnt==5){
			$("#nextImg").addClass("blink_me");
			$("#soundButton").css({'pointer-events':'none'});
		}
		var dataSelectCell=document.getElementById(VerbMonster.highlightedCell).getAttribute("data");
		if(dataSelectCell=="off")
			scoredMarks++;
		$("#"+VerbMonster.highlightedCell).css({'pointer-events':'none',"opacity":"0.6"});
		getDuration(Utils.Path + 'sounds/' +optionSound);
			$("#"+VerbMonster.ans).addClass('animated pulse');
			$(".sentenceDiv").removeClass("highLight");
			document.getElementById("playSound").src=Utils.Path+'sounds/instruction/Right_answer__Aditi.mp3';
}

VerbMonster.wrongAns = function()//when ans is wrong
{
	document.getElementById(VerbMonster.highlightedCell).setAttribute("data","on");
		$("#"+VerbMonster.ans).addClass('animated shake');
		document.getElementById("playSound").src=Utils.Path+'sounds/instruction/wrong_answer!_Aditi.mp3';
		if (VerbMonster.wrongTimer) {
			clearTimeout(VerbMonster.wrongTimer);
			VerbMonster.wrongTimer = null;
		}
		VerbMonster.wrongTimer = setTimeout(function () {
			$("#"+VerbMonster.ans).text("");
			$("#"+VerbMonster.ans).removeClass('animated shake');
			$("#optionsDiv").css({'pointer-events':'auto'});
		}, 800);
}
VerbMonster.nextQuestion=function() 	//next button		
{
	document.getElementById("verbDiv").style.visibility = "hidden";
	document.getElementById("playSound").pause();
	sellIndex = 0;
	VerbMonster.rightAnsCnt = 0;
	VerbMonster.nextClicked=true;
	VerbMonster.randomOptionArray=[];
	clearTimeout(VerbMonster.wrongTimer);
	clearTimeout(VerbMonster.Timer);
	clearTimeout(VerbMonster.instructionTimer);
	$("#nextImg").removeClass("blink_me");
	$("#optionsDiv").css({'pointer-events':'none'});
	$("#tenseChart").css({'pointer-events':'auto'});
	if(scoreFlag == false){
		scoredMarks=-1;
		VerbMonster.scoreFunction();
	}
	if(scoreFlag == true)
	{
		VerbMonster.scoreFunction();
	}
	nextButtonClick++;
	$(".sentenceDiv").css({'pointer-events':'auto'});
	  for(var i=0;i<9;i++)
	 {
		 if( $("#"+VerbMonster.idArray[i]).hasClass("selctedSellClass"))
			  $("#"+VerbMonster.idArray[i]).removeClass("selctedSellClass");
	 } 
	if(nextButtonClick==2)
	{
		document.getElementById("endPage").style.display = "block";
		document.getElementById("gamePage").style.display = "none";
		VerbMonster.gameOver();
	}
	else
	{
		$("#acknowledgementDiv").hide();
		document.getElementById("verbListPage").style.display="block";
		document.getElementById("gamePage").style.display="none";
	}
}
VerbMonster.gameOver=function()
 {
	 VerbMonster.homeFlag = false;
	 document.getElementById("playSound").pause();
	 document.getElementById("gameOver").innerHTML = VerbMonster.hardcodedData.gameOverText;
 }
 VerbMonster.callHome = function()
 {  
	 document.getElementById("playSound").pause();
	 document.getElementById("verbDiv").style.visibility = "hidden";
	 document.getElementById("gameOver").innerHTML = " ";
	 VerbMonster.randomOptionArray=[];
	 if(VerbMonster.homeFlag)
	 {
		 VerbMonster.homeFlag = false;
		 sellIndex = 0;
	     nextButtonClick = 0;
		 document.getElementById("verbListPage").style.display = "block";
		 document.getElementById("gamePage").style.display="none";
		 document.getElementById("endPage").style.display="none";
	 }
	 else
	 {
		 if(VerbMonster.homeFlag == false && nextButtonClick ==2)
		 {
			sellIndex = 0;
			nextButtonClick = 0;
		    document.getElementById("verbListPage").style.display = "block";
			document.getElementById("gamePage").style.display="none";
			document.getElementById("endPage").style.display="none";
		}
		 else
		 {
			location.reload();
		 }
	 }
}
  VerbMonster.replayGame = function()
 {
	nextButtonClick=0;
	VerbMonster.sliderFlag = false;
	document.getElementById("gameOver").innerHTML = " ";
	document.getElementById("endPage").style.display="none";
	document.getElementById("gamePage").style.display="none";
	document.getElementById("verbListPage").style.display="block";
 }
 VerbMonster.createAcknowledgementDivs = function () {
    var i = 0, div;
    for (i = 0; i < Object.keys(VerbMonster.AcknowledgementPageData).length; i++) {
        div = document.createElement('div');
        div.className = "fontClass firstLetter col-xs-12 col-sm-12 col-md-12 col-lg-12";
        div.innerHTML = Object.keys(VerbMonster.AcknowledgementPageData)[i] + " : " + Object.values(VerbMonster.AcknowledgementPageData)[i];
        acknowledgementDiv.appendChild(div);
    }
    div = document.createElement('div');
    div.className = "fontClass firstLetter col-xs-12 col-sm-12 col-md-12 col-lg-12";
    div.style.marginBottom = "2vh";
    acknowledgementDiv.appendChild(div);
}
VerbMonster.showAcknowledgement = function () {
    $("#acknowledgementDiv").show();
}
VerbMonster.scoreFunction = function () {
    console.log(resId, questionId, scoredMarks, totalMarks, level, startTime, label);
    if (Utils.mobileDeviceFlag) {
        Android.addScore(resId, questionId, scoredMarks, totalMarks, level, startTime);
    }
}
