

function Submit() {
 var message="";
 var count=0;
 var score;
 var problem_count=10;
 var ans = false;
 
 if (isAnyBlank()) 
 {
 		var question=confirm('You have not completed all questions yet. Are you sure you want to submit the test? ');
		if (!question){return false;}
 }
 
//check answers and calculate score
 for (i=0;i<4;i++){
   if (document.QuestionForm.T1[i].checked && document.QuestionForm.T1[i].value==document.QuestionForm.H1.value){ans=true; }
 }
 if (ans){
		count=count+1;
 }
 else {
	 document.QuestionForm.H1.style.display='block';
 }
 
 ans=false;
 for (i=0;i<4;i++){
   if (document.QuestionForm.T2[i].checked && document.QuestionForm.T2[i].value==document.QuestionForm.H2.value){ans=true; }
 }
 if (ans){
		count=count+1;
 }
 else {
	 document.QuestionForm.H2.style.display='block';
 }

 ans=false;
 for (i=0;i<4;i++){
   if (document.QuestionForm.T3[i].checked && document.QuestionForm.T3[i].value==document.QuestionForm.H3.value){ans=true; }
 }
 if (ans){
		count=count+1;
 }
  else {
	 document.QuestionForm.H3.style.display='block';
 }

 ans=false;
 for (i=0;i<4;i++){
   if (document.QuestionForm.T4[i].checked && document.QuestionForm.T4[i].value==document.QuestionForm.H4.value){ans=true; }
 }
 if (ans){
		count=count+1;
 }
 else {
	 document.QuestionForm.H4.style.display='block';
 }

 ans=false;
 for (i=0;i<4;i++){
   if (document.QuestionForm.T5[i].checked && document.QuestionForm.T5[i].value==document.QuestionForm.H5.value){ans=true; }
 }
 if (ans){
		count=count+1;
 }
  else {
	 document.QuestionForm.H5.style.display='block';
 }

 ans=false;
 for (i=0;i<4;i++){
   if (document.QuestionForm.T6[i].checked && document.QuestionForm.T6[i].value==document.QuestionForm.H6.value){ans=true; }
 }
 if (ans){
		count=count+1;
 }
  else {
	 document.QuestionForm.H6.style.display='block';
 }

 ans=false;
 for (i=0;i<4;i++){
   if (document.QuestionForm.T7[i].checked && document.QuestionForm.T7[i].value==document.QuestionForm.H7.value){ans=true; }
 }
 if (ans){
		count=count+1;
 }
  else {
	 document.QuestionForm.H7.style.display='block';
 }

 ans=false;
 for (i=0;i<4;i++){
   if (document.QuestionForm.T8[i].checked && document.QuestionForm.T8[i].value==document.QuestionForm.H8.value){ans=true; }
 }
 if (ans){
		count=count+1;
 }
  else {
	 document.QuestionForm.H8.style.display='block';
 }

 ans=false;
 for (i=0;i<4;i++){
   if (document.QuestionForm.T9[i].checked && document.QuestionForm.T9[i].value==document.QuestionForm.H9.value){ans=true; }
 }
 if (ans){
		count=count+1;
 }
  else {
	 document.QuestionForm.H9.style.display='block';
 }

 ans=false;
 for (i=0;i<4;i++){
   if (document.QuestionForm.T10[i].checked && document.QuestionForm.T10[i].value==document.QuestionForm.H10.value){ans=true; }
 }
 if (ans){
		count=count+1;
 }
  else {
	 document.QuestionForm.H10.style.display='block';
 }


  score=Math.ceil(count/problem_count * 100) ;
  document.QuestionForm.score.value=score;

//show score
  showScore (score);

//submit
  disableForm();
  QuestionForm.submit(); 
}

function disableForm(){
 //hide Submit button
  document.all.btn_submit.style.display = 'none';
    document.all.btn_exit.style.display = 'block';

  
  //disable input fields, need to figure out later ...

}

function isAnyBlank(){
  var isBlank=true;
  
	for (i=0;i<4;i++){
	   if (document.QuestionForm.T1[i].checked ){ isBlank =false;}	   
	}
	if (isBlank) {return true;}
	isBlank=true;
	for (i=0;i<4;i++){
	   if (document.QuestionForm.T2[i].checked){ isBlank =false;}		   
	}
	if (isBlank) {return true;}
	isBlank=true;
	for (i=0;i<4;i++){
	   if (document.QuestionForm.T3[i].checked ){ isBlank =false;}		   
	}
	if (isBlank) {return true;}
	isBlank=true;
	for (i=0;i<4;i++){
	   if (document.QuestionForm.T4[i].checked ){ isBlank =false;}	  
	}
	if (isBlank) {return true;}
	isBlank=true;
	for (i=0;i<4;i++){
	   if (document.QuestionForm.T5[i].checked ){ isBlank =false;}	   
	}
	if (isBlank) {return true;}
	isBlank=true;
	for (i=0;i<4;i++){
	   if (document.QuestionForm.T6[i].checked ){ isBlank =false;}	 
	}
	if (isBlank) {return true;}
	isBlank=true;
	for (i=0;i<4;i++){
	   if (document.QuestionForm.T7[i].checked ){ isBlank =false;}	   
	}
	if (isBlank) {return true;}
	isBlank=true;
	for (i=0;i<4;i++){
	   if (document.QuestionForm.T8[i].checked ){ isBlank =false;}		  
	}
	if (isBlank) {return true;}
	isBlank=true;
	for (i=0;i<4;i++){
	   if (document.QuestionForm.T9[i].checked ){ isBlank =false;}		  
	}
	if (isBlank) {return true;}
	isBlank=true;
	for (i=0;i<4;i++){
	   if (document.QuestionForm.T10[i].checked ){ isBlank =false;}	
	}
	if (isBlank) {return true;}
	else {return false;}
}



function showScore(score) {

	document.getElementById("score1").innerHTML=score ;
	document.getElementById("score2").innerHTML=score ;
	document.getElementById("score3").innerHTML=score ;
	document.getElementById("score4").innerHTML=score ;


if (score<80 ){
		document.all.msg_excellent.style.display = 'none';
		document.all.msg_good.style.display = 'none';
		document.all.msg_tryagain.style.display = 'block';
		document.all.msg_excellent2.style.display = 'none';
		document.all.msg_good2.style.display = 'none';
		document.all.msg_tryagain2.style.display = 'block';

 }
  if (score>=80 && score<100  ){
		document.all.msg_excellent.style.display = 'none';
		document.all.msg_good.style.display = 'block';
		document.all.msg_tryagain.style.display = 'none';
		document.all.msg_excellent2.style.display = 'none';
		document.all.msg_good2.style.display = 'block';
		document.all.msg_tryagain2.style.display = 'none';

    }
   if (score==100 ){
		document.all.msg_excellent.style.display = 'block';
		document.all.msg_good.style.display = 'none';
		document.all.msg_tryagain.style.display = 'none';
		document.all.msg_excellent2.style.display = 'block';
		document.all.msg_good2.style.display = 'none';
		document.all.msg_tryagain2.style.display = 'none';
    }


}


