function affiche(id) {
 for (var i = 1; i <= 11; i++) {
   if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display = 'none';}
 }
 if (document.getElementById(id)) {document.getElementById(id).style.display = 'block';}
}

function cachetout() {
  for (var i = 1; i <= 11; i++) {
    if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display = 'none';}
  }
}

function deroule(id) {
 if (document.getElementById(id).style.display == 'none') {document.getElementById(id).style.display = 'block';}
 else {document.getElementById(id).style.display = 'none';}
}

function sendData(data, page, method, destination) {
  if(document.all) {
    //Internet Explorer
    var XhrObj = new ActiveXObject("Msxml2.XMLHTTP") ;
  }
  else {
    //Mozilla
    var XhrObj = new XMLHttpRequest();
  }
			
  //définition de l'endroit d'affichage:
  if (document.getElementById(destination)) var content = document.getElementById(destination);

  //si on envoie par la méthode GET:
  if(method == "GET") {
    if(data == 'null') {
      //Ouverture du fichier s&eacute;lectionn&eacute;:
      XhrObj.open("GET", page);
    }
    else {
      //Ouverture du fichier en methode GET
      XhrObj.open("GET", page+"?"+data);
    }
  }
  else if(method == "POST") {
    //Ouverture du fichier en methode POST
    XhrObj.open("POST", page);
  }

  //Ok pour la page cible
  XhrObj.onreadystatechange = function() {
    if (XhrObj.readyState == 4 && XhrObj.status == 200 && document.getElementById(destination)) {content.innerHTML = XhrObj.responseText;}
  }

  if(method == "GET") {XhrObj.send(null);}
  else if(method == "POST") {
    XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    XhrObj.send(data);
  }
}

function popupC(page,largeur,hauteur,options) {
  var top = ( screen.height - hauteur ) / 2;
  var left = ( screen.width - largeur ) / 2;
  window.open( page, "", "top="+top+", left="+left+", width="+largeur+", height="+hauteur+", "+options);
}

function popup(url, largeur, hauteur) {
  var coordY  = ( screen.height - hauteur ) / 2;
  var coordX  = ( screen.width - largeur ) / 2;
  window.open( url, '', "top=" + coordY + ", left=" + coordX + ", width=" + largeur + ", height=" + hauteur + ", status=no, resizable=no, location=no, directories=no, scrollbars=yes");
}

function popupScroll(url, largeur, hauteur) {
  var coordY  = ( screen.height - hauteur ) / 2;
  var coordX  = ( screen.width - largeur ) / 2;
  window.open( url, '', "top=" + coordY + ", left=" + coordX + ", width=" + largeur + ", height=" + hauteur + ", status=no, resizable=yes, location=no, directories=no, scrollbars=yes");
}

function isEmail(adresse) {
  var place = adresse.indexOf("@",1);
  var point = adresse.indexOf(".",place+1);
		
  if ((place > -1)&&(adresse.length >2)&&(point > 1)) return(true);
  else return(false);
}

function isDate(d) {
  if (d == "") return false;
  else {
    e = new RegExp("^[0-9]{1,2}/[0-9]{1,2}/([0-9]{2}|[0-9]{4})$");
		
    if (e.test(d) == false) return false;
    else {
      j = parseInt(d.split("/")[0],10); // jour
      m = parseInt(d.split("/")[1],10); // mois
      a = (d.split("/")[2]); // année
		
      switch(a.length) {
        case 2:
          a = parseInt(a);
          if (a < 1000) {
            if (a < 89) a += 2000; // Si a < 89 alors on ajoute 2000 sinon on ajoute 1900
            else a += 1900;
          }
          break;
        case 4:
          a = parseInt(a);
          break;
        default:
          return(false);
          break;
      }
      if (a%4 == 0 && a%100 !=0 || a%400 == 0) fev = 29;
      else fev = 28;
      nbJours = new Array(31,fev,31,30,31,30,31,31,30,31,30,31);
      return ( m >= 1 && m <=12 && j >= 1 && j <= nbJours[m-1] );
    }
  }
}

function titreajax() {
  sendData(null, 'web/artiste-titre.php', 'GET', 'artistetitre'); //function sendData(data, page, method, destination)
  setTimeout("titreajax()", 3000);
}

function contact() {
  var a, s, n;
  function Crypt(s) {r='';for(i=0;i<s.length;i++){n = s.charCodeAt(i); if (n >= 8364) {n = 128;} r += String.fromCharCode( n - 3 ); }return r;}
  a = "pdlowr=";
  m = '&#64;';
  d = unescape(m);
  var nom = "studios";
  var domaine = "radiopac.fr";
  var aro = nom + d + domaine;
  document.write('<a href='+Crypt(a)+aro+'><img src="IMG/template/PACContact.png"></a>');
}

function redaction() {
  var a, s, n;
  function Crypt(s) {r='';for(i=0;i<s.length;i++){n = s.charCodeAt(i); if (n >= 8364) {n = 128;} r += String.fromCharCode( n - 3 ); }return r;}
  a = "pdlowr=";
  m = '&#64;';
  d = unescape(m);
  var nom = "studios";
  var domaine = "radiopac.fr";
  var aro = nom + d + domaine;
  document.write('<a href='+Crypt(a)+aro+'><img src="IMG/template/PACRedaction.png"></a>');
}

function afficheTousLesArticles(id1, id2) {
  if (document.getElementById(id1).style.display == 'none') {document.getElementById(id2).innerHTML='Afficher tous les articles';}
  else {document.getElementById(id2).innerHTML='Masquer les articles ci-dessous';}
}

function submitSondage(act) {
  document.write(act);
  document.write(document.getElementById('actions').value);
  document.getElementById('actions').value = "voir";
  document.monSondage.submit();
}

function sondage() {
  sendData(null, 'sondage/sondage.php', 'POST', 'sondage');
}