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


<SCRIPT>
function CheckALL() {
	for(a=0; a<document.form.length; ++a){
		document.form[a].checked=true
	}
}
</SCRIPT>


<?php
	$name = $_GET["name"];
	
	
	
	$requete="select B.\"SPECIES\", A.* from \"CLONE\" A, \"MOL_ENTITY\" B where (A.\"CLONE_NAME\"='$name') and (B.\"MOL_ID\"=A.\"CLONE_ID\")";
	$stmt = pg_query($c,$requete);
	if( $row=pg_fetch_array($stmt) ){
	
	
///	if(ocicolumnisnull($stmt,"CLONE_ID")){
///	    print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>";
///	}else{
		
	    $nameClone=$row["CLONE_NAME"];
	    $libid=$row["LIBRARY_ID"];
	
	
	    $requete2="select * from \"LIBRARY\" where \"LIBRARY_ID\"='$libid'";
	    $stmt2 = pg_query($c,$requete2);
	
	
        print "<h2><strong><em>Clone ".$row["CLONE_NAME"]."</em></strong></h2>";
    
	
	    print "<u><strong>Features</strong></u><br>";
	    print "<table width=\"100%\">";
        print "<tr><td  width=\"20%\"><strong>Name: </strong></td><td>".$row["CLONE_NAME"]."</td></tr>";
        print "<tr valign=\"top\" align=\"left\"><td><strong>Species: </strong></td><td>".$row["SPECIES"]."</td></tr>";
		if( $row2=pg_fetch_array($stmt2) ){
            print "<tr valign=\"top\" align=\"left\"><td><strong>Library: </strong></td><td>".$row2["TITLE"]."&nbsp;&nbsp;(".$row2["LIB_SIZE"]." clones)</td></tr>";
			print "<tr valign=\"top\" align=\"left\"><td><strong>Tissue: </strong></td><td>".$row2["TISSUE"]."</td></tr>";
			print "<tr valign=\"top\" align=\"left\"><td><strong>Organ: </strong></td><td>".$row2["ORGAN"]."</td></tr>";
			print "<tr valign=\"top\" align=\"left\"><td><strong>Vector: </strong></td><td>".$row2["VECTOR"]."</td></tr>";
		}
		print "</table>";
	    
	    print "<br><br><br><center><a href=\"insitu-result.php?target=$name\"><img src=\"pictures/button-getPics.jpg\" border=\"0\"></a></center>";
	    
        print "<br><br><u><strong>Sequences</strong></u><br>";
        $requete="select \"GENBANK_ID\", \"CLONE_NAME\", \"END\", \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"='$name' order by \"NAME\"";
        $stmt = pg_query($c,$requete);
		
        print '<form name="form" action="AllClonesFASTA.php" target="_BLANK" method="POST"><table width="50%" border="0" cellspacing="0" cellpadding="0">';
        print '<tr align="center" valign="middle" bgcolor="#990000"><td>&nbsp;</td><td>Clone name</td><td>Genbank ID</td><td>End</td><td  background="pictures/barre-red.jpg">Cluster</td></tr>';
        $count=0;
	    while($row=pg_fetch_array($stmt)){
	        ++$count;
	        print "<tr align=\"center\"><td><input name=\"id[]\" type=\"checkbox\" value=\"".$row["GENBANK_ID"]."\"></td><td width=\"25%\"><a href=\"molecule-clone.php?name=".$row["GENBANK_ID"]."\">".$row["CLONE_NAME"]."</a></td><td width=\"25%\"><a href=\"molecule-clone.php?name=".$row["GENBANK_ID"]."\">".$row["GENBANK_ID"]."</a></td><td width=\"25%\">".$row["END"]."</td><td width=\"25%\"><a href=\"ESTcluster.php?name=".$row["ANISEED_CLUSTER_ID"]."\">".$row["ANISEED_CLUSTER_ID"]."</a></td></tr>";
	    }
	    print "</table></form>";
	
	    if($count==0){
	        print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>";
	    }
		
		print "<br>&nbsp;&nbsp;&nbsp;<img border=\"0\" src=\"pictures/button-selectALL.jpg\" onClick=\"CheckALL();\">";
		//print "&nbsp;&nbsp;&nbsp;<img border=\"0\" src=\"pictures/button-download.jpg\" onClick=\"self.getSelected();\">";
		print "&nbsp;&nbsp;&nbsp;<img border=\"0\" src=\"pictures/button-download.jpg\" onClick=\"document.form.submit();\">";
		
	}else{print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>";}
?>

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