/* auteur: Dany Aubut */
/* date de creation: 17/03/2002 */
var MX_MOTEURS = 20;
var UNECHAINE = "chercher+un+item";

function FaireVecteur(n) {
   for (var i = 1; i <= n; i++) {
     this[i] = 0;
   }
   this.maxlen = n;
   this.len = 0;
   return this;
}

var lesmoteurs = new FaireVecteur(MX_MOTEURS);

function trouver_sous_chaine(aiguille, Botte_foin) {
   var i, lngaiguille = aiguille.length, lngbotte = Botte_foin.length;
   for (i=0; i<=lngbotte-lngaiguille; i++) {
      if (aiguille == Botte_foin.substring(i,i+lngaiguille))
        return i;
   }
   return false;
}

function Moteur(nom, option, home, search) {
  var objet = trouver_sous_chaine(UNECHAINE, search);
  this.nom = nom; this.option = option;this.home = home;
  this.pre_objet = search.substring(0,objet);
  this.post_objet= search.substring(objet+UNECHAINE.length, search.length);
}

function Ajouter(nom, option, home, search) {
  lesmoteurs.len++;
  if (lesmoteurs.len <= lesmoteurs.maxlen) {
    lesmoteurs[lesmoteurs.len] = new Moteur(nom, option, home, search)
  }
}

// Ajouter jusqu'à 30 moteurs de recherche.

// moteurs francophone 
Ajouter("Toile du Québec", "SELECTED","http://toile.qc.ca/","http://recherche.toile.qc.ca/cgi-bin/recherche?lang=fr&range=0-19&operator=and&query=chercher+un+item&x=51&y=10" );

Ajouter("Yahoo Canada", "","http://www.yahoo.fr/Exploration_geographique/Pays/Canada/","http://search.yahoo.fr/search/fr?p=chercher+un+item&y=y&e=2100028444&f=0%3A7825331%3A9159814%3A2100000001%3A2100025521%3A2100025528%3A2100028444&r=Exploration+g%E9ographique%02Pays%02Canada" );
   
Ajouter("Yahoo France", "","http://www.yahoo.fr/","http://search.yahoo.fr/search/fr?p=chercher+un+item" );   
// fin des moteurs francophone
////////////////////////////////////////////////////////////////////////////////////
/////////////////////
//debut moteur anglophone
Ajouter("Google", "","http://www.google.ca/","http://www.google.ca/search?q=chercher+un+item&hl=fr&meta=" );

Ajouter("AltaVista", "","http://altavista.digital.com/","http://altavista.digital.com/cgi-bin/query?pg=q&what=web&fmt=d&q=chercher+un+item" );

Ajouter("Lycos", "","http://www.lycos.com/","http://www.lycos.com/cgi-bin/pursuit?cat=dir&query=chercher+un+item&maxhits=20" );

   
Ajouter("Yahoo!", "","http://www.yahoo.com/",
   "http://search.yahoo.com/bin/search?p=chercher+un+item" );
/*
Ajouter("partagiciel/Windows", "","http://www.shareware.com/",
   "http://search.shareware.com/code/engine/Find?logop=and&cfrom=quick&orfile=True&hits=25&search=chercher+un+item&category=MS-Windows%28all%29" );

Ajouter("partagiciel/Unix", "","http://www.shareware.com/",
   "http://search.shareware.com/code/engine/Find?logop=and&cfrom=quick&orfile=True&hits=25&search=chercher+un+item&category=UNIX" );

// fin des ajouts de moteur de recherche.*/ 

function HandleForm(form) {
  form.submit(); //  bug du enter avec netscape
  var i, oldq=form.query.value, newq="";
  for (i=0; i<oldq.length; i++) {  // compress [ ]+ into \+
    var thischar = oldq.charAt(i);
    if (thischar != ' ')
      newq += thischar;
    else if (lastchar != ' ')
      newq += '+';
    lastchar = thischar;
  }
  var moteur = lesmoteurs[1+form.service.selectedIndex];
  var  fenetreNote = window.open('','Note','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,' + 'width=640' + ',height=480');
  fenetreNote.location = newq ? moteur.pre_objet + newq + moteur.post_objet : moteur.home ;
}

function afficherFormulaire() {
 

  for (i=1; i <= lesmoteurs.len; i++) {
    document.writeln("<OPTION value=" + lesmoteurs[i].option + "> " + lesmoteurs[i].nom);
  }
 
}

function AfficherMap() 
{
  window.open("map.html","","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,width=398,height=400,left=400,top=100");
}




function PopWin(fen) 
{
  var wintoopen;
  if(wintoopen)
  {
  	wintoopen.location=fen;
	wintoopen.focus();
  }
  else
  {
  	wintoopen = window.open(fen,"","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0,width=520,height=450,left=100,top=100");
  	wintoopen.focus();
  }
}

function PopPendu(fen) 
{
  var penduwindow;
  if(penduwindow)
  {
  	penduwindow.location=fen;
	penduwindow.focus();
  }
  else
  {
  	penduwindow = window.open(fen,"","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,width=440,height=320,left=100,top=100");
  	penduwindow.focus();
  }
}


function checkSupportedBrowser(succesurl,errorurl)
{
	if(navigator.appName == "Netscape" && (parseInt(navigator.appVersion) <= 4 ))
		document.location=errorurl;
		
	else
		document.location=succesurl;
}

function addBr()
{
	if((navigator.appName.substring(0,9) == 'Microsoft') ||
	   (navigator.appVersion.substring(0,3) >= 5.0 && navigator.appName == 'Netscape'))
		document.writeln("<br>");
}

function VersionNavigateur(Netscape, Explorer) {
  if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||      
      (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
    return true;
else return false;
}


var tmpImage
function preload(nomfichier)
{
	tmpImage = new Image(0,0); tmpImage.src=nomfichier
}
function animerLien(nomImage,nomfichier)
{
	if (VersionNavigateur(3.0,4.0))  
		nomImage.src=nomfichier
}

function remettrelien(nomImage,nomfichier)
{
	nomImage.src=nomfichier
}

