﻿/*---------------------------------------------------------------------*/
/*----------------------Envoi à un ami---------------------------------*/
/*---------------------------------------------------------------------*/

function sendMailAmi(){
  if(document.getElementById('contact_ami_mail').value == ''){
    alert('Veuillez saisir votre adresse email.');
    return;
  }
  if(document.getElementById('contact_ami_nom').value == ''){
    alert('Veuillez saisir votre nom.');
    return;
  }
  if(document.getElementById('contact_ami_mail_ami').value == ''){
    alert('Veuillez saisir votre l\'adresse email de votre ami.');
    return;
  }    
  
  if(!isMail(document.getElementById('contact_ami_mail'),'Cette adresse mail semble incorrecte.')){
    return;
  } 
  
  if(!isMail(document.getElementById('contact_ami_mail_ami'),'Cette adresse mail semble incorrecte.')){
    return;
  } 
  
  
  var email = encodeURIComponent($('#contact_ami_mail').val());
  var nom = encodeURIComponent($('#contact_ami_nom').val());
  var emailami = encodeURIComponent($('#contact_ami_mail_ami').val());
  var message = encodeURIComponent($('#contact_ami_message').val());  
  
  var reg=new RegExp("&", "g");
  var regSess=new RegExp("sessionuniqueid=.*&typerubrique", "gi");
  $('#fiche_envoi_ami .contentToRefresh').load(root+pageParameters["LANGUAGE"]+'/xslt.aspx?typerubrique=1&rubriqueid=100&actionner=CONTACT_AMI&contact_mail='+email+'&contact_message='+message+'&contact_mail_ami='+emailami+'&contact_nom='+nom+'&contact_lien='+location.href.replace(regSess,'typerubrique').replace(reg,'*')); 
    
}


/*---------------------------------------------------------------------*/
/*----------------------Envoi mot de passe-----------------------------*/
/*---------------------------------------------------------------------*/

function sendMailOubli(){
  if(document.getElementById('oubli_mail').value == ''){
    alert('Veuillez saisir votre adresse email.');
    return;
  }    
  if(!isMail(document.getElementById('oubli_mail'),'Cette adresse mail semble incorrecte.')){
    return;
  } 
  
  var email = encodeURIComponent($('#oubli_mail').val());  
  var reg=new RegExp("&", "g");
  var regSess=new RegExp("sessionuniqueid=.*&typerubrique", "gi");
  $('#fiche_mail_oubli .contentToRefresh').load(root+pageParameters["LANGUAGE"]+'/xslt.aspx?typerubrique=1&rubriqueid=102&actionner=MAIL_OUBLI&contact_mail='+email); 
    
}

/*---------------------------------------------------------------------*/
/*----------------------Formulaire de contact--------------------------*/
/*---------------------------------------------------------------------*/

function sendContact(){
  if(document.getElementById('contact_nom').value == ''){
    alert('Veuillez saisir votre nom.');
    return;
  }
  if(document.getElementById('contact_mail').value == ''){
    alert('Veuillez saisir votre adresse email.');
    return;
  }  
    
  if(document.getElementById('contact_objet').value == ''){
    alert("Veuillez indiquer l'objet du contact.");
    return;
  }    
  
  if(!isMail(document.getElementById('contact_mail'),'Cette adresse mail semble incorrecte.')){
    return;
  }   
  
  var email = encodeURIComponent($('#contact_mail').val());
  var nom = encodeURIComponent($('#contact_nom').val());  
  var message = encodeURIComponent($('#contact_message').val());  
  var objet = encodeURIComponent($('#contact_objet').val());  
  
  var reg=new RegExp("&", "g");
  var regSess=new RegExp("sessionuniqueid=.*&typerubrique", "gi");
  $('#form_contact .contentToRefresh').fadeOut();
  $('#form_contact .contentToRefresh').load(root+pageParameters["LANGUAGE"]+'/xslt.aspx?typerubrique=1&rubriqueid=101&actionner=FORM_CONTACT&contact_mail='+email+'&contact_message='+message+'&contact_nom='+nom+'&contact_objet='+objet+'&contact_lien='+location.href.replace(regSess,'typerubrique').replace(reg,'*'), function(){
    $('#form_contact .contentToRefresh').fadeIn();  
  });     
}


function cacheVote(){
  document.getElementById('submitSond').style.display='none';
  document.getElementById('confirmVote').style.display='block';
}

function confirmationModification(){
  alert('Changement effectué');
}

function affichageErreur(){
  alert('Erreur durant la modification des informations');
}
