// --- Création de l'index ---
Index = new Array() ;
DateTri = new Array() ;

//alert(baseCodeArray.length) ;

function CreeIndex()
  {
	
	// -- Initialisation --
    for(k=0; k<baseCodeArray.length; k++)
      {
        Index[k]=k ;
        DateTri[k]=baseDateArray[k] ;
      }
    // -- Trie du tableau --
    fin = 0 ;
    i = 0 ;
    var temp ; 
    for(kk=0 ; !fin ; kk++) //while (!fin)
      {
        if (DateTri[i]<=DateTri[i+1])
          { 
            if (i==baseCodeArray.length-2)
            fin = 1;
            i++;             // Si on est en bas du tableau,
                             // On arrête
                             // On incrémente i  
          }
        else
          { 
            temp = DateTri[i];
            DateTri[i] = DateTri[i+1];
            DateTri[i+1] = temp;
            temp = Index[i];
            Index[i] = Index[i+1];
            Index[i+1] = temp;
            if (i>0)         // Si on n'est pas en haut du
            i--;             // On permutte les éléments
                             // tab[i] et tab[i+1]
                             // Si on n'est pas en haut du
                             // tableau, on décrémente i 
          } 
      } 
  }



//alert("aa") ;


Stamp = new Date();
var DateJour
DateJour=Stamp.getYear()+""
if ( Stamp.getMonth()+1 < 10 ) 
  {
  DateJour += "0"+(Stamp.getMonth()+1) ;
  }
else
  {
  DateJour += ""+(Stamp.getMonth()+1) ;
  }
DateJour +=""+Stamp.getDate()
//document.write(DateJour)


// TABLEAU DYNAMIQUE D'AFFICHAGE DES PROMOTIONS

function displayPromo()
  {
    var output ;
    var NoLigne = -1 ;
    CreeIndex() ;
    output = "<DIV ALIGN=\"CENTER\"><CENTER><TABLE BORDER=\"0\" WIDTH=\"500\">" ;
    for(k=0; k<baseCodeArray.length; k++)
    {
    //alert(DateJour)
    if( baseDateArray[Index[k]] >= DateJour )
      {
//alert(k+"  "+Index[k]+"  /  "+baseCodeArray.length+"       "+baseDateArray[Index[k]]+">="+DateJour);
      NoLigne++ ;
      output += "<TR>"
      output += "<TD VALIGN=\"MIDDLE\" WIDTH=\"75\"><CENTER><A HREF=\""+ baseFichierArray[Index[k]] +"\" onMouseOver=\"deselect(" + NoLigne + ")\" onMouseOut=\"select(" + NoLigne + ")\"><IMG SRC=\"..\/images\/fr\/detail-on.gif\" LOWSRC=\"..\/images\/fr\/detail-off.gif\" WIDTH=\"54\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Cliquez ici\"><\/A><\/CENTER><\/TD>"      
      output += "<TD VALIGN=\"MIDDLE\">" + baseTitleArray[Index[k]] + "<\/TD>"
      output += "<TD VALIGN=\"MIDDLE\"  ALIGN=\"RIGHT\" WIDTH=\"120\"><DIV ALIGN=\"RIGHT\">" + baseDisplayDateArray[Index[k]] + "<\/DIV><\/TD>"
      }
    }
    output += "<\/TABLE>"
    output += "<\/CENTER><\/DIV>"
    document.write(output);
  }


function displayPromoOld()
  {
    var output ;
    var NoLigne = -1 ;
    output = "<DIV ALIGN=\"CENTER\"><CENTER><TABLE BORDER=\"0\" WIDTH=\"500\">" ;
    for(k=0; k<baseCodeArray.length; k++)
    {
    if(baseDateArray[k] == baseDateArray[k])
      {
      NoLigne++ ;
      output += "<TR>"
      output += "<TD VALIGN=\"MIDDLE\" WIDTH=\"75\"><CENTER><A HREF=\""+ baseFichierArray[k] +"\" onMouseOver=\"deselect(" + NoLigne + ")\" onMouseOut=\"select(" + NoLigne + ")\"><IMG SRC=\"..\/images\/fr\/detail-on.gif\" LOWSRC=\"..\/images\/fr\/detail-off.gif\" WIDTH=\"54\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Cliquez ici\"><\/A><\/CENTER><\/TD>"      
      output += "<TD VALIGN=\"MIDDLE\">" + baseTitleArray[k] + "<\/TD>"
      output += "<TD VALIGN=\"MIDDLE\" WIDTH=\"120\"><CENTER>" + baseDateArray[k] + "<\/CENTER><\/TD>"
      }
    }
    output += "<\/TABLE>"
    output += "<\/CENTER><\/DIV>"
    document.write(output);
  }








function FindBasePrice(thecode)
  {
  nulloutput=""
  for(k=0; k<baseCodeArray.length; k++)
    {
    if(thecode == baseCodeArray[k])
      {
      nulloutput += basePriceArray[k] + " F" 
      }
    }
  document.write(nulloutput);
  }




function FindBaseDateFin(thecode)
  {
  nulloutput=""
  for(k=0; k<baseCodeArray.length; k++)
    {
    if(thecode == baseCodeArray[k])
      {
      nulloutput += baseDateArray[k] 
      }
    }
  document.write(nulloutput);
  }


