var txt=new Array();
var compt_txt=0;

function nouitem(text)
{
	txt[compt_txt]=text;
	compt_txt++;
}
function neteja(num)
{
	for(i=0;i<num;i++)
	{
		document.forms[0].elements[i].value="";
	}
}
function solinptxt(num)
{	
	if (compt_txt==num)
	{
		correctes=0;
		for(i=0;i<num;i++)
		{
			if (document.forms[0].elements[i].value==txt[i])
				correctes++;

		}
		if (correctes==num) alert("Felicitats! Has encertat totes les preguntes.");
		else
		{
			if (correctes==0) mis="No has encertat cap pregunta.";
			else
			{
				mis="Has encertat " + correctes 
				if (num>1) mis=mis+" de les " + num +" preguntes.";
				else  mis="No has encertat la pregunta.";
		
			}
		alert(mis +"\nTorna a intentar-ho");
		}
	
	}
}
function fsol(num)
{
	valor="";
	resposta_unica=true;
	for (i=1;i<num+1;i++)
	{
		ref=eval("document.forms[0].p"+i);
		j=0;
		while (ref[j])
		{
		if (ref[j].checked==true) valor=valor+ref[j].value;
		j++;
		}
		if (valor.length<i) valor=valor+" ";
		else if (valor.length>i) resposta_unica=false;		
	}
	if (resposta_unica==false) alert("Només hi ha una resposta vŕlida per a cada pregunta.\nTorna a intentar-ho");
	else
	{
		if (valor==solucio) alert("Felicitats! Has encertat totes les preguntes.");
		else
		{
			compta=0;
			for(i=0;i<num;i++)
			{
				if (valor.substring(i,i+1)==solucio.substring(i,i+1)) compta++;
			}
			if (compta==0) mis="No has encertat cap pregunta.";
			else
			{
				mis="Has encertat " + compta 
				if (num>1) mis=mis+" de les " + num +" preguntes.";
				else  mis="No has encertat la pregunta.";
		
			}
		alert(mis +"\nTorna a intentar-ho");
		}
	}


}

function surt()
{
	window.close();	
}

