function quizCompleted() {
	
		document.frmQuestion.hidCurrQuestion.value++;
		if (document.frmQuestion.hidCorrect.value==1) {
			document.frmQuestion.hidRight.value++;
		}
		
		
		
		var strDone = getCookie("QuizDone");
	
	
	    if (strDone != "Done") {
			setCookie ("QuizDone","Done",365*5);
			document.frmQuestion.hidCompleted.value=1;
			document.frmQuestion.hidAnswer.value = "";
			document.frmQuestion.sRedirectPath.value = document.frmQuestion.sRedirectPath.value + '?r=' + document.frmQuestion.hidRight.value + '&t=' + document.frmQuestion.hidTotal.value + '&m=' + document.frmQuestion.hidQuizMode.value;
			document.frmQuestion.action="/webapps/mail/sendmail.asp";
		} else {
			setCookie ("QuizDone","Done",365*5);
			document.frmQuestion.hidCompleted.value=1;
			document.frmQuestion.hidAnswer.value = "";
			document.frmQuestion.sRedirectPath.value = document.frmQuestion.sRedirectPath.value + '?r=' + document.frmQuestion.hidRight.value + '&t=' + document.frmQuestion.hidTotal.value + '&m=' + document.frmQuestion.hidQuizMode.value;
			document.frmQuestion.action="/webapps/mail/sendmail.asp";
		}
		

		document.frmQuestion.submit();
	
}

function getCookie(name) { // use: getCookie("name");
	var cookiedoc = document.cookie;
    var index = cookiedoc.indexOf(name + "=");
    if (index == -1) return null;
    index = cookiedoc.indexOf("=", index) + 1; // first character
    var endstr = cookiedoc.indexOf(";", index);
    if (endstr == -1) endstr = cookiedoc.length; // last character
    return unescape(cookiedoc.substring(index, endstr));
  }
function setCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function nextQuestion() {
	
		document.frmQuestion.hidCompleted.value=0;
		document.frmQuestion.hidCurrQuestion.value++;
		if (document.frmQuestion.hidCorrect.value==1) {
			document.frmQuestion.hidRight.value++;
		}
		document.frmQuestion.hidAnswer.value = "";
		document.frmQuestion.submit();
	
}


function questionCheck() {

	var radioButtonArr = getSelectedRadioValue(document.frmQuestion.radiogroup);
	if (radioButtonArr.length == 0) { 
		alert("Merci de sèlectionner une ou plusieurs rèponses");
		document.frmQuestion.hidAnswer.value = 0;
		return false
	} else {
		document.frmQuestion.hidAnswer.value = radioButtonArr;
		document.frmQuestion.hidAnsQuestion.value = document.frmQuestion.hidAnsQuestion.value + "|" + getSelectedRadio(document.frmQuestion.radiogroup);
		return true
	}
}


function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function


