<?

##########################################################################
# index.php:  PHP file for the Simcal1 module.                           #
# Copyright (c) 2004 Daniel Dvorkin.                                     #
# Distributed under the Artistic License, WITHOUT "optional clause 8"    #
# (see http://www.opensource.org/licenses/artistic-license.php).         #
# All rights not granted in this license are reserved by the author.     #
##########################################################################

include_once("main_inc.php");

/* DATA PREPARATION */

if(!isset($_REQUEST['action']))
	$_REQUEST['action'] = "Introduction";
	
switch($_REQUEST['action'])
{
	case "Genes":
	case "Gene Search Results":
	case "Gene":
		$theEntity = new GeneViewable($_REQUEST['Id']);
	break;
	
	case "Clusters":
	case "Cluster Search Results":
	case "Cluster":
		$theEntity = new ClusterViewable
			($_REQUEST['Id'], $_REQUEST['Rank']);
	break;
	
	default:
		$theEntity = NULL;
	break;
}

$title = "Fadok Lab: SiMCAL1: ";
if(is_object($theEntity))
{
	$title .= $theEntity->title_string();
	if($_REQUEST['subaction'] == "Save Changes")
		$theEntity->do_handle_changes();
}
else
{
	$title .= $_REQUEST['action'];
}

/* DISPLAY */

open_page($title);
	
?>

<table cellpadding = "0" cellspacing = "0" width = "100%"><tr>

	<td width = "12%">
	
		<p class = "header">Menu</p>
			
		<?
		
		show_navbar();
		
		?>
		
	</td>
		
	<td width = "*">
	
		<?
		
		switch($_REQUEST['action'])
		{
			case "Introduction":
				show_introduction();
			break;
			
			case "Genes":
				$theEntity->show_general();
			break;
			
			case "Clusters":
				$theEntity->show_general();
			break;
			
			case "Gene Search":
			case "Cluster Search":
				DbEntityViewable::show_search();
			break;
			
			case "Gene Search Results":
			case "Cluster Search Results":
				$theEntity->show_search_results();
				$theEntity->show_search_form();
			break;
			
			case "Logarithms":
				show_logarithms();
			break;
			
			case "Gene":
			case "Cluster":
				$theEntity->show_self();
			break;
		}
			
		?>
	
	</td>

</tr></table>

<?

close_page();
	
?>