//startingDate:26-06-2021
var UnlikeFraction = {};
var Utils = {};
Utils.Path = '';
Utils.mobileDeviceFlag = false;
var questionId = 0, startTime = 0, scoredMarks = 0, totalMarks = 10, resId = 0, level = 1, label = '';
UnlikeFraction.queNumArray=[];
UnlikeFraction.queDnumArray=[];
UnlikeFraction.lcmAns=0;
UnlikeFraction.blinkCnt=0;
UnlikeFraction.queCount=0;
UnlikeFraction.numberLength=0;
UnlikeFraction.withoutLcmFlag=false;
UnlikeFraction.attemptFlag=false;

$(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("UnlikeFraction");  */
	setTimeout(function () {
		UnlikeFraction.init();
	}, 100);
});

UnlikeFraction.init = function () {
	$("#coverPage").show();
	$("#gamePage").hide();
	$("#homeButton").css("visibility", "hidden");
	document.body.style.backgroundImage = "url(" + Utils.Path + "images/skin/" + UnlikeFraction.hardcodedData.coverPage + ")";
	UnlikeFraction.setAllImages();
	UnlikeFraction.createNumberDivs(numberSystemDiv);
	$("#playImg").addClass("pulse");
}
UnlikeFraction.initializeVariables = function () {
	UnlikeFraction.unicSelectionArray=[];
}
UnlikeFraction.setAllImages = function () {
	document.getElementById("homeImage").src = Utils.Path + "images/skin/Home.png";
	//document.getElementById("next").src = Utils.Path + "images/skin/Next.png";
	document.getElementById("logoImage").src = Utils.Path + "images/skin/logo.png";
	document.getElementById("playImg").src = Utils.Path + "images/skin/play.png";
	document.getElementById("creditImg").src = Utils.Path + "images/skin/Credits.png";
	document.getElementById("replayImg").src = Utils.Path + "images/skin/Replay.png";
	document.getElementById("nextImg").src = Utils.Path + "images/skin/Next.png";//
	document.getElementById("mainQueDiv").style.backgroundImage = "url(" + Utils.Path + "images/skin/Q1box.png"+")";
	document.getElementById("instruction").style.backgroundImage = "url(" + Utils.Path + "images/skin/Q2box.png"+")";//
	document.getElementById("instructionLCM").style.backgroundImage = "url(" + Utils.Path + "images/skin/Q2box.png"+")";//ansLCM
	document.getElementById("ansLCM").style.backgroundImage = "url(" + Utils.Path + "images/skin/Op12Box.png"+")";
	document.getElementById("type1").style.backgroundImage = "url(" + Utils.Path + "images/skin/Op12Box.png"+")";
	document.getElementById("type2").style.backgroundImage = "url(" + Utils.Path + "images/skin/Op12Box.png"+")";
	document.getElementById("type3").style.backgroundImage = "url(" + Utils.Path + "images/skin/Op3.png"+")";
	document.getElementById("type_12").style.backgroundImage = "url(" + Utils.Path + "images/skin/op12rope.png"+")";//
	document.getElementById("type_3").style.backgroundImage = "url(" + Utils.Path + "images/skin/op12rope.png"+")";
	document.getElementById("ansLCM_rope").style.backgroundImage = "url(" + Utils.Path + "images/skin/op12rope.png"+")";
	document.getElementById("nextQueImg").src = Utils.Path + "images/skin/Next.png";
	document.getElementById("numberSystemDiv").style.backgroundImage = "url(" + Utils.Path + "images/skin/calculatorBox.png"+")";//
	document.getElementById("finalAnsDiv").style.backgroundImage = "url(" + Utils.Path + "images/skin/ansBox.png"+")";
	document.getElementById("finalAnsDivRope").style.backgroundImage = "url(" + Utils.Path + "images/skin/ansBoxRope.png"+")";
	document.getElementById("gameOver").innerHTML = UnlikeFraction.hardcodedData.gameOver;
}
UnlikeFraction.playGame = function () {
	document.body.style.backgroundImage = "url(" + Utils.Path + "images/skin/background.png"+")";
	$("#homeButton").css("visibility", "visible");
	$("#coverPage,#mainQueDiv,#numberSystemDiv").hide();
	$("#gamePage,#page1,#nextDiv").show();
	UnlikeFraction.makeQuestion();
	UnlikeFraction.LCMFlag=false;
}
UnlikeFraction.makeQuestion = function ()		//generate word Sentence
{
	UnlikeFraction.makeQueDivs();
	UnlikeFraction.selectQue();
	var d;
	d = new Date();
	startTime = d.getDate() + "-" + (d.getMonth() + 1) + "-" + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
	
}
UnlikeFraction.makeQueDivs = function ()
{
	$("#finalAnsDiv,#finalAnsDivRope,#ansLCM_rope").hide();
	$("#page1").show();
	UnlikeFraction.queNumArray=[];
	UnlikeFraction.queDnumArray=[];
	for(var i=0;i<16;i++)
	{
		outerDiv = document.createElement("div");
		outerDiv.setAttribute("id","outerDivId"+ i);
		outerDiv.setAttribute("class", "noPadding outerDivClass col-sm-2 col-lg-2 col-md-2 col-xs-2 col-sm-offset-1 col-lg-offset-1 col-md-offset-1 col-xs-offset-1");
		questionDiv.appendChild(outerDiv);
		var uniqueQueArray=[];
		for(var j=0;j<2;j++)
		{
			var randomNo=0;
			ineerDiv = document.createElement("div");
			ineerDiv.setAttribute("id","ineerDivId"+i+""+j);
			ineerDiv.setAttribute("class", "noPadding ineerDivClass col-sm-8 col-lg-8 col-md-8 col-xs-8 col-sm-offset-2 col-lg-offset-2 col-md-offset-2 col-xs-offset-2");
			outerDiv.appendChild(ineerDiv);
			randomNo=Math.floor(Math.random()*15)+1;
			while(uniqueQueArray.includes(randomNo)){
				randomNo=Math.floor(Math.random()*15)+1;
			}
			uniqueQueArray.push(randomNo);
			if(j==0)
			{
				$("#ineerDivId"+ i+""+j).addClass("numaratorDiv");
				UnlikeFraction.queNumArray.push(randomNo);
			}
			else
				UnlikeFraction.queDnumArray.push(randomNo);
			$("#ineerDivId"+ i+""+j).text(randomNo);
		}
	}
	console.log(UnlikeFraction.queNumArray);
	console.log(UnlikeFraction.queDnumArray);
}
UnlikeFraction.selectQue=function()
{
	
	/* if(!UnlikeFraction.selectionFlag)
	{ */
		UnlikeFraction.selectionFlag=true;
		$(".outerDivClass").css("border","2px solid white");
		UnlikeFraction.unicSelectionArray=[];
		for(var i=0;i<2;i++)
		{
		var rNo=Math.floor(Math.random()*15);
		while(UnlikeFraction.unicSelectionArray.includes(rNo))
			var rNo=Math.floor(Math.random()*15);
		UnlikeFraction.unicSelectionArray.push(rNo);
		}
		UnlikeFraction.unicSelectionArray.sort(function (a, b) { return a-b });
		for(var i=0;i<2;i++)
		{
			$("#outerDivId"+UnlikeFraction.unicSelectionArray[i]).css("border","4px solid yellow");
		}
		console.log(UnlikeFraction.unicSelectionArray);
		document.getElementById("nextImg").src = Utils.Path + "images/skin/continue.png";//continue
	/* }
	else{ */
		$("#questionDiv,#arrowDiv,#finalAnsDiv3").hide();
		$("#page1,#mainQueDiv,#finalAnsDiv1,#finalAnsDiv2").show();
		$("#instruction").text(UnlikeFraction.hardcodedData.queInstruction);
		$("#numberSystemDiv").show();
		$("#ansLCM").hide();
	$("#firstNum0").text(UnlikeFraction.queNumArray[UnlikeFraction.unicSelectionArray[0]]);
	$("#firstNum1").text(UnlikeFraction.queDnumArray[UnlikeFraction.unicSelectionArray[0]]);
	$("#secondNum0").text(UnlikeFraction.queNumArray[UnlikeFraction.unicSelectionArray[1]]);
	$("#secondNum1").text(UnlikeFraction.queDnumArray[UnlikeFraction.unicSelectionArray[1]]);
	//$(".typeStyle").css("pointerEvents","none");
	
}
UnlikeFraction.selectType0=function()
{
	UnlikeFraction.attemptFlag=true;
	document.getElementById("playSound").pause();
	document.getElementById("playSound").src=Utils.Path+'sounds/instructions/Try_again.mp3';
		document.getElementById("playSound").play();
}
UnlikeFraction.selectType1=function()
{
	UnlikeFraction.attemptFlag=true;
	$("#finalAnsDiv").hide();
	$("#ansLCM_rope,#page2,#instruction,#instructionLCM").show();
	//$("#instructionLCM,#ansLCM_rope").hide();
	document.getElementById("playSound").pause();
	if($("#firstNum1").text()!=$("#secondNum1").text())
	{
		$("#page1").hide();
		UnlikeFraction.queTypeLCM();
	}
	else
	{
		document.getElementById("questionMsg").innerHTML = UnlikeFraction.modalData.firstError;
		$("#responseBoxDiv").show();
		UnlikeFraction.errorMsgTimer = setTimeout(function ()
		{
			$("#responseBoxDiv").hide();
		},3500);
	}
}
UnlikeFraction.selectType2=function()
{
	UnlikeFraction.attemptFlag=true;
	document.getElementById("playSound").pause();
	if($("#firstNum1").text()==$("#secondNum1").text())
	{
		UnlikeFraction.queTypeAddNumertors();
		$("#finalAnsDiv").show();
		$("#instructionLCM").hide();
	}
	else
	{
		document.getElementById("questionMsg").innerHTML = UnlikeFraction.modalData.secondError;
		$("#responseBoxDiv").show();
		UnlikeFraction.errorMsgTimer = setTimeout(function ()
		{
			$("#responseBoxDiv").hide();
		},3500);
	}
}
UnlikeFraction.queTypeLCM=function()
{
	//$("#finalAnsDiv").show();
	UnlikeFraction.withoutLcmFlag=false;
	$("#nextDiv,#finalAnsDiv1,#finalAnsDiv2").hide();
	$("#page2,#numberSystemDiv").show();
	$("#instructionLCM ").text(UnlikeFraction.queDnumArray[UnlikeFraction.unicSelectionArray[0]]+" और "+" "+ UnlikeFraction.queDnumArray[UnlikeFraction.unicSelectionArray[1]]+" का लघुत्तम समापवर्त्य:")
	//..... और ... का लघुत्तम समापवर्त्य
	$("#ansLCM").show();
	$("#ansLCM").addClass("blink_me");
	$("#numberSystemDiv").css("top","15vh");
	UnlikeFraction.a=$("#firstNum1").text();
	UnlikeFraction.b=$("#secondNum1").text();
}
UnlikeFraction.queTypeAddNumertors=function()
{
	UnlikeFraction.LCMFlag=true;
	UnlikeFraction.withoutLcmFlag=true;
	UnlikeFraction.signArray=["","+","="];
	document.getElementById("finalAnsDiv3").innerHTML="";
	UnlikeFraction.createAnsFractionDiv(finalAnsDiv3,"Fparent",UnlikeFraction.signArray,"secondNum");
	$("#page1,#nextDiv,#finalAnsDiv1,#finalAnsDiv2").hide();
	$("#page2,#numberSystemDiv,#finalAnsDiv3").show();
	$("#instructionLCM ").text("L.C.M. of "+" "+UnlikeFraction.queDnumArray[UnlikeFraction.unicSelectionArray[0]]+" and "+" "+ UnlikeFraction.queDnumArray[UnlikeFraction.unicSelectionArray[1]]+" is:");
	$("#Fparentnum00").text($("#firstNum0").text())
	$("#Fparentnum02,#Fparentnum12,#Fparentnum22").text($("#firstNum1").text());
	$("#Fparentnum10").text($("#secondNum0").text())
	$("#Fparentnum20").addClass("blink_me");
	UnlikeFraction.currentBlinkId="Fparentnum20";
}
UnlikeFraction.checkLCM=function(){
	UnlikeFraction.LCMFlag=false;
	UnlikeFraction.lcmAns=UnlikeFraction.findLCM(UnlikeFraction.a,UnlikeFraction.b);
	if($("#ansLCM").text()==UnlikeFraction.lcmAns)
	{
		
		if (UnlikeFraction.lcmTimer) {
			clearTimeout(UnlikeFraction.lcmTimer);
			UnlikeFraction.lcmTimer = null;
		}
		UnlikeFraction.lcmTimer = setTimeout(function ()
		{
			$("#finalAnsDiv,#finalAnsDivRope").show();
			$("#numberSystemDiv").css("top","7vh");
			$("#instructionLCM,#ansLCM_rope").hide();
			$("#ansLCM").hide();
			UnlikeFraction.signArray=["","X","="];
			document.getElementById("finalAnsDiv1").innerHTML="";
			document.getElementById("finalAnsDiv2").innerHTML="";
			UnlikeFraction.createFractionDiv(finalAnsDiv1,"parent",UnlikeFraction.signArray,"firstNum");
			UnlikeFraction.createFractionDiv(finalAnsDiv2,"Sparent",UnlikeFraction.signArray,"secondNum");
			$("#finalAnsDiv1,#finalAnsDiv2").show();
			UnlikeFraction.LCMFlag=true;
			$("#"+UnlikeFraction.divSequenceArray[UnlikeFraction.blinkCnt]).addClass("blink_me");
		},1000);
	}
	else
	{
		if (UnlikeFraction.lcmTimerWrongAns) {
			clearTimeout(UnlikeFraction.lcmTimerWrongAns);
			UnlikeFraction.lcmTimerWrongAns = null;
		}
		UnlikeFraction.lcmTimerWrongAns = setTimeout(function ()
		{
		$("#ansLCM").text("");
		UnlikeFraction.LCMFlag=false;
	},1000);
	}
	console.log(UnlikeFraction.lcmAns);
}
UnlikeFraction.findLCM=function(a,b){
		let min = Math.min(a, b);
		while(min >= 2){
		   if(a % min === 0 && b % min === 0){
			  return (a*b)/min;
		   };
		   min--;
		};
		return (a*b);
	// console.log(lcm(6, 8));
}
UnlikeFraction.createFractionDiv = function(finalAnsDiv,id,signArray,digitDiv)
{
	for(var i=0;i<3;i++)
	{
		outerDiv = document.createElement("DIV");
		outerDiv.setAttribute("id", id + i);
		outerDiv.setAttribute("class", "nopadding parentClass col-xs-4 col-md-4 col-lg-4 col-sm-4");
		finalAnsDiv.appendChild(outerDiv);

		signDiv = document.createElement("DIV");
		signDiv.setAttribute("id", id +"sign"+ i);
		signDiv.setAttribute("class", "nopadding signClass col-xs-5 col-md-5 col-lg-5 col-sm-5");
		$(signDiv).text(signArray[i]);
		outerDiv.appendChild(signDiv);
		innerDiv = document.createElement("DIV");
		innerDiv.setAttribute("id", id +"inner"+ i);
		innerDiv.setAttribute("class", "nopadding col-xs-7 col-md-7 col-lg-7 col-sm-7");
		outerDiv.appendChild(innerDiv);
		var k=0;
		for(var j=0;j<3;j++)
		{
			numDiv = document.createElement("DIV");
			numDiv.setAttribute("id", id +"num"+ i+""+j);
			if(j==1)
				numDiv.setAttribute("class", "nopadding lineDiv col-xs-12 col-md-12 col-lg-12 col-sm-12");
			else{
				
			if(i==0)
			{
				numDiv.setAttribute("class", "nopadding diffHeight col-xs-10 col-md-10 col-lg-10 col-sm-10 col-xs-offset-1 col-md-offset-1 col-lg-offset-1 col-sm-offset-1");
				$(numDiv).text($("#"+digitDiv+""+k).text());
				k++;
			}
			else
				numDiv.setAttribute("class", "nopadding removeText height col-xs-10 col-md-10 col-lg-10 col-sm-10 col-xs-offset-1 col-md-offset-1 col-lg-offset-1 col-sm-offset-1");
				if(i==2 && j==2)
				{
					$(numDiv).text(UnlikeFraction.lcmAns);
				}
			}
			innerDiv.appendChild(numDiv);
		}
	}
}
UnlikeFraction.displayInTextBox = function (element) {
	if(!UnlikeFraction.LCMFlag)
	{
		UnlikeFraction.numberLength=UnlikeFraction.findLCM(UnlikeFraction.a,UnlikeFraction.b).toString().length;
		if ($("#ansLCM").text().length < UnlikeFraction.numberLength)
		$("#ansLCM").append($(element).text());
		Number(UnlikeFraction.numberLength);
			if ($("#ansLCM").text().length == UnlikeFraction.numberLength) {
				UnlikeFraction.checkLCM();
		}
		$("#"+UnlikeFraction.divSequenceArray[UnlikeFraction.blinkCnt]).addClass("blink_me");
	}
	else
	{
		UnlikeFraction.numberLength=0;
		if(!UnlikeFraction.withoutLcmFlag)
			UnlikeFraction.currentBlinkId=UnlikeFraction.divSequenceArray[UnlikeFraction.blinkCnt];
		if(UnlikeFraction.currentBlinkId=="parentnum12" || UnlikeFraction.currentBlinkId=="parentnum10")
		{
			UnlikeFraction.number=Number($("#parentnum22").text()/$("#parentnum02").text());
			console.log(UnlikeFraction.number);
			UnlikeFraction.numberLength=UnlikeFraction.number.toString().length;
		}
		else if(UnlikeFraction.currentBlinkId=="parentnum20")
		{
			UnlikeFraction.number=Number($("#parentnum00").text()*$("#parentnum10").text());
			UnlikeFraction.numberLength=UnlikeFraction.number.toString().length;
		}
		else if(UnlikeFraction.currentBlinkId=="Sparentnum12" || UnlikeFraction.currentBlinkId=="Sparentnum10")
		{
			UnlikeFraction.number=Number($("#Sparentnum22").text()/$("#Sparentnum02").text());
			console.log(UnlikeFraction.number);
			UnlikeFraction.numberLength=UnlikeFraction.number.toString().length;
		}
		else if(UnlikeFraction.currentBlinkId=="Sparentnum20")
		{
			UnlikeFraction.number=Number($("#Sparentnum00").text()*$("#Sparentnum10").text());
			UnlikeFraction.numberLength=UnlikeFraction.number.toString().length;
		}
		else
		{
			UnlikeFraction.number=Number(Number($("#Fparentnum00").text())+Number($("#Fparentnum10").text()));
			UnlikeFraction.numberLength=UnlikeFraction.number.toString().length;
		}
		UnlikeFraction.number=Number(UnlikeFraction.number);
			if ($("#"+UnlikeFraction.currentBlinkId).text().length < UnlikeFraction.numberLength)
				$("#"+UnlikeFraction.currentBlinkId).append($(element).text());
			if ($("#"+UnlikeFraction.currentBlinkId).text().length == UnlikeFraction.numberLength) 
				UnlikeFraction.checkCrossMult();
	}
}
UnlikeFraction.checkCrossMult = function () {
	if(UnlikeFraction.currentBlinkId=="parentnum12" || UnlikeFraction.currentBlinkId=="parentnum10")
	{
		if(UnlikeFraction.number==$("#"+UnlikeFraction.currentBlinkId).text())
		{
			UnlikeFraction.blinkCnt++;
		}
		else
		{
			setTimeout(function ()
		{
			$("#"+UnlikeFraction.currentBlinkId).css("background-color","red");
		},400)
		if (UnlikeFraction.WrongAns0) {
			clearTimeout(UnlikeFraction.WrongAns0);
			UnlikeFraction.WrongAns0 = null;
		}
		UnlikeFraction.WrongAns0 = setTimeout(function ()
		{
			$("#"+UnlikeFraction.currentBlinkId).text("");
			$("#"+UnlikeFraction.currentBlinkId).css("background-color","white");
		},1500)
	}
	}
	else if(UnlikeFraction.currentBlinkId=="parentnum20")
	{
		clearTimeout(UnlikeFraction.WrongAns0);
		var ans=$("#parentnum00").text()*$("#parentnum10").text();
		if(ans==$("#"+UnlikeFraction.currentBlinkId).text())
		{
			UnlikeFraction.blinkCnt++;
		}
		else
		{
			setTimeout(function ()
		{
			$("#"+UnlikeFraction.currentBlinkId).css("background-color","red");
		},400)
		if (UnlikeFraction.WrongAns1) {
			clearTimeout(UnlikeFraction.WrongAns1);
			UnlikeFraction.WrongAns1 = null;
		}
		UnlikeFraction.WrongAns1 = setTimeout(function ()
		{
		$("#"+UnlikeFraction.currentBlinkId).text("");
		$("#"+UnlikeFraction.currentBlinkId).css("background-color","white");
		},1500)
	}
	}
	else if(UnlikeFraction.currentBlinkId=="Sparentnum12" || UnlikeFraction.currentBlinkId=="Sparentnum10")
	{
		clearTimeout(UnlikeFraction.WrongAns1);
		if(UnlikeFraction.number==$("#"+UnlikeFraction.currentBlinkId).text())
		{
			UnlikeFraction.blinkCnt++;
			//clearTimeout(UnlikeFraction.WrongAns);
		}
		else
		{
			setTimeout(function ()
		{
			$("#"+UnlikeFraction.currentBlinkId).css("background-color","red");
		},400)
		if (UnlikeFraction.WrongAns) {
			clearTimeout(UnlikeFraction.WrongAns);
			UnlikeFraction.WrongAns = null;
		}
		UnlikeFraction.WrongAns = setTimeout(function ()
		{
		$("#"+UnlikeFraction.currentBlinkId).text("");
		$("#"+UnlikeFraction.currentBlinkId).css("background-color","white");
		},1500)
	}
	}
	else if(UnlikeFraction.currentBlinkId=="Sparentnum20")
	{
		var ans=$("#Sparentnum00").text()*$("#Sparentnum10").text();
		if(ans==$("#"+UnlikeFraction.currentBlinkId).text())
		{
			if (UnlikeFraction.nextQueTimer) {
				clearTimeout(UnlikeFraction.nextQueTimer);
				UnlikeFraction.nextQueTimer = null;
			}
			UnlikeFraction.nextQueTimer = setTimeout(function ()
			{
				UnlikeFraction.blinkCnt++;
				clearTimeout(UnlikeFraction.WrongAns);
				$("#finalAnsDiv2,#finalAnsDiv1").hide();
				$("#finalAnsDiv3").show();
				UnlikeFraction.signArray=["","+","="];
				document.getElementById("finalAnsDiv3").innerHTML="";
				UnlikeFraction.createAnsFractionDiv(finalAnsDiv3,"Fparent",UnlikeFraction.signArray,"secondNum");
				$("#numberSystemDiv").css("pointerEvents","auto");
				$("#"+UnlikeFraction.divSequenceArray[UnlikeFraction.blinkCnt]).addClass("blink_me");
			}, 1000);
		$("#numberSystemDiv").css("pointerEvents","none");
		}
		else
		{
		if (UnlikeFraction.WrongAns) {
			clearTimeout(UnlikeFraction.WrongAns);
			UnlikeFraction.WrongAns = null;
		}
		UnlikeFraction.WrongAns = setTimeout(function ()
		{
		$("#"+UnlikeFraction.currentBlinkId).text("");
		},1000)
	}
	}
	else
	{
		var ans=Number(Number($("#Fparentnum00").text())+Number($("#Fparentnum10").text()));
		$("#nextDiv").show();
		if(ans==$("#"+UnlikeFraction.currentBlinkId).text())
		{
			scoredMarks=10;
			$("#nextQueImg").addClass("pulse");
			UnlikeFraction.blinkCnt++;
			clearTimeout(UnlikeFraction.WrongAns);
			$("#"+UnlikeFraction.currentBlinkId).removeClass("blink_me");
			document.getElementById("playSound").src=Utils.Path+'sounds/instructions/thats_right.mp3';
			document.getElementById("playSound").play();
			$("#finalAnsDiv1,#finalAnsDiv2").hide();
			document.getElementById("finalAnsDiv1").innerHTML="";
			document.getElementById("finalAnsDiv2").innerHTML="";
		}
		else
		{
			scoredMarks=0;
			$("#"+UnlikeFraction.currentBlinkId).text("");
			document.getElementById("playSound").src=Utils.Path+'sounds/instructions/Try_again.mp3';
			document.getElementById("playSound").play();
		}
		
	}
	
	$(".blink_me").removeClass("blink_me");
		$("#"+UnlikeFraction.divSequenceArray[UnlikeFraction.blinkCnt]).addClass("blink_me");
}
UnlikeFraction.createAnsFractionDiv = function(finalAnsDiv1,id,signArray,digitDiv)
{
	for(var i=0;i<3;i++)
	{
		outerDiv = document.createElement("DIV");
		outerDiv.setAttribute("id", id + i);
		outerDiv.setAttribute("class", "nopadding parentClass col-xs-4 col-md-4 col-lg-4 col-sm-4");
		finalAnsDiv1.appendChild(outerDiv);

		signDiv = document.createElement("DIV");
		signDiv.setAttribute("id", id +"sign"+ i);
		signDiv.setAttribute("class", "nopadding signClass col-xs-5 col-md-5 col-lg-5 col-sm-5");
		$(signDiv).text(signArray[i]);
		outerDiv.appendChild(signDiv);
		innerDiv = document.createElement("DIV");
		innerDiv.setAttribute("id", id +"inner"+ i);
		innerDiv.setAttribute("class", "nopadding col-xs-7 col-md-7 col-lg-7 col-sm-7");
		outerDiv.appendChild(innerDiv);
		var k=0;
		for(var j=0;j<3;j++)
		{
			numDiv = document.createElement("DIV");
			numDiv.setAttribute("id", id +"num"+ i+""+j);
			if(j==1)
				numDiv.setAttribute("class", "nopadding lineDiv col-xs-12 col-md-12 col-lg-12 col-sm-12");
			else{
				
			if(i!=2)
			{
				numDiv.setAttribute("class", "nopadding diffHeight col-xs-10 col-md-10 col-lg-10 col-sm-10 col-xs-offset-1 col-md-offset-1 col-lg-offset-1 col-sm-offset-1");
				if(j==2)
					$(numDiv).text(UnlikeFraction.lcmAns);
				else if(j==0 && i==0)
					$(numDiv).text($("#parentnum20").text());
				else if(j==0 && i==1)
					$(numDiv).text($("#Sparentnum20").text());
				k++;
			}
			else
				numDiv.setAttribute("class", "nopadding removeText height col-xs-10 col-md-10 col-lg-10 col-sm-10 col-xs-offset-1 col-md-offset-1 col-lg-offset-1 col-sm-offset-1");
				if(i==2 && j==2)
				{
					$(numDiv).text(UnlikeFraction.lcmAns);
				}
			}
			innerDiv.appendChild(numDiv);
		}
	}
}
UnlikeFraction.nextQue = function () {
	if(!UnlikeFraction.attemptFlag)
		scoredMarks=-1;
	console.log(resId, questionId, scoredMarks, totalMarks, level, startTime, label);
		if (Utils.mobileDeviceFlag)
			Android.addScore(resId, questionId, scoredMarks, totalMarks, level, startTime, label);
	$("#nextQueImg").removeClass("pulse");
	UnlikeFraction.queCount++;
	if(UnlikeFraction.queCount==5)
	{
		$("#gamePage").hide();
		$("#endPage").show();
		document.getElementById("acknowledgementDiv").innerHTML="";
		UnlikeFraction.createAcknowledgementDivs();
	}
	else
	{
		UnlikeFraction.attemptFlag=false;
		$("#numberSystemDiv,#nextDiv,#page2").hide();
		$(".removeText").text(" ");
		UnlikeFraction.blinkCnt=0;
		UnlikeFraction.playGame();
	}

}
/***...........................................***/
UnlikeFraction.playAgain = function () {
	UnlikeFraction.soundFlag = true;
	$("#acknowledgementDiv").hide();
	$("#endPage").hide();
	$("#gamePage").show();
	//UnlikeFraction.nextQuestion();
	UnlikeFraction.playGame();
		$("#numberSystemDiv").hide();
		$(".removeText").text(" ");
		UnlikeFraction.blinkCnt=0;
		UnlikeFraction.queCount=0;
}
UnlikeFraction.callHome=function()
{
	if(UnlikeFraction.attemptFlag)
{
	console.log(resId, questionId, scoredMarks, totalMarks, level, startTime, label);
		if (Utils.mobileDeviceFlag)
			Android.addScore(resId, questionId, scoredMarks, totalMarks, level, startTime, label);
}
	location.reload();
}
UnlikeFraction.clearText=function()
{
	
}
UnlikeFraction.createAcknowledgementDivs = function () {
	var i = 0, div;
	for (i = 0; i < Object.keys(UnlikeFraction.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(UnlikeFraction.AcknowledgementPageData)[i] + " : " + Object.values(UnlikeFraction.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.innerHTML = UnlikeFraction.hardcodedData['createdOn'];
	div.style.marginBottom = "2vh";
	acknowledgementDiv.appendChild(div);
}
UnlikeFraction.showAcknowledgement = function () {
	$("#acknowledgementDiv").show();
}