// Limites imposées à la longueur de la chaîne pour le moteur de recherche
var SEARCH_MIN_LENGTH=3;
var SEARCH_MAX_LENGTH=50;

function isEmpty(s) 
{   return ((s == null) || (s.length == 0)); 
} 

// Returns true if string s is empty or  
// whitespace characters only. 
 
function isWhitespace (s) 
 
{   // Is s empty? 
    return (isEmpty(s) || reWhitespace.test(s)); 
} 
	
function isPhrase(s)
{   var i,chaine;
    if (isWhitespace(s) || s.length <1) {
		return false;
	}
    else {
	   for (i=1;i<=9;i++)
	   {	
	   	while (s.indexOf(i) > 0)
	   	{ 
		s = s.substring(0,s.indexOf(i)) + s.substring(s.indexOf(i)+1,s.length);
		}
		}
		if (isNaN(s)) 
		{
	        return reAlphabetic.test(s);
		}
		else
		{
			return true;
		}		
			
    }
}

function LienFichier(ident)
{
var largeur =437;
var hauteur = 430;
 var left=(screen.width-largeur)-10;
 var top=(screen.height-hauteur)/2;
 var newindow=window.open(ident,'nouvelle2','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,top='+top+',left='+left+',width='+largeur+',height='+hauteur);
 newindow.focus();
}

function LienFichier2(ident)
{
 var newindow=window.open(ident,'nouvelle2','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=760,height=352');
 newindow.focus();
}

//********************** moteur de recherche ***************************************

// S'agit-il d'un mot significatif
function isNotSignificantWord(mot)
{
		return(reNonSignificantWord.test(mot));
}

//*** verifier le champ de rechercher non vide

function doSearch(frm, action)
{	
	var mot=frm.search.value;
	if (isWhitespace (mot)) {
		alert("Merci de spécifier l'objet de votre recherche.");
		frm.reset();
	}
	else {
		if (!isPhrase(mot.toLowerCase()) || reSpecialChars.test(mot.toLowerCase())) {
			alert("Merci de na pas utiliser de ponctuation ou caractères spéciaux dans le champ recherche.");
			frm.reset();
		}
		else {	
			  if (isNotSignificantWord(mot.toLowerCase())) {
			  	alert("Désolé, le mot que vous avez saisi n'est pas significatif.\nMerci de préciser votre recherche.");
				frm.reset();
			  }
			  else {
				frm.submit(); 
			  }
	
	   	}
	}
}

//************************ fin moteur de recherche ***********************************

