/* l_keywords.js
 * Version 2.3 - 10/02/2009
 * Role : cours - scripts pour page Keywords
 * Projet : The Web Language Lab
 * Auteur : Etienne CHEVILLARD
 *
 * Copyright (C) 2003 Etienne CHEVILLARD
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 */

// donnees specifiques a la page
var titrePage = txtLng[4];
var hauteurPage = 400;

// retourne le code pour les instructions
function codeInstruc() {
  var txt;
  txt = "<p class=\"liste1\">";
  txt+= txtLng[20];
  txt+= "<p class=\"liste1\">";
  txt+= txtLng[21];
  return (txt);
} // fin codeInstruc()

// retourne le code pour l'ordre chronologique
function codeChrono() {
  var txt;
  txt = "<table width=620 border=0 cellspacing=4 cellpadding=2><tr><td>";
  for(var i=0; i<keywordsC.length; i++) {
    txt+= "<p class=\"script1\"><b>";
    txt+= keywordsC[i][0];
    txt+= "&nbsp;:</b> &nbsp;";
    txt+= keywordsC[i][1];
  }
  txt+= "</td></tr></table>";
  return (txt);
} // fin codeChrono()

// retourne le code pour l'ordre alphabetique
function codeAlpha() {
  var txt;
	var keywords2 = new Array(keywordsC.length);
	for(var i=0; i<keywords2.length; i++) {
		keywords2[i] = keywordsC[i][0].toLowerCase();
  }
	keywords2.sort();
	txt = "<table width=620 border=0 cellspacing=4 cellpadding=2><tr><td>";
	for(var i=0; i<keywords2.length; i++) {
    for(var j=0; j<keywordsC.length; j++) {
		  if (keywords2[i] == keywordsC[j][0].toLowerCase()) {
        txt+= "<p class=\"script1\"><b>";
        txt+= keywordsC[j][0];
        txt+= "&nbsp;:</b> &nbsp;";
        txt+= keywordsC[j][1];	
		  }
		}
  }
  txt+= "</td></tr></table>";
  return (txt);
} // fin codeAlpha()

// retourne le code pour les onglets - ordre chronologique
function codeOnglets(idx) {
  var txt;
  txt = "<table width=626 class=\"onglet_table\" border=1 cellspacing=0 cellpadding=0><tr>";
  txt+= "<td width=10 height=20 class=\"onglet_vide\">&nbsp;";
  // chrono
  txt+= "</td><td width=180 height=20 ";
  if (parseInt(idx) == 0) {
    txt+= "class=\"onglet_actif\">";
    txt+= "<p class=\"centre\"><b>" + txtLng[22] + "</b>";
  } else {
    txt+= "class=\"onglet_gauche\">";
    txt+= "<p class=\"centre\">";
    txt+= lienTexteWeb(txtLng[22], "javascript:afficherChrono()", "", txtLng[22]);
  }
  // alpha  
  txt+= "</td><td width=180 height=20 ";
  if (parseInt(idx) == 1) {  
    txt+= "class=\"onglet_actif\">";
    txt+= "<p class=\"centre\"><b>" + txtLng[23] + "</b>";
  } else {
    txt+= "class=\"onglet_droite\">";
    txt+= "<p class=\"centre\">";
    txt+= lienTexteWeb(txtLng[23], "javascript:afficherAlpha()", "", txtLng[23]);
  }
  txt+= "</td><td width=256 height=20 class=\"onglet_vide\">&nbsp;";
  txt+= "</td></tr></table>";
  return (txt);
} // fin codeOngletsChrono()

// charge la page
function chargerPage() {
  var posH = 135;
  var posV = 100;
  // elements communs
  chargerCommun();
  // informations specifiques
  modifierCodeDivision("infos1", codeInfos(txtLng[24]));
  // instructions
  modifierCodeDivision("instr1", codeInstruc());
  deplacerDivisionVers("instr1", posH, 30);
  montrerDivision("instr1");
  // cadre du fond
  modifierCouleurFondDivision("fond1", "#8D8D8D");
  modifierDimensionsDivision("fond1", 626, (hauteurPage-115));
  deplacerDivisionVers("fond1", posH, posV+19);
  modifierZIndexDivision("fond1", 1);
  montrerDivision("fond1");
  // mots-cles
  modifierDimensionsDivision("keyw1", 624, (hauteurPage-117));
  deplacerDivisionVers("keyw1", posH+1, posV+20);
  modifierZIndexDivision("keyw1", 2);
  montrerDivision("keyw1");
  // onglets
  deplacerDivisionVers("ongl1", posH, posV);
  modifierZIndexDivision("ongl1", 3);
  montrerDivision("ongl1");
  // par defaut, ordre chronologique
  afficherChrono();
  return;
} // fin chargerPage()

// affiche les mots-cles en ordre chronologique
function afficherChrono() {
  modifierCodeDivision("ongl1", codeOnglets(0));
  modifierCodeDivision("keyw1", codeChrono());
  return;
}

// affiche les mots-cles en ordre alphabetique
function afficherAlpha() {
  modifierCodeDivision("ongl1", codeOnglets(1));
  modifierCodeDivision("keyw1", codeAlpha());
  return;
}
