<?php
	require '../connect.php';
	$sql="SELECT id, nom, id_page FROM regions WHERE id_parent='".$_POST['id_parent']."' ORDER BY nom ASC";
	$result = mysql_query($sql, $link);
	while ($ligne = mysql_fetch_array($result, MYSQL_ASSOC)) {
		$nom=$ligne['nom'];
		$id=$ligne['id'];
		$id_page=$ligne['id_page'];
		if ($id==$_POST['id_region'])  {
			if ($_POST['id_commune']==0) echo '<a href="#" class="regions" onClick="detail_region('.$id.',0);affiche_texte('.$id.');return false;" style="color:#6e0000;text-decoration:underline;">'.$nom.'</a>';
			else echo '<a href="#" class="regions" onClick="detail_region('.$id.',0);affiche_texte('.$id.');return false;">'.$nom.'</a>';
			$sql3="SELECT id_page FROM regions WHERE id='".$_POST['id_region']."'";
			$result3 = mysql_query($sql3, $link);
			$ligne3 = mysql_fetch_array($result3, MYSQL_ASSOC);
			$id_page=$ligne3['id_page'];
			$sql2="SELECT id, nom FROM regions WHERE id_parent='$id_page' ORDER BY nom ASC";
			$result2 = mysql_query($sql2, $link);
			while ($ligne2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
				$nom=$ligne2['nom'];
				$id=$ligne2['id'];
				if ($_POST['id_commune']!=0) {
					if ($_POST['id_commune']==$id) echo '<a href="#" class="communes" onClick="affiche_texte('.$id.');detail_region('.$_POST['id_region'].','.$id.');affiche_telechargements('.$id.');return false;" style="color:#6e0000;text-decoration:underline;">'.$nom.'</a>';
					else echo '<a href="#" class="communes" onClick="affiche_texte('.$id.');detail_region('.$_POST['id_region'].','.$id.');affiche_telechargements('.$id.');return false;">'.$nom.'</a>';
				} else echo '<a href="#" class="communes" onClick="affiche_texte('.$id.');detail_region('.$_POST['id_region'].','.$id.');affiche_telechargements('.$id.');return false;">'.$nom.'</a>';
			}
		} else echo '<a href="#" class="regions" onClick="detail_region('.$id.',0);affiche_texte('.$id.');return false;">'.$nom.'</a>';
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
?>