var qnum=5;
var score=0;
var could_have_scored=0;
var total_points=15;
var questions_tried=0;
var score_string="";


columns1 = new Array(4);      
columns2 = new Array(4);   
columns3 = new Array(4);
columns4 = new Array(4);
columns5 = new Array(4);


tries = new Array();
tries[0] = columns1;
tries[1] = columns2;
tries[2] = columns3;
tries[3] = columns4;
tries[4] = columns5;

for (i=0; i < qnum; i++)
for (j=0; j < 4; j++) { tries[i][j] = 0; } 

var answers_array=new Array()

//<p align=\"right\"><i>- Sandeha Nivarani chapter 11</i> </p>

answers_array[0]="<p align=\"justify\">Swami said &ldquo;Good Boy! Always speak the truth!&rdquo; He waved His hand, materialized a gold chain and put it around the boy&rsquo;s neck. &ldquo;Speak the truth always, and I shall give you everything you want!&rdquo; He assured him. Imagine what an impact it would have made on the boy and the others watching the whole scene. Needless to say, only the Divine Mother Sai can do this in such a beautiful and loving way! <br>  <br><a href=\"http://media.radiosai.org/Journals/Vol_02/11June01/02_Cover_Story/cover_story.htm\">Click here: Cover Story: God's Own Children - June 1st 2004</a></p>";

answers_array[1]="<p align=\"justify\">Dutt continued: &ldquo;Swami asked me: &lsquo;Tell me! Do you believe in Swami or not?&rsquo; (By now it had become a choice between wanting to believe in Swami or not). He then gave me an undeniable and incredible proof of His Omnipresence, of which even my own mother did not know. He told me how, utilizing my pocket money, I had gone to a Hindi movie, instead of attending school. He even told me the name of the film I had gone to, the name of the friend with whom I had gone, a Sarabjit Singh and even the amount of money I spent on '<em>samosas'</em> during the interval, which was incidentally Rs. 10/? This revelation jolted me into the realization of my aimless derogatory living and opened new vistas of a happy, joyful life, in which I have made and am making sincere efforts to transform myself.&rdquo; <br>  <br><a href=\"http://media.radiosai.org/Journals/Vol_02/11June01/05_Moments_Memories/memories.htm\">Click here: Moments Memories and Miracles: The Glimpse He Granted - June 1st 2004</a></p>";

answers_array[2]="<p align=\"justify\">It faced a blank wall. The man asked the nurse what could have compelled his deceased roommate who had described such wonderful things outside this window. The nurse responded that the man was blind and could not even see the wall. She said, &quot;Perhaps he just wanted to encourage you.&quot; <br>  <br>  <em>Epilogue...<strong></strong></em><br>  There is tremendous happiness in making others happy, despite our own situations. Shared grief is half the sorrow, but happiness when shared, is doubled. If you want to feel rich, just count all of the things you have that money can't buy. <br>  <br>  <a href=\"http://media.radiosai.org/Journals/Vol_02/12June15/04_Kindle_Your_Spirit/spirit.htm\">Click here: Kindle Your Spirit: A Room with a View - June 15th 2004</a></p>";

answers_array[3]="<p align=\"justify\">Prof. G.Venkataraman reminds us that Swami also says that <em>Sparshan</em> removes <em>Karma</em> [consequences of past actions], and <em>Sambhashan</em> removes <em>Sankatas </em>[difficulties]. <br>  <br><em>&ldquo;Sparshan</em> , for most of us, means <em>Pada Namaskar</em>. When Swami brought the curtain down on <em>Pada Namaskar</em> some years ago, basically He asked, &ldquo;Who is giving <em>Namaskar</em> to whom? You and I are One; so where is the question of My giving <em>Namaskar</em> to you?&rdquo; <br><br>That remark sends a strong message: &ldquo;Snap out of it and go beyond <em>Dvaitam</em> or duality to <em>Advaitam</em> or the non-dual state.&rdquo; We don&rsquo;t want to do that and wish to cling to the dual state but the Master would have none of that. So when we say denial, it simply means we want to be in the KG while our dear Lord and Master wants us to move on to a higher class. <br><br>Swami has also said: &ldquo;Do you think you can get Liberation, just by touching My Feet? If it were so easy then every fly that sits on My Feet would get liberated!&rdquo; <br><br><a href=\"http://media.radiosai.org/Journals/Vol_02/11June01/03_Spiritual_Blossoms/02_Reflections/reflection.htm\">Click here: Reflections: True Meaning of Darshan Sparshan and Sambarshan - June 1st 2004</a></p>";

answers_array[4]="<p align=\"justify\">The student continued: &ldquo;Swami turned His palm upwards and showed me a pair of fruits. He asked, &ldquo;What is this?&rdquo; I replied, &ldquo;Swami, they are plums.&rdquo; Swami gave His sweet smile and said, &ldquo;Do plums grow on creepers?&rdquo; <br>  <br>Swami instructed the students to board the bus and Swami graciously joined us. As we started to move, He put the &ldquo; Plum&rdquo; into the mouth of one of the boys and asked, &ldquo;How does it taste?&rdquo; he replied, &ldquo;Like chocolate and no seed!&rdquo; <br><br><a href=\"http://media.radiosai.org/Journals/Vol_02/12June15/05_Moments_Memories/memories.htm\">Click here: Moments Memories and Miracles: The Creator - June 15th 2004</a></p>";

//<img src=\"images/14_TestYourSQ/H2H/01.jpg\" alt='image' width='175' height='250' border='1' align='right'>
var answer_images=new Array()
answer_images[0]="";
answer_images[1]="";
answer_images[2]="";
answer_images[3]="";
answer_images[4]="";


var right_answers=new Array()
right_answers[0]="3";
right_answers[1]="1";
right_answers[2]="2";
right_answers[3]="1";
right_answers[4]="4";

var lock=new Array()

lock[0]="0";
lock[1]="0";
lock[2]="0";
lock[3]="0";
lock[4]="0";


var first_attempt= new Array();
first_attempt[0]="Congrats! You have got it right in the very first attempt! You get 3 Points";
first_attempt[1]="Great! First attempt and right! You get 3 Points";
first_attempt[2]="You've got it in the very first attempt!! You get 3 Points";
first_attempt[3]="Well done! First click and right answer! You get 3 Points";
first_attempt[4]="You got it! Great going! You get 3 Points";
first_attempt[5]="Correct! You make it so easy! You get 3 Points";
first_attempt[6]="That's right! You are doing well! You get 3 Points";
first_attempt[7]="Absolutely correct! Well done! You get 3 Points";

var second_attempt= new Array();
second_attempt[0]="Good! You have got it right now! You get 2 Points";
second_attempt[1]="Yes! You got it now! You get 2 Points";
second_attempt[2]="That's right! Now you got it! You get 2 Points";
second_attempt[3]="Right! That's the answer! You get 2 Points";
second_attempt[4]="Yes! Now you have got it! You get 2 Points";
second_attempt[5]="That's right! Good try! You get 2 Points";
second_attempt[6]="Good! Thats the correct answer! You get 2 Points";
second_attempt[7]="You have now answered correctly! Well done! You get 2 Points";


var third_attempt= new Array();
third_attempt[0]="Finally! You got it right! You get 1 Point";
third_attempt[1]="Now you've got it! You get 1 Point";
third_attempt[2]="That's right! You get 1 Point";
third_attempt[3]="Correct! You have got it right now! You get 1 Point";
third_attempt[4]="Yes! That's the answer we were looking for! You get 1 Point";
third_attempt[5]="Finally! You guessed it right! You get 1 Point";
third_attempt[6]="Nice try! You did get it finally! You get 1 Point";
third_attempt[7]="Yes! Nice guess! You get 1 Point";

var final_score_messages= new Array();
final_score_messages[0]=" <strong>Very Good</strong>, Keep it up!";
final_score_messages[1]=" <strong>Good</strong>, you have scored well.";
final_score_messages[2]=" Good attempt. Thank you very much for trying the quiz";
final_score_messages[3]=" Good Try. Thank you very much for trying the quiz";

var right_textanswers=new Array();
var your_answers=new Array();
var your_textanswers=new Array();



function set_string(){
	
	if (questions_tried == 1)
		score_string="You get "+score+" out of "+could_have_scored+" for the 1st question.";
		
	else
		score_string="You get "+score+" out of "+could_have_scored+" for the "+questions_tried+" questions you attempted.";
}

function check(i){
    
	var answerarea="answer_area"+i;
	var sum =0;
	var random_num = Math.round(7*Math.random());
	
	//check if tries are allowed
	for(a=0;a<4;a++){sum += tries[i][a];}
	if (sum>=3){ 
		var radiobuttonname="l"+i+"_"+lock[i];
		document.getElementById(radiobuttonname).checked = true;
		return true;
		}
	
	//if tries are allowed
	sum = 0;
	document.getElementById(answerarea).innerHTML="";
	document.getElementById("score_area").innerHTML="";
	
	for(a=0;a<4;a++){
			var radiobuttonname="l"+i+"_"+a;
			var labelname="label"+i+"_"+a;
			if(document.getElementById(radiobuttonname).checked){
				your_answers[i]=document.getElementById(radiobuttonname).value;
				your_textanswers[i]=document.getElementById(labelname).innerHTML;
				tries[i][a]=1;
				lock[i]=a;
				}
			if(document.getElementById(radiobuttonname).value==right_answers[i]){
				right_textanswers[i]=document.getElementById(labelname).innerHTML;
				}
			sum += tries[i][a];	
		}
		if(your_answers[i]==right_answers[i]){
			var chancestogo=4-sum;
			if(chancestogo==3){
			score+=3;
			could_have_scored+=3;
			questions_tried+=1;
			set_string();
			document.getElementById(answerarea).innerHTML += "<table width='100%'  style='background-color:#CCFFCC;border:0;font-size:10pt;font-family:Arial' cellpadding='5'><tr><td width='78%'><font color='#000088'><b>"+ first_attempt[random_num] +"</b></font><br><br><font color='green'><b>Correct Answer : </b></font><font color='brown'>"+your_textanswers[i] + "</font><p align='justify'> <font color='#000088'>" + answers_array[i]+ " <br> <strong>SCORE:</strong> "+score_string+"</font></p></td><td width='22%'>"+ answer_images[i]+"</td></tr></table>";
			
			
			}
			if(chancestogo==2){
			score+=2;
			could_have_scored+=3;
			questions_tried+=1;
			set_string();
			document.getElementById(answerarea).innerHTML += "<table width='100%'  style='background-color:#CCFFCC;border:0;font-size:10pt;font-family:Arial' cellpadding='5'><tr><td width='78%'><font color='#000088'><b>"+ second_attempt[random_num] +"</b></font><br><br><font color='green'><b>Correct Answer : </b></font><font color='brown'>"+your_textanswers[i] + "</font><p align='justify'> <font color='#000088'>" + answers_array[i]+ " <br> <strong>SCORE:</strong> "+score_string+"</font></p></td><td width='22%'>"+ answer_images[i]+"</td></tr></table>";
			
			
			}
			if(chancestogo==1){
			score+=1;
			could_have_scored+=3;
			questions_tried+=1;
			set_string();
			document.getElementById(answerarea).innerHTML += "<table width='100%'  style='background-color:#CCFFCC;border:0;font-size:10pt;font-family:Arial' cellpadding='5'><tr><td width='78%'><font color='#000088'><b>"+ third_attempt[random_num] +"</b></font><br><br><font color='green'><b>Correct Answer : </b></font><font color='brown'>"+your_textanswers[i] + "</font><p align='justify'> <font color='#000088'>" + answers_array[i]+ " <br> <strong>SCORE:</strong>"+score_string+"</font></p></td><td width='22%'>"+ answer_images[i]+"</td></tr></table>";
			
			
			}
			
			
			for (j=0; j < 4; j++) { tries[i][j] = 1; }
			 
		}
		if(your_answers[i]!=right_answers[i]){
			if(sum >=3){
			could_have_scored+=3;
			questions_tried+=1;
			set_string();
			document.getElementById(answerarea).innerHTML += "<table width='100%'  style='background-color:#FFCCCC;border:0;font-size:10pt;font-family:Arial' cellpadding='5'><tr><td width='78%'><font color='brown'><b>Wrong... <br><br>Your Answer : </b>"+your_textanswers[i] +"</font><br><font color='green'><b>Correct Answer : </b></font><font color='brown'>"+right_textanswers[i] + "</font><p align='justify'> <font color='#000088'>" + answers_array[i]+ " <br> <strong>SCORE:</strong>"+score_string+"</font></p></td><td width='22%'>"+ answer_images[i]+"</td></tr></table>";
			
			
			}
			else{
					var chancestogo=3-sum;
					if(chancestogo==1){
					document.getElementById(answerarea).innerHTML+="<p><table width='100%' style='background-color:#FFCCCC;border:1 black;font-size:10pt;font-family:Arial' cellpadding='5'><tr><td style='color:brown'><b>Sorry... this is not the right answer.<br>You have just one more chance to go....</b></td></tr></table>";
					
					}
					else{
					document.getElementById(answerarea).innerHTML+="<p><table width='100%' style='background-color:#FFCCCC;border:1 black;font-size:10pt;font-family:Arial' cellpadding='5'><tr><td style='color:brown'><b>Sorry... this is not the right answer.<br>You have two more chances to go....</b></td></tr></table>";
					
					}
				}
		}
		
	document.getElementById(answerarea).style.display="inline";
	if (questions_tried == qnum)
	{ if(score >= 12)
		{
			document.getElementById("score_area").innerHTML += "<table width='100%'  style='background-color:#FFCC99;border:0;font-size:10pt;font-family:Arial' cellpadding='5'><tr><td width='100%'><p align='justify'> <font color='#000088'> <br> <strong>SCORE:</strong> [ "+score+" of "+total_points+" ]"+final_score_messages[0]+"</font></p> </td></tr></table>";
		}
		if(score >= 8 && score <12)
		{
			document.getElementById("score_area").innerHTML += "<table width='100%'  style='background-color:#FFCC99;border:0;font-size:10pt;font-family:Arial' cellpadding='5'><tr><td width='100%'><p align='justify'> <font color='#000088'> <br> <strong>SCORE:</strong> [ "+score+" of "+total_points+" ]"+final_score_messages[1]+"</font></p> </td></tr></table>";
		}
		if(score >=4 && score< 8)
		{
			document.getElementById("score_area").innerHTML += "<table width='100%'  style='background-color:#FFCC99;border:0;font-size:10pt;font-family:Arial' cellpadding='5'><tr><td width='100%'><p align='justify'> <font color='#000088'> <br> <strong>SCORE:</strong> [ "+score+" of "+total_points+" ]"+final_score_messages[2]+"</font></p> </td></tr></table>";
		}
		if(score <4)
		{
			document.getElementById("score_area").innerHTML += "<table width='100%'  style='background-color:#FFCC99;border:0;font-size:10pt;font-family:Arial' cellpadding='5'><tr><td width='100%'><p align='justify'> <font color='#000088'> <strong>SCORE:</strong> [ "+score+" of "+total_points+" ]"+final_score_messages[3]+"</font></p> </td></tr></table>";
		}
			
	document.getElementById("score_area").style.display="inline";
	}
	
}


function reset_all(){
	document.question_form.reset();
	for (i=0; i<=qnum; i++){
		var answerarea="answer_area"+i;
		for (j=0; j < 4; j++) { tries[i][j] = 0; } 
		document.getElementById(answerarea).innerHTML="";
		document.getElementById(answerarea).style.display="none";
		document.getElementById("score_area").innerHTML="";
		document.getElementById("score_area").style.display="none";
		document.location.href = "quiz.htm#";
		score=0;
		questions_tried=0;
		could_have_scored=0;
		score_string="";
	}
	
}
