//script pour les persos ayant acquis un niveau
function init(arg,tabd)
{
	var flag1=0
	var flag2=0
	var flag3=0
	var flag4=0
	var flag5=0
	var flag6=0
	Tab = new Array(arg);
	for(i=0;i<arg;i++)
	{
		if (tabd[i])
			Tab[i] = true;
		else
			Tab[i] = false;
	}
}


function plus(arg)
{
	switch (arg)
	{
		case 1:document.f1.forc.value=1+parseInt(document.f1.forc.value);
			flag1+=1;
			document.f1.cpt.value=parseInt(document.f1.cpt.value)-1;break;
		case 2:document.f1.dex.value=1+parseInt(document.f1.dex.value);
			flag2+=1;
			document.f1.cpt.value=parseInt(document.f1.cpt.value)-1;break;
		case 3:document.f1.con.value=1+parseInt(document.f1.con.value);
			flag3+=1;
			document.f1.cpt.value=parseInt(document.f1.cpt.value)-1;break;
		case 4:document.f1.inte.value=1+parseInt(document.f1.inte.value);
			flag4+=1;
			document.f1.cpt.value=parseInt(document.f1.cpt.value)-1;break;
		case 5:document.f1.sag.value=1+parseInt(document.f1.sag.value);
			flag5+=1;
			document.f1.cpt.value=parseInt(document.f1.cpt.value)-1;break;
		case 6:document.f1.cha.value=1+parseInt(document.f1.cha.value);
			flag6+=1;
			document.f1.cpt.value=parseInt(document.f1.cpt.value)-1;break;
	}
	if (document.f1.cpt.value==0)
	{
		document.f1.action="validcara.php5";
		document.f1.submit();
	}
}
/*FONCTON PERMETTANT DE REDUIRE LES POINTS DE CARAC MAIS NON UTILISE CAR NON CONFORME AUX REGLES
function moins(arg)
{
 switch (arg)
 {
  case 1:if (flag1)
       {document.f1.forc.value=parseInt(document.f1.forc.value)-1;flag1-=1;document.f1.cpt.value=1+parseInt(document.f1.cpt.value);}break;
  case 2:if (flag2)
       {document.f1.dex.value=parseInt(document.f1.dex.value)-1;flag2-=1;document.f1.cpt.value=1+parseInt(document.f1.cpt.value);}break;
  case 3:if (flag3)
       {document.f1.con.value=parseInt(document.f1.con.value)-1;flag3-=1;document.f1.cpt.value=1+parseInt(document.f1.cpt.value);}break;
  case 4:if (flag4)
       {document.f1.inte.value=parseInt(document.f1.inte.value)-1;flag4-=1;document.f1.cpt.value=1+parseInt(document.f1.cpt.value);}break;
  case 5:if (flag5)
       {document.f1.sag.value=parseInt(document.f1.sag.value)-1;flag5-=1;document.f1.cpt.value=1+parseInt(document.f1.cpt.value);}break;
  case 6:if (flag6)
       {document.f1.cha.value=parseInt(document.f1.cha.value)-1;flag6-=1;document.f1.cpt.value=1+parseInt(document.f1.cpt.value);}break;
 }
}*/

function decom(arg)
{
	var cpt=parseInt(document.f1.cptr.value)
	i=0;
	while ((Tab[i]==false)||(Tab[i]==true))			//on parcours le tableau des dons
	{
		if (Tab[i]!=arg[i].selected)	//si il y a différence entre le tableau des dons et les dons séléctionnés, on sort note
		{
			if ((cpt>0)&&(arg[i].selected==true))
			{
				Tab[i]=true
				arg[i].selected=true
				cpt-=1
				document.f1.cptr.value=cpt
			}
			else if (arg[i].selected==false)
			{
				Tab[i]=false
				arg[i].selected=false
				cpt+=1
				document.f1.cptr.value=cpt
			}
			else if (cpt==0)
				arg[i].selected=false
		}
		i++;
	}
}

function selecta(arg)
{
	if(window.XMLHttpRequest)
	{
		xhr_object = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		return(false);
	}
	xhr_object.open("GET","/perso/communs/affdons.php5?typ="+arg, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4)
	{
		document.getElementById("doncat").innerHTML = xhr_object.responseText;
	}
}

