ResultatRecherche=function(elementRecherche)
{
	// variable de titre linguistique :
	this.tabTitre=new Array();
	this.tabTitre['fr']="Rechercher";
	this.tabTitre['en']="Search";
	this.tabTitre['jp']="Search";
	
	var tabNoResult=new Array();
	tabNoResult['fr']=' r&eacute;sultats trouv&eacute;s pour "';
	tabNoResult['en']=' results found for "';
	tabNoResult['jp']=' results found for "';
	


	this.me=$("<div/>");
	
	var content=$('<div/>');
	
	var resultats=$('<div/>');
	resultats.css('padding'  , '5px');
	
	this.me.append(resultats);
	this.me.append(content);
	


	
	
	traiterReponse=function(reponse , cntn)
	{	
		if (reponse.resultats.length>0)
		{
			// création de la table des résultats :
			
			table=$('<table/>');
			table.addClass('tableRecherche');
			
			$.each(reponse.resultats , 
				function(i  , resultat)
				{
					table.append((new BoutonRecherche(i , resultat.idContenu , resultat.titreArticle, resultat.texteArticle)).me);
					
				}
			)
			content.append(table);
			
			resultats.html(reponse.resultats.length+tabNoResult[ModeleInteraction.getLangue()]+elementRecherche+'".');
		}
		else
		{
			resultats.html('0'+tabNoResult[ModeleInteraction.getLangue()]+elementRecherche+'".');
		}
	}	

	//$.getJSON(ModeleInteraction.root+'chargements/recherche.php?recherche='+elementRecherche+"&langue="+ModeleInteraction.getLangue() , traiterReponse);
	
	
	
	
	// différencie le nombre d'appel //
	firstAppel=function(reponse , cntn)
	{
		if (reponse.resultats[0].nbReponse==0)
		{
			resultats.html('0'+tabNoResult[ModeleInteraction.getLangue()]+elementRecherche+'".');
		}
		else if (reponse.resultats[0].nbReponse<20)
		{
			$.getJSON(ModeleInteraction.root+'chargements/recherche.php?recherche='+elementRecherche+"&langue="+ModeleInteraction.getLangue()+"&index=10" , traiterReponse)
		}
		else
		{
			$.getJSON(ModeleInteraction.root+'chargements/recherche.php?recherche='+elementRecherche+"&langue="+ModeleInteraction.getLangue()+"&index=10" , traiterReponse)
		}
	}
	
	
	
	// appel au script de recherche :
	$.getJSON(ModeleInteraction.root+'chargements/recherche.php?type=firstAppel&recherche='+elementRecherche+"&langue="+ModeleInteraction.getLangue() , firstAppel);
}

