// (gH)   --  tc1.js  ;  TimeStamp (unix) : 23 Novembre 2004 vers 08:58

function initTab() {

  document.nbChap = 5
  document.nbSect = 2

} ; // fin de fonction initTab() {

function permuteValeur(pic) {
var lng = document.ch.length
//alert(' document.ch est '+document.ch + ' de longueur '+lng)
  newCh = ''
  for (var idc=0;idc<=lng-1;idc++) {
     carCh =  document.ch.substring(idc,idc+1)
     if ((pic-1)==idc) {
        if (carCh==1) { carCh = 0 }
               else   { carCh = 1 }
     } ; // fin de si
     newCh = newCh + carCh ;
  } ; // fin pour
  newCh = newCh +''
//alert(' newch est '+newCh)
  document.location='tc.htm?ch='+newCh

} // fin de fonction permuteValeur

function getParam(){

 vu = 0 ;
 if(window.location.search.length > 1) 	{
   var parms = window.location.search.substring(1).split("&");
   var parmList = new Array();
   for(var i = 0; i < parms.length; i++){
     parmList[i] = new Object;
     parmList[i].name = parms[i].substring(0,parms[i].indexOf("="));
     parmList[i].value = parms[i].substring(parms[i].indexOf("=")+1);
     if (parmList[i].name == "ch") { document.ch = parmList[i].value ; vu = 1 } ;
   } ; // fin de pour
 } ; // fin de si

 if (vu == 0) {
     lstch = "" ;
     for (var idc=1;idc<=document.nbChap;idc++) {
        lstch = lstch + "0" ;
     } ; // fin pour
     document.ch = lstch
     parmList = null;
     window.location = window.location + "?ch="+lstch
 } ; // fin de si

 return ;

} ; // fin de fonction getParam

function affiche() {

  initTab()  ;
  getParam() ;

  document.writeln('<script language ="javascript" type="text/javascript" src="tc.js">') ;
  document.writeln('</script>') ;
  document.writeln('<h1>')  ;
  document.writeln('Cliquez sur les boutons + et - pour') ;
  document.writeln('<br>') ;
  document.writeln('montrer ou masquer les sections') ;
  document.writeln('</h1>') ;
  document.writeln('<blockquote>') ;

  for (ichap=1;ichap<=document.nbChap;ichap++) {

   document.write('<a href="javascript:permuteValeur('+ichap+')">') ;
   lecarch = document.ch.substr(ichap-1,1)
//alert(" ichap = " + ichap + " lecarch est "+lecarch )
   if (lecarch == 0) {
      // sans image : document.write(' + ')
      document.write('<img src="boutonplus.gif" align="middle" />')
   } else {
      document.write('<img src="boutonmoins.gif" align="middle" />')
   } // fin de si

   document.write('</a>')

   document.writeln(' Chapitre '+ichap+'<p>')

   for (jsec=1;jsec<=document.nbSect;jsec++) {
       if (lecarch == 1) {
           document.writeln(' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;')
           document.writeln(' Section '+ichap+'.'+jsec+'<p>')
       } // fin de si
   } // fin de pour jsec

  } // fin de pour ichap

  document.writeln('</blockquote>')
  document.close()

} ; // fin de fonction affiche

