function load(lang)
{
  if(document.getElementById('flash'))
    onload_flash(lang);
}

function lien(page)
{
  document.location.href=page;
}

function dl(num)
{
  if (num == 1) window.open('Specifications_WiFi_Pro_Interieur.pdf', 'spec_int', 'toolbar=no, menubar=no');
  if (num == 2) window.open('Specifications_WiFi_Pro_Exterieur.pdf', 'spec_ext', 'toolbar=no, menubar=no');
  if (num == 5) window.open('Pages_accueil_Service_Internet.pdf', 'ecoparticipation', 'toolbar=no, menubar=no');
  if (num == 6) window.open('EcoParticipation.pdf', 'ecoparticipation', 'toolbar=no, menubar=no');
  if (num == 7) window.open('Conditions_Generales_de_Vente_WiFi_Pro.pdf', 'ecoparticipation', 'toolbar=no, menubar=no');
}

function contact_valider()
{
  document.cookie = "c[contact]=" + escape(
    document.getElementById("id_nom").value + "|" +
    document.getElementById("id_prenom").value + "|" +
    document.getElementById("id_societe").value + "|" +
    document.getElementById("id_adresse").value + "|" +
    document.getElementById("id_telephone").value + "|" +
    document.getElementById("id_email").value + "|" +
    document.getElementById("id_message").value
    );
  document.location.href='contact.php';
}


function onload_flash(lang)
{
  var flashvars = {};
  flashvars.lang = lang;
  var params = {};
  var attributes = {};
  swfobject.embedSWF("cart.swf", "carte_flash", "900", "500", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}

function clignotement(){
  if (document.getElementById("bouton_chat_lien").className=="bouton_visible")
     document.getElementById("bouton_chat_lien").className="bouton_invisible";
  else
     document.getElementById("bouton_chat_lien").className="bouton_visible";
}

function requete(page,lang)
{
  if(page=="index")
  {
    var clef = (token != "") ? token : key;
    if(clef!="")
    {
      var tab = new Array();
      tab['fr'] = "Accès direct à<br/>ma conso et à<br/>WifiChat";
      tab['es'] = "Acceso directo<br/>a mi consumo y<br/>WifiChat";
      tab['en'] = "Direct Access to<br/>my time credit <br/>and to WiFiChat";
      tab['nl'] = "Directe toegang tot<br/>mijn account <br/>en WifiChat";
      tab['de'] = "Hier gehts zur<br/>Verbrauchsübersicht<br/>(minutenzähler)<br/>und zum WiFiChat";
      switch(lang)
      {
      case 'de':
        tailletxt = "style=\"font-size: 14px;line-height: 14px;\"";
        break;
      default:
          tailletxt = "style=\"font-size: 16px;line-height: 16px;\"";
      }
      document.getElementById('bouton_chat').innerHTML+="<button id='bouton_chat_lien' class='bouton_visible' align='middle' onclick=\"javascript:window.location.href='acces.php?&key="+clef+"';\">"+tab[lang]+"</button>";
      setInterval('clignotement()', 500);
    }
  }
}

function acces(lang)
{
  document.form_login.submit();
}

function effacer(msg, e)
{
  if(e.value==msg)
    e.value="";
}

function enter(e,lang)
{
  e = e || window.event;
  var code = e.keyCode || e.which;
  if(code == 13)
    acces(lang);
}

function verif(val)
{
  if(document.getElementById('userNameField').value=="")
  {
    return false;
  }
  else
  {
    document.getElementById('userNameField').value=document.getElementById('userNameField').value.replace(/[\u20ac\u00c8\u00c9\u00ca\u00cb\u00e8\u00e9\u00ea\u00eb]/g,"e");
    document.getElementById('userNameField').value=document.getElementById('userNameField').value.replace(/[\u00cc\u00cd\u00ce\u00cf\u00ec\u00ed\u00ee\u00ef]/g,"i");
    document.getElementById('userNameField').value=document.getElementById('userNameField').value.replace(/[\u00d9\u00da\u00db\u00dc\u00f9\u00fa\u00fb\u00fc]/g,"u");
    document.getElementById('userNameField').value=document.getElementById('userNameField').value.replace(/[\u00a5\u00dd\u0178\u0177\u00fd\u00dd\u0176\u00ff]/g,"y");
    document.getElementById('userNameField').value=document.getElementById('userNameField').value.replace(/[\u0040\u00c1\u00c0\u00c2\u00c3\u00c4\u00c5\u00e1\u00e0\u00e2\u00e3\u00e4\u00e5]/g,"a");
    document.getElementById('userNameField').value=document.getElementById('userNameField').value.replace(/[\u00d2\u00d3\u00d4\u00d5\u00d6\u00f2\u00f3\u00f4\u00f5\u00f6]/g,"o");
    if(censures(document.getElementById('userNameField').value)==1)
    {
      document.location.href="http://www.wificamping.com";
      return false;
    }
  }
}


function  censures(paraf)
  {
    var cens = new Array();
    var mot = new Array();
//    paraf = this.accents(paraf);
    var phrase = accents(paraf);
    phrase = phrase.split("\n");
    for(var z=0;z<phrase.length;z++)
       mot = mot.concat(phrase[z].split(" "));
    var censure = filtre();
    var cpt = 0;
    var censureLength=censure.length;
    var motLength=mot.length;
    var motiLength;
    var texte;var b;
    var decalage = 0;
    var idecalage = 0;
    var dif="";
    var bool;
    var reg = new RegExp("^[a-z]+$","");
    for(var i=0;i<motLength;i++)
    {
      texte=mot[i];
      texte=texte.toLowerCase();
  //    texte=accents(texte);
      motiLength=mot[i].length;
      for(var j=0;j<censureLength;j++)
      {
          for(var k=0;k<motiLength;k++)
          {
            if(k==2 && ((cpt*100/2)<50 ))
              break;
            b=k;
            while(texte.charAt(b)==texte.charAt(b+1))
            {
              texte=texte.substring(0,b)+texte.substring(b+1,texte.length);
              motiLength--;
            }
            if(texte.charAt(k+decalage)==censure[j].charAt(k+idecalage))
            {
              cpt++;
            }
            else
            {
              if(texte.charCodeAt(k+decalage)!=13 && texte.charCodeAt(k+decalage)!=32 && !bool)
                  dif+=texte.charAt(k+decalage);
            }
            if(texte.charCodeAt(k+decalage)==32)
              idecalage--;
          }
          if((cpt*100)/censure[j].length>=76 &&  !reg.test(dif))// || dif==""))
          {
            cens.push(mot[i]);
            cpt=0;
            break;
          }
          else
          {
            if(dif=="" && motiLength==censure[j].length)
            {
              cens.push(mot[i]);
              cpt=0;
              break;
            }
          }
          decalage=0;
          idecalage=0;
          cpt=0;
          dif="";
        }
      }
      if(cens.length>0)
        return 1;
      else
        return 0;
  }

function  accents(chaine)
  {
    chaine = chaine.replace(/[\u20ac\u00c8\u00c9\u00ca\u00cb\u00e8\u00e9\u00ea\u00eb]/g,"e");
    chaine = chaine.replace(/[\u00cc\u00cd\u00ce\u00cf\u00ec\u00ed\u00ee\u00ef]/g,"i");
    chaine = chaine.replace(/[\u00d9\u00da\u00db\u00dc\u00f9\u00fa\u00fb\u00fc]/g,"u");
    chaine = chaine.replace(/[\u00a5\u00dd\u0178\u0177\u00fd\u00dd\u0176\u00ff]/g,"y");
    chaine = chaine.replace(/[\u00d2\u00d3\u00d4\u00d5\u00d6\u00f2\u00f3\u00f4\u00f5\u00f6]/g,"o");
    chaine = chaine.replace(/[\u0040\u00c1\u00c0\u00c2\u00c3\u00c4\u00c5\u00e1\u00e0\u00e2\u00e3\u00e4\u00e5]/g,"a");
    chaine = chaine.replace(/[\u0024]/g,"s");
    chaine = chaine.replace(/[\u002e\u0022\u0027\u005b\u005d\u002c\u00bf\u003f]/g," ");
    return chaine;
  }

function filtre()
  {
    var filtre = new Array(
      'abrutis',
      'abruties',
      'becases',
      'bordel',
      'couiles',
      'chieurs',
      'chieuses',
      'cons',
      'conards',
      'conases',
      'coneries',
      'cones',
      'couilons',
      'cretins',
      'chiants',
      'debiles',
      'enfoires',
      'encules',
      'enculeurs',
      'enculeuses',
      'putes',
      'grognases',
      'imbeciles',
      'niquer',
      'bites',
      'culs',
      'lopetes',
      'merdes',
      'merdeux',
      'morveux',
      'pedales',
      'pedes',
      'pd',
      'petases',
      'poufes',
      'poufiases',
      'putains',
      'foutre',
      'salauds',
      'salops',
      'salopes',
      'saloperies',
      'tentouses',
      'tarlouses',
      'tarlouzes',
      'fuck',
      'ashole',
      'bitch',
      'biatch',
      'dick',
      'bastard',
      'shit',
      'dumb',
      'sucker',
      'fucking',
      'cock',
      'cunt',
      'motherfucker',
      'wanker',
      'toser',
      'arsehole',
      'shag',
      'whore',
      'twat',
      'slag',
      'dickhead ',
      'arse',
      'buger',
      'crap',
      'pusy',
      'tits',
      'dyke',
      'cocksucker',
      'prickteaser',
      'slut'
      );
      return filtre;
  }

function verif_form_gps()
{
    gpsnum = document.form_gps.gps.value;
    if (gpsnum == "0")
    {
      return false;
    }
    // Gestion de la 2nd liste..
    if (document.form_gps.gps_version)
    {
      if (document.form_gps.gps_version.value == "0")
      {
        return false;
      }
    }
}

function check_modele_gps(texte_liste)
{
    gpsnum = document.form_gps.gps.value;
    switch(gpsnum)
    {
    case "100":
        document.getElementById("modele_gps").innerHTML=
        "<select name=\"gps_version\" STYLE=\"width:200px; vertical-align:middle;\">"+
          "<option value=\"0\">"+texte_liste+"</option>"+
          "<option value=\"100\">TomTom (ov2)</option>"+
          "<option value=\"101\">TomTom itinerary (itn)</option>"+
        "</select>";
        break;
    case "300":
        document.getElementById("modele_gps").innerHTML=
        "<select name=\"gps_version\" STYLE=\"width:200px; vertical-align:middle;\">"+
          "<option value=\"0\">"+texte_liste+"</option>"+
          "<option value=\"300\">Destinator (csv)</option>"+
          "<option value=\"301\">Destinator (dat)</option>"+
        "</select>";
        break;
    case "500":
        document.getElementById("modele_gps").innerHTML=
        "<select name=\"gps_version\" STYLE=\"width:200px;\">"+
          "<option value=\"0\">"+texte_liste+"</option>"+
          "<option value=\"500\">Navio (csv)</option>"+
          "<option value=\"501\">Navio (asc)</option>"+
        "</select>";
        break;
    case "600":
        document.getElementById("modele_gps").innerHTML=
        "<select name=\"gps_version\" STYLE=\"width:200px\">"+
          "<option value=\"0\">"+texte_liste+"</option>"+
          "<option value=\"600\">Garmin (csv)</option>"+
          "<option value=\"601\">Garmin (gpx)</option>"+
        "</select>";
        break;
    case "700":
        document.getElementById("modele_gps").innerHTML=
        "<select name=\"gps_version\" STYLE=\"width:200px\">"+
          "<option value=\"0\">"+texte_liste+"</option>"+
          "<option value=\"700\">Miomap (csv)</option>"+
          "<option value=\"701\">Mio (csv)</option>"+
          "<option value=\"702\">Mio (asc)</option>"+
        "</select>";
        break;
    case "1400":
        document.getElementById("modele_gps").innerHTML=
        "<select name=\"gps_version\" STYLE=\"width:200px\">"+
          "<option value=\"0\">"+texte_liste+"</option>"+
          "<option value=\"1400\">Nokia (csv)</option>"+
          "<option value=\"1401\">Nokia (lmx)</option>"+
        "</select>";
        break;
    case "2100":
        document.getElementById("modele_gps").innerHTML=
        "<select name=\"gps_version\" STYLE=\"width:200px\">"+
          "<option value=\"0\">"+texte_liste+"</option>"+
          "<option value=\"2100\">Acer (csv)</option>"+
          "<option value=\"2101\">Acer (dat)</option>"+
        "</select>";
        break;
    default:
        document.getElementById("modele_gps").innerHTML="";
    }
}
