var no,count,total;
var myword="";
var curr,flag;
var score=0;

function start()
{
 currN=0;
 flag=0;
 console.log('started');
 no=count=score=0;
 total=21;
 document.getElementById('score').innerHTML="Score : "+score;
 next1();
}

function next1()
{
 
for(var v1=1;v1<=10;v1++) document.getElementById('n'+v1).disabled=false;
	for(var v=1;v<11;v++)
    {
	 document.getElementById('n'+v).disabled=false;
	 document.getElementById('n'+v).style.color='black';
	}
   
 flag=0;
   document.getElementById('iii').src="images/invisible.png";
   document.getElementById('skip').style.color="black";
   document.getElementById('skip').innerHTML="Skip";
 no++;
 if(no>=total-1)
  document.getElementById('skip').innerHTML="Finish";
 if(no==total)
 {
  if(score>100)
  alert("Congratulations! You are done with this task :) :) \n\nSCORE : "+score+"\n\nKindly continue to next game Calculations.");
  else
  alert("Congratulations! You are done with this task :) :) \n\nSCORE : "+score+"\n\nKindly continue to next game Calculations. You can also try again to improve your score.");
  no--;
  for(var v1=1;v1<=10;v1++) document.getElementById('n'+v1).disabled=true;
  document.getElementById('skip').innerHTML="Finish";
 }
 else
 {
  document.getElementById('q').innerHTML = "Question : "+no+"/20";
  var tem=Math.floor(Math.random()*8);
  currN = (currN + tem + 1)%20;
  document.getElementById('ii').src = "images/maths/"+currN+".jpg";
  console.log(Math.floor(currN/2)+1);
 }
}

function check( param )
{
 if(Math.floor(currN/2)+1==param)
 {
  if(flag==0)
  {
   score = score + 10;
   document.getElementById('n'+param).style.color='green';
   for(var v=1;v<11;v++)
    document.getElementById('n'+v).disabled=true;
   flag=1;
  }
   document.getElementById('score').innerHTML="Score : "+score;
   document.getElementById('skip').style.color="green";
   document.getElementById('skip').innerHTML="Next";
   document.getElementById('iii').style.visibility="visible";
   document.getElementById('iii').src="images/correct.png";
   for(var v1=1;v1<=10;v1++) document.getElementById('n'+v1).disabled=true;
 }
 else
 {
   document.getElementById('n'+param).disabled=true;
   document.getElementById('iii').style.visibility="visible";
   document.getElementById('iii').src="images/incorrect.png";
   document.getElementById('skip').style.color="black";
   document.getElementById('skip').innerHTML="Skip";
   score = score - 1;
   document.getElementById('score').innerHTML="Score : "+score;
 }
}

function clr()
{
 score = score - 1 ;
 document.getElementById('score').innerHTML="Score : "+score;
 myword="";
}

function exit()
{
 if(confirm("Do you really want to exit?"))
  window.location="index.html";
}

function restart()
{
if(confirm("Do you really want to restart game?"))
 {
  start();
 }
}

function skip()
{
 next1();
}