ns4 = (document.layers) ? true:false 
ie4 = (document.all) ? true:false 
ng5 = (document.getElementById) ? true:false	

//select answer
function selectThis(name, val){
	
	var ANS = document.getElementById(name+"_ans").value*1;
	var Clik = document.getElementById(name+"_try").value*1; //last try result
	var Score = document.getElementById("Score").value*1;
	var count = document.getElementById(name+"_qty").value*1;
	
	//document.getElementById(name+"_try").value = Clik + 1; //increament No. of click record
	
	for (var i=1;i<=count;i++){
		document.getElementById(name+"_"+i+"note").style.display='none';
	}
	
	document.getElementById(name+"_"+val+"note").style.display='inline';
	
	
	/*	
	if (val == ANS || (count > 2 && Clik+1 == 2) || (count == 2 && Clik == 0)){//2 try maximum 
		
		for (var j=1;j<=count;j++){
			document.getElementById(name+"_"+j).disabled=true;
		}
		
		if (val == ANS){//update score
			document.getElementById("Score").value = Score + 1;
		}
		
		checkSubmit(); //check if all questions are answered
	}*/
	
	//update score
	if (val == ANS && Clik == 0){//1st time selected a good choice
		document.getElementById("Score").value = Score + 1;
		document.getElementById(name+"_try").value = 1;
	}
	else if (val != ANS && Clik == 1){//cancel last good choice
		document.getElementById("Score").value = Score - 1;
		document.getElementById(name+"_try").value = 0;
	}
}

//check if all questions are answered
/*function checkSubmit(){
	
	var Qty = document.getElementById("Q_qty").value*1;
	var Name = document.getElementById("Q_name").value;//E-Q
	
	for (var i=1; i<=Qty; i++){//loop all questions
		
		var loopCount = document.getElementById(Name+i+"_qty").value*1;//get no. of choices of this question
	
		for (var j=1; j<=loopCount; j++){//check each answer of this question is still open for selection
			
			if (! document.getElementById(Name+i+"_"+j).disabled)
				return false;
			
		}
		
	}
	
	var res = window.confirm("Soumettez votre test !");
	
	if (res)
		document.Questions.submit();
	
}
*/


function checkLength(val, thisField,string, nextField){
	if (val==1 && string.length > 4){
		document.getElementById(thisField).value = string.substring(0,4);
		alert("Seulement avoir quatre chiffres pour l'année!");
	}
	else if (val==1 && string.length == 4){
		document.getElementById(Student_Status_Year).value = string;
	}
}


function setfocus(a_field_id) {
        $(a_field_id).focus();
}

function checkError(form){
	
	if(form==1){//Formulaire_Reference
		var Student_Status = document.Formulaire_Reference.Student_Status.value;
		var Student_Status_Year = document.Formulaire_Reference.Student_Status_Year.value;
		
		if (Student_Status == ""){
			alert("Vous devez choisir si vous êtes un étudiant ou un diplômé!");
		}
		
		else if (Student_Status_Year == ""){
			alert("Veuillez entrez l'année!");
		}
		else
			document.Formulaire_Reference.submit();
		
	}
	
}
