function bonus(typ)
{
 texte = file('ajax_affichage_bonus.php?type='+escape(typ));

 a = document.getElementById("focus_bonus").value;
 
 if(typ==""){idchamp="typevide";}else{idchamp="type"+typ;}
 
 if(a!="typevide"){document.getElementById(a).className="color10 pointeur";}
 document.getElementById(idchamp).className="color01 pointeur";
 document.getElementById("focus_bonus").value=idchamp;
 
 document.getElementById('affichage_bonus').innerHTML = texte;
}

function concours_valide()
{
 if(document.getElementById('membre_connecte').value!='')
 {
  a = document.concours.rep_question1.value;
  b = document.concours.rep_question2.value;
  c = document.concours.rep_question3.value;
  
  if(a!='' && b!='' && c!='')
  {
   texte = file('ajax_concours.php?a='+escape(a)+'&b='+escape(b)+'&c='+escape(c));
   
   if(texte==1)
   {
    document.concours.reset();
    dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Concours Asuka</B><BR><BR>Votre participation a bien été prise en compte</DIV><BR>',300,115); 
   }
  }
  else
  {
   dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Concours Asuka</B><BR><BR>Vous devez répondre à toutes les questions</DIV><BR>',300,100); 
  }
 }
 else
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Concours Asuka</B><BR><BR>Vous devez être membre d\'Asuka Lounge et vous identifier pour participer au concours</DIV><BR>',300,115); 
 }
}   

function change_banniere()
{
 a1 = document.getElementById("nb_banniere").value;
 a2 = document.getElementById("ban_active").value;
 a3 = document.getElementById("pause").value; 
     
 b = (a2*1)+1;
 
 if(b>a1){b=1;}
 
 c = document.getElementById("vala"+b).value;
 d = document.getElementById("valb"+b).value;
 e = document.getElementById("valc"+b).value;
 
 if(a3=="0")
 {
  rotate('grande_banniere',c,d,e);
 }
 
 window.setTimeout ('change_banniere()',5000)
}

function contact()
{
 if(document.getElementById('videoaccueil')){document.getElementById('videoaccueil').style.display='none';}
 
 texte = file('ajax_contact_texte.php');

 dialog(texte,320,690);
}

function contact_send()
{
 a = document.getElementById("id_dest").value;
 b = document.getElementById("cont_mail").value;
 c = document.getElementById("cont_message").value;
 d = document.getElementById("cont_code").value;
  
 a = a*1; 

 texte = file('ajax_verif_code.php?code='+escape(d));

 if(b.indexOf("@")=="-1" || b.indexOf(".")=="-1" || b.length<=6)
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Contact Asuka</B></DIV><BR>Vous devez saisir une adresse email valide<BR><BR>',300,100);
 }
 else if(a<1)
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Contact Asuka</B></DIV><BR>Vous devez choisir un destinataire<BR><BR>',300,100);
 }
 else if(texte!=1)
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Contact Asuka</B></DIV><BR>Vous devez recopier le code de sécurité<BR><BR>',300,100);
 }
 else if(c=="Tapez votre texte ici ..." || c=="")
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Contact Asuka</B></DIV><BR>Vous devez saisir un message<BR><BR>',300,100);
 }
 else
 {
  texte = file('ajax_contact_send.php?dest='+escape(a)+'&mail='+escape(b)+'&code='+escape(d)+'&mess='+escape(c));
 
  Windows.closeAll();
 
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Contact Asuka</B></DIV><BR>Votre message a bien été envoyé<BR><BR>',300,100);
 }
}

function recherche()
{
 if(document.getElementById('videoaccueil')){document.getElementById('videoaccueil').style.display='none';}

 a = document.getElementById("rech_motcles").value;
 b = document.getElementById("rech_serie").value;
 
 if(b!="")
 {
  window.location='catalogue_serie.php?serie='+b;
 }
 else if(a!="" && a!="Mots-clés ...")
 {
  texte = file('ajax_recherche.php?rech='+escape(a));

  dialog(texte,400,500);
 }
}

function tome(serie,tome)
{
 texte = file('ajax_affichage_tome.php?serie='+escape(serie)+'&tome='+escape(tome));

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

function tome_serie(serie)
{
 texte = file('ajax_affichage_serie.php?serie='+escape(serie));

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

function planning(date)
{
 texte = file('ajax_affichage_planning.php?date='+escape(date));

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

function compte_logout()
{
 texte = file('ajax_compte_logout.php');
 
 document.getElementById('affichage_lounge').innerHTML = texte;
}

function compte_login()
{
 if(document.getElementById('videoaccueil')){document.getElementById('videoaccueil').style.display='none';}

 texte = file('ajax_compte_formulaire_login.php');

 Dialog.confirm(texte, 
 {windowParameters: {className: "alphacube", width:320, height:190} ,
 okLabel: "Authentification", ok:function(win){compte_connexion('old');},
 cancelLabel: "Annuler",cancel:function(win){debug("validate cancel panel"); return true;}});
}

function compte_mot_de_passe()
{
 texte = file('ajax_compte_formulaire_perte_mdp.php');

 Dialog.confirm(texte, 
 {windowParameters: {className: "alphacube", width:320, height:190} ,
 okLabel: "Recevoir mon mot de passe", ok:function(win){compte_envoi_mdp();},
 cancelLabel: "Annuler",cancel:function(win){debug("validate cancel panel"); return true;}});
}

function compte_envoi_mdp()
{
 f=document.getElementById("perte_mail").value;
 
 texte = file('ajax_compte_envoi_mdp.php?f='+escape(f));

 if(texte==0)
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Identification Asuka Lounge</B></DIV><BR>Il n\'y a pas de compte avec cette adresse Mail<BR><BR>',300,100);
 }
 else if(texte==1)
 {
  Windows.closeAll();
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Identification Asuka Lounge</B></DIV><BR>Votre mot de passe vous a été envoyé<BR><BR>',300,100);
 }
}

function compte_connexion(typ)
{
 if(typ=="old")
 {
  f=document.getElementById("log_mail").value;
  g=document.getElementById("log_mdp").value;
 }
 else if(typ=="new")
 {
  f=document.getElementById("mbr_mail").value;
  g=document.getElementById("mbr_mdp1").value;
 }
 else if(typ=="cookie")
 {
  f=document.getElementById("coo_log").value;
  g=document.getElementById("coo_mdp").value;
 }
 
 texte = file('ajax_compte_connexion.php?f='+escape(f)+'&g='+escape(g));
 
 if(texte==0)
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Identification Asuka Lounge</B></DIV><BR>Erreur d\'authentification<BR><BR>',300,100);
 }
 else
 {
  text2 = file('ajax_compte_connecte.php');
  document.getElementById('affichage_lounge').innerHTML = text2;
  
  Windows.closeAll();
 }
}

function compte_creation(typ)
{
 if(document.getElementById('videoaccueil')){document.getElementById('videoaccueil').style.display='none';}
 
 texte = file('ajax_compte_formulaire.php?typ='+typ);

 if(typ=="new")
 {
  Dialog.confirm(texte, 
  {windowParameters: {className: "alphacube", width:320, height:610} ,
  okLabel: "Inscription", ok:function(win){compte_validation();},
  cancelLabel: "Annuler",cancel:function(win){debug("validate cancel panel"); return true;}});
 }
 else
 {
  Dialog.confirm(texte, 
  {windowParameters: {className: "alphacube", width:320, height:600} ,
  okLabel: "Modification", ok:function(win){compte_validation();},
  cancelLabel: "Annuler",cancel:function(win){debug("validate cancel panel"); return true;}});
 }
}

function compte_validation()
{
 if(document.getElementById("mbr_sexe1").checked){a="F";}else{a="H";}

 b = document.getElementById("mbr_pseudo").value;
 c = document.getElementById("mbr_nom").value;
 d = document.getElementById("mbr_prenom").value;
 e = document.getElementById("mbr_date").value;
 f = document.getElementById("mbr_mail").value;
 g = document.getElementById("mbr_mdp1").value;
 h = document.getElementById("mbr_mdp2").value;
 i = document.getElementById("mbr_ville").value;
 j = document.getElementById("mbr_telephone").value;
 k = document.getElementById("mbr_manga").value;
 l = document.getElementById("mbr_anime").value;
 m = document.getElementById("mbr_nbmois").value;
 
 if(document.getElementById("mbr_news").checked){n="O";}else{n="N";}
 
 if(document.getElementById("mbr_cdg").checked==false)
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Création de compte Asuka Lounge</B></DIV><BR>Vous devez accepter les CGU avant toutes actions<BR><BR>',300,100);
 }
 else if(b=="")
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Création de compte Asuka Lounge</B></DIV><BR>Vous devez saisir un pseudo<BR><BR>',300,100);
 }
 else if(c.length<3 || d.length<3)
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Création de compte Asuka Lounge</B></DIV><BR>Vous devez saisir vos nom et prénom<BR><BR>',300,100);
 }
 else if(f.indexOf("@")=="-1" || f.indexOf(".")=="-1" || f.length<=6)
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Création de compte Asuka Lounge</B></DIV><BR>Vous devez saisir une adresse email valide<BR><BR>',300,100);
 }
 else if(g!=h || g.length<=5)
 {
  dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Création de compte Asuka Lounge</B></DIV><BR>Il y a une erreur dans votre mot de passe<BR><BR>',300,100);
 }
 else
 {
  texte = file('ajax_compte_ajout.php?a='+escape(a)+'&b='+escape(b)+'&c='+escape(c)+'&d='+escape(d)+'&e='+escape(e)+'&f='+escape(f)+'&g='+escape(g)+'&h='+escape(h)+'&i='+escape(i)+'&j='+escape(j)+'&k='+escape(k)+'&l='+escape(l)+'&m='+escape(m)+'&n='+escape(n));
  
  if(texte==1)
  {
   compte_connexion('new');
   Windows.closeAll();
   dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Création de compte Asuka Lounge</B></DIV><BR>Merci de vous être inscrit sur Asuka.fr<BR><BR>',300,100);
  }
  else if(texte==2)
  {
   dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Création de compte Asuka Lounge</B></DIV><BR>Ce pseudo est déjà utilisé<BR><BR>',300,100);
  }
  else if(texte==3)
  {
   dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Création de compte Asuka Lounge</B></DIV><BR>Cette adresse mail est déjà utilisé<BR><BR>',300,100);
  }
  else if(texte==4)
  {
   compte_logout();
   compte_connexion('new');
   Windows.closeAll();
   dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Modification de compte Asuka Lounge</B></DIV><BR>Votre compte a bien été modifié<BR><BR>',300,100);
  }
 }
}

function cdg(provenance)
{
 text = file('ajax_cdg_texte.php');
 texte = '<DIV class="menu03">'+text+'<BR><BR>';
 
 if(document.getElementById('videoaccueil')){document.getElementById('videoaccueil').style.display='none';}
 
 Dialog.confirm(texte, 
 {windowParameters: {className: "alphacube", width:500, height:600} ,
 okLabel: "J&#39;accepte les CGU", ok:function(win){accepte_cdg('1',provenance); return true;},
 cancelLabel: "Je refuse les CGU",cancel:function(win){accepte_cdg('0',provenance); return true;}});
}

function accepte_cdg(valeur,provenance)
{
 if(provenance=="membre")
 {
  if(valeur==1)
  {
   document.getElementById("mbr_cdg").checked=true;
  }
  else
  {
   document.getElementById("mbr_cdg").checked=false;
  }
 } 
 
 text = file('ajax_cdg.php?cdg='+valeur);
 document.getElementById('acc_cdg').value=valeur; 
}

function affiche_liste(type,serie)
{
 texte = file('ajax_liste_serie.php?type='+escape(type)+'&serie='+escape(serie));

 dialog(texte,400,500);
}

function rotate(lieu,image,lien,indice)
{
 document.getElementById(lieu).style.backgroundImage = 'url('+image+')';
 document.getElementById(lieu).onclick = function(){window.location=lien};
 fin_banniere = document.getElementById("nb_banniere").value; 
  
 for (i=1; i<=fin_banniere; i++)
 {    
  if(i==indice)
  {
   document.getElementById('rond'+i).src="create_image_bg.php?texte="+i+"&b=1";
  }
  else
  {
   document.getElementById('rond'+i).src="create_image_bg.php?texte="+i;
  }
 }
 
 document.getElementById("ban_active").value = indice;
}

function inscription_newsletter()
{     
 email = document.getElementById("insc_newsletter").value;
 
 if (email.indexOf("@")!="-1" && email.indexOf(".")!="-1" && email.length>6)
 {
  Dialog.confirm('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Inscription à la newsletter</B><BR><BR>En validant votre inscription vous certifiez avoir pris connaissance des conditions générales d\'utilisation.</DIV><BR>', 
 {windowParameters: {className: "alphacube", width:400, height:120} ,
 okLabel: "J&#39;accepte les CGU", ok:function(win)
 {
  result = file('ajax_newsletter.php?mail='+escape(email));
 
  if(result==1)
  {
   dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Inscription à la newsletter</B></DIV><BR>Votre desinscription a bien été prise en compte<BR><BR>',300,100);  
  }
  else if(result==2)
  {
   dialog('<DIV align=left><img src="./images/popup/fleche.gif" border="0"> <B>Inscription à la newsletter</B></DIV><BR>Votre inscription a bien été prise en compte<BR><BR>',300,100);  
  } 
 
  document.getElementById("insc_newsletter").value = "adresse@mail.com"; 
 
  return true;
 },
 cancelLabel: "Je refuse les CGU",cancel:function(win){debug("validate cancel panel"); return true;}});
 }
}

function dialog(texte,largeur,hauteur)
{
  Dialog.alert(texte, 
   {windowParameters: {className: "alphacube", width:largeur, height:hauteur} ,okLabel: "Fermer", ok:function(win)
   {debug("validate alert panel"); return true;}, cancel:function(win) {debug("validate cancel panel"); return true;}});
}

function file(fichier)
{
 if(window.XMLHttpRequest) // FIREFOX
 {
  xhr_object = new XMLHttpRequest();
 }
 else if(window.ActiveXObject) // IE
 {
  xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
 }
 else
 {
  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
  return;
 }

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

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