/***********************************************************************
 *   Fichier : Scripts.js                                              *
 *   Scripts pour les membres                                          *
 ***********************************************************************/

/***********************************************************************
 * Identification                                                      *
 ***********************************************************************/

function mvIdent()
{
var wUrl;

if (document.FrmMain.TxtIdent.value == "")
  {
  alert("Il manque l'identifiant !");
  document.FrmMain.TxtIdent.focus();
  return;
  }
if (document.FrmMain.TxtPassword.value == "")
  {
  alert("Il manque le mot de passe !");
  document.FrmMain.TxtPassword.focus();
  return;
  }
wUrl = "Ident.php?ident=" + document.FrmMain.TxtIdent.value + "&password=" + document.FrmMain.TxtPassword.value;
document.location.replace(wUrl);
}

/***********************************************************************
 * Mise à jour des informations dans la fiche                          *
 *---------------------------------------------------------------------*
 * pUser : Code du membre                                              *
 ***********************************************************************/

function mvFicheDisplay(pUser)
{
var wObject, wHtml, wValue, wPos;
var wCode, wSexe, wNom, wPrenom, wAdresse, wTel, wMail, wFonction, wPhoto, wView;
var wIfAdresse, wIfTel, wIfMail, wIfPhoto, wVisible;

wValue = document.FrmMain.LstMembres.value;
wPos = wValue.indexOf("|", 0);
wCode = wValue.substr(0, wPos);
wValue = wValue.substr(wPos + 1, 1024);
wPos = wValue.indexOf("|", 0);
wSexe = wValue.substr(0, wPos);
wValue = wValue.substr(wPos + 1, 1024);
wPos = wValue.indexOf("|", 0);
wNom = wValue.substr(0, wPos);
wValue = wValue.substr(wPos + 1, 1024);
wPos = wValue.indexOf("|", 0);
wPrenom = wValue.substr(0, wPos);
wValue = wValue.substr(wPos + 1, 1024);
wPos = wValue.indexOf("|", 0);
wAdresse = wValue.substr(0, wPos);
wValue = wValue.substr(wPos + 1, 1024);
wPos = wValue.indexOf("|", 0);
wTel = wValue.substr(0, wPos);
wValue = wValue.substr(wPos + 1, 1024);
wPos = wValue.indexOf("|", 0);
wMail = wValue.substr(0, wPos);
wValue = wValue.substr(wPos + 1, 1024);
wPos = wValue.indexOf("|", 0);
wFonction = wValue.substr(0, wPos);
wValue = wValue.substr(wPos + 1, 1024);
wPos = wValue.indexOf("|", 0);
wPhoto = wValue.substr(0, wPos);
wValue = wValue.substr(wPos + 1, 1024);
wPos = wValue.indexOf("|", 0);
wView = wValue.substr(0, wPos);

wIfAdresse = ((wView.substr(0, 1) == "1") ? true : false);
wIfTel = ((wView.substr(1, 1) == "1") ? true : false);
wIfMail = ((wView.substr(2, 1) == "1") ? true : false);
wIfPhoto = ((wView.substr(3, 1) == "1") ? true : false);
if (!wIfAdresse)
  wAdresse = "<br><br><br>";
if (!wIfTel)
  wTel = "&nbsp;";
if (!wIfMail)
  wMail = "&nbsp;";
if (!wIfPhoto)
  wPhoto = "";
switch (wFonction)
  {
  case "1":
    wFonction = ((wSexe == 1) ? "Président" : "Présidente");
    break;
  case "2":
    wFonction = ((wSexe == 1) ? "Vice-président" : "Vide-présidente");
    break;
  case "3":
    wFonction = ((wSexe == 1) ? "Trésorier" : "Trésorière");
    break;
  case "4":
    wFonction = ((wSexe == 1) ? "Trésorier adjoint" : "Trésorière adjointe");
    break;
  case "5":
    wFonction = "Secrétaire";
    break;
  case "6":
    wFonction = ((wSexe == 1) ? "Secrétaire adjoint" : "Secrétaire adjointe");
    break;
  case "7":
    wFonction = ((wSexe == 1) ? "Enseignant" : "Enseignante");
    break;
  case "8":
    wFonction = ((wSexe == 1) ? "Enseignant adjoint" : "Enseignante adjointe");
    break;
  default:
    wFonction = "Membre";
    break;
  }
wHtml  = "<table border=0 cellspacing=0 cellpadding=0>";
wHtml += "<tr><td valign='top'><small>Nom :&nbsp;</small></td><td valign='top'><small>" + wNom + "</small></td></tr>";
wHtml += "<tr><td colspan=2 height=4></td></tr>";
wHtml += "<tr><td valign='top'><small>Prénom :&nbsp;</small></td><td valign='top'><small>" + wPrenom + "</small></td></tr>";
wHtml += "<tr><td colspan=2 height=4></td></tr>";
wHtml += "<tr><td valign='top'><small>Adresse :&nbsp;</small></td><td valign='top'><small>" + wAdresse + "</small></td></tr>";
wHtml += "<tr><td colspan=2 height=4></td></tr>";
wHtml += "<tr><td valign='top'><small>Tél. :&nbsp;</small></td><td valign='top'><small>" + wTel + "</small></td></tr>";
wHtml += "<tr><td colspan=2 height=4></td></tr>";
wHtml += "<tr><td valign='top'><small>Mail :&nbsp;</small></td><td valign='top'><small>" + wMail + "</small></td></tr>";
wHtml += "<tr><td colspan=2 height=4></td></tr>";
wHtml += "<tr><td valign='top'><small>Statut :&nbsp;</small></td><td valign='top'><small>" + wFonction + "</small></td></tr>";
wHtml += "</table>";
wObject = document.getElementById("IdInfo");
wObject.innerHTML = wHtml;
if (wPhoto > "")
  wUrl = "Photos/" + wPhoto + ".jpg";
  else
    wUrl = "../Decor/Empty.gif";
document.images["ImgPhoto"].src = wUrl;
wVisible = ((wCode == pUser) ? "visible" : "hidden");
document.FrmMain.CmdModify.style.visibility = wVisible;
}

/***********************************************************************
 * Modifier les information de le fiche du membre                      *
 *---------------------------------------------------------------------*
 * pUser : Code du membre                                              *
 ***********************************************************************/

function mvFicheModify(pUser)
{
var wUrl;

wUrl = "MembresModify.php?user=" + pUser;
document.location.replace(wUrl);
}

/***********************************************************************
 * Ajouter un message                                                  *
 *---------------------------------------------------------------------*
 * pUser : Code de l'utilisateur                                       *
 ***********************************************************************/

function mvAppendMessage(pUser)
{
var wMsg, wUrl;

wMsg = prompt("Contenu du message");
if (wMsg == null)
  return;
wUrl = "MailSend.php?user=" + pUser + "&msg=" + wMsg + "&mode=1";
document.location.replace(wUrl);
}

/***********************************************************************
 * Réponse au message                                                  *
 *---------------------------------------------------------------------*
 * pUser : Code de l'utilisateur                                       *
 * pMsg  : Message d'origine                                           *
 ***********************************************************************/

function mvResponseMessage(pUser, pMsg)
{
var wMsg, wUrl;

wMsg = prompt("Contenu du message");
if (wMsg == null)
  return;
wUrl = "MailSend.php?user=" + pUser + "&msg=" + wMsg + "&mode=2&code=" + pMsg;
document.location.replace(wUrl);
}

/***********************************************************************
 * Effacer un message                                                  *
 *---------------------------------------------------------------------*
 * pUser : Code de l'utilisateur                                       *
 * pMsg  : Message à effacer                                           *
 * pConf : Message de confirmation pour la suppression                 *
 ***********************************************************************/

function mvDeleteMessage(pUser, pMsg, pConf)
{
var wUrl;

if (!confirm(pConf))
  return;
wUrl = "MailSend.php?user=" + pUser + "&mode=3&code=" + pMsg;
document.location.replace(wUrl);
}
