function verifForm(kelForm){
	message = "";
	if(kelForm['REPONSE']){
		//QCM
		//alert('QCM');
		i=0;
		nbCheck=0;
		while(kelForm['REPONSE'][i]){
			if(kelForm['REPONSE'][i].checked) nbCheck++;	
			i++;	
		}
		if(nbCheck==0){
			message += "\n- cochez au moins une proposition";
		}
	}else{
		//Réponse libres
		//alert('Réponse libres');
		i=0;
		nbCheck=0;
		while(kelForm['TABREPONSE[]'][i]){
			if(kelForm['TABREPONSE[]'][i].value.replace(/\s+/g,"")) nbCheck++;	
			i++;	
		}
		if(nbCheck==0){
			message += "\n- Remplissez au moins une proposition";
		}
	}
	
	if(message){
		alert('Formulaire incomplet :'+message);
		return false;
	}else{
		return true;
	}
}


function recupIdProps(kelChamps){
	listIDPROPS = "";
	tabIDPROPS = document.getElementById('formSondage').IDPROPS.value.split(',');
	for(i=0;i<tabIDPROPS.length;i++){
		if(i!=kelChamps){
			if(listIDPROPS!="") listIDPROPS += ',';
			listIDPROPS += tabIDPROPS[i];
		}
	}	
	return listIDPROPS;
}

tempo = "";
function refreshSemiAutoProps(e,koi,kelChamps,idSondage){
	//kelForm = $('#formPrincipal');
	touche= ($.browser.msie) ? e.keyCode : e.which ;
	if(touche == "40"){
		if($('#resultat0').length) $('#resultat0').focus();
	}else{
		$.post("sa_sondage.php", { RECHERCHE : koi, IDPROPS : recupIdProps(kelChamps), KELCHAMPS : kelChamps, IDSONDAGE : idSondage }, function(text){
			if(text){
				$('#semiAutoProp'+kelChamps).html(text);
				$('#semiAutoProp'+kelChamps).show();
			}else{
				$('DIV.semiauto').hide();
			}
		});
	}
}

function selectSemiAutoProps(e,kelPos,kelChamps){
	clearTimeout(tempo); 
	touche= ($.browser.msie) ? e.keyCode : e.which ;
	//alert(touche);
	newPos = "";
	if(touche == "38"){
		newPos = kelPos - 1;
	}
	if(touche == "40"){
		newPos = kelPos + 1;
	}
	//alert(newPos);	
	if(newPos !== ""){
		if(newPos == "-1"){
			$('#REPONSE'+kelChamps).focus();
		}
		if($('#resultat'+newPos).length){
			$('#resultat'+newPos).focus();
		}
	}else{
		$('#resultat'+newPos).focus();
	}
}
	
function selectProp(koi,kelProp,kelChamps){
	//document.location.href=racine+"/catalogue/index.php?idProd="+koi;
	$('#REPONSE'+kelChamps).val(kelProp);
	clearTimeout(tempo); 
	$('DIV.semiauto').hide();
	if(typeof(window['modifProps']) != 'undefined') modifProps('ajout',koi,kelChamps);
}

function masqueSemiAutoProps(){
	$('DIV.semiauto').html();
	$('DIV.semiauto').hide();
}

function modifProps(kelModif,kelIdProp,kelChamps){
	kelForm = document.getElementById('formSondage');
	idProps = "";
	tabProps = kelForm.IDPROPS.value.split(',');
	if(kelModif == 'ajout'){
		i=0;
		while(kelForm['TABREPONSE[]'][i]){
			if(i>0) idProps += ',';
			if(kelChamps == i){
				idProps += kelIdProp;
			}else{
				idProps += (tabProps[i]) ? tabProps[i] : '' ;
			}
			i++;	
		}
		kelForm.IDPROPS.value = idProps;
	}
}
