  var encours;
  function separeMilliers (sNombre) {
    separateurMilliers = ' ';
    var sRetour = "";
    while (sNombre.length % 3 != 0) {
      sNombre = "0"+sNombre;
    }
    for (i = 0; i < sNombre.length; i += 3) {
      if (i == sNombre.length-1) separateurMilliers = '';
        sRetour += sNombre.substr(i, 3)+separateurMilliers;
      }
    while (sRetour.substr(0, 1) == "0") {
      sRetour = sRetour.substr(1);
    }
    return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
  }

  function incremente()
  {
    encours += Math.round(Math.random()*2)+1;
    document.getElementById('nb_msg').innerHTML=separeMilliers(encours);
  }

  function load_from_graph(bw_id,bw_str,d_ft,type_parent_ws)
  {
    var day_after=Number(d_ft.substring(8,10))+1;
    var myday = new Date(d_ft.substring(0,4),(d_ft.substring(5,7)-1),day_after);
    var month=myday.getMonth()+1;
    if (month<10) month="0"+month;
    var day=myday.getDate();
    if (day<10) day="0"+day;
    var clean_to=myday.getFullYear()+'-'+month+'-'+day;
    window.parent.myLightWindow.activateWindow({href:"/membre/modules/module_full.php?mod=TagsPop&nb_res=20&bw="+bw_id+"&d_from="+d_ft+"&d_to="+d_ft+"&module=module_trend"+"&type_parent_ws="+type_parent_ws,title:'WebTracker "'+bw_str+'"',type:'external',width:950,loadingAnimation:'false'});
  }

 function load_from_pie(wt_id,wt_str,type_str,ws_type,ws_type_parent,d_from,d_to) {
    window.parent.myLightWindow.activateWindow({href:"/membre/modules/module_full.php?mod=TagsPop&nb_res=20&bw="+wt_id+"&ws_type="+ws_type+"&module=module_type_ws"+"&type_parent_ws="+ws_type_parent+"&d_from_pie="+d_from+"&d_to_pie="+d_to,title:'WebTracker "'+wt_str+'"'+' - '+type_str,type:'external',width:950, loadingAnimation:'false'});
  }

  function load_from_tags(url,title)
  {
    window.parent.myLightWindow.activateWindow({href:url,title:'WebTracker "'+title+'"',type:'external',width:950, loadingAnimation:'false'});
    return false;
  }

  function load_graph (flash_file, library_path, php_source, width, height, bgColor)
  {
    height=217;
    var html ="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='"+width+"' height='"+height+"' id='charts' align='middle'>\n";

    html+="<param name='wmode' value='transparent' />\n<param name='movie' value='"+flash_file+"?library_path="+library_path+"&amp;php_source="+php_source+"' />\n<param name='quality' value='high' />\n<param name='bgcolor' value='"+bgColor+"'/>\n";

    html+="<embed src='"+flash_file+"?library_path="+library_path+"&amp;php_source="+php_source+"' wmode='transparent' quality='high' bgcolor='"+bgColor+"' id=charts width='"+width+"' height='"+height+"' swLiveConnect='true'  name='charts' align='' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
    document.getElementById('graph_aera').innerHTML=html;
  }


  function update_tag(keywords,tag_id,ws_type, ws_type_parent) {
    myWord=keywords;
    if (typeof select_tag!="undefined")  document.getElementById("tag_"+select_tag).style.background="none"; 
    document.getElementById("tag_"+tag_id).style.background="#BCDFFF"; 
    select_tag=tag_id;
    xajax_UpdateTagsPop(keywords,document.getElementById("d_from").value, document.getElementById("d_to").value,0,ws_type,ws_type_parent); 
    return false;
  }

 /**********************
** controlmail()
** in : email : chaine de caractere devant contenir un mail
** out : booleen -> oui / non le mail est correct OU vide
** Objet : avertit si une chaine de caractere correspond à la forme d'un mail  
***********************/    
function controlmail(email)
{
  // re -> expression reguliere
  var re = /^[\w\x80-\xFF]+([\.-]?[\w\x80-\xFF]+)*@[\w\x80-\xFF]+([\.-]?[\w\x80-\xFF]+)*(\.[\w\x80-\xFF]{2,4})+$/;
  //si pas regulier et pas vide
  if(!re.test(email) && email!="")
  {
    alert("Veuillez entrer une adresse mail correcte.");
    return false;
  }
  return true;
}

 /**********************
** loading()
** in : div_id : id de la DIV
**      texte : texte a afficher ("chargement")
** out : -
** Objet : affiche la DIV indiquant un chargement
***********************/
function show_loading(div_id,texte)
{
  document.getElementById(div_id).innerHTML = '<img src=/img/loading.gif />'+texte+'<br/>';
  document.getElementById(div_id).style.display = 'block';
}

/*
Change la couleur de l id button passe en param et remet l autre a la couleur par defaut
*/
function change_color(button){
  if(button=='date')
    document.getElementById('trendy').className='bouton_sort_off';
  else
    document.getElementById('date').className='bouton_sort_off';
  document.getElementById(button).className='bouton_sort_on';
}

 /**********************
** loading()
** in : div_id : id de la DIV
**      texte : texte a afficher ("chargement") en style centre
** out : -
** Objet : affiche la DIV indiquant un chargement
***********************/
function show_loading_center(div_id,texte){
  document.getElementById(div_id).innerHTML = '<div align=\'center\'><br/><img src=/img/loading.gif />'+texte+'<br/></div>';
  document.getElementById(div_id).style.display = 'block';
}
