function posa(quin){
	for(i=2;i<=4;i++){
		if(i==quin){
			document.getElementById('paso'+i).style.display="block";
		} else {
			document.getElementById('paso'+i).style.display="none";
		}
	}
}
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function resuelve_cuestionario(idioma){
	respostes1 = new Array(0, 1, 4, 3, 4, 4, 2, 1, 1, 4, 2, 2, 4, 3, 4, 3, 4, 2);
	respostes2 = new Array(0, 1, 4, 4, 4, 4, 2, 1, 1, 4, 2, 2, 4, 3, 4, 3, 4, 2);
	for(i=1;i<=17;i++){
		comprovapregunta = false;
		nposrespostes = eval("document.form_cuestionario.pregunta"+i+".length");
		for(j=0;j<document.form_cuestionario["pregunta"+i].length;j++){
			if(eval("document.form_cuestionario.pregunta"+i+"["+j+"].checked")==true){
				comprovapregunta = true;
			}
		}
		if(comprovapregunta==false){
			if(idioma==1){
				alert("Tienes que responder la pregunta nº "+i);
			} else {
				alert("Please answer question number "+i);	
			}
			document.form_cuestionario["pregunta"+i][0].focus();
			return;
		}
	//		eval("document.form_cuestionario.pregunta"+i+"["+j+"].checked")==true)			
	}
	var error;
	error = 0;
	for(i=1;i<=17;i++){
		//alert(eval("document.form_cuestionario.pregunta"+i+"[0].checked"));
//		alert("pregunta "+i+" amb resposta:"+respostes1[i]+" o "+respostes2[i]);
		for(j=0;j<document.form_cuestionario["pregunta"+i].length;j++){
			if(eval("document.form_cuestionario.pregunta"+i+"["+j+"].checked")==true){
				if((eval("document.form_cuestionario.pregunta"+i+"["+j+"].value") == respostes1[i])||(eval("document.form_cuestionario.pregunta"+i+"["+j+"].value") == respostes2[i])){
//					alert("la pregunta "+i+" està malament");
					error = 1;
				}
			} 	
		}
	}
	document.form_cuestionario.valido.value = error;
	//alert(document.form_cuestionario.valido.value);
	posa(3);
//	alert(document.form_cuestionario.valido.value);
}
