var Division = {}; //namespace
var Utils = {};
Utils.Path = "";
Division.numberOfDigit = 1; // number of digit of answer;
var resId = 0, questionId = 0, startTime = 0, scoredMarks = 0, totalMarks = 10, label = " ", level = 1, scoreFlag = false, number = 0, text;
$(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("Division"); */
    setTimeout(function () { Division.Initilize(); }, 200);
});
Division.Initilize = function () {
    Division.setImage();
	document.title = Division.hardcoded.gameTitle;
    document.getElementById("widgeDiv").style.display = "none";
    document.getElementById("gamePage").style.display = "none";
    document.getElementById("endPage").style.display = "none";
    Division.variableInitilization();
}
Division.setImage = function () {
    document.body.style.backgroundImage = "url('images/skin/Cover.png')";
    document.getElementById("logoImg").src = Utils.Path + "images/skin/logo.png";
    document.getElementById("playImage").src = Utils.Path + "images/skin/Play.png";
    document.getElementById("soundImage").src = Utils.Path + "images/skin/sound.png";
    document.getElementById("nextImage").src = Utils.Path + "images/skin/Skip.png";
    document.getElementById("nextGameImg").src = Utils.Path + "images/skin/Next.png";
    document.getElementById("confiramtionText").innerHTML = Division.modalData.responseMsg;
    document.getElementById("Yes").innerHTML = Division.modalData.yes;
    document.getElementById("No").innerHTML = Division.modalData.no;
	document.getElementById("gamePage").style.backgroundImage=Utils.Path+"url('images/skin/gadget_yellow.png')";
    document.getElementById("titleId").style.backgroundImage=Utils.Path+"url('images/skin/long-gray-button.png')";
    document.getElementById("titleId").innerHTML = Division.hardcoded.title;
    document.getElementById("scoreId").innerHTML = Division.hardcoded.scoreText;
}
Division.variableInitilization = function () {
    Division.DivId = 0; //variable contain id of the ansdiv
    Division.level = 0; //game level {0,1,2,3,4}
    Division.ansCount = 0; //count num of attempt ans
    Division.ansLevel = 1;
    Division.quesLevel = 1;
    Division.counter = 0;//keep track of the the finalquestionArray
    Division.seconds = 0; //seconds count to play "plz ans the ques"
	Division.levelNumber = 0;
    Division.index = 0;
	Division.starCount=0;//no. of correct ans to give score
    Division.correctCounter = 0; //total num of star
	Division.total_No_of_Questions = 10;
    Division.noResponseTimer;//timer Id for the instruction "plz ans the ques"
    Division.timerID;//timer Id to check the counter of the attempted ques an dtotal no. of ques
    Division.correctGreenColor; //timer for the calculator button color chnage 
    Division.pointertimer; 
    Division.colorTimerId // timer tochange the color of the div on correct ans
    Division.wrongRedColorTimerId;
    Division.finalArray = []; //ques array
	Division.randomNumberArray = [];  //2 random number for mult
	Division.answerFlag = false;//flag to identify clicked answer div
    Division.quesFlag = false; //flag for the skip ques
    Division.soundFlag = true; //flag for next instr sound
    Division.instructionTimer;//instruction after some time
}
Division.startGame = function () {
    document.body.style.backgroundImage = "url('images/skin/BG1.jpg')";
    document.getElementById("gamePage").style.display = "block";
    document.getElementById("playGame").style.display = "none";
    document.getElementById("widgeDiv").style.display = "block";
    document.getElementById("endPage").style.display = "none";
    numberKey();
    Division.randomCalculation();
    Division.equationDiv();
    Division.setEquation(1, 1);
    Division.playInstruction();
}
Division.playInstruction = function () {
    clearInterval(Division.noResponseTimer);
    Division.seconds=0;
    Division.soundFlag=true;
    src =  "sound/instruction/simpleDivision_Instruction.mp3";
    Division.getDuration(src);
}
Division.getDuration=function(src){
    var duration = 0;
	if (Division.soundFlag) {
		$('#playSound').on("loadedmetadata", function () {
			Division.soundFlag = false;
			duration = $('#playSound').prop('duration');
			$('#playSound').unbind("loadedmetadata");
			Division.playNextSound(duration);
		});
		$('#playSound').prop('src', src);
	}
}
Division.playNextSound = function (duration)//plz ans ques function call
{
	document.getElementById('playSound').play();
	if (Division.instructionTimer) {
		clearTimeout(Division.instructionTimer);
		Division.instructionTimer = null;
	}
	Division.instructionTimer = setTimeout(function () {
		document.getElementById('playSound').pause();
		Division.startTimer();
	}, duration * 1000);
}
Division.randomCalculation = function () { //calculate 2 random multiplication
    while (Division.randomNumberArray.length < 4) {
        var number1 = Math.floor(Math.random() * 10);
        if (number1 > 1 && number1 < 10) {
            if (Division.randomNumberArray.indexOf(number1) == -1) {
                Division.randomNumberArray.push(number1);
            }
        }
	}
    Division.calculation();
}
Division.calculation = function () { //calculation to make equation
    var quesArray = [], j = 0,num1,num2;
    for (var i = 0; i < 2; i++) {
        jsonObj = {};
        num1 = Division.randomNumberArray[j];
         num2 = Division.randomNumberArray[j + 1];
        if ((num1 * num2) > 9) { // create divident 
            jsonObj['divident'] = num1 * num2;
            jsonObj['divisor'] = num1;
            jsonObj['ans'] = num2;
            jsonObj['level'] = Division.levelNumber;
        }
        else {
            Division.randomNumberArray = [];
            quesArray = [];
            Division.randomCalculation();
			return 0;
        }
        quesArray.push(jsonObj);
        j = 2;
    }
    Division.levelNumber++;
    Division.finalArray.push(quesArray);
    console.log(Division.finalArray);

    if (Division.finalArray.length < 5) {
        Division.randomNumberArray = [];
        Division.randomCalculation();
    }
}
Division.equationDiv = function () {//create div and set value
    Division.quesFlag = false;
    var DivTag, equDiv;
 document.getElementById("score").innerHTML = Division.correctCounter + Division.hardcoded.score;
   for (var i = 0; i < 2; i++){ //Question Div
      DivTag = document.createElement("div");
      DivTag.setAttribute("id", "divId" + i);
      DivTag.setAttribute("class", "nopadding divIdClass col-sm-12 col-xs-12 col-lg-12 col-md-12");
      var innerDivTag = document.createElement("div");
      innerDivTag.setAttribute("id", "innerDivId" + i);
      innerDivTag.setAttribute("class", "nopadding innerDivClass col-sm-6 col-xs-6 col-md-6 col-lg-6");
      innerDivTag.style.backgroundImage =Utils.Path+"url('images/skin/gray_button.png')";
      DivTag.appendChild(innerDivTag);
      for (var j = 0; j < 3; j++) {
          spanTag = document.createElement("span");
          spanTag.setAttribute("id", "spanId" + i + j);
          spanTag.setAttribute("class", "nopadding spanIDclass");
          innerDivTag.appendChild(spanTag);
      }
      var equalSign = document.createElement("div");//equal sign div
      equalSign.setAttribute("id","equalSign"+i);
      equalSign.setAttribute("class","nopadding equalClass col-sm-1 xol-xs-1 col-lg-1 col-md-1");
      equalSign.innerHTML=Division.hardcoded.equalSign;
      DivTag.appendChild(equalSign);
      var equDiv = document.createElement("div");//ans div
      equDiv.setAttribute("id", "AnswerDivId" + i);
      equDiv.setAttribute("class", "nopadding AnswerDivIdclass answer col-sm-5 col-xs-5 col-md-5 col-lg-5");
      equDiv.setAttribute("questionId", i);
      equDiv.style.backgroundImage =Utils.Path+"url('images/skin/gray_button.png')";
      equDiv.setAttribute("onclick", "Division.shownumberPad(this.id)");
       equDiv.innerHTML = " ";
      DivTag.appendChild(equDiv);
      document.getElementById("questionDiv").appendChild(DivTag);
      $("#AnswerDivId0").addClass('blink_me');
      $("#AnswerDivId0").removeClass('answer');
  }
}
Division.setEquation = function (levelValue, questionLevel) {
    d = new Date();  //date object
    startTime = d.getDate() + "-" + (d.getMonth() + 1) + "-" + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();  //to get the current date 
    scoreFlag = false;
    clearTimeout(Division.pointertimer);
    var numLen,numArray,splitatedNumber,i,j;
    for (i = 0; i < 2; i++) {
        for ( j = 0; j < 4; j++) {
            if (j == 0) {
                splitatedNumber = numberSplit(levelValue * Division.finalArray[Division.counter][Division.index].divident);
                numLen = splitatedNumber.length;
                numArray = splitatedNumber.toString();
                for (let m = 0; m < numLen; m++) {
                    var innerSpan = document.createElement("span");
                    innerSpan.setAttribute("id", "innerSpanId" + i + m);
                    innerSpan.setAttribute("class", "nopadding spanClass");
                    innerSpan.innerHTML = numArray[m];
                    if (i == 0)
                        document.getElementById("spanId00").appendChild(innerSpan);
                    else
                        document.getElementById("spanId10").appendChild(innerSpan);
				}
			}
			else if (j == 1) 
				document.getElementById("spanId" + i + j).innerHTML = Division.hardcoded.DivisionSign;
            else if (j == 2) 
                document.getElementById("spanId" + i + j).innerHTML = Division.finalArray[Division.counter][Division.index].divisor * questionLevel;
           }
            Division.index++;
     }
        Division.index = 0;
        Division.colorQuesZero();
        $("#keyPadDiv").css('pointer-events', 'auto');
}
Division.colorQuesZero = function(){//color zero level wise
    if (Division.finalArray[Division.counter][Division.index].level == 1) 
    $("#innerSpanId02,#innerSpanId12").addClass("highlightZero");
    else if (Division.finalArray[Division.counter][Division.index].level == 2) 
        $("#innerSpanId03,#innerSpanId13,#innerSpanId04,#innerSpanId14").addClass("highlightZero");
    else if (Division.finalArray[Division.counter][Division.index].level == 4) 
        $("#innerSpanId04,#innerSpanId14").addClass("highlightZero");
}
function displayNumber(elementInformation) {//display  clicked number to ans Div
    document.getElementById("playSound").pause();
    clearTimeout(Division.pointertimer);
    clearInterval(Division.noResponseTimer);
    clearTimeout(Division.instructionTimer);
    scoreFlag = true;
    if (!Division.answerFlag) //current answerDiv's id
        Division.DivId = $('.blink_me').attr("id");

    document.getElementById(elementInformation.id).style.color="black";
    setTimeout(function()
    { 
         document.getElementById(elementInformation.id).style.color ='white';  
    }, 250);
    clicked_id = elementInformation.id;  //numberpad's clicked button id
    text = $("#" + clicked_id).text();

    if (Division.DivId == 'AnswerDivId0') {
         var ansSpan = document.createElement("span");
            ansSpan.setAttribute("id", "ansspanId" + number);
            ansSpan.setAttribute("class", "nopadding");
            ansSpan.append(text);
            document.getElementById(Division.DivId).appendChild(ansSpan);
			number++;
	}
    else {
         var ansSpan = document.createElement("span");
             ansSpan.setAttribute("id", "ansspanId0" + number);
             ansSpan.setAttribute("class", "nopadding");
             ansSpan.append(text);
             document.getElementById(Division.DivId).appendChild(ansSpan);
             number++;
    }
    
    if (document.getElementById(Division.DivId).getAttribute("questionId") == 0) {
        if (String(($("#" + Division.DivId).text())).length - 1 == Division.numberOfDigit) {
            $("#keyPadDiv").css('pointer-events', 'none');
                if (Division.finalArray[Division.counter][Division.index].level == 4) {
                    if (Division.finalArray[Division.counter][0].ans * 1 * Division.quesLevel == $   ("#" + Division.DivId).text()) 
                        Division.checkAnswer();
                    else 
                        Division.wrongAnswer();
                }
                else if(Division.finalArray[Division.counter][Division.index].level == 3 ){
                    if (Division.finalArray[Division.counter][0].ans * 1 == $("#" + Division.DivId).text())
                         Division.checkAnswer();
                    else 
                        Division.wrongAnswer();
                }
                else if (Division.finalArray[Division.counter][0].ans * Division.ansLevel * Division.quesLevel == $("#" + Division.DivId).text()) 
                      Division.checkAnswer();
                else 
                      Division.wrongAnswer();
                    
            }
        }
        else {
                if (String(($("#" + Division.DivId).text())).length - 1 == Division.numberOfDigit) {
                   $("#keyPadDiv").css('pointer-events', 'none');
                 if (Division.finalArray[Division.counter][Division.index].level == 4) {
                     if (Division.finalArray[Division.counter][1].ans * 1 * Division.quesLevel == $("#" + Division.DivId).text()) 
                         Division.checkAnswer();
                     else 
                         Division.wrongAnswer();
                  }
                 else if(Division.finalArray[Division.counter][Division.index].level == 3){
                     if (Division.finalArray[Division.counter][1].ans * 1 == $("#" + Division.DivId).text()) 
                          Division.checkAnswer();
                     else 
                           Division.wrongAnswer();
                  }
                else if (Division.finalArray[Division.counter][1].ans * Division.ansLevel == $("#" + Division.DivId).text()) 
                   Division.checkAnswer();
                else 
                   Division.wrongAnswer();
             }
        }
    }

Division.colorAnsZero = function(){//color ans zero
    if (Division.DivId == 'AnswerDivId0') {
       if (Division.finalArray[Division.counter][Division.index].level == 1 || Division.finalArray[Division.counter][Division.index].level == 4) 
         $("#ansspanId1").addClass("highlightZero");
       else if (Division.finalArray[Division.counter][Division.index].level == 2) 
         $("#ansspanId1,#ansspanId2").addClass("highlightZero");
    }
    else{
        if (Division.finalArray[Division.counter][Division.index].level == 1 || Division.finalArray[Division.counter][Division.index].level == 4) 
            $("#ansspanId01").addClass("highlightZero");
        else if (Division.finalArray[Division.counter][Division.index].level == 2) 
        $("#ansspanId01,#ansspanId02").addClass("highlightZero");
    }
}
Division.shownumberPad = function (clicked_id) {//numberPad after clicking on answerDiv
    Division.answerFlag = true;
    clearInterval(Division.noResponseTimer);
    if(clicked_id == 'AnswerDivId0')
    {
         Division.DivId = clicked_id;
        $("#AnswerDivId1").removeClass("blink_me");
        $("#AnswerDivId0").addClass("blink_me");
        $("AnswerDivId0").removeClass("answer");
        $("#AnswerDivId1").addClass("answer");
    }
    if(clicked_id == 'AnswerDivId1')
    {
        Division.DivId = clicked_id;
        $("#AnswerDivId0").removeClass("blink_me");
        $("#AnswerDivId1").addClass("blink_me");
        $("#AnswerDivId1").removeClass("answer");
        $("#AnswerDivId0").addClass("answer");
    }
    number = 0;
    Division.seconds=0;
    Division.startTimer();
}
Division.checkAnswer = function () { //right ans
    document.getElementById("playSound").pause();
    clearTimeout(Division.pointertimer);
    clearTimeout(Division.timerID);
    clearTimeout(Division.instructionTimer);
    clearInterval(Division.noResponseTimer);
    $('#' + Division.DivId).css('pointer-events', 'none');
    $('#' + Division.DivId).css('color','green');
    $("#" + Division.DivId).addClass('animated flash');
    document.getElementById("playSound").src = "sound/instruction/Buzzercorrect 1.mp3";
    document.getElementById("playSound").play();
    Division.starCount++; //inccrease score by 5
    Division.correctCounter++; //increase number of star by 1
    Division.ansCount++; //increase the attempt ques by 1
    number = 0;
    Division.quesFlag=true;
    Division.answerFlag = false;
    document.getElementById("score").innerHTML = Division.correctCounter + Division.hardcoded.score;
    if (Division.correctGreenColor) {
        clearTimeout(Division.correctGreenColor);
        Division.correctGreenColor = null;
    }
	document.getElementById("gamePage").style.backgroundImage=Utils.Path+"url('images/skin/gadget_green.png')";
    Division.correctGreenColor = setTimeout(function () {
        if ($("#" + Division.DivId).hasClass('blink_me')) {
            $("#" + Division.DivId).removeClass('blink_me');
        }
		for (var i = 0; i < 2; i++) {
            if ($("#AnswerDivId" + i).hasClass('answer')) {
                $("#AnswerDivId" + i).addClass('blink_me');
                $("#AnswerDivId" + i).removeClass('answer');
            }
        }
		 	document.getElementById("gamePage").style.backgroundImage=Utils.Path+"url('images/skin/gadget_yellow.png')";  $('.flash').removeClass("flash"); $('#' + Division.DivId).css('color','black'); Division.colorAnsZero();
    }, 500);
    Division.pointertimer = setTimeout(function(){$("#keyPadDiv").css('pointer-events', 'auto');},1900);
        
    Division.seconds=0;
    Division.startTimer();
    if (Division.timerID) {
        clearTimeout(Division.timerID);
        Division.timerID = null;
    }
    if(Division.ansCount == 2)
		   Division.timerID = setTimeout(Division.checkCounter, 2000);
}
Division.wrongAnswer = function () {//wrong ans
    document.getElementById("playSound").play();
    clearTimeout(Division.pointertimer);
	clearTimeout(Division.timerID);
    clearInterval(Division.noResponseTimer);
    clearTimeout(Division.instructionTimer);
    $('#' + Division.DivId).css('pointer-events', 'none');
    $('#' + Division.DivId).css('color','red');
    $("#" + Division.DivId).addClass('animated shake');
    document.getElementById("playSound").src = "sound/instruction/wrongSound.mp3";
    document.getElementById("playSound").play();
    number = 0;
	Division.ansCount++;
    Division.quesFlag = true;
    Division.answerFlag = false;
    document.getElementById("gamePage").style.backgroundImage=Utils.Path+"url('images/skin/gadget_red.png')";
	if (Division.wrongRedColorTimerId) {
        clearTimeout(Division.wrongRedColorTimerId);
        Division.wrongRedColorTimerId = null;
    }
    Division.wrongRedColorTimerId = setTimeout(function () { 
	    if ($("#" + Division.DivId).hasClass('blink_me')) 
            $("#" + Division.DivId).removeClass('blink_me');
        for (var i = 0; i < 2; i++) {
            if ($("#AnswerDivId" + i).hasClass('answer')) {
                $("#AnswerDivId" + i).addClass('blink_me');
                $("#AnswerDivId" + i).removeClass('answer');
            }
        }
	    document.getElementById("gamePage").style.backgroundImage=Utils.Path+"url('images/skin/gadget_yellow.png')";  $('#' + Division.DivId).css('color','black');
      $('.shake').removeClass('shake');}, 500);
      Division.pointertimer = setTimeout(function(){$("#keyPadDiv").css('pointer-events', 'auto');},1900);
      Division.seconds=0;
       Division.startTimer();
   if (Division.timerID) {
        clearTimeout(Division.timerID);
        Division.timerID = null;
    }
     if(Division.ansCount == 2)
          Division.timerID = setTimeout(Division.checkCounter, 2000);
}
Division.checkCounter = function () {//function to check attempt ques
    clearTimeout(Division.timerID);
    clearInterval(Division.noResponseTimer);
    clearTimeout(Division.instructionTimer);
    if(Division.quesFlag)
        Division.finalArray.splice(Division.counter, 1);
    else
        Division.counter++;
    if (Division.counter < Division.finalArray.length) 
            Division.nextQuestion();
    else {
        if (Division.finalArray.length != 0) {
            Division.counter = 0;
            Division.seconds=0
            document.getElementById("responseBoxDiv").style.display = "block";
            document.getElementById("soundlogo").style.pointerEvents = "none";
			document.getElementById("playSound").pause();
        }
        else 
            Division.gameOver();
	}
}
Division.nextQuestion = function () {//function two next ques after correct ans
    document.getElementById("playSound").pause();
    clearTimeout(Division.timerID);
    clearTimeout(Division.instructionTimer);     
     if(scoreFlag){
       if(Division.starCount==2)
             scoredMarks = 10;
        else if(Division.starCount==1)
              scoredMarks=5;
        else
              scoredMarks = 0;
      Division.scoreFunction();
   }
   number = 0;
  Division.ansCount = 0;
  Division.starCount =0;
  Division.answerFlag=false;
  Division.quesFlag = false;
  scoreFlag = false;
  if (Division.counter < Division.finalArray.length) {
      document.getElementById("questionDiv").innerHTML = " ";
      document.getElementById("score").innerHTML=" ";
      Division.equationDiv();
      switch (Division.finalArray[Division.counter][0].level) {
       case 1:
              Division.ansLevel = 10;
              Division.quesLevel = 1;
              Division.numberOfDigit=2;
              Division.setEquation(10, 1);
              break;
     case 2:
              Division.ansLevel = 100;
              Division.quesLevel = 1;
              Division.numberOfDigit=3;
              Division.setEquation(100, 1);
              break;
     case 3: Division.ansLevel = 10;
              Division.numberOfDigit = 1
              Division.setEquation(10,10);
              break;
     case 4: Division.ansLevel = 100;
              Division.quesLevel = 10;
              Division.numberOfDigit = 2;
              Division.setEquation(100, 10);
              break;
    default : 
                   Division.ansLevel = 1;
                   Division.quesLevel = 1;
                  Division.numberOfDigit = 1;
                  Division.setEquation(1, 1);
      }
   }
   Division.seconds=0;
   Division.startTimer();
}
function clearText() {//clear the text from answerDiv
  number = 0;
  clearInterval(Division.noResponseTimer);
  if (Division.finalArray[Division.counter][0].level == 1 || Division.finalArray[Division.counter][0].level == 4) 
      Division.numberOfDigit = 2;
  else if (Division.finalArray[Division.counter][0].level == 2) 
      Division.numberOfDigit = 3;
  else if (Division.finalArray[Division.counter][0].level  == 3) 
      Division.numberOfDigit = 1;
  else 
      Division.numberOfDigit = 1;
  document.getElementById(Division.DivId).innerHTML = " ";
  Division.seconds=0;
  Division.startTimer();
}
Division.gameOver = function () {
	clearTimeout(Division.timerID);
    clearInterval(Division.noResponseTimer);
    document.getElementById("playSound").pause();
    document.getElementById("endPage").style.display = "block";
    document.getElementById("widgeDiv").style.display = "none";
    document.getElementById("gamePage").style.display = "none";
    document.getElementById("responseBoxDiv").style.display = "none";
    document.getElementById("nextGameDiv").classList.add("blink-image");
    document.getElementById("gameOver").innerHTML = Division.hardcoded.gameOver;
    Division.createStars();
    Division.giveStars();
}
Division.createStars = function () {//create div for stars
    clearInterval(Division.noResponseTimer);
    var newImage, newDiv, i, numberOfStars = 5;
    for (i = 1; i <= Math.floor(numberOfStars); i++) {
        newDiv = document.createElement("div");
        newDiv.setAttribute("id", "starDiv" + i);
        newDiv.setAttribute("class", "nopadding stars col-xs-2 col-md-2 col-lg-2 col-sm-2");
        newImage = document.createElement("img");
        newImage.setAttribute("id", "starImg" + i);
        newImage.setAttribute("class", "img-responsive nopadding col-sm-12 col-lg-12 col-md-12 col-xs-12");
        newImage.setAttribute("src", Utils.Path + "images/skin/star1.png");
        $(newDiv).append(newImage);
        $("#starsDiv").append(newDiv);
    }
}
Division.giveStars = function () {//calculate stars
    clearInterval(Division.noResponseTimer);
    var i, numberOfStars = 0, temp;
    ans = Division.total_No_of_Questions / 5;
    temp = Division.correctCounter / ans;
    numberOfStars = Math.round(temp);
    temp = Math.round(temp);
    console.log(numberOfStars);
    console.log(temp);
    for (i = 1; i <= Math.floor(numberOfStars); i++)
        document.getElementById("starImg" + i).setAttribute("src", Utils.Path + "images/skin/star2.png");
    $("#starsDiv").css("visibility", "visible");
    if (numberOfStars != 0) {
        document.getElementById("playSound").src = Utils.Path + "sound/instruction/" + "Star" + numberOfStars + ".mp3";
        document.getElementById("playSound").play();
    }
    if (Utils.mobileDeviceFlag)
        Android.StudentCertification(Division.correctCounter,Division.total_No_of_Questions, "10");
}
Division.showNext = function () {
    document.getElementById("responseBoxDiv").style.display = "none";
    clearInterval(Division.noResponseTimer);
    clearTimeout(Division.timerID);
    if (Division.finalArray.length != 0) {
        Division.counter = 0;
		Division.nextQuestion();
    }
    else {
        Division.gameOver();
    }
    Division.seconds=0;
    Division.startTimer();
}
Division.startTimer = function () {//instruction plz ans the ques
    if (Division.noResponseTimer) {
        clearInterval(Division.noResponseTimer);
        Division.noResponseTimer = null;
        Division.seconds = 0;
    }
    Division.noResponseTimer = setInterval(function () {
        Division.seconds++;
        if (Division.seconds >= 7) {
            document.getElementById("playSound").src = Utils.Path + "sound/instruction/please_ans_the_ques.mp3";
            document.getElementById("playSound").play();
            clearInterval(Division.noResponseTimer);
            if (Division.timeOut) {
                clearTimeout(Division.timeOut);
                Division.timeOut = null;
            }
            Division.timeOut = setTimeout(function () {
                Division.seconds = 0;
                Division.startTimer();
            }, 2000);
        }
    }, 1000);
}
Division.goNext = function () {
    if (Utils.mobileDeviceFlag)
        Android.GotoNextGame();
}
Division.scoreFunction = function () {//display score
    console.log(resId, questionId, scoredMarks, totalMarks, level, startTime, label);
    if (Utils.mobileDeviceFlag) {
        Android.addScore(resId, questionId, scoredMarks, totalMarks, level, startTime, label);
    }
}

