var SkillDisplay = 0;

function show1(){
document.getElementById("talent1").style.display = "block";
document.getElementById("talent2").style.display = "none";
document.getElementById("talent3").style.display = "none";
}

function show2(){
document.getElementById("talent1").style.display = "none";
document.getElementById("talent2").style.display = "block";
document.getElementById("talent3").style.display = "none";
}

function show3(){
document.getElementById("talent1").style.display = "none";
document.getElementById("talent2").style.display = "none";
document.getElementById("talent3").style.display = "block";
}

function GetValeurEnCours(GetIt){
if (talents[GetIt][0] == TypeTalent1) { ValeurEnCours = document.getElementById("ValeurTalent1").innerHTML; }
if (talents[GetIt][0] == TypeTalent2) { ValeurEnCours = document.getElementById("ValeurTalent2").innerHTML; }
if (talents[GetIt][0] == TypeTalent3) { ValeurEnCours = document.getElementById("ValeurTalent3").innerHTML; }
return ValeurEnCours;
}

function TalentResume(){
var imprimable = window.open("","","resizable=1,toolbar=0,top=0,left=0,width=600,height=500,status=0,scrollbars=1,menubar=1");
if(imprimable != null)
{
imprimable.document.write("<html><head><title>Simulateur de talent - L'Assemblée des Défias</title></head>\n");
imprimable.document.write("<body bgcolor=\"#000000\" text=\"#FFFFFF\" style=\"font-family:Verdana,Arial,sans-serif; font-size:9pt;\">\n");
if (SkillDisplay == 0) { TalentClasseDisplay=TalentClasseFr; } else { TalentClasseDisplay=TalentClasse; }
imprimable.document.write("<br><b>Template Voleur niveau "+document.getElementById("TalentNiveauRequis").innerHTML+"<br></b>\n");

var Tal = "";
for(var i = 0; i < nbtalents; i++) {
GetValeurEnCours(i);
if (talents[i][0] != Tal && ValeurEnCours > 0){
if (ValeurEnCours <= 1) { DisplayPoint = "point"; } else { DisplayPoint = "points"; }
imprimable.document.write("<br><br><b><u><font color=orange>"+description[i][(2+parseInt(SkillDisplay))]+"</font></u></b> ("+ValeurEnCours+" "+DisplayPoint+")<br>\n"); Tal = talents[i][0]; }
if (document.getElementById("nbpoints"+i+"").innerHTML != null && document.getElementById("nbpoints"+i+"").innerHTML != 0){
imprimable.document.write("<br>"+description[i][(0+parseInt(SkillDisplay))]+" - Rang "+document.getElementById("nbpoints"+i+"").innerHTML+"/"+talents[i][2]+"<br>\n");
}
}
imprimable.document.write("</body></html>");
imprimable.document.close();
}
}


function ModifierTexte(ValeurTexte){
if (document.getElementById("nbpoints"+ValeurTexte+"").innerHTML == "") { TalentStatus = 0; } else { TalentStatus = document.getElementById("nbpoints"+ValeurTexte+"").innerHTML }
if (TalentStatus == talents[ValeurTexte][2]) { TalentTexte = "<b><font class=\"altcolor\">"+description[ValeurTexte][(0+parseInt(SkillDisplay))]+"</font></b><br>Rang <font color=#FFD200>"+TalentStatus+"/"+talents[ValeurTexte][2]+"</font>"; }
else { TalentTexte = "<b><font class=\"altcolor\">"+description[ValeurTexte][(0+parseInt(SkillDisplay))]+"</font></b><br>Rang "+TalentStatus+"/"+talents[ValeurTexte][2]+""; }
GetValeurEnCours(ValeurTexte);
if (talents[ValeurTexte][3] != 0){
if (ValeurEnCours >= parseInt(talents[ValeurTexte][3])) { TalentTexte = TalentTexte+"<br><br>Nécessite "+talents[ValeurTexte][3]+" points en "+description[ValeurTexte][(2+parseInt(SkillDisplay))]+""; }
else { TalentTexte = TalentTexte+"<br><br><font color=red>Nécessite "+talents[ValeurTexte][3]+" points en "+description[ValeurTexte][(2+parseInt(SkillDisplay))]+"</font>"; }
}
if (talents[ValeurTexte][4] != ""){
if (talents[ValeurTexte][3] == 0) { TalentTexte = TalentTexte+"<br>"; }
if (talents[ValeurTexte][5] == 1) { Points = "point"; } else { Points = "points"; }
if (document.getElementById("nbpoints"+talents[ValeurTexte][4]+"").innerHTML >= talents[ValeurTexte][5]) { TalentTexte = TalentTexte+"<br>Nécessite "+talents[ValeurTexte][5]+" "+Points+" en "+description[talents[ValeurTexte][4]][(0+parseInt(SkillDisplay))]+""; }
else { TalentTexte = TalentTexte+"<br><font color=red>Nécessite "+talents[ValeurTexte][5]+" "+Points+" en "+description[talents[ValeurTexte][4]][(0+parseInt(SkillDisplay))]+"</font>"; }
}
TalentTexte = TalentTexte+"<br><br>"+description[ValeurTexte][4]+"<br><br>";

for(var i = 0; i < talents[ValeurTexte][2]; i++) {
if (talents[ValeurTexte][2] == 1){
TalentTexte = TalentTexte+""+talents[ValeurTexte][6]+"<br>";
} else {
if ( document.getElementById("nbpoints"+ValeurTexte+"").innerHTML == (i+1)){
TalentTexte = TalentTexte+"<b>Rang "+(i+1)+" : "+talents[ValeurTexte][i+6]+"</b><br>";
} else { TalentTexte = TalentTexte+"Rang "+(i+1)+" : "+talents[ValeurTexte][i+6]+"<br>"; }
}
}
document.getElementById("ShowDescription").innerHTML = TalentTexte;
}

function SupprimerTexte(){
TalentTexte = "";
document.getElementById("ShowDescription").innerHTML = TalentTexte;
}

function Ajouter(IdTalent) {
if (document.getElementById("TalentRestant").innerHTML <= 0 || document.getElementById("nbpoints"+IdTalent+"").innerHTML == "" || document.getElementById("nbpoints"+IdTalent+"").innerHTML>(talents[IdTalent][2]-1)) { return false }
else
{
document.getElementById("nbpoints"+IdTalent+"").innerHTML++;
document.getElementById("TalentDepense").innerHTML++;
if (document.getElementById("TalentRestant").innerHTML != 51){ document.getElementById("TalentNiveauRequis").innerHTML++; }
document.getElementById("TalentRestant").innerHTML--;
if ( talents[IdTalent][0] == TypeTalent1 ) { document.getElementById("ValeurTalent1").innerHTML++; }
if ( talents[IdTalent][0] == TypeTalent2 ) { document.getElementById("ValeurTalent2").innerHTML++; }
if ( talents[IdTalent][0] == TypeTalent3 ) { document.getElementById("ValeurTalent3").innerHTML++; }
RefreshCanLearn(IdTalent);
ModifierTexte(IdTalent);
}
}

function Enlever(IdTalent) {
if (document.getElementById("nbpoints"+IdTalent+"").innerHTML == "" || document.getElementById("nbpoints"+IdTalent+"").innerHTML<1) { return false }
else
{
CanUnlearn(IdTalent);
if (ValidTalent == true) {
document.getElementById("nbpoints"+IdTalent+"").innerHTML--;
document.getElementById("TalentDepense").innerHTML--;
if (document.getElementById("TalentRestant").innerHTML != 50){ document.getElementById("TalentNiveauRequis").innerHTML--; }
document.getElementById("TalentRestant").innerHTML++;
if ( talents[IdTalent][0] == TypeTalent1 ) { document.getElementById("ValeurTalent1").innerHTML--; }
if ( talents[IdTalent][0] == TypeTalent2 ) { document.getElementById("ValeurTalent2").innerHTML--; }
if ( talents[IdTalent][0] == TypeTalent3 ) { document.getElementById("ValeurTalent3").innerHTML--; }
}
RefreshUnlearn(IdTalent);
ModifierTexte(IdTalent);
}
}

function RefreshCanLearn(IdTalent){
var Pal = 0;
var Position = 0;
var TotalTalent = 0;
var TotalTemp = 0;

for(var i = 0; i < nbtalents; i++) {
if (talents[IdTalent][0] == talents[i][0]){

if (document.getElementById("nbpoints"+i+"").innerHTML == talents[i][2]) { document.getElementById("nbpoints"+i+"").style.color = "#E8E123" }
else { document.getElementById("nbpoints"+i+"").style.color = "" }

if (document.getElementById("nbpoints"+i+"").innerHTML == "") { PalierTemp = 0; }
else { PalierTemp = document.getElementById("nbpoints"+i+"").innerHTML; }

if (talents[i][3] == Pal){
TotalTemp = parseInt(TotalTemp) + parseInt(PalierTemp);
if (document.getElementById("nbpoints"+i+"").innerHTML == "" && talents[i][3] <= TotalTalent && talents[i][4] == 0)
{ document.getElementById("nbpoints"+i+"").innerHTML = 0; }
if (document.getElementById("nbpoints"+i+"").innerHTML == "" && talents[i][3] <= TotalTalent && talents[i][4] != 0 && document.getElementById("nbpoints"+talents[i][4]+"").innerHTML >= talents[i][5])
{ document.getElementById("nbpoints"+i+"").innerHTML = 0; }
}

if (talents[i][3] != Pal){
Pal = talents[i][3];
Position++;
TotalTalent = parseInt(TotalTalent) + parseInt(TotalTemp);
TotalTemp = 0;
TotalTemp = PalierTemp;
if (document.getElementById("nbpoints"+i+"").innerHTML == "" && talents[i][3] <= TotalTalent && talents[i][4] == 0)
{ document.getElementById("nbpoints"+i+"").innerHTML = 0; }
if (document.getElementById("nbpoints"+i+"").innerHTML == "" && talents[i][3] <= TotalTalent && talents[i][4] != 0 && document.getElementById("nbpoints"+talents[i][4]+"").innerHTML >= talents[i][5])
{ document.getElementById("nbpoints"+i+"").innerHTML = 0; }
}
}
}
}

function RefreshUnlearn(IdTalent){

var Pal = 0;
var Position = 0;
var TotalTalent = 0;
var TotalTemp = 0;

for(var i = 0; i < nbtalents; i++) {
if (talents[IdTalent][0] == talents[i][0]){

if (document.getElementById("nbpoints"+i+"").innerHTML == talents[i][2]) { document.getElementById("nbpoints"+i+"").style.color = "#E8E123" }
else { document.getElementById("nbpoints"+i+"").style.color = "" }

if (document.getElementById("nbpoints"+i+"").innerHTML == "") { PalierTemp = 0; }
else { PalierTemp = document.getElementById("nbpoints"+i+"").innerHTML; }

if (talents[i][3] == Pal){
TotalTemp = parseInt(TotalTemp) + parseInt(PalierTemp);
if (document.getElementById("nbpoints"+i+"").innerHTML == 0 && talents[i][3] > TotalTalent)
{ document.getElementById("nbpoints"+i+"").innerHTML = ""; }
if (document.getElementById("nbpoints"+i+"").innerHTML == 0 && talents[i][4] != 0 && document.getElementById("nbpoints"+talents[i][4]+"").innerHTML < talents[i][5])
{ document.getElementById("nbpoints"+i+"").innerHTML = ""; }
}

if (talents[i][3] != Pal){
Pal = talents[i][3];
Position++;
TotalTalent = parseInt(TotalTalent) + parseInt(TotalTemp);
TotalTemp = 0;
TotalTemp = PalierTemp;
if (document.getElementById("nbpoints"+i+"").innerHTML == 0 && talents[i][3] > TotalTalent)
{ document.getElementById("nbpoints"+i+"").innerHTML = ""; }
if (document.getElementById("nbpoints"+i+"").innerHTML == 0 && talents[i][4] != 0 && document.getElementById("nbpoints"+talents[i][4]+"").innerHTML < talents[i][5])
{ document.getElementById("nbpoints"+i+"").innerHTML = ""; }
}
}
}
}

function CanUnlearn(IdTalent){

ValidTalent = true;

var Pal = 0;
var Position = 0;
var TotalTalent = 0;
var TotalTemp = 0;
var Doaction = 0;

for(var i = 0; i < nbtalents; i++) {
if (talents[IdTalent][0] == talents[i][0]){

if (parseInt(talents[i][4]) == IdTalent){
if (document.getElementById("nbpoints"+i+"").innerHTML == "" || document.getElementById("nbpoints"+i+"").innerHTML == 0 || document.getElementById("nbpoints"+talents[i][4]+"").innerHTML > talents[i][5]) {} 
else { ValidTalent = false; }
}

if (document.getElementById("nbpoints"+i+"").innerHTML == "") { PalierTemp = 0; }
else { PalierTemp = document.getElementById("nbpoints"+i+"").innerHTML; }

if (talents[i][3] == Pal){
if (IdTalent == i) { Doaction = 1; }
TotalTemp = parseInt(TotalTemp) + parseInt(PalierTemp);
if(talents[i][3] > TotalTalent && PalierTemp > 0) { ValidTalent = false; }
}

if (talents[i][3] != Pal){
Pal = talents[i][3];
Position++;
TotalTalent = (parseInt(TotalTalent) + parseInt(TotalTemp)) - parseInt(Doaction);
Doaction = 0;
TotalTemp = 0;
TotalTemp = PalierTemp;
if (IdTalent == i) { Doaction = 1; }
if(talents[i][3] > TotalTalent && PalierTemp > 0) { ValidTalent = false; }
}
}
}

return ValidTalent;
}

function ResetArbres(){
for(var i = 0; i < nbtalents; i++){
document.getElementById("nbpoints"+i+"").style.color = ""
if (talents[i][3] == 0 && talents[i][4] == "") { document.getElementById("nbpoints"+i+"").innerHTML = 0; }
else { document.getElementById("nbpoints"+i+"").innerHTML = ""; }
}
document.getElementById("ValeurTalent1").innerHTML = 0;
document.getElementById("ValeurTalent2").innerHTML = 0;
document.getElementById("ValeurTalent3").innerHTML = 0;
document.getElementById("TalentDepense").innerHTML = 0;
document.getElementById("TalentRestant").innerHTML = 51;
document.getElementById("TalentNiveauRequis").innerHTML = 10;
}

function ResetArbre(GetIt){
var Asoustraire = 0;
var AsoustraireT = 0;
for(var i = 0; i < nbtalents; i++){
if (talents[i][0] == GetIt){
if (document.getElementById("nbpoints"+i+"").innerHTML == "") { AsoustraireT = 0; } else { AsoustraireT = document.getElementById("nbpoints"+i+"").innerHTML }
Asoustraire = parseInt(Asoustraire) + parseInt(AsoustraireT);
document.getElementById("nbpoints"+i+"").style.color = ""
if (talents[i][3] == 0 && talents[i][4] == "") { document.getElementById("nbpoints"+i+"").innerHTML = 0; }
else { document.getElementById("nbpoints"+i+"").innerHTML = ""; }
}
}
document.getElementById("TalentDepense").innerHTML = parseInt(document.getElementById("TalentDepense").innerHTML) - parseInt(Asoustraire);
document.getElementById("TalentRestant").innerHTML = parseInt(document.getElementById("TalentRestant").innerHTML) + parseInt(Asoustraire);
document.getElementById("TalentNiveauRequis").innerHTML = parseInt(document.getElementById("TalentNiveauRequis").innerHTML) - parseInt(Asoustraire);
if (document.getElementById("TalentNiveauRequis").innerHTML == 9) { document.getElementById("TalentNiveauRequis").innerHTML = 10; }
if (GetIt == TypeTalent1) { document.getElementById("ValeurTalent1").innerHTML = 0; }
if (GetIt == TypeTalent2) { document.getElementById("ValeurTalent2").innerHTML = 0; }
if (GetIt == TypeTalent3) { document.getElementById("ValeurTalent3").innerHTML = 0; }
}

function Version(ver){
if (ver == 0){
document.getElementById("vf").style.fontWeight = "bold";
document.getElementById("vo").style.fontWeight = "normal";
document.getElementById("vf").style.color = ""
document.getElementById("vo").style.color = "#FFCC66"
VersionArbre1 = TypeTalentFr1;
VersionArbre2 = TypeTalentFr2;
VersionArbre3 = TypeTalentFr3;
SkillDisplay = 0;
}
if (ver == 1){
document.getElementById("vf").style.fontWeight = "normal";
document.getElementById("vo").style.fontWeight = "bold";
document.getElementById("vf").style.color = "#FFCC66"
document.getElementById("vo").style.color = ""
VersionArbre1 = TypeTalent1;
VersionArbre2 = TypeTalent2;
VersionArbre3 = TypeTalent3;
SkillDisplay = 1;
}
document.getElementById("aa1").innerHTML = VersionArbre1;
document.getElementById("aa2").innerHTML = VersionArbre2;
document.getElementById("aa3").innerHTML = VersionArbre3;
document.getElementById("ab1").innerHTML = VersionArbre1;
document.getElementById("ab2").innerHTML = VersionArbre2;
document.getElementById("ab3").innerHTML = VersionArbre3;
document.getElementById("ac1").innerHTML = VersionArbre1;
document.getElementById("ac2").innerHTML = VersionArbre2;
document.getElementById("ac3").innerHTML = VersionArbre3;
document.getElementById("ad1").innerHTML = VersionArbre1;
document.getElementById("ad2").innerHTML = VersionArbre2;
document.getElementById("ad3").innerHTML = VersionArbre3;
}
