/*
Script amélioré par le site WEB Creation
http://www.bonsplansmaroc.com
*/  
var IE = (document.all);
var win = window;    
var n   = 0;

function findInPage(str) {
  var txt, i, found;

  if (str == "") {
        alert("Veuillez entrer un mot à chercher");
		search.rechercher.value="Rechercher";
		search.quoi.focus();	
		return false;
	}
	
  if (document.all) {
    txt = win.document.body.createTextRange();
    for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
      txt.moveStart("character", 1);
      txt.moveEnd("textedit");
    }
    if (found) {
      txt.moveStart("character", -1);
      txt.findText(str);
      txt.select();
      txt.scrollIntoView();
      n++;
    } else {
      if (n > 0) {
        n = 0;
        findInPage(str);
      } else {
        alert("Le mot cherché n'existe pas sur cette page.");
		search.rechercher.value="Rechercher";
		search.quoi.focus();	
		}
    }
  } else {
    if (!win.find(str))
      while(win.find(str, false, true))
        n++;
    else
      n++;

    if (n == 0) {
      alert("Le mot cherché n'existe pas sur cette page.");
		search.rechercher.value="Rechercher";
		}
  }
  return false;
}
