<center><?php
if(isset($_POST['motcle'])) {
$base_jvxcom = 'http://www.jeuxvideo.com/recherche/jeux/';

$motcle = stripslashes($_POST['motcle']);
// on remplace les caractères spéciaux
$motcle = str_replace(array('à','á','â','ã','ä','å'),'a',$motcle);
$motcle = str_replace(array('ò','ó','ô','õ','ö','ø'),'o',$motcle);
$motcle = str_replace(array('è','é','ê','ë'),'e',$motcle);
$motcle = str_replace('ç','c',$motcle);
$motcle = str_replace(array('ì','í','î','ï'),'i',$motcle);
$motcle = str_replace(array('ù','ú','û','ü'),'u',$motcle);
$motcle = str_replace('ÿ','y',$motcle);
$motcle = str_replace('ñ','n',$motcle);
// passage des majuscule en minuscule
$motcle = strtolower($motcle);

$search_list = explode("\n", htmlentities($motcle));
$tmp = 0;

foreach($search_list as $search_string) {

	$url_jvxcom = $base_jvxcom . $search_string . '.htm';
    $url_jvxcom = str_replace(" ","+",$url_jvxcom);
	
	list($jeux,$erreur) = getListJeuJvxcom($url_jvxcom);


	if(!empty($jeux)) {
	
	      echo '<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                  <td height="91" valign="bottom" background="./images/img_jeu/f_jeu_h.png"></td></tr><tr>
                  <td background="./images/img_jeu/f_jeu_c.png">';

		foreach($jeux as $unJeu)
		{
		  
		  echo '<div class="jeux"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                <td>'.$unJeu['affiche'].'</td>
                </tr>
                <tr>
                <td><table border="0" cellspacing="0" cellpadding="0">
                <tr>
                <td><ul class="liste_liens"><li>' . $unJeu['titre'] . '</td><td width="30" align="center"><a href="http://www.jeuxvideo.com/jeux/' . $unJeu['id'] . '.htm" target="_blank">
				<img src="'.$url_default.'/images/fiche_jeu.gif" title="Voir la Fiche Complète sur Jeuxvideo.com" width="16" height="16" border="0"></a></td>
                <td width="45" align="right"><form name="jeuvideo" id="info" action="?page=jeux&action=info" method="post"><input type="hidden" name="jeuinfo[' . $tmp . '][titre]" value="' . $unJeu['titre'] . '"><input type="hidden" name="jeuinfo[' . $tmp . '][id]" value="' . $unJeu['id'] . '"><input type="image" src="./images/ok_jeu.png" border="0" name="' . $unJeu['id'] . '" title="Selectionner cette Fiche" onmouseover="javascript:this.src=\'./images/ok_jeu1.png\';" onmouseout="javascript:this.src=\'./images/ok_jeu.png\';"></form></li></ul></td>
                </tr>
                </table></td>
                </tr>
                </table></div>';

		$tmp++;
		
		}	
echo '<br></td></tr><tr><td height="13" background="./images/img_jeu/f_jeu_b.png"></td></tr></table>';
	}else{
		if(!empty($erreur)) {
		echo '<center><meta http-equiv="Refresh" content="5;URL='.$PHP_SELF.'?page=jeux">
              <div style="background-color:#FFCCCC; border:#000000 1px double; width:100%">
              <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
              <td align="center" valign="middle"><img src="./images/Panneauattention.png" hspace="10" vspace="10" border="0"></td>
              <td width="100%" align="center" valign="middle"><p>! --- ### ATTENTION ### --- !</p>
              <p>Une erreur s\'est produite, Veuillez nous en escuser ....</p>
              <p>( Redirection dans 5 secondes)</p></td>
              <td align="center" valign="middle"><img src="./images/Panneauattention.png" hspace="10" vspace="10" border="0"></td>
              </tr>
              </table>
              </div></center>';
			  

	}else {
	
	echo '<center><meta http-equiv="Refresh" content="5;URL='.$PHP_SELF.'?page=jeux">
          <div style="background-color:#FFCCCC; border:#000000 1px dashed; width:100%">
          <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
          <td align="center" valign="middle"><img src="./images/Aide.png" hspace="10" vspace="10" border="0"></td>
          <td width="100%" align="center" valign="middle"><p>! --- ### ATTENTION ### --- !</p>
          <p>&quot; Vous avez specifié un mot clé incorrect , ou il n\'existe pas &quot;</p>
          <p>Veuillez retaper un mot clé svp ...</p>
          <p>( Redirection dans 5 secondes)</p></td>
          <td align="center" valign="middle"><img src="./images/Aide.png" hspace="10" vspace="10" border="0"></td>
          </tr>
          </table>
          </div></center>';
		
	}
	}
	

}
}else{ echo '<meta http-equiv="Refresh" content="1;URL='.$PHP_SELF.'?page=jeux">';}
?>
</center>