/***********************************************************************
 *   Fichier : Scripts.js                                              *
 *   Fonctions globales du site                                        *
 ***********************************************************************/

var i, gMembre, gMenu;

gMembre = 0;
gMenu = new Array(20);
gMenu[0] = "Reservations.php";
gMenu[1] = "Messages.php";
gMenu[2] = "Preparation.php";
gMenu[3] = "Regles/Regles.php";
gMenu[4] = "VieClub/VieClub.php";
for (i = 5 ; i < 20 ; i++)
  gMenu[i] = "";

/***********************************************************************
 * Initialisation du membre                                            *
 ***********************************************************************/

function mvInitialiseMembre(pMembre)
{
gMembre = pMembre;
}

/***********************************************************************
 * Affichage d'une cellule en surbrillance ou en normal                *
 ***********************************************************************/

function mvPointer(pRow, pDefaultColor, pPointerColor)
{
pRow.style.color = pDefaultColor;
pRow.style.backgroundColor = pPointerColor;
}

/***********************************************************************
 * Affichage d'une ligne en surbrillance ou en normal                  *
 ***********************************************************************/

function mvInvert(pRow, pDefaultColor, pPointerColor)
{
var wCells, wRowCellsCnt, c;

if (pPointerColor == '' || typeof(pRow.style) == 'undefined')
  return false;
if (typeof(document.getElementsByTagName) != 'undefined')
  wCells = pRow.getElementsByTagName('td');
  else if (typeof(pRow.cells) != 'undefined')
    wCells = pRow.cells;
    else
      return false;
wRowCellsCnt  = wCells.length;
for (c = 0 ; c < wRowCellsCnt ; c++)
  {
  wCells[c].style.color = pDefaultColor;
  wCells[c].style.backgroundColor = pPointerColor;
  }
return true;
}

/***********************************************************************
 * Affichage de la ligne sélectionnée après un rechargement            *
 ***********************************************************************/

function mvBlink(pUrl)
{
var i, wCells, wIndex, wStart;

wStart = 18;
wCells = document.getElementsByTagName('td');
wIndex = wStart + 10;
for (i = 0 ; i < 20 ; i++)
  {
  if (pUrl == gMenu[i])
    {
    wIndex = wStart + (i * 2);
    break;
    }
  }
wCells[wIndex].style.color = "#752600";
wCells[wIndex].style.backgroundColor = "#FFB895";
}

/***********************************************************************
 * Lien vers une page normale                                          *
 ***********************************************************************/

function mvLink(pRow, pUrl, pMenu)
{
var wCells, wRowCellsCnt, c, wString;

wCells = document.getElementsByTagName('td');
wRowCellsCnt  = wCells.length;
for (c = 0 ; c < wRowCellsCnt ; c++)
  {
  if (wCells[c].style.color == "#752600")
    {
    wCells[c].style.color = "#005177";
    wCells[c].style.backgroundColor = "#C3C3C3";
    }
  }
if (pRow != 'undefined')
  {
  pRow.style.color = "#752600";
  pRow.style.backgroundColor = "#FFB895";
  }
window.top.frames['frClient'].document.location.replace(pUrl);
wString = "Summary.php?membre=" + gMembre + "&menu=" + pMenu;
document.location.replace(wString);
}

/***********************************************************************
 * Lien vers une page réservée                                         *
 ***********************************************************************/

function mvMembre(pRow, pUrl, pMenu)
{
var wUrl, wCells, wRowCellsCnt, c, wString;

wCells = document.getElementsByTagName('td');
wRowCellsCnt  = wCells.length;
for (c = 0 ; c < wRowCellsCnt ; c++)
  {
  if (wCells[c].style.color == "#752600")
    {
    wCells[c].style.color = "#005177";
    wCells[c].style.backgroundColor = "#C3C3C3";
    }
  }
if (pRow != 'undefined')
  {
  pRow.style.color = "#752600";
  pRow.style.backgroundColor = "#FFB895";
  }
if (gMembre == 0)
  wUrl = "Membres/Identify.php?url=" + pUrl;
  else
    wUrl = "Membres/" + pUrl + "?membre=" + gMembre;
window.top.frames['frClient'].document.location.replace(wUrl);
wString = "Summary.php?membre=" + gMembre + "&menu=" + pMenu;
document.location.replace(wString);
}

/***********************************************************************
 * Lien vers la page d'administration                                  *
 ***********************************************************************/

function mvAdmin(pRow)
{
var wUrl, wCells, wRowCellsCnt, c;

wCells = document.getElementsByTagName('td');
wRowCellsCnt  = wCells.length;
for (c = 0 ; c < wRowCellsCnt ; c++)
  {
  if (wCells[c].style.color == "#752600")
    {
    wCells[c].style.color = "#005177";
    wCells[c].style.backgroundColor = "#C3C3C3";
    }
  }
if (pRow != 'undefined')
  {
  pRow.style.color = "#752600";
  pRow.style.backgroundColor = "#FFB895";
  }
if (gMembre == 0)
  wUrl = "Membres/Identify.php?url=@Admin";
  else
    wUrl = "Admin/Administration.php?membre=" + gMembre;
window.top.frames['frClient'].document.location.replace(wUrl);
wString = "Summary.php?membre=" + gMembre + "&menu=16";
document.location.replace(wString);
}

/***********************************************************************
 * Ouverture de la fenêtre du calcul du centrage                       *
 ***********************************************************************/

function mvCentrage()
{
var wState, wView, wWidth, wLeft, wTop, wHeight;

wWidth = 800;
wHeight = 600;
wLeft = (screen.width - wWidth) / 2;
if (wLeft > 147)
  wLeft = 147;
wTop = (screen.height - wHeight) / 2;
if (wTop > 73)
  wTop = 73;
wState = "toolbar=no, location=no, directories=no, status=no, scrollbars=no, ";
wState += "resizable=no, copyhistory=no, width=" + wWidth;
wState += ", height=" + wHeight + ", left=" + wLeft + ", top=" + wTop;
wView = window.open("Centrage.php", "mvCentrage", wState);
}

/***********************************************************************
 * Imprimer un document                                                *
 ***********************************************************************/

function mvPrint(pUrl)
{
var wState, wView, wWidth, wLeft, wTop, wHeight;

wWidth = 800;
wHeight = 600;
wLeft = 0;
wTop = 0;
wState = "toolbar=no, location=no, directories=no, status=no, scrollbars=no, ";
wState += "resizable=no, copyhistory=no, width=" + wWidth;
wState += ", height=" + wHeight + ", left=" + wLeft + ", top=" + wTop;
wView = window.open(pUrl, "mvPrinting", wState);
}
