<?php
	//connection
	include("connection.php");
	
	if($_GET["FHeader"]!="n" )
	    include("frames_header.php");
	else
		echo '<body bgcolor="#505F70" text="#FFFFFF" link="#000000" vlink="#000000" alink="#000000">';
?>

<script language="JavaScript">

//Ma fonction
	function giveMe(species,dev,ishid)
	{
	tab=new Array();
	count=0;
	for(a=0;a<document.form2.length;++a){
			if(document.form2[a].checked==true){
				obj=document.form2[a];
				tab[obj.name]=obj.value;
				++count;
			}
		}

	reg='';
	for (key in tab){
	if(tab[key]=="idanat") reg=reg+key+':';
	}
	
	regi='idanat='+reg;
	
	phplink='deletepartanatselected.php?'+regi;

	if(count==0){
			alert("Click on the checkboxes to select the properties you want to search for.");
			return;
		}
	//alert(phplink);
		//window.document.open(phplink);
	
		document.location.href=phplink+'&species='+species+'&dev='+dev+'&insituid='+ishid;
		
		

	}
//Fin de ma fonction



	function searchIt(){
		tab=new Array();
		
		count=0;
		for(a=0;a<document.form2.length;++a){
			if(document.form2[a].checked==true){
				obj=document.form2[a];
				tab[obj.name]=obj.value;
				++count;
			}
		}
		
		targ=''; amp=''; reg=''; mut='';
		
		for (key in tab){
				if(tab[key]=="idanat")
					reg=reg+key+':';
					
				if(tab[key]=="amputation")
					amp=amp+key+':';
				
				else if(tab[key]=="target")
					targ=targ+':'+key;
				
				else if(tab[key]=="mutant")
					mut=mut+':'+key;
		}
		
		targ='&target='+targ.substring(1,targ.length);
		reg='&idanat='+reg;
		amp='&amputation='+amp;
		mut='&mutant='+mut.substring(1,mut.length);
		
		phplink='insitu-result.php?BOOLanat=1&BOOLmut=1&BOOLtarg=1&BOOLamp=1'+targ+reg+amp+mut;
		
		if(document.form.species.checked==true){
			phplink+="&species="+document.form.species.value;
			++count;
		}
		if(document.form.stage.checked==true){
			phplink+="&selectediddev="+document.form.stage.value+":";
			++count;
		}
		
		
		for (a=0;a<document.form3.length;a++) {
		 	if ( (document.form3[a].checked)&&(document.form3[a].value=='1') ) {
				phplink+="&xref=1";
		 	}
		 	else if ( (document.form3[a].checked)&&(document.form3[a].value=='2') ) {
				phplink+="&xref=2";
		 	}
			
		}
		
		if(count==0){
			alert("Click on the checkboxes to select the properties you want to search for.");
			return;
		}
		
		//window.document.open(phplink);
		document.location.href=phplink;
	}
	

//fonctions pour le zoom des images
	function ZoomIn() {
			for(a=0;a<document.images.length;++a){
				if(document.images[a].name=="thumb")
					document.images[a].width+=20;
			}
	}
	function ZoomOut() {
			for(a=0;a<document.images.length;++a){
				if(document.images[a].name=="thumb")
					document.images[a].width-=20;
			}
	}

//systeme pour afficher en grand le thumbnail selectionne
	function growPics(pic){
		document.images["BIGimage"].src = pic.src;
		document.images["BIGimage"].id = pic.name;
		document.images["BIGimage"].border = 1;
		
		//pour la curation
		document.images["BIGdel"].id = pic.name;
	}
	
	function growPics2(pic){
		document.images["BIGimage"].src = pic.src;
		document.images["BIGimage"].id = pic.name;
		document.images["BIGimage"].border = 1;
		document.images["BIGimage"].width = 370;
	}
	
	function getOriginal(lien){
		if(lien.id.length>0)
			//window.open("insitu-original-picture.php?id="+lien.id);
			self.location.href = "insitu-original-picture.php?id="+lien.id;
	}

</script>




<?php
	$id = $_GET["id"];
	
	/////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////requete//////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	
	$requete="SELECT A.\"PRIVATE\", A.\"WILD_TYPE\", A.\"DEV_STAGE_ID\", A.\"SPECIES\", A.\"EXP_COMMENTS\", A.\"TIME\", A.\"TEMPERATURE\", A.\"IM_COMMENTS\", B.\"NAME\" AS \"DEV\", C.\"NAME\", C.\"SURNAME\", C.\"MAIL\", D.\"ENTRY_DATE\" FROM \"IN_SITU\" A, \"DEV_STAGE\" B, \"AUTHOR\" C, \"ENTRY_ORIGIN\" D WHERE (A.\"IN_SITU_ID\"=$id) AND (A.\"DEV_STAGE_ID\"=B.\"DEV_STAGE_ID\") AND (D.\"BIO_ID\"=$id) AND (D.\"AUTHOR_ID\"=C.\"AUTHOR_ID\")";
    $stmtcond = pg_query($c,$requete);
    if (! $rowcond=pg_fetch_array($stmtcond) ){
	    print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>";
		if($_GET["FHeader"]!="n" )
			include("frames_footer.php");
		else
			echo '</body>';
		return;
	}
?>

		<form name="form">
		Annotator: <strong><a href="mailto:<?php echo ($rowcond["MAIL"]."\">".$rowcond["SURNAME"]." ".$rowcond["NAME"]); ?></a></strong>&nbsp;&nbsp;&nbsp;<?php print $rowcond["ENTRY_DATE"] ?>
        <br>
		

<?php 
       if($rowcond["PRIVATE"]=='y')
	       print '<center><font color="#990000" size="+3"><strong>WARNING: PRIVATE ENTRY</strong></font></enter><br>';

        //curation
        print '<div align="right"><img src="pictures/button-public.jpg" border="0" title="Make public" onClick="window.open(\'curator-state.php?mode=1&id='.$id.'\')">&nbsp;<img src="pictures/button-private.jpg" border="0" title="Make private"  onClick="window.open(\'curator-state.php?mode=2&id='.$id.'\')">&nbsp;<img src="pictures/button-not-curated.jpg" border="0" title="Make not curated" onClick="window.open(\'curator-state.php?mode=3&id='.$id.'\')"></div>';
		print '<div align="right"><img src="pictures/button-cur-delete.gif" border="0" title="Delete" onClick="window.open(\'curator-delete.php?id='.$id.'\')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="pictures/button-cur-validate.gif" border="0" title="Accept"  onClick="window.open(\'curator-validate.php?id='.$id.'\')"></div>';
        //print '';
?>
		
		<table border="0" width="100%" cellspacing="0">
          <tr bgcolor="#000000">
            <td bgcolor="#000033"><strong>Picture description</strong></td>
		  </tr><tr>
            <td align="right" width="50%"><?php 
						$species=$rowcond["SPECIES"] ; //D
						$stadedev=$rowcond["DEV_STAGE_ID"]; //D
						print $rowcond["SPECIES"]."<input name=\"species\" type=\"checkbox\" value=\"".$rowcond["SPECIES"]."\">&nbsp; &nbsp; &nbsp;".$rowcond["DEV"]."<input name=\"stage\" type=\"checkbox\" value=\"".$rowcond["DEV_STAGE_ID"]."\">";  ?></td>
		  </tr><tr> 
            <td valign="top"> 
				<table border="0" width="100%" cellspacing="0">
					<tr>
						<td align="left" valign="top">
							
							<?php
							//curation
							print '<img src="pictures/button-add.jpg" border="0" onClick="window.open(\'curator-pic-add.php?id='.$id.'\')"><br><br>';
							
							/*
							//recherche des images
							$requete="SELECT PICTURE_ID FROM CIONA_DESIGN.PICTURE WHERE IN_SITU_ID = $id";
							$stmt = OCIParse($connection, $requete);
							OCIExecute($stmt);
							while(OCIFetch($stmt)){
								$idpicture=OCIresult($stmt,"PICTURE_ID");
								echo "<img src=\"picture.php?id=$idpicture\" border=\"1\" width=\"180\" name=\"$idpicture\" onClick=\"self.growPics(this);\"> ";
							}
							*/
							
							//recherche des images
							$requete="SELECT \"PICTURE_ID\", \"CONTROL\", \"PATH\" FROM \"PICTURE\" WHERE \"IN_SITU_ID\" = $id";
							$stmt = pg_query($c,$requete);
							while($row=pg_fetch_array($stmt)){
								$idpicture=$row["PICTURE_ID"];
								print '<table border="0" cellspacing="0" cellpadding="0">';
								//echo "<tr><td><img src=\"picture.php?id=$idpicture\" border=\"1\" width=\"180\" name=\"$idpicture\" onClick=\"self.growPics(this);\"></td></tr> ";
								if(strlen($row["PATH"])>0)
									echo "<tr><td><img src=\"picturesDB/".$row["PATH"]."\" border=\"1\" width=\"180\" name=\"$idpicture\" onClick=\"self.growPics2(this);\"></td></tr> ";
								else
								    echo "<tr><td><img src=\"picture.php?id=$idpicture\" border=\"1\" width=\"180\" name=\"$idpicture\" onClick=\"self.growPics(this);\"></td></tr> ";

							    if ($row["CONTROL"]=="y"){
								    print "<tr><td align=\"center\" valign=\"top\"><H4>Control</H4></td></tr><tr><td>&nbsp;</td></tr>";
								}
								print '</table>';
							}
							
							
							
							//echo "<img src=\"picture.php?id=$id\">&nbsp;"
							//echo "<a href=\"insitu-original-picture.php?id=$id\">Get the original file</a>" 
							?>
						</td>
						<td width="400" align="center">
							<img border="0" name="BIGimage" src="pictures/clic a picture.gif" onClick="self.getOriginal(this);" id="">
						    <!-- curation -->
							<br><img name="BIGdel" id="" src="pictures/button-cur-delete.gif" border="0" onClick="window.open('curator-pic-delete.php?id='+this.id)">
						</td>
					</tr>
				</table>
 
            </td>
          </tr>
		  <tr>
		  	<td align="left" valign="top" >
			
			 <?php
			 //curation
			 print '<br><br><a href="curator-edit.php?id='.$id.'&part=IM_COMMENTS" target="_blank"><img src="pictures/button-cur-edit.gif" title="Edit" border="0"></a>';
			 print '<br>';
			 echo ($rowcond["IM_COMMENTS"]);
			 ?>
		  </tr>
        </table>
		</form>
		<br>
		
   	  <form name="form2">
	  <center>
    <table width="99%" cellpadding="0" cellspacing="0" border="0">
      <tr align="center" valign="middle" bgcolor="#990000" bordercolor="#990000"> 
        <td><strong>Expression profile</strong></td>
        <td><strong>Clone</strong></td>
        <td><strong>Method</strong></td>
        <td><strong>Substrate</strong></td>
<!--Ajout-->	
<td  background="pictures/barre-red.jpg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
      </tr>
      <tr>
	<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<!--Ajout-->	
<td>&nbsp;</td>

      </tr>
      <?php

$requete="SELECT distinct(\"NAME\") from \"TARGET\" where \"IN_SITU_ID\"='$id'";

$stmt=pg_query($c,$requete);
$clone="";

if (pg_num_rows($stmt)==1)
{
$row=pg_fetch_array($stmt);
$clone=$row["NAME"];
}


 print '<tr><td><a href="addpartanat.php?species='.$species.'&dev='.$stadedev.'&insituid='.$id.'&cloneid='.$clone.'&substrate='.$substrate.'" target="_blank"><img border="0" src="pictures/button-add.jpg"></a> </td><td>

<img src="pictures/button-remove.jpg" border="0" onClick="self.giveMe(\''.$species.'\',\''.$stadedev.'\',\''.$id.'\');">

<!--<a href="" Onclick="javascript:self.giveMe(\''.$species.'\',\''.$stadedev.'\',\''.$id.'\');" target="_blank">
<img src="pictures/button-remove.jpg" border="0">
</a>
-->



</td><td>&nbsp;</td><td>&nbsp;</td>
<!--Ajout-->	
<td>&nbsp;</td>

</tr> <tr>
	<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<!--Ajout-->	
<td>&nbsp;</td>

      </tr>';

	  //creation de l'arbre anatomique minimal
//			$requeteT="SELECT A.TARGET_ID, A.REGION_ID, A.SUBCELL_POS, A.PROBE_ID, A.METHOD, A.INTENSITY, A.SUBSTRATE, B.NAME, B.FULL_NAME, B.TYPE, C.NAME AS ANATNAME, D.NAME AS SONDENAME, D.FULL_NAME AS SONDEFULL_NAME, D.TYPE AS SONDETYPE FROM CIONA_DESIGN.TARGET A, CIONA_DESIGN.MOL_ENTITY B, CIONA_DESIGN.MOL_ENTITY D, CIONA_DESIGN.ANAT_ENTITY C WHERE (A.IN_SITU_ID=$id) AND (A.TARGET_ID=B.MOL_ID) AND (A.REGION_ID=C.ANAT_ID) AND (A.PROBE_ID=D.MOL_ID)";
            $requeteT="SELECT A.\"TARGET_ID\", A.\"SURE\", A.\"PART_OF\", A.\"REGION_ID\", A.\"SUBCELL_POS\", A.\"PROBE_ID\", A.\"METHOD\", A.\"INTENSITY\", A.\"SUBSTRATE\", B.\"NAME\", B.\"FULL_NAME\", B.\"TYPE\" FROM \"TARGET\" A, \"MOL_ENTITY\" B WHERE (A.\"IN_SITU_ID\"=$id) AND (A.\"TARGET_ID\"=B.\"MOL_ID\")";
            
			$stmtT = pg_query($c,$requeteT);
			$compte=-1;
			while($rowT=pg_fetch_array($stmtT)){
			    ++$compte;
				$data[$compte] = $rowT["REGION_ID"];
				
				$row=$rowT["REGION_ID"];
				$data2[$row][0] = $rowT["SURE"];
				$data2[$row][1] = $rowT["SUBCELL_POS"];
				$data2[$row][2] = $rowT["INTENSITY"];
				$data2[$row][3] .= $rowT["NAME"]."#";
				$data2[$row][4] = $rowT["METHOD"];
				$method=$rowT["METHOD"]; //D
				$data2[$row][5] = $rowT["SUBSTRATE"];
				$substrate=$rowT["SUBSTRATE"]; //D
                		$data2[$row][6] = $rowT["TYPE"];
				$data2[$row][7] = $rowT["PART_OF"];
				$targetid=$rowT["TARGET_ID"]; //D
     
				$mol[$rowT["TARGET_ID"]]=$rowT["NAME"]; //recup du nom et de l'id des mol. pour faire des recherches de similitudes et de divergences /contextes.
				$typemol[$rowT["TARGET_ID"]]=$rowT["TYPE"]; //recup de son type;
			}
			
/*ici*/
/* SIMULATION D'UNE REQUETE SUR HIERARCHIE PAR UNE PROCEDURE DE REQUETES RECURSIVES */

function select_recursif_descendant($conn,$start,$res,$nivo)
{
global $rowcond;
global $data;
global $data2;
global $row;
global $dataline;
global $lines;
global $final;
global $ll;
global $id;

if ($start!='')
$requete="SELECT * FROM \"ANAT_ENTITY\" WHERE \"DEV_STAGE_ID\"=".$rowcond["DEV_STAGE_ID"]." and \"CHILD_OF\"= $start ";
else 
$requete="SELECT * FROM \"ANAT_ENTITY\" WHERE \"DEV_STAGE_ID\"=".$rowcond["DEV_STAGE_ID"]." and \"CHILD_OF\" is null ";

//print $requete;

$stmt=pg_query($conn,$requete);

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


while($row2=pg_fetch_array($stmt))
	{
			        $dataline="<tr><td>";
				
				for($a=0;$a<$nivo-1;++$a){
					if( $nivo>1 )
					    $dataline.='&nbsp;&nbsp;<font color="#999999">|</font>&nbsp;&nbsp;';
				}
				
				if( $row2["TYPE"]=='cell' )
					$dataline.="<img src=\"pictures/cell.gif\">";
				else if( $row2["TYPE"]=='organism' )
					$dataline.="<img src=\"pictures/tetard.gif\">";
				else
					$dataline.="<img src=\"pictures/region.gif\">";
				
				
				if( in_Array($row2["ANAT_ID"],$data) ){
		            $row=$row2["ANAT_ID"];
			
					//intensite du signal -> mot +/- gros
					if($data2[$row][2]=="++"){
					    $dataline.='<font size="+1">';
					}else if($data2[$row][2]=="+++"){
					    $dataline.='<font size="+2">';
					}else{
					    $dataline.='<font>';
			        }
					
					$partof="";
					if($data2[$row][7]=="X") $partof='<font color="#990000">Part of </font>'; else $partof="";
					
					$dataline.=$partof.'<strong><a href="short_hierarchy.php?region='.$row2["ANAT_ID"].'&dev='.$rowcond["DEV_STAGE_ID"].'">'.$row2["NAME"].'</a></strong></font><input type="checkbox" name="'.$row2["ANAT_ID"].'"value="idanat">'; 
					
					//indique une localisation sub cellulaire
					if( strlen($data2[$row][1])>0 ){ $dataline.='<font color="#990000">('.$data2[$row][1].')</font>'; }
					
					//indique si l'annotation est sure ou non
					if($data2[$row][0]=="X") $dataline.='<img src="pictures/not-sure.jpg" title="Not sure">';
			
					$print=1;//ordre d'imprimer les lignes de la hierarchie de cet element
				}else{
					$dataline.=$row2["NAME"];
				}
				if( $print==1 ){
////				    $dataline.='</td><td align="center"><a href="molecule-clone.php?name='.$data2[$row][3].'">'.$data2[$row][3].'</a><input type="checkbox" name="'.$data2[$row][3].'"value="target">';
				    $aa=split("#",$data2[$row][3]);
					$dataline.= '</td><td align="center">';
					for($a=0;$a<count(@aa);++$a){
					    if(strlen($aa[$a])>0){
						
							if( $data2[$row][6]=="clone" )
								$dataline.=
								'
								
								<a href="editpartanat.php?insituid='.$id.'&cloneid='.$aa[$a].'&anatid='.$row2["ANAT_ID"].'&name='.$row2["NAME"].'" target="_blank"><img width="25" border="0" src="pictures/button-cur-edit.gif"></a> &nbsp;

								<a href="molecule-clone2.php?name='; //D
							else if( $data2[$row][6]=="clone_sequence" )
								$dataline.=
								'

								<a href="editpartanat.php?insituid='.$id.'&cloneid='.$aa[$a].'&anatid='.$row2["ANAT_ID"].'&name='.$row2["NAME"].'" target="_blank"><img width="25" border="0" src="pictures/button-cur-edit.gif"></a> &nbsp;

								
								<a href="molecule-clone.php?name='; //D
							else if( $data2[$row][6]=="gene" )
								$dataline.=
								'
								<a href="editpartanat.php?insituid='.$id.'&cloneid='.$aa[$a].'&anatid='.$row2["ANAT_ID"].'&name='.$row2["NAME"].'" target="_blank"><img width="25" border="0" src="pictures/button-cur-edit.gif"></a> &nbsp;

								
								<a href="molecule-gene.php?name='; //D
							else if( $data2[$row][6]=="construction" )
								$dataline.=
								'
								
								
								
								
								<a href="molecule-construction.php?name='; //D
							else
							    $dataline.='<a href="" name="';

					        //$dataline.=$aa[$a].'">'.$aa[$a].'</a><input type="checkbox" name="'.$aa[$a].'"value="target"> ';
						$dataline.=$aa[$a].'">'.$aa[$a].'</a>&nbsp&nbsp;&nbsp;';

						
						}					}
					$dataline.='</td><td align="center">'.$data2[$row][4].'</td>';
					$dataline.='</td><td align="center">'.$data2[$row][5].'</td>';
					$dataline.='</td><td align="center"><a href="editpartanat.php?insituid='.$id.'&cloneid='.$aa[$a].'&anatid='.$row2["ANAT_ID"].'&name='.$row2["NAME"].'" target="_blank"><img width="25" border="0" src="pictures/button-cur-edit.gif"></a> &nbsp;';
				}
				
				$dataline.='</td></tr>';
				$lines[ $nivo-1 ]=$dataline;
				$lines=array_slice($lines,0,$nivo);
				if( $print==1 ){
				    for($f=0; $f<count($lines); ++$f){
					    if(! in_array($lines[$f], $final) )
						    $final[$ll++]=$lines[$f];
                    }
					$print=0;
				}
	$res=select_recursif_descendant($conn,$row2["ANAT_ID"],$res,$nivo);
	}
return $res;
}
/* FIN DE LA SIMULATION */

			$lines=array(); $print=0; $final=array(); $ll=0;
						
			$res=select_recursif_descendant($c,null,$res,$nivo);



            foreach($final as $key=>$value){
			    print $value;
			}
		

		



?>
  </table>
  </center>

<?php
//recherche des genes correspondants:
	print "<br><br><br><strong>Predicted corresponding gene: </strong><br>";
	print '<table width="99%" border="0" cellspacing="0" cellpadding="0">';
	$abc=0;
	while (list($key, $value) = each($mol)) {
	      $count=0;
	      $geneidlist="";
		  if( $typemol[$key]=="clone" ){
			  $requete="SELECT distinct \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"='$value'";
			  $stmt = pg_query($c,$requete);
			  while($row=pg_fetch_array($stmt)){
			       $geneidlist[$count++]=$row["ANISEED_CLUSTER_ID"]; //+ieur genes poss si les est d'un meme clone correspondent a des modeles differents
			  }
		  }
		  else if( $typemol[$key]=="clone_sequence" ){
			  $requete="SELECT \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_SEQ_ID\"=$key";
			  $stmt = pg_query($c,$requete);
			  while($row=pg_fetch_array($stmt)){
			       $geneidlist[$count++]=$row["ANISEED_CLUSTER_ID"];
			  }
		  }
		  else if( $typemol[$key]=="gene" ){
		      $geneidlist[$count++]=$key;
	      }
		  else if( $typemol[$key]=="construction" ){
		      $geneidlist[$count++]=$key;
	      }
		  
		  for($a=0; $a<count($geneidlist); ++$a){
		    if(strlen($geneidlist[$a])>0){
			  ++$abc;
			  $requete="SELECT distinct A.\"NAME\", B.\"SYNO\", B.\"ORIGIN\" from \"GENE\" A, \"SYNO\" B where A.\"GENE_ID\"=B.\"GENE_ID\" and B.\"GENE_ID\"=".$geneidlist[$a]."order by B.\"ORIGIN\" DESC";
			  $stmt = pg_query($c,$requete);
			  $syno="";
			  while($row=pg_fetch_array($stmt)){
			      $genename=$row["NAME"];
			      if($row["SYNO"]==$row["NAME"])
				      continue;
				  $syno.=$row["SYNO"];
				  if($row["ORIGIN"]=="user-JGI")
				      $syno.="*";
				  $syno.="&nbsp; ";
			  }
              print "<tr valign=\"top\"><td><hr size=\"1\">".$value." </td><td><hr size=\"1\"><a href=\"molecule-gene.php?name=".$genename."\">".$genename."</a></td><td width=\"60%\"><hr size=\"1\">".$syno."</td></tr>";
		    }
		  }
	}
	print '</table>';
	if($abc==0)
	    print "None";
	reset($mol);



?>


<br><br>
<table width="100%" border="0" cellspacing="0">
  <tr bgcolor="#000033">
    <td><strong>Experimental conditions</strong></td>
  </tr>
  
<?php
    print '<tr><td><a href="curator-edit.php?id='.$id.'&part=EXP_COMMENTS" target="_blank"><img src="pictures/button-cur-edit.gif" title="Edit" border="0"></a></td></tr>';
	
	$comments=$rowcond["EXP_COMMENTS"];
	echo "<tr><td>$comments</td></tr>";
	echo "<tr><td>&nbsp;</td></tr>";
	if(strlen($owcond["TIME"])>0)
		echo "<tr><td><strong>Staining duration: </strong>".$rowcond["TIME"]." H</td></tr>";
	if(strlen($rowcond["TEMPERATURE"])>0)
		echo "<tr><td><strong>Temperature: </strong>".$rowcond["TEMPERATURE"]." C</td></tr>";
	
?>
</table>

<br>
<?php
if( ($rowcond["WILD_TYPE"]=='n')or($rowcond["WILD_TYPE"]=='N') ){
      ////////////////////////////////
	  //TAB des molecules deregulees//
	  ////////////////////////////////
      print '<strong>Deregulated molecules</strong>';
      print '<center><table width="99%" cellpadding="0" cellspacing="0" border="1" bordercolor="#333333">  <tr bgcolor="#990000" bordercolor="#990000" align="center" valign="middle">  <td><strong>Name</strong></td>  <td><strong>Regulation type</strong></td>  <td><strong>Molecular tool</strong></td>  <td><strong>From stage</strong></td>  <td background="pictures/barre-red.jpg"><strong>To stage</strong></td>  </tr>';
   	///////////////////////////////////////////
      //$requete="SELECT A.BIO_ID, A.UP_DOWN, A.TO_ID, A.FROM_ID, A.COMMENTS, B.NAME, B.FULL_NAME, C.NAME AS FROMSTAGE, D.NAME AS TOSTAGE FROM CIONA_DESIGN.MUTANT A, CIONA_DESIGN.MOL_ENTITY B, CIONA_DESIGN.DEV_STAGE C, CIONA_DESIGN.DEV_STAGE D WHERE (A.IN_SITU_ID=$id) AND (A.BIO_ID=B.MOL_ID) AND (A.FROM_ID=C.DEV_STAGE_ID) AND (A.TO_ID=D.DEV_STAGE_ID)";
	  //on ne peut pas faire de jointures avec les dev stage id car ces donnees sont optionnelles
	  $requete="SELECT A.\"INHIBITOR_ID\", A.\"BIO_ID\", A.\"UP_DOWN\", A.\"TO_ID\", A.\"FROM_ID\", B.\"NAME\", B.\"FULL_NAME\", B.\"TYPE\" FROM \"MUTANT\" A, \"MOL_ENTITY\" B WHERE (A.\"IN_SITU_ID\"=$id) AND (A.\"BIO_ID\"=B.\"MOL_ID\") order by A.\"BIO_ID\"";// AND (A.FROM_ID=C.DEV_STAGE_ID)";// AND (A.TO_ID=C.DEV_STAGE_ID)";

	        
	  $stmt = pg_query($c,$requete);
	  $count=0;
  	  while($row=pg_fetch_array($stmt)){
	      ++$count;
	  	  print "<tr align=\"center\" valign=\"middle\" >\n";
		  
		  //elts deregules
		  
			  $name='';
			  if(strlen($row["NAME"])>0)
			  	$name=$row["NAME"];
			  else
			  	$name=$row["FULL_NAME"];
		  
			  print "<td><a href= 'molecule-gene.php?name=".$row["NAME"]."'>".$row["NAME"]."</a><input type=\"checkbox\" name=\"".$name."\"value=\"mutant\"></td>\n";
		  
		  
		  //regu type
		  print "<td>".$row["UP_DOWN"]."</td>\n";
		  
		  //mol tool
		  if(strlen($row["INHIBITOR_ID"])>0){
			  $re = "SELECT \"NAME\" FROM \"MOLECULAR_TOOL\" WHERE \"MOLECULAR_TOOL_ID\" = ".$row["INHIBITOR_ID"];
			  $st = pg_query($c,$re);
			  $r=pg_fetch_array($st);			  
			  print "<td><a href=\"molecule-tool.php?id=".$row["INHIBITOR_ID"]."\">".$r["NAME"]."</a></td>\n";
		  }else{print "<td>&nbsp;</td>";}
		  
		  //from
		  if(strlen($row["FROM_ID"])>0){
			  $re = "SELECT \"NAME\" FROM \"DEV_STAGE\" WHERE \"DEV_STAGE_ID\" = ".$row["FROM_ID"];
			  $st = pg_query($c,$re);
			  $r=pg_fetch_array($st);		  
			  print "<td>".$r["NAME"]."</td>\n";
		  }else{print "<td>&nbsp;</td>";}
		  
		  //to
		  if(strlen($row["TO_ID"])>0){
			  $re="SELECT \"NAME\" FROM \"DEV_STAGE\" WHERE \"DEV_STAGE_ID\"='".$row["TO_ID"]."'";
			  $st = pg_query($c,$re);
			  $r=pg_fetch_array($st);
			  print "<td>".$r["NAME"]."</td>\n";
		  }else{print "<td>&nbsp;</td>";}
		  
		  //print "<td>&nbsp;".OCIResult($stmt, "COMMENTS")."</td>\n";
		  
	  	  print "</tr>\n";
  	  }
      print '</table>';
	  if($count==0) print 'NONE';
	  print '</center>';




     
///////////////////////////////
      //TAB des manip embryo
///////////////////////////////
      print '<br><br><strong>Embryo manipulations</strong> ';
      print '<center><table width="99%" cellpadding="0" cellspacing="0" border="1" bordercolor="#333333">  <tr bgcolor="#990000" bordercolor="#990000" align="center" valign="middle">  <td><strong>Removed anatomy part</strong></td>  <td background="pictures/barre-red.jpg"><strong>From stage</strong></td>  </tr>';
  
	  $requete="SELECT A.\"STRUCTURE_ID\", A.\"FROM_ID\", C.\"NAME\" FROM \"EMBRYO_MANIP\" A, \"ANAT_ENTITY\" C WHERE (A.\"IN_SITU_ID\"=$id) AND (A.\"STRUCTURE_ID\"=C.\"ANAT_ID\")";
      $stmt = pg_query($c,$requete); 
  	  $count=0;
  	  while($row=pg_fetch_array($stmt)){
	      ++$count;
	  	  print "<tr align=\"center\" valign=\"middle\">\n";

		  	  //if(strlen(OCIResult($stmt, "STRUCTURE_ID"))>0){
				  //$re="SELECT NAME FROM CIONA_DESIGN.ANAT_ENTITY WHERE ANAT_ID=".OCIResult($stmt, "STRUCTURE_ID");
				  //$st = OCIParse($connection, $re);
				  //OCIExecute($st);
				  //OCIFetch($st);
				  print "<td><a href= \"short_hierarchy.php?dev=".$rowcond["DEV_STAGE_ID"]."&region=".$row["STRUCTURE_ID"]."#tag\">".$row["NAME"]."</a><input type=\"checkbox\" name=\"".$row["STRUCTURE_ID"]."\"value=\"amputation\"></td>\n";
			  //}else{print "<td></td>";}
			  
			  if(strlen($row["FROM_ID"])>0){
				  $re = "SELECT \"NAME\" FROM \"DEV_STAGE\" WHERE \"DEV_STAGE_ID\"='".$row["FROM_ID"]."'";
				  $st = pg_query($c,$re);
				  $r=pg_fetch_array($st);
				  print "<td>".$r["NAME"]."</td>\n";
			  }else{print "<td>&nbsp;</td>";}
			  
			  //print "<td>".OCIResult($stmt, "COMMENTS")."&nbsp;</td>\n";
		  
	  	  print "</tr>\n";
  	  }
      print '</table>';
	  if($count==0) print 'NONE';
	  
	  print '</center>';
}else{
    print "Wild_Type Embryo.";
}
?>
</form>
<br><br><br>


<table width="100%" border="0" cellspacing="0">
	<tr bgcolor="#000033">
  		<td><strong>References&nbsp;&nbsp;&nbsp;<a href="addreference.php?id=<? print $id; ?>" target="_blank"><img border="0" src="pictures/button-add.jpg"></a>&nbsp;&nbsp;&nbsp;<a style="color:white;" href="addreferencebyparsing.php?id=<? print $id; ?>" target="_blank">Add by PubmedID</a>&nbsp;&nbsp;&nbsp;</strong></td>
	</tr>
	
	<?php
	$requete="SELECT \"TITLE\",\"PUBMED_ID\",\"PAPER\",\"AUTHORS\",\"COMMENTS\",\"URL\" FROM \"REFERENCE\" WHERE \"BIO_ID\"=$id";
	$stmtT = pg_query($c,$requete);
	$count=0;

	while ($rowT=pg_fetch_array($stmtT)){
		++$count;
		echo '
			<tr><td><br>';
		echo "

<a href=\"editreference.php?pubmedid=".$rowT["PUBMED_ID"]."&id=$id\" target=\"_blank\"><img src=\"pictures/button-cur-edit.gif\" title=\"Edit\" width=\"30\" border=\"0\"></a>&nbsp;&nbsp;
<a href=\"deletereference.php?id=$id&pubmedid=".$rowT["PUBMED_ID"]."\" target=\"_blank\"><img width=\"30\" border=\"0\" src=\"pictures/button-cur-delete.gif\"></a>
<a target=\"blank\" href=\"http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=PubMed&cmd=Retrieve&list_uids=".$rowT["PUBMED_ID"]."&dopt=Abstract\">".$rowT["TITLE"]."</a>  &nbsp; &nbsp;<strong>".$rowT["AUTHORS"]."</strong>    &nbsp; &nbsp;".$rowT["PAPER"]."<a target=\"blank\" href=\"".$rowT["URL"]."\">".$rowT["URL"]."</a>" ;
		echo '<br>'.$rowT["COMMENTS"].'<br><br>' ;
		echo '</td></tr>';
	}
	if($count==0)
		{
		
		echo '
		<!--<a href="addreference.php?id=toto" target="_blank"><img border="0" src="pictures/button-add.jpg"></a>-->
		<tr><td>
		NONE
		</td></tr>';
		}
	?>
	
</table>




<br>

<?php
	if($_GET["FHeader"]!="n" )
    	include("frames_footer.php");
	else
		echo '</body>';
?> 