function achat_direct(cadeau_id)
{
 texte = file('ajax_cadeau_achat.php?cad_id='+escape(cadeau_id));
 
 alert(texte);
 window.location.reload();
}

function add_panier(cadeau_id)
{
 texte = file('ajax_cadeau_ajout.php?cad_id='+escape(cadeau_id));

 window.location.reload();
}

function sup_panier(cadeau_id)
{
 texte = file('ajax_cadeau_supprime.php?cad_id='+escape(cadeau_id));

 window.location.reload();
}

function validation_carte(empl)
{
 texte = file('ajax_carte_validation.php');

 txt=texte.split('|');
 
 document.getElementById('selec_carte'+empl).innerHTML = txt[1];
 document.getElementById('new_carte_'+empl).value = txt[0];
 
 if(empl==1){empl2=2;}else{empl2=1;}
 
 if(document.getElementById('new_carte_'+empl2).value==txt[0])
 {
  document.getElementById('selec_carte'+empl2).innerHTML = txt[2];
  document.getElementById('new_carte_'+empl2).value='';
 } 
}

function selection_classe(mv)
{
 texte = file('ajax_carte_selection_classe.php?move='+escape(mv));
 
 txt=texte.split('|'); 

 document.getElementById('nom_categorie').value = txt[1];
 document.getElementById('aff_img_classe').src = './images/icone_classe_0'+txt[0]+'.png'; 

 selection_carte('raz');
}

function selection_carte(mv)
{
 texte = file('ajax_carte_selection.php?move='+escape(mv));
 document.getElementById('compteur_carte').value = texte;

 affichage_carte();
}

function affichage_carte()
{
 texte = file('ajax_carte_choix.php');

 document.getElementById('aff_carte').innerHTML = texte;
}

function connexion()
{
 l = document.getElementById("fc_login").value;
 p = document.getElementById("fc_password").value;
  
 if(document.getElementById("fc_retenir").checked){r="1";}else{r="0";} 
                
 texte = file('ajax_compte_connexion.php?l='+escape(l)+'&p='+escape(p)+'&r='+escape(r));

 if(texte!=0)
 {
  window.location.reload();
 }
}

function deconnexion()
{
 texte = file('ajax_compte_deconnexion.php');
 
 window.location='index.html';
}

function affiche_menu_action(ordre)
{
 document.getElementById('selecact1').style.display='none';
 document.getElementById('selecact2').style.display='none';
 document.getElementById('seleccible3').style.display='none';
 document.getElementById('seleccible4').style.display='none';
 
 if(ordre==1){ document.getElementById('selecact1').style.display='inline'; }
 else if(ordre==2){ document.getElementById('selecact2').style.display='inline'; } 
 else if(ordre==3){ document.getElementById('seleccible3').style.display='inline'; }
 else if(ordre==4){ document.getElementById('seleccible4').style.display='inline'; }
}

function select_cible(id,joueur,txt,ordre,classe)
{
 document.getElementById('chxcible'+ordre).innerHTML = "<FONT class='"+classe+"'>"+txt+"</FONT>";
 document.getElementById('new_cible'+ordre).value = id;
 document.getElementById('new_joueur'+ordre).value = joueur;
 document.getElementById('seleccible'+ordre).style.display='none';
}

function select_action(id,txt,ordre)
{
 idbase = document.getElementById('carte'+ordre+'_id').value;
 
 document.getElementById('chxact'+ordre).innerHTML = txt;
 document.getElementById('new_act'+ordre).value = id;
 document.getElementById('selecact'+ordre).style.display='none';
 
 ordrecible = (ordre*1)+2;
 
 texte = file('ajax_selection_cible.php?action='+escape(id)+'&ordre='+escape(ordrecible)+'&idbase='+escape(idbase));
 
 document.getElementById('seleccible'+ordrecible).innerHTML=texte;
 document.getElementById('chxcible'+ordrecible).innerHTML = '';
 document.getElementById('new_cible'+ordrecible).value = '';
 document.getElementById('seleccible'+ordrecible).style.display='inline';
}

function select_duree(txt,duree)
{
 document.getElementById('chxduree').innerHTML = txt;
 document.getElementById('new_duree').value = duree;
 document.getElementById('selecduree').style.display='none';
}

function file(fichier)
{
 if(window.XMLHttpRequest) // FIREFOX
 {xhr_object = new XMLHttpRequest();}
 else if(window.ActiveXObject) // IE
 {xhr_object = new ActiveXObject("Microsoft.XMLHTTP");}
 else
 {alert("Erreur Javascript"); return;}

 xhr_object.open("GET", fichier, false);
 xhr_object.send(null);

 if(xhr_object.readyState == 4){return(xhr_object.responseText);}
 else{return(false);}
}
