<?php

	function indent_field($field, $array){
		$right = array();
		for($i=0;$i < sizeof($array);$i++){
		/* only check stack if there is one */
			if(count($right)>0) {
			/* check if we should remove a node from the stack */
				while ($right[count($right)-1]<$array[$i]['rgt']) {
					array_pop($right);
				}
			}
			/* display indented node title */
			$array[$i]['indent'] = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",count($right));
			/* add this node to the stack */
				$right[] = $array[$i]['rgt'];
			} /* end for*/
			return $array;
	} /* end function */

class class_list  extends listbox{
	function list_content(){	
		$content[0]=array(label=>"label1",lft=>"0",rgt=>"21");
		$content[1]=array(label=>"label2",lft=>"1",rgt=>"14");
		$content[2]=array(label=>"label3",lft=>"2",rgt=>"7");
		$content[3]=array(label=>"label4",lft=>"3",rgt=>"4");
		$content[4]=array(label=>"label5",lft=>"5",rgt=>"6");
		$content[5]=array(label=>"label6",lft=>"8",rgt=>"13");
		$content[6]=array(label=>"label7",lft=>"9",rgt=>"10");
		$content[7]=array(label=>"label8",lft=>"11",rgt=>"12");
		$content[8]=array(label=>"label9",lft=>"15",rgt=>"20");
		$content[9]=array(label=>"label10",lft=>"16",rgt=>"17");
		$content[10]=array(label=>"label11",lft=>"18",rgt=>"19");
		return $content;
	}
}	

class listbox{
	var $sql;
	function display(){
		/* get the content we need to display */
			$content=$this->list_content();
		/* format the content we need to display */
			$content=indent_field(label, $content);
		/* display the content */
		echo "<table>";
			for($i=0;$i<sizeof($content);$i++){
				echo "<tr id=\"".$content[$i]['rgt']."\"";
				echo "<td>".$content[$i]['indent'];
				echo "<a href=\"javascript:hide_children(".$content[$i]['lft'].",".$content[$i]['rgt'].")\">+</a>";
				echo $content[$i]['label']."</td>";
				echo "<td>date information</td>";
				echo "<td>active information</td>";
				echo "<td>class average</td>";
				echo "</tr>";
			}
		echo "</table>";
	}
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
<script language="javascript">
var dge=document.getElementById;

function hide_children(lft,rgt){
	var element
	for(n=lft; n<rgt; n++){
		element=document.getElementById(n)
		if(element !== null){
			document.getElementById(n).style.display = 
    	  (document.getElementById(n).style.display=='none')?
 	    'block':'none';
		}
	}
}
</script>
</head>
<body>
<?php
$listbox=new class_list;
$show_box=$listbox->display();
?>
</body>

