var x = document.getElementById("myAudio"); 
var g;
var h;
var i;
var j;
var k;
var m;

function openCity(evt, cityName) {
    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    document.getElementById(cityName).style.display = "block";
    evt.currentTarget.className += " active";
}
var vid = document.getElementById("myVideo"); 

function playVid() { 
  vid.play(); 
} 

function pauseVid() { 
  vid.pause(); 
} 
function startQuiz(){
	$( "#btnStart" ).addClass( "hide-control" );
	$( "#imStart" ).addClass( "hide-control" );
	$( "#001" ).addClass( "hide-control" );
	pauseVid();
	document.getElementById('divQuestion1').style.display = "block";
	$('#tab1').addClass('active');
	$("#input001").focus();
}
function backHome()
{
	$( "#btnStart" ).addClass( "show-control" );
	$( "#001" ).addClass( "show-control" );
	vid.play();
}
  function checkAns(){
b = input001.value;

	if (b == "Although") {
		g = 1;
		playAudio("./audio/WellDone.mp3");
		input001.value = b;
		check001.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		playAudio("./audio/wrong.mp3");
		input001.value = b;
		check001.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
		
	}

  }
function checkAnsb(){
	c=input002.value;
	
	if (c == "As") {
		h = 1
		playAudio("./audio/WellDone.mp3");
		input002.value = c;
		check002.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		playAudio("./audio/wrong.mp3");
		input002.value = c;
		check002.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}
}
function checkAnsc(){
	d=input003.value;
	
	if (d == "Before") {
		i = 1;
		playAudio("./audio/WellDone.mp3");
		input003.value = d;
		check003.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		playAudio("./audio/wrong.mp3");
		input003.value = d;
		check003.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}
	
}

function checkAnsd(){
	e=input004.value;
	
	if (e == "As") {
		j = 1;
		playAudio("./audio/WellDone.mp3");
		input004.value = e;
		check004.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		playAudio("./audio/wrong.mp3");
		input004.value = e;
		check004.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}
	
}
function checkAnse(){
	f=input005.value;
	if (f == "Although") {
		k = 1;
		playAudio("./audio/WellDone.mp3");
		input005.value = f;
		check005.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		playAudio("./audio/wrong.mp3");
		input005.value = f;
		check005.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}
	
}
function checkAnsf(){
	
	l=input006.value;
	if (l == "Before") {
		m = 1;
		playAudio("./audio/WellDone.mp3");
		input006.value = l;
		check006.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		playAudio("./audio/wrong.mp3");
		input006.value = l;
		check006.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}
	
}


function nextQut(tabNo){
	no = tabNo + 1;
	
	//Hide Previous Tab:
	document.getElementById('divQuestion' + tabNo).style.display = "none";
    $('#tab' + tabNo).removeClass('active');
	
	//Display Next Tab:
	document.getElementById('divQuestion' + no).style.display = "block";
    $('#tab' + no).addClass('active');
	$( "#input00" + no).focus();
}

function prevQut(tabNo){
	no = tabNo - 1;
		
	//Display Previous Tab:
	document.getElementById('divQuestion' + no).style.display = "block";
    $('#tab' + no).addClass('active');
	$( "#input00" + no).focus();
	
	//Hide Actual Tab:
	document.getElementById('divQuestion' + tabNo).style.display = "none";
    $('#tab' + tabNo).removeClass('active');
}
function playAudio(audioPath){	 
	var audio = document.getElementById('audioPlay');
	var source = document.getElementById('audioSource');
	source.src = audioPath;
	audio.load(); 
	audio.play(); 
}

function submit001() {
	
	b = input001.value;
	c = input002.value;
	d = input003.value;
	e = input004.value;
	f = input005.value;
	l = input006.value;
		
	if (b == "Although") {
		g = 1;
		input001.value = b;
		check001.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		input001.value = b;
		check001.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}

	if (c == "As") {
		h = 1
		input002.value = c;
		check002.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		input002.value = c;
		check002.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}

	if (d == "Before") {
		i = 1;
		input003.value = d;
		check003.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		input003.value = d;
		check003.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}

	if (e == "As") {
		j = 1;
		input004.value = e;
		check004.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		input004.value = e;
		check004.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}

	if (f == "Although") {
		k = 1;
		input005.value = f;
		check005.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		input005.value = f;
		check005.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}
	if (l == "Before") {
		m = 1;
		input006.value = l;
		check006.innerHTML = "<text class=button002>" + "&#9989" + "</text>";
	} else {
		input006.value = l;
		check006.innerHTML = "<text class=button004>" + "&#9785" + "</text>";
	}
	
	if(g == 1 && h == 1 && i == 1 && j == 1 && k == 1 && m == 1)
	{		
		new Audio("./audio/welldone.mp3").play();		
		$( "#message001" ).removeClass( "hide-control" );
	}	
	$( "#btnSubmit" ).addClass( "hide-control" );
	$( "#btnLastQuBack" ).addClass( "hide-control" );	
	$( "#btnRetry" ).removeClass( "hide-control" );
}

function repeat001() {	
	location.reload();
}

$(document).ready(function() {
    $('[data-rel=popover]').popover({
      html: true,
      trigger: "click"
    });
});