function cal()
{
	var sum= 0;
	var ms="";
	var flag=0;
	var attempt = 0;


	for (i=0;i<document.test.Q1.length;i++)
	{
		if (document.test.Q1[i].checked ==false && document.test.Q2[i].checked ==false && document.test.Q3[i].checked ==false && document.test.Q4[i].checked ==false && document.test.Q5[i].checked ==false && document.test.Q6[i].checked ==false && document.test.Q7[i].checked ==false && document.test.Q8[i].checked ==false && document.test.Q9[i].checked ==false)
		{flag=1; }
		else {flag=0;
		break;}
	}


	if(flag==1)
	{document.test.textarea1.value = "Please select at least one option!"
	}

   else{

		for (i=0;i<document.test.Q1.length;i++)
		{
		if (document.test.Q1[i].checked && document.test.Q1[i].value=="b")
			{attempt= attempt + 1; sum=sum + 1;} 
			else if(document.test.Q1[i].checked && document.test.Q1[i].value=="a")
			{attempt= attempt + 1; var ms = ms + "\nQ1. Are you agree on that husband and wife arguments are usually won by the spouse who does the most talking?\n\tCorrect Ans: No \n\nExplanation -> No  I am not agree.\n";}

		if (document.test.Q2[i].checked && document.test.Q2[i].value=="b")
			{attempt= attempt + 1; sum=sum + 1;}
			else if (document.test.Q2[i].checked && document.test.Q2[i].value=="a")
			{attempt= attempt + 1; var ms = ms + "\nQ2. Men are not good at solving complicated problems than women?\n\tCorrect Ans: No \n\nExplanation -> Actually women's are emotionally strong.\n"}

		if (document.test.Q3[i].checked && document.test.Q3[i].value=="b")
			{attempt= attempt + 1; sum=sum + 1;}
			else if(document.test.Q3[i].checked && document.test.Q3[i].value=="a")
			{attempt= attempt + 1; var ms = ms + "\nQ3. Men are not more cheerful and optimistic than women?\n\tCorrect Ans: No \n\nExplanation -> Yes. Women's are naturally beautiful. But men's are also handsome.\n"}

		if (document.test.Q4[i].checked && document.test.Q4[i].value=="b")
			{attempt= attempt + 1; sum=sum + 1;}
			else if (document.test.Q4[i].checked && document.test.Q4[i].value=="a")
			{attempt= attempt + 1; var ms = ms + "\nQ4. Women get along on sleep more than men?\n\tCorrect Ans: No \n\nExplanation -> No. It is not true. It depends on type of work done by women or men.\n"}


		if (document.test.Q5[i].checked && document.test.Q5[i].value=="b")
			{attempt= attempt + 1; sum=sum + 1;}
			else if (document.test.Q5[i].checked && document.test.Q5[i].value=="a")
			{attempt= attempt + 1; var ms = ms + "\nQ5. When faced with a problem, a woman is more strong than men?\n\tCorrect Ans: No \n\nExplanation -> Actually men are facing problem.\n"}


		if (document.test.Q6[i].checked && document.test.Q6[i].value=="b")
			{attempt= attempt + 1; sum=sum + 1;}
			else if (document.test.Q6[i].checked && document.test.Q6[i].value=="a")
			{attempt= attempt + 1; var ms = ms + "\nQ6. Women are not fussier about their food?\n\n\tCorrect Ans: No \n\nExplanation -> No. Not like that. It depends on each person diet.\n"}


		if (document.test.Q7[i].checked && document.test.Q7[i].value=="a")
			{attempt= attempt + 1; sum=sum + 1;}
			else if (document.test.Q7[i].checked && document.test.Q7[i].value=="b")
			{attempt= attempt + 1; var ms = ms + "\nQ7. Women tend to be more self centered than men?\n\tYour Ans: No\tCorrect Ans: Yes \n\nExplanation -> We can not say women are self centered.\n"}

		if (document.test.Q8[i].checked && document.test.Q8[i].value=="b")
			{attempt= attempt + 1; sum=sum + 1;}
			else if (document.test.Q8[i].checked && document.test.Q8[i].value=="a")
			{attempt= attempt + 1; var ms = ms + "\nQ8.Men talk less about women than women talk about men?\n\tCorrect Ans: No \n\nExplanation -> No. It is not true. Men are also talking more about women.\n"}

		if (document.test.Q9[i].checked && document.test.Q9[i].value=="b")
			{attempt= attempt + 1; sum=sum + 1;}
			else if (document.test.Q9[i].checked && document.test.Q9[i].value=="a")
			{attempt= attempt + 1; var ms = ms + "\nQ9. Husbands understand their wives better than their wives understand them?\n\tCorrect Ans: No \n\nExplanation -> Sometimes husband understand his wives and sometimes wives understant her husband.\n"}

       }

  
  document.test.textarea1.value = ""
  var rs=""
  if (sum<=5)
	  { var rs="Your relationship is in critical stage."}
  if (sum>5 && sum<8) 
	  {var rs="You have good relation with your partner, but still you have to improve it."}
  if (sum>=8) 
	  {var rs="Congratulations! You are in love."}

  document.test.textarea1.value = "             Love and Relationship Test Result\n\n" + rs +"\n\nAttempted Questions : " + attempt + "\nCorrect Answers : " + sum + "\nTotal Questions : " + 10 + "\nYour Percentage : " + (sum/10)*100 + "%"+ "\n\n\nKeep scrolling to find out explanation for your wrong answers...\n" + ms

  }
	
}

