<?php
	//connection
	include("connection.php");
    include("frames_header.php");
?>

<h2><strong><em>Induction description.</em></strong> </h2><br>
<center>
<form action="induction3.php" method="post" name="formu" target="_blank">

<?php


	$dev="";
    if(isset($_POST["devstage"]))
		$dev = $_POST["devstage"];
	
	
	if( strlen($dev)<=0 ){
	    print "<center><h2></h2><br>Please select a developmental stage</center>";
		include("frames_footer.php");
	    return;
	}
    


	print '<table border="1" cellspacing="0" cellpadding="0"><tr>';
	

/*Hierarchie*/	


function select_recursif_descendant_2($conn,$start,$res,$nivo)
{
global $dev;
//global $level;
global $region;
global $i;
//global $nivo;
/*ON ECRIT SA REQUETE*/

//print "la";
if ($start!='')
{
$requete2="SELECT * FROM \"ANAT_ENTITY\" WHERE  \"DEV_STAGE_ID\"= ".$dev." and  \"CHILD_OF\"= $start ";
//print $start;
$level++;
}
else {
$requete2="SELECT * FROM \"ANAT_ENTITY\" WHERE  \"DEV_STAGE_ID\"= ".$dev." and  \"CHILD_OF\" is null";
//$level=0;
}

$stmt2=pg_query($conn,$requete2) or die("<strong>Error</strong> ".pg_last_error($c));

//if (pg_num_rows($stmt2)==0) {$level--;}

if (pg_num_rows($stmt2)!=0) $nivo++;//print "Nz";
if (pg_num_rows($stmt2)==0) $nivo--;//print "Ze";

while($row2=pg_fetch_array($stmt2))
	{
			for($a=0;$a<$nivo-1;++$a){
				if( $nivo>1 )
					echo '&nbsp;&nbsp;<font color="#999999">|</font>&nbsp;&nbsp;';
			}
			
			if( $row2["TYPE"]=='cell' )
				print "<img src=\"pictures/cell.gif\">";
			else if( $row2["TYPE"]=='organism' )
				print "<img src=\"pictures/tetard.gif\">";
			else
				print "<img src=\"pictures/region.gif\">";
			

			echo $row2["NAME"];
			print "<input name=\"region".$i."\" type=\"radio\" value=\"".$row2["ANAT_ID"]."\">";

			print '<br>';
	
	$res=select_recursif_descendant_2($conn,$row2["ANAT_ID"],$res,$nivo);

	
	}

return $res;
}








	
for($i=0; $i<2; ++$i){

	print '<td valign="top">';

	$requete= "SELECT \"NAME\", \"SPECIES\" FROM \"DEV_STAGE\" WHERE \"DEV_STAGE_ID\"= $dev";
    $stmt = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
    if( $row=pg_fetch_array($stmt) ){
//		print "<center><h2><strong><em>".OCIResult($stmt, "SPECIES")."  (".OCIResult($stmt, "NAME").")<br>Anatomical tree</em></strong> </h2></center><br><br>";
//	    print "Select anatomical part below and click on buttons to access the relevant information.<br>";
//		print "\n&nbsp;&nbsp;<img src=\"pictures/button-getPics.jpg\" border=\"0\" onClick=\"self.location.href = 'insitu-result.php?BOOLanat=1&xref=2&idanat=' + self.getValue()+':'\">    &nbsp;<img src=\"pictures/button-lineage.jpg\" border=\"0\"onClick=\"self.location.href = 'lineage.php?idanat=' + self.getValue()\">    &nbsp;<img src=\"pictures/button-position.jpg\" border=\"0\" onClick=\"self.location.href = 'position.php?idanat=' + self.getValue()\">    &nbsp;<img src=\"pictures/button-fates.jpg\" border=\"0\" onClick=\"self.location.href = 'fates.php?idanat=' + self.getValue()\">\n<br><br><br>";		
	    print "<center>".$row["SPECIES"]."&nbsp;-&nbsp;".$row["NAME"]."</center><br>";
		
		if($i==0)
		    print "<br><strong><center>select the inducing cell</center></strong><br>";
		else
		    print "<br><strong><center>select the induced cell</center></strong><br>";
			
		print '<center>___________________________________</center><br>';

$nivo=0;

	select_recursif_descendant_2($c,null,$res,$nivo);


		print "</td>";
	
	}else{ print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>"; }
	
}
	
	print '</tr><tr><td align="center" valign="middle" colspan="2">
	  <table border="0" cellspacing="0" cellpadding="0">
	  <tr><td align="center" valign="top">
		<br><strong>Extracellular ligand*</strong><br>(eg: ci0100133709)<br>
	    <input type="text" name="molecule" size="20">
		
		<br><br><strong>Intracellular cascade*</strong><br>(eg: ci0100133709)<br>
	    <input type="text" name="cascade" size="20">
		';
		
		$flist="";
		$requete2="select \"KEYWORDS\" from \"FATE_KW\"";
		$stmt = pg_query($c,$requete2) or die("<strong>Error</strong> ".pg_last_error($c));
		while($row=pg_fetch_array($stmt)){
		    $flist .= '<option>'.$row["KEYWORDS"].'</option>';
		}
		print '<br><br><strong>Induced fate</strong><br> <select name="ifate[]" size="5" multiple>'.$flist.'</select>';

		print '<br><strong>Default fate</strong><br> <select name="dfate" size="5">'.$flist.'</select>';

		
	  print '</td><br>
	  <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
      <td align="center" valign="top">
	    

		<br><strong>Receptor*</strong><br>(eg: ci0100133709)<br>
	    <input type="text" name="receptor" size="20">
	    
		<br><br><strong>Direct transcriptional target*</strong><br>(eg: ci0100133709)<br>
	    <input type="text" name="target" size="20">

		
		<br><br><strong>Comments</strong><br>
	    <textarea name="comment" cols="30" rows="14"></textarea>
		
	  </td>
	  </tr>
	  <tr>
	    <td align="center" colspan="3">
		        _______________________________________________________
				<br><strong>Reference 1</strong><br>
				<br><strong>Authors</strong> <input type="text" name="author" size="20">
				&nbsp;&nbsp;&nbsp;&nbsp; <strong>Title</strong> <input type="text" name="title" size="20">
				<br><strong>Paper</strong> <input type="text" name="paper" size="20">
				&nbsp;&nbsp;&nbsp;&nbsp; <strong>PMID</strong> <input type="text" name="pmid" size="20">
				<br><strong>url</strong> <input type="text" name="url" size="20">
				<br><br><strong>Comments</strong> (do not use the " \' " symbol in your text)<br>
				<textarea name="comment2" cols="40" rows="5"></textarea>
		</td>
	  </tr>

  <tr>
	    <td align="center" colspan="3">
		        _______________________________________________________
				<br><strong>Reference 2</strong><br>
				<br><strong>Authors</strong> <input type="text" name="author2" size="20">
				&nbsp;&nbsp;&nbsp;&nbsp; <strong>Title</strong> <input type="text" name="title2" size="20">
				<br><strong>Paper</strong> <input type="text" name="paper2" size="20">
				&nbsp;&nbsp;&nbsp;&nbsp; <strong>PMID</strong> <input type="text" name="pmid2" size="20">
				<br><strong>url</strong> <input type="text" name="url2" size="20">
				<br><br><strong>Comments</strong> (do not use the " \' " symbol in your text)<br>
				<textarea name="comment22" cols="40" rows="5"></textarea>
		</td>
	  </tr>

  <tr>
	    <td align="center" colspan="3">
		        _______________________________________________________
				<br><strong>References 3</strong><br>
				<br><strong>Authors</strong> <input type="text" name="author3" size="20">
				&nbsp;&nbsp;&nbsp;&nbsp; <strong>Title</strong> <input type="text" name="title3" size="20">
				<br><strong>Paper</strong> <input type="text" name="paper3" size="20">
				&nbsp;&nbsp;&nbsp;&nbsp; <strong>PMID</strong> <input type="text" name="pmid3" size="20">
				<br><strong>url</strong> <input type="text" name="url3" size="20">
				<br><br><strong>Comments</strong> (do not use the " \' " symbol in your text)<br>
				<textarea name="comment23" cols="40" rows="5"></textarea>
		</td>
	  </tr>


  <tr>
	    <td align="center" colspan="3">
		        _______________________________________________________
				<br><strong>Reference 4</strong><br>
				<br><strong>Authors</strong> <input type="text" name="author4" size="20">
				&nbsp;&nbsp;&nbsp;&nbsp; <strong>Title</strong> <input type="text" name="title4" size="20">
				<br><strong>Paper</strong> <input type="text" name="paper4" size="20">
				&nbsp;&nbsp;&nbsp;&nbsp; <strong>PMID</strong> <input type="text" name="pmid4" size="20">
				<br><strong>url</strong> <input type="text" name="url4" size="20">
				<br><br><strong>Comments</strong> (do not use the " \' " symbol in your text)<br>
				<textarea name="comment24" cols="40" rows="5"></textarea>
		</td>
	  </tr>







	  <tr>
	  <td colspan="3" align="center">
	    <br><br>
		<input name="submit" type="image" src="pictures/button-submit.jpg" onClick="submit">
	    <br>
		<br>
		*Enter multiple entries separated with the : symbol
	 </td>
	 </tr>
	 </table>
		
	</td>
	</tr></table>';

?>
</form>
</center>



<?php
    include("frames_footer.php");
?>