function mail_cycles()
{
   window.open("../../commun/mail_cycles.php", "Avmail", "locationbar=no,toolbar=no,name=\"ahaha\",width=520,height=350,resizable=yes,scrollbars=yes,alwaysraised=yes,dependent=no,titlebar=no,menubar=no,hotkeys=no");
}

function mail()
{
   window.open("../../commun/mail.php", "Avmail", "locationbar=no,toolbar=no,name=\"ahaha\",width=520,height=360,resizable=yes,scrollbars=yes,alwaysraised=yes,dependent=no,titlebar=no,menubar=no,hotkeys=no");
}

function mail_prix()
{
   window.open("../commun/mail_prix.php", "Avmail", "locationbar=no,toolbar=no,name=\"ahaha\",width=520,height=350,resizable=yes,scrollbars=yes,alwaysraised=yes,dependent=no,titlebar=no,menubar=no,hotkeys=no");
}

function mail_anthos()
{
   window.open("../../commun/mail_recueils.php", "Avmail", "locationbar=no,toolbar=no,name=\"ahaha\",width=520,height=350,resizable=yes,scrollbars=yes,alwaysraised=yes,dependent=no,titlebar=no,menubar=no,hotkeys=no");
}

function mail_collec()
{
   window.open("../../commun/mail_collec.php", "Avmail", "locationbar=no,toolbar=no,name=\"ahaha\",width=520,height=350,resizable=yes,scrollbars=yes,alwaysraised=yes,dependent=no,titlebar=no,menubar=no,hotkeys=no");
}

function aff_mail(dest, msg, sujet, fin) {
 var cod="";
 if (dest == "cg") {
  cod="b] zp89=\"u]yvns:0yvv8o@<79yAt8n;6zpyony]t@<79yAt8n\"C0yvv8o@<79yAt8n;6zpyony]t@<79yAt8nb/]C";}
 else if (dest == "gc") {
  cod="b] zp89=\"u]yvns:6zpyony]t@<79yAt8n;0yvv8o@<79yAt8n\"C6zpyony]t@<79yAt8n;0yvv8o@<79yAt8nb/]C";}
 else if (dest == "c") {
  cod="b] zp89=\"u]yvns:6zpyony]t@<79yAt8n\"C6zpyony]t@<79yAt8nb/]C";}
 else if (dest == "g") {
  cod="b] zp89=\"u]yvns:0yvv8o@<79yAt8n\"C0yvv8o@<79yAt8nb/]C";}
 var f=cod.length-4;
 var d=7+(f/2);
 if (cod != "") {
  adr = dcod(cod);
  if (msg != "") { adr = adr.substr(0,d+2) + msg + adr.substr(f);}
  if (sujet != "") { adr = adr.substr(0,d) + "?subject=" + sujet + adr.substr(d);}
  if (fin == 1) { adr = adr.substr(0,2) + " onclick=\"mclose()\" " + adr.substr(2);}
  document.write(adr);
 }
}

function dcod (_code) {
 var key = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1029384756><#].";
 var wTG;var mcH=key.length/2;var _txt="";var dv;
 for (var x=0; x<_code.length; x++) {
  wTG = key.indexOf(_code.charAt(x));
  if (wTG>mcH) {dv=wTG-mcH;_txt+=key.charAt(33-dv);}
  else {
   if (key.indexOf(_code.charAt(x))<0) {
    _txt+=_code.charAt(x);} 
   else {dv=mcH-wTG; _txt+=key.charAt(33+dv);}
  }
 }
 return (_txt);
}

function mclose()
{
   setTimeout("javascript:self.close()",3000);
}

function certif(type, path, lien)
{
 path+="/";
 document.write ("<p>");
 if (type == "xhtml")
 {
    if (lien == 1)
    {
       document.write (" <a href=\"http://validator.w3.org/check?uri=referer\"><img src=\""+path+"images/valid-xhtml10\" alt=\"Valid XHTML 1.0!\" border=\"0\" height=\"31\" width=\"88\" /></a>");
    }
    else
    {
       document.write (" <img src=\""+path+"images/valid-xhtml10\" alt=\"Valid XHTML 1.0!\" border=\"0\" height=\"31\" width=\"88\" />");
    }
 }
 document.write ("</p>");
}

function aff_datemod()
{
  document.write("Dernière mise &agrave; jour : " + document.lastModified);
}

var newurl="";
var newwin=0;
function go_url()
{
  if (newurl != "") {
    if (newwin == 0) { document.location.replace(newurl); }
    else             { window.open(newurl); }
    newurl="";
  }
  else
  {
     alert("Remplissez la zone de recherche...");
  }
  return false;
}

function repurl(path, typ)
{
  value=document.getElementById("bdfi_cherche").value;
  if (value != "")
  {
    if (typ == "antinea")
    {
      newurl="http://search.antinea.org/findit.php3?b=imagine&q="+value;
      newwin=1;
    }
    else if ((typ == "auteur") || (typ == "serie") || (typ == "recueil") || (typ == "collection"))
    {
      newurl=path+typ+"s/recherche.php?str="+value;
      newwin=0;
    }
    else if (typ == "topics")
    {
      newurl=path+"search.php?action=search&keywords="+value+"&search_in=titles&show_as=topics&search=Submit";
    }
    else if (typ == "posts")
    {
      newurl=path+"search.php?action=search&keywords="+value+"&show_as=posts&search=Poster";
    }
    else if (typ == "wiki")
    {
      newurl=path+"doku.php?do=search&id="+value;
    }
    else if (typ == "base")
    {
      newurl="http://search.antinea.org/findit.php3?b=imagine&q="+value;
      newwin=1;
    }
    document.getElementById("bdfi_cherche").value = "";
  }
}

// Basé sur diverses sources :
// menus de départ horizontaux et verticaux : scripts alsacreation
// http://css.alsacreations.com/Construction-de-menus-en-CSS/Un-menu-deroulant-en-CSS-et-XHTML-vertical-et-horizontal
// fading d'images : http://www.brainerror.net/scripts_js_blendtrans.php
// pb IE : http://jszen.blogspot.com/2005/04/ie6-opacity-filter-caveat.html

var desc = new Array()
desc['menu01'] = { action:'affiche', fading:0, timer:0 };
desc['menu02'] = { action:'affiche', fading:0, timer:0 };
desc['menu03'] = { action:'affiche', fading:0, timer:0 };
desc['menu04'] = { action:'affiche', fading:0, timer:0 };
desc['menu05'] = { action:'affiche', fading:0, timer:0 };

desc['menu1'] = {action:'affiche', fading:0, timer:0};
desc['menu2'] = {action:'affiche', fading:0, timer:0};
desc['menu3'] = {action:'affiche', fading:0, timer:0};
desc['menu4'] = {action:'affiche', fading:0, timer:0};
desc['menu5'] = {action:'affiche', fading:0, timer:0};
desc['menu6'] = {action:'affiche', fading:0, timer:0};
desc['menu7'] = {action:'affiche', fading:0, timer:0};
desc['menu8'] = {action:'affiche', fading:0, timer:0};
desc['menu9'] = {action:'affiche', fading:0, timer:0};

var nb_etapes = 20;                      // nb affichages intermediaires
var retard = new Array(200, 100);        // retard effacement en ms
var duree_fading = new Array(600, 300);  // duree effacement en ms
var delta_fading = 100/nb_etapes;

function m0_show(id) {
  desc[id].action = 'affiche';
  process(id, 0);
}

function m0_quit(id) {
  desc[id].action = 'quitte';
  process(id, 0);
}

function m0_click(id)
{
 desc[id].action != 'affiche' ? m0_show(id) : m0_quit(id);
}

function ini_menu(on_off)
{
   for (var i = 1; i<=10; i++) {
      var id='menu'+i;
      if (document.getElementById(id)) {
         if (on_off == 0)
         {
            document.getElementById(id).style.display = 'none';
            desc[id].fading = 0;
            desc[id].action = 'quitte';
         }
         else
         {
            document.getElementById(id).style.display = 'block';
            desc[id].fading = 100;
            desc[id].action = 'affiche';
         }
      }
   }
}

function menu(id)
{ 
 if (desc[id].action != 'affiche')
 {
    desc[id].action = 'affiche';
    process(id, 1);
 }
 else
 {
    desc[id].action = 'quitte';
    process(id, 1);
 }
}

function process(id, menu_level)
{
  var style = document.getElementById(id).style;

  // annul timeout si existe
  if (desc[id].timer) { window.clearTimeout(desc[id].timer); }

  if (desc[id].action == 'affiche')
  {
      // On remet a "block" si besoin
      style.display = 'block';
      // on réaffiche par fading en partant de la valeur courante
      if (desc[id].fading < 100)
      {
         desc[id].fading += delta_fading;
         set_opacity(id, desc[id].fading);
         desc[id].timer = window.setTimeout("process(\"" + id + "\"," + menu_level + ")", duree_fading[menu_level]/nb_etapes);
      }
   }
   else if (desc[id].action == 'quitte')
   {
      // On retarde le debut de l'effacement
      desc[id].action = 'efface';
      desc[id].timer = window.setTimeout("process(\"" + id + "\"," + menu_level + ")", retard[menu_level]);
   }
   else if (desc[id].action == 'efface')
   {
      // on efface par fading en partant de la valeur courante
      desc[id].fading -= delta_fading;
      if (desc[id].fading >= delta_fading)
      {
         set_opacity(id, desc[id].fading);
         desc[id].timer = window.setTimeout("process(\"" + id + "\"," + menu_level + ")", duree_fading[menu_level]/nb_etapes);
      }
      else
      {
         // la derniere etape consiste a supprimer l'affichage
         desc[id].fading = 0;
         set_opacity(id, desc[id].fading);
         style.display = 'none';
      }
   }
}

//change the opacity for different browsers
function set_opacity(id, opacity)
{ 
  var style = document.getElementById(id).style;
  style.opacity = (opacity / 100);
  style.MozOpacity = (opacity / 100);
  style.KhtmlOpacity = (opacity / 100);
  style.filter = "alpha(opacity=" + opacity + ")";
}

