function getSelectedButton(buttonGroup){
	for(var i=0;i<buttonGroup.length;i++){
		if(buttonGroup[i].checked){
			return i;
		}
	}
	return 9999;
}

function validate(){
	var Form = document.forms[0];
	var valeur = "";
	var dosub = true;
	var tablo_erreurs = new Array();
	var id_tablo = 0;
	for(i=1;i<=1;i++){
		var valeur = eval('getSelectedButton(document.form1.q' + i + ')');
		if( valeur == "9999" ){
			tablo_erreurs[id_tablo] = i;
			id_tablo ++;
			dosub = false;
		}		
	}
	if( tablo_erreurs.length > 0 ){
		var erreur_string = "Vous n'avez pas r\xE9pondu aux questions suivantes : \n";
		for(j=0;j<tablo_erreurs.length;j++){
			erreur_string += "Question " + tablo_erreurs[j] + "\n";
		}
		alert(erreur_string);
	}
	
	if( dosub == true ){
		calcul();
	}	
}

function get_radio_value(quelGroup) {
for (var i=0; i < document.form1[quelGroup].length; i++)
   {
   if (document.form1[quelGroup][i].checked) {
      var rad_val = document.form1[quelGroup][i].value;
      return rad_val;
      }
   }
}

function calcul() {
	var total = 0;
	
	if (get_radio_value('q1') == "a") {
		total += 5;
	}
	if (get_radio_value('q2') == "e") {
		total += 5;
	}
	if (get_radio_value('q3') == "e") {
		total += 5;
	}
	if (get_radio_value('q4') == "a") {
		total += 5;
	}
	if (get_radio_value('q5') == "b") {
		total += 5;
	}
	if (get_radio_value('q6') == "c") {
		total += 5;
	}
	if (get_radio_value('q7') == "c") {
		total += 5;
	}
	if (get_radio_value('q8') == "c") {
		total += 5;
	}
	if (get_radio_value('q9') == "b") {
		total += 5;
	}
	if (get_radio_value('q10') == "c") {
		total += 5;
	}
	if (get_radio_value('q11') == "a") {
		total += 5;
	}
	if (get_radio_value('q12') == "d") {
		total += 5;
	}
	if (get_radio_value('q13') == "c") {
		total += 5;
	}

	leURLActuel = document.URL;
	if (leURLActuel.indexOf("/fr") != -1) {
		var langue = "fr";
	} else {
		var langue = "en";
	}
	document.location.href = "/" + langue + "/services/divers_test_resultat.html?resultat=" + total;
}
