Index: /trunk/web/addons/toga/graph.php
===================================================================
--- /trunk/web/addons/toga/graph.php	(revision 143)
+++ /trunk/web/addons/toga/graph.php	(revision 143)
@@ -0,0 +1,303 @@
+<?php
+/* $Id: graph.php,v 1.8 2005/02/18 14:20:35 knobi1 Exp $ */
+include_once "./conf.php";
+include_once "./get_context.php";
+
+if ( !empty( $_GET ) ) {
+        extract( $_GET );
+}
+
+# Graph specific variables
+$size = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["z"] ));
+$graph = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["g"] ));
+$grid = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["G"] ));
+$self = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["me"] ));
+$max = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["x"] ));
+$min = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["n"] ));
+$value = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["v"] ));
+$load_color = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["l"] ));
+$vlabel = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["vl"] ));
+$sourcetime = escapeshellcmd($HTTP_GET_VARS["st"]);
+
+# Assumes we have a $start variable (set in get_context.php).
+if ($size == "small")
+    {
+      $height = 40;
+      $width = 130;
+    }
+else if ($size == "medium")
+    {
+      $height = 75;
+      $width = 300;
+    }
+else
+    {
+      $height = 100;
+      $width = 400;
+    }
+
+
+# This security fix was brought to my attention by Peter Vreugdenhil <petervre@sci.kun.nl>
+# Dont want users specifying their own malicious command via GET variables e.g.
+# http://ganglia.mrcluster.org/graph.php?graph=blob&command=whoami;cat%20/etc/passwd
+#
+if($command)
+    {
+      exit();
+    }
+
+switch ($context)
+{
+    case "meta":
+      $rrd_dir = "$rrds/__SummaryInfo__";
+      break;
+    case "grid":
+      $rrd_dir = "$rrds/$grid/__SummaryInfo__";
+      break;
+    case "cluster":
+      $rrd_dir = "$rrds/$clustername/__SummaryInfo__";
+      break;
+    case "host":
+      $rrd_dir = "$rrds/$clustername/$hostname";
+      break;
+    default:
+      exit;
+}
+
+if ($graph)   /* Canned graph request */
+    {
+      if($graph == "cpu_report")
+         {
+            $style = "CPU";
+
+            $upper_limit = "--upper-limit 100 --rigid";
+            $lower_limit = "--lower-limit 0";
+
+            $vertical_label = "--vertical-label Percent ";
+
+            if($context != "host" )
+               {
+                  /* If we are not in a host context, then we need to calculate the average */
+                  $series =
+                  "DEF:'num_nodes'='${rrd_dir}/cpu_user.rrd':'num':AVERAGE "
+                  ."DEF:'cpu_user'='${rrd_dir}/cpu_user.rrd':'sum':AVERAGE "
+                  ."CDEF:'ccpu_user'=cpu_user,num_nodes,/ "
+                  ."DEF:'cpu_nice'='${rrd_dir}/cpu_nice.rrd':'sum':AVERAGE "
+                  ."CDEF:'ccpu_nice'=cpu_nice,num_nodes,/ "
+                  ."DEF:'cpu_system'='${rrd_dir}/cpu_system.rrd':'sum':AVERAGE "
+                  ."CDEF:'ccpu_system'=cpu_system,num_nodes,/ "
+                  ."DEF:'cpu_idle'='${rrd_dir}/cpu_idle.rrd':'sum':AVERAGE "
+                  ."CDEF:'ccpu_idle'=cpu_idle,num_nodes,/ "
+                  ."AREA:'ccpu_user'#$cpu_user_color:'User CPU' "
+                  ."STACK:'ccpu_nice'#$cpu_nice_color:'Nice CPU' "
+                  ."STACK:'ccpu_system'#$cpu_system_color:'System CPU' ";
+                  if (file_exists("$rrd_dir/cpu_wio.rrd")) {
+                     $series .= "DEF:'cpu_wio'='${rrd_dir}/cpu_wio.rrd':'sum':AVERAGE "
+                     ."CDEF:'ccpu_wio'=cpu_wio,num_nodes,/ "
+                     ."STACK:'ccpu_wio'#$cpu_wio_color:'WAIT CPU' ";
+                  }
+                  $series .= "STACK:'ccpu_idle'#$cpu_idle_color:'Idle CPU' ";
+               }
+            else
+               {
+                  $series ="DEF:'cpu_user'='${rrd_dir}/cpu_user.rrd':'sum':AVERAGE "
+                  ."DEF:'cpu_nice'='${rrd_dir}/cpu_nice.rrd':'sum':AVERAGE "
+                  ."DEF:'cpu_system'='${rrd_dir}/cpu_system.rrd':'sum':AVERAGE "
+                  ."DEF:'cpu_idle'='${rrd_dir}/cpu_idle.rrd':'sum':AVERAGE "
+                  ."AREA:'cpu_user'#$cpu_user_color:'User CPU' "
+                  ."STACK:'cpu_nice'#$cpu_nice_color:'Nice CPU' "
+                  ."STACK:'cpu_system'#$cpu_system_color:'System CPU' ";
+                  if (file_exists("$rrd_dir/cpu_wio.rrd")) {
+                     $series .= "DEF:'cpu_wio'='${rrd_dir}/cpu_wio.rrd':'sum':AVERAGE "
+                     ."STACK:'cpu_wio'#$cpu_wio_color:'WAIT CPU' ";
+                  }
+                  $series .= "STACK:'cpu_idle'#$cpu_idle_color:'Idle CPU' ";
+               }
+         }
+      else if ($graph == "mem_report")
+         {
+            $style = "Memory";
+
+            $lower_limit = "--lower-limit 0 --rigid";
+            $extras = "--base 1024";
+            $vertical_label = "--vertical-label Bytes";
+
+            $series = "DEF:'mem_total'='${rrd_dir}/mem_total.rrd':'sum':AVERAGE "
+               ."CDEF:'bmem_total'=mem_total,1024,* "
+               ."DEF:'mem_shared'='${rrd_dir}/mem_shared.rrd':'sum':AVERAGE "
+               ."CDEF:'bmem_shared'=mem_shared,1024,* "
+               ."DEF:'mem_free'='${rrd_dir}/mem_free.rrd':'sum':AVERAGE "
+               ."CDEF:'bmem_free'=mem_free,1024,* "
+               ."DEF:'mem_cached'='${rrd_dir}/mem_cached.rrd':'sum':AVERAGE "
+               ."CDEF:'bmem_cached'=mem_cached,1024,* "
+               ."DEF:'mem_buffers'='${rrd_dir}/mem_buffers.rrd':'sum':AVERAGE "
+               ."CDEF:'bmem_buffers'=mem_buffers,1024,* "
+               ."CDEF:'bmem_used'='bmem_total','bmem_shared',-,'bmem_free',-,'bmem_cached',-,'bmem_buffers',- "
+               ."AREA:'bmem_used'#$mem_used_color:'Memory Used' "
+               ."STACK:'bmem_shared'#$mem_shared_color:'Memory Shared' "
+               ."STACK:'bmem_cached'#$mem_cached_color:'Memory Cached' "
+               ."STACK:'bmem_buffers'#$mem_buffered_color:'Memory Buffered' ";
+            if (file_exists("$rrd_dir/swap_total.rrd")) {
+               $series .= "DEF:'swap_total'='${rrd_dir}/swap_total.rrd':'sum':AVERAGE "
+               ."DEF:'swap_free'='${rrd_dir}/swap_free.rrd':'sum':AVERAGE "
+               ."CDEF:'bmem_swapped'='swap_total','swap_free',-,1024,* "
+               ."STACK:'bmem_swapped'#$mem_swapped_color:'Memory Swapped' ";
+            }
+            $series .= "LINE2:'bmem_total'#$cpu_num_color:'Total In-Core Memory' ";
+         }
+      else if ($graph == "load_report")
+         {
+            $style = "Load";
+
+            $lower_limit = "--lower-limit 0 --rigid";
+            $vertical_label = "--vertical-label 'Load/Procs'";
+
+            $series = "DEF:'load_one'='${rrd_dir}/load_one.rrd':'sum':AVERAGE "
+               ."DEF:'proc_run'='${rrd_dir}/proc_run.rrd':'sum':AVERAGE "
+               ."DEF:'cpu_num'='${rrd_dir}/cpu_num.rrd':'sum':AVERAGE ";
+            if( $context != "host" )
+               {
+                  $series .="DEF:'num_nodes'='${rrd_dir}/cpu_num.rrd':'num':AVERAGE ";
+               }
+            $series .="AREA:'load_one'#$load_one_color:'1-min Load' ";
+            if( $context != "host" )
+               {
+                  $series .= "LINE2:'num_nodes'#$num_nodes_color:'Nodes' ";
+               }
+            $series .="LINE2:'cpu_num'#$cpu_num_color:'CPUs' ";
+            $series .="LINE2:'proc_run'#$proc_run_color:'Running Processes' ";
+         }
+      else if ($graph == "network_report")
+         {
+            $style = "Network";
+
+            $lower_limit = "--lower-limit 0 --rigid";
+            $extras = "--base 1024";
+            $vertical_label = "--vertical-label 'Bytes/sec'";
+
+            $series = "DEF:'bytes_in'='${rrd_dir}/bytes_in.rrd':'sum':AVERAGE "
+               ."DEF:'bytes_out'='${rrd_dir}/bytes_out.rrd':'sum':AVERAGE "
+               ."LINE2:'bytes_in'#$mem_cached_color:'In' "
+               ."LINE2:'bytes_out'#$mem_used_color:'Out' ";
+         }
+      else if ($graph == "packet_report")
+         {
+            $style = "Packets";
+
+            $lower_limit = "--lower-limit 0 --rigid";
+            $extras = "--base 1024";
+            $vertical_label = "--vertical-label 'Packets/sec'";
+
+            $series = "DEF:'bytes_in'='${rrd_dir}/pkts_in.rrd':'sum':AVERAGE "
+               ."DEF:'bytes_out'='${rrd_dir}/pkts_out.rrd':'sum':AVERAGE "
+               ."LINE2:'bytes_in'#$mem_cached_color:'In' "
+               ."LINE2:'bytes_out'#$mem_used_color:'Out' ";
+         }
+      else
+         {
+      /* Custom graph */
+      $style = "";
+
+      $subtitle = $metricname;
+      if ($context == "host") 
+      {
+          if ($size == "small")
+              $prefix = $metricname;
+          else
+              $prefix = $hostname;
+
+          $value = $value>1000 ? number_format($value) : number_format($value, 2);
+
+          if ($range=="job") {
+               $hrs = intval( -$jobrange / 3600 );
+               $subtitle = "$prefix last ${hrs}h (now $value)";
+          }
+          else
+              $subtitle = "$prefix last $range (now $value)";
+      }
+
+      if (is_numeric($max))
+         $upper_limit = "--upper-limit '$max' ";
+      if (is_numeric($min))
+         $lower_limit ="--lower-limit '$min' ";
+
+      if ($vlabel)
+         $vertical_label = "--vertical-label '$vlabel'";
+      else if ($upper_limit or $lower_limit)
+         {
+            $max = $max>1000 ? number_format($max) : number_format($max, 2);
+            $min = $min>0 ? number_format($min,2) : $min;
+
+            $vertical_label ="--vertical-label '$min - $max' ";
+         }
+
+      $rrd_file = "$rrd_dir/$metricname.rrd";
+      $series = "DEF:'sum'='$rrd_file':'sum':AVERAGE "
+         ."AREA:'sum'#$default_metric_color:'$subtitle' ";
+      if ($jobstart)
+         $series .= "VRULE:$jobstart#$jobstart_color ";
+    }
+
+# Set the graph title.
+if($context == "meta")
+   {
+     $title = "$self $meta_designator $style last $range";
+   }
+else if ($context == "grid")
+  {
+     $title = "$grid $meta_designator $style last $range";
+  }
+else if ($context == "cluster")
+   {
+      $title = "$clustername $style last $range";
+   }
+else
+   {
+    if ($size == "small")
+      {
+        # Value for this graph define a background color.
+        if (!$load_color) $load_color = "ffffff";
+        $background = "--color BACK#'$load_color'";
+
+        $title = $hostname;
+      }
+    else if ($style)
+       $title = "$hostname $style last $range";
+    else
+       $title = $metricname;
+   }
+
+# Fix from Phil Radden, but step is not always 15 anymore.
+if ($range=="month")
+   $end = floor($end / 672) * 672;
+
+#
+# Generate the rrdtool graph command.
+#
+$command = RRDTOOL . " graph - --start $start --end $end ".
+   "--width $width --height $height $upper_limit $lower_limit ".
+   "--title '$title' $vertical_label $extras $background ".
+   $series;
+
+$debug=0;
+
+# Did we generate a command?   Run it.
+if($command)
+ {
+   /*Make sure the image is not cached*/
+   header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");   // Date in the past
+   header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
+   header ("Cache-Control: no-cache, must-revalidate");   // HTTP/1.1
+   header ("Pragma: no-cache");                     // HTTP/1.0
+   if ($debug) {
+     header ("Content-type: text/html");
+     print "$command\n\n\n\n\n";
+    }
+   else {
+     header ("Content-type: image/gif");
+     passthru($command);
+    }
+ }
+
+?>
+
Index: /trunk/web/addons/toga/index.php
===================================================================
--- /trunk/web/addons/toga/index.php	(revision 142)
+++ /trunk/web/addons/toga/index.php	(revision 143)
@@ -187,4 +187,14 @@
 	}
 
+	if( $view == "search" ) {
+		$node_menu .= "<B>&gt;</B>\n";
+		$node_menu .= "<B>Jobarchive</B> ";
+		$tpl->assign("view", "search" );
+		$tpl->assign("form_name", "archive_search_form" );
+	} else {
+		$tpl->assign("form_name", "toga_form" );
+		$tpl->assign("view", "overview" );
+	}
+
 	$tpl->assign("node_menu", $node_menu);
 
Index: /trunk/web/addons/toga/libtoga.php
===================================================================
--- /trunk/web/addons/toga/libtoga.php	(revision 142)
+++ /trunk/web/addons/toga/libtoga.php	(revision 143)
@@ -216,5 +216,5 @@
 			$this->connect();
 
-		printf( "query = [%s]\n", $query );
+		//printf( "query = [%s]\n", $query );
 		$result = pg_query( $this->conn, $query );
 
Index: /trunk/web/addons/toga/search.php
===================================================================
--- /trunk/web/addons/toga/search.php	(revision 142)
+++ /trunk/web/addons/toga/search.php	(revision 143)
@@ -118,7 +118,4 @@
 
 	$time_fields = explode( ':', $time );
-	reset( $time_fields );
-
-	print_r( $time_fields );
 
 	$hours = $time_fields[0];
@@ -161,5 +158,7 @@
 function makeSearchPage() {
 	global $clustername, $tpl, $id, $user, $name, $start_from_time, $start_to_time, $queue;
-	global $end_from_time, $end_to_time, $filter;
+	global $end_from_time, $end_to_time, $filter, $default_showhosts, $m, $hosts_up;
+
+	$metricname = $m;
 
 	$tpl->assign( "cluster", $clustername );
@@ -210,17 +209,128 @@
 			$tpl->assign( "runningtime", makeTime( $runningtime ) );
 			
-			print_r( $job );
-			print_r( $nodes );
-			//output jobzooi
-
+			//print_r( $job );
+			//print_r( $nodes );
 		}
+
 		
 		if( count( $search_ids ) == 1 ) {
 
 			$tpl->newBlock( "showhosts" );
+
+			$showhosts = isset($sh) ? $sh : $default_showhosts;
+			//if( !$showhosts) $showhosts = $default_showhosts;
+			$tpl->assign("checked$showhosts", "checked");
+
+			# Present a width list
+			$cols_menu = "<SELECT NAME=\"hc\" OnChange=\"toga_form.submit();\">\n";
+
+			$hostcols = ($hc) ? $hc : 4;
+
+			foreach(range(1,25) as $cols) {
+				$cols_menu .= "<OPTION VALUE=$cols ";
+				if ($cols == $hostcols)
+					$cols_menu .= "SELECTED";
+				$cols_menu .= ">$cols\n";
+			}
+			$cols_menu .= "</SELECT>\n";
+
+			$tpl->assign("metric","$metricname $units");
+			$tpl->assign("id", $id);
+			# Host columns menu defined in header.php
+			$tpl->assign("cols_menu", $cols_menu);
+
+			if( $showhosts ) {
+				//bla
+
+				if( !isset($start) ) $start="jobstart";
+				if( !isset($stop) ) $stop="now";
+				//$tpl->assign("start", $start);
+				//$tpl->assign("stop", $stop);
+
+				$sorted_hosts = array();
+				$hosts_up = $jobs[$filter[id]][nodes];
+
+				$r = intval($job_runningtime * 1.25);
+
+				$jobrange = ($job_runningtime < 3600) ? -3600 : -$r ;
+				$jobstart = $report_time - $job_runningtime;
+
+				if ($reports[$metricname])
+					$metricval = "g";
+				else
+					$metricval = "m";
+
+				foreach ($hosts_up as $host ) {
+					$host = $host. '.'.$domain;
+					$cpus = $metrics[$host]["cpu_num"][VAL];
+					if (!$cpus) $cpus=1;
+					$load_one  = $metrics[$host]["load_one"][VAL];
+					$load = ((float) $load_one)/$cpus;
+					$host_load[$host] = $load;
+					$percent_hosts[load_color($load)] += 1;
+					if ($metricname=="load_one")
+						$sorted_hosts[$host] = $load;
+					else
+						$sorted_hosts[$host] = $metrics[$host][$metricname][VAL];
+				}
+				switch ($sort) {
+					case "descending":
+						arsort($sorted_hosts);
+						break;
+					case "by hostname":
+						ksort($sorted_hosts);
+						break;
+					default:
+					case "ascending":
+						asort($sorted_hosts);
+						break;
+				}
+
+				//$sorted_hosts = array_merge($down_hosts, $sorted_hosts);
+
+				# First pass to find the max value in all graphs for this
+				# metric. The $start,$end variables comes from get_context.php,
+				# included in index.php.
+				list($min, $max) = find_limits($sorted_hosts, $metricname);
+
+				# Second pass to output the graphs or metrics.
+				$i = 1;
+				foreach ( $sorted_hosts as $host=>$value  ) {
+					$tpl->newBlock ("sorted_list");
+					//$host = $host. '.'.$domain;
+					$host_url = rawurlencode($host);
+					$cluster_url = rawurlencode($clustername);
+
+					$textval = "";
+					//printf("host = %s, value = %s", $host, $value);
+					//echo "$host: $value, ";
+					$val = $metrics[$host][$metricname];
+					$class = "metric";
+					$host_link="\"?c=$cluster_url&h=$host_url&r=job&jr=$jobrange&js=$jobstart\"";
+
+					if ($val[TYPE]=="timestamp" or $always_timestamp[$metricname]) {
+						$textval = date("r", $val[VAL]);
+					} elseif ($val[TYPE]=="string" or $val[SLOPE]=="zero" or $always_constant[$metricname] or ($max_graphs > 0 and $i > $max_graphs )) {
+						$textval = "$val[VAL] $val[UNITS]";
+					} else {
+						$load_color = load_color($host_load[$host]);
+						$graphargs = ($reports[$metricname]) ? "g=$metricname&" : "m=$metricname&";
+						$graphargs .= "z=small&c=$cluster_url&h=$host_url&l=$load_color" ."&v=$val[VAL]&x=$max&n=$min&r=job&jr=$jobrange&js=$jobstart";
+					}
+					if ($textval) {
+						$cell="<td class=$class>".  "<b><a href=$host_link>$host</a></b><br>".  "<i>$metricname:</i> <b>$textval</b></td>";
+					} else {
+						$cell="<td><a href=$host_link>".  "<img src=\"../../graph.php?$graphargs\" ".  "alt=\"$host\" height=112 width=225 border=0></a></td>";
+					}
+
+					$tpl->assign("metric_image", $cell);
+					if (! ($i++ % $hostcols) )
+						 $tpl->assign ("br", "</tr><tr>");
+				}
+
+				//einde bla
+			}
 		}
 
-		// show search results
-
 	}
 }
Index: /trunk/web/addons/toga/templates/header.tpl
===================================================================
--- /trunk/web/addons/toga/templates/header.tpl	(revision 142)
+++ /trunk/web/addons/toga/templates/header.tpl	(revision 143)
@@ -9,5 +9,5 @@
 <BODY BGCOLOR="#FFFFFF">
 
-<FORM ACTION="./" METHOD="GET" NAME="toga_form">
+<FORM ACTION="./?c={cluster}&view={view}" METHOD="GET" NAME="{form_name}">
 <TABLE WIDTH="100%">
 <TR>
Index: /trunk/web/addons/toga/templates/search.tpl
===================================================================
--- /trunk/web/addons/toga/templates/search.tpl	(revision 142)
+++ /trunk/web/addons/toga/templates/search.tpl	(revision 143)
@@ -3,5 +3,42 @@
 
 <SCRIPT LANGUAGE="javascript" SRC="ts_picker.js"></SCRIPT>
-<SCRIPT LANGUAGE="javascript" SRC="libtoga.js"></SCRIPT>
+<SCRIPT LANGUAGE="javascript">
+function setSort( sortbyval ) {
+
+        if( sortbyval != document.archive_search_form.sortby.value ) {
+
+                document.archive_search_form.sortby.value = sortbyval;
+                document.archive_search_form.sortorder.value = "asc";
+
+        } else {
+
+                if( document.archive_search_form.sortorder.value == "desc" )
+                        document.archive_search_form.sortorder.value = "asc";
+                else if( document.archive_search_form.sortorder.value == "asc" )
+                        document.archive_search_form.sortorder.value = "desc";
+        }
+
+        document.forms['archive_search_form'].submit();
+}
+
+function setFilter( filtername, filterval ) {
+
+        var myfilterorder = document.archive_search_form.elements['filterorder'].value;
+
+        if( document.archive_search_form.elements[filtername] ) {
+                document.archive_search_form.elements[filtername].value = filterval;
+                if( myfilterorder != '')
+                        myfilterorder = myfilterorder + "," + filtername;
+                else
+                        myfilterorder = filtername;
+
+        }
+        document.archive_search_form.elements['filterorder'].value = myfilterorder;
+
+        //setTimeout( "document.forms['archive_search_form'].submit();", 1000 );
+
+        document.forms['archive_search_form'].submit();
+}
+</SCRIPT>
 <SCRIPT LANGUAGE="javascript">
 
@@ -92,5 +129,5 @@
   <TD></TD>
   <TD>
-  Job <B>start</B> between
+  Job <B>start</B>
   </TD>
 
@@ -100,5 +137,8 @@
   <TD>
   <INPUT TYPE="HIDDEN" NAME="start_from_time" VALUE="{start_from_value}">
-  <INPUT TYPE="TEXT" NAME="start_from_pick" VALUE="{start_from_value}" DISABLED="TRUE"> <A HREF="javascript:show_calendar('document.archive_search_form.start_from_pick', document.archive_search_form.start_from_pick.value );"><IMG SRC="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>
+  <INPUT TYPE="TEXT" NAME="start_from_pick" VALUE="{start_from_value}" DISABLED="TRUE"> 
+  <A HREF="javascript:show_calendar('document.archive_search_form.start_from_pick', document.archive_search_form.start_from_pick.value );">
+  <IMG SRC="cal.gif" width="16" height="16" border="0" title="Click to select a date/time" alt="Click to select a date/time"></a> 
+  <a href="#" onClick="document.archive_search_form.start_from_pick.value=''" alt="Click here to clear field" title="Click here to clear field"><IMG SRC="redcross.jpg" BORDER=0></A>
   </TD>
   
@@ -108,14 +148,18 @@
   <TD>
   <INPUT TYPE="HIDDEN" NAME="start_to_time" VALUE="{start_to_value}">
-  <INPUT TYPE="TEXT" NAME="start_to_pick" VALUE="{start_to_value}" DISABLED="TRUE"><a href="javascript:show_calendar('document.archive_search_form.start_to_pick', document.archive_search_form.start_to_pick.value );"> <img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>
-  </TD>
-  
-</TR>
-
-<TR>
-
-  <TD></TD>
-  <TD>
-  Job <B>end</B> between
+  <INPUT TYPE="TEXT" NAME="start_to_pick" VALUE="{start_to_value}" DISABLED="TRUE">
+  <a href="javascript:show_calendar('document.archive_search_form.start_to_pick', document.archive_search_form.start_to_pick.value );"> 
+  <img src="cal.gif" width="16" height="16" border="0" title="Click to select a date/time" alt="Click to select a date/time"></a> 
+  <a href="#" onClick="document.archive_search_form.start_to_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
+  <IMG SRC="redcross.jpg" BORDER=0></A>
+  </TD>
+  
+</TR>
+
+<TR>
+
+  <TD></TD>
+  <TD>
+  Job <B>finish</B>
   </TD>
 
@@ -125,5 +169,9 @@
   <TD>
   <INPUT TYPE="HIDDEN" NAME="end_from_time" VALUE="{end_from_value}">
-  <INPUT TYPE="TEXT" NAME="end_from_pick" VALUE="{end_from_value}" DISABLED="TRUE"> <A HREF="javascript:show_calendar('document.archive_search_form.end_from_pick', document.archive_search_form.end_from_pick.value );"><IMG SRC="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>
+  <INPUT TYPE="TEXT" NAME="end_from_pick" VALUE="{end_from_value}" DISABLED="TRUE"> 
+  <A HREF="javascript:show_calendar('document.archive_search_form.end_from_pick', document.archive_search_form.end_from_pick.value );">
+  <IMG SRC="cal.gif" width="16" height="16" border="0" title="Click to select a date/time" alt="Click to select a date/time"></a> 
+  <a href="#" onClick="document.archive_search_form.end_from_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
+  <IMG SRC="redcross.jpg" BORDER=0></A>
   </TD>
   
@@ -133,5 +181,9 @@
   <TD>
   <INPUT TYPE="HIDDEN" NAME="end_to_time" VALUE="{end_to_value}">
-  <INPUT TYPE="TEXT" NAME="end_to_pick" VALUE="{end_to_value}" DISABLED="TRUE"><a href="javascript:show_calendar('document.archive_search_form.end_to_pick', document.archive_search_form.end_to_pick.value );"> <img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>
+  <INPUT TYPE="TEXT" NAME="end_to_pick" VALUE="{end_to_value}" DISABLED="TRUE">
+  <a href="javascript:show_calendar('document.archive_search_form.end_to_pick', document.archive_search_form.end_to_pick.value );"> 
+  <img src="cal.gif" width="16" height="16" border="0" title="Click to select a date/time" alt="Click to select a date/time"></a> 
+  <a href="#" onClick="document.archive_search_form.end_to_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
+  <IMG SRC="redcross.jpg" BORDER=0></A>
   </TD>
   
@@ -199,6 +251,6 @@
   <FONT SIZE="-1">
   Show Hosts:
-  yes<INPUT type=radio name="sh" value="1" OnClick="toga_form.submit();" {checked1}>
-  no<INPUT type=radio name="sh" value="0" OnClick="toga_form.submit();" {checked0}>
+  yes<INPUT type=radio name="sh" value="1" OnClick="archive_search_form.submit();" {checked1}>
+  no<INPUT type=radio name="sh" value="0" OnClick="archive_search_form.submit();" {checked0}>
   </FONT>
   |
@@ -212,8 +264,14 @@
     <INPUT TYPE="HIDDEN" NAME="stop" VALUE="{stop}">
     Set graph timeperiod from 
-    <INPUT TYPE="text" NAME="period_start_pick" VALUE="{start}" SIZE=12 ALT="Start time" DISABLED="TRUE">
-    <a href="javascript:show_calendar('document.archive_search_form.period_start_pick', document.archive_search_form.period_start_pick.value);"><img src="cal.gif" width="16" height="16" border="0"></a>
+    <INPUT TYPE="text" NAME="period_start_pick" VALUE="{start}" ALT="Start time" DISABLED="TRUE">
+    <a href="javascript:show_calendar('document.archive_search_form.period_start_pick', document.archive_search_form.period_start_pick.value);" alt="Click to select a date/time" title="Click to select a date/time">
+    <img src="cal.gif" width="16" height="16" border="0"></a> 
+    <a href="#" onClick="javascript: document.archive_search_form.period_start_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
+    <IMG SRC="redcross.jpg" BORDER=0></A>
     to <INPUT TYPE="text" NAME="period_stop_pick" VALUE="{stop}" SIZE=12 ALT="Stop time" DISABLED="TRUE">
-    <a href="javascript:show_calendar('document.archive_search_form.period_stop_pick', document.archive_search_form.period_stop_pick.value);"><img src="cal.gif" width="16" height="16" border="0"></a>
+    <a href="javascript:show_calendar('document.archive_search_form.period_stop_pick', document.archive_search_form.period_stop_pick.value);" alt="Click to select a date/time" title="Click to select a date/time">
+    <img src="cal.gif" width="16" height="16" border="0"></a> 
+    <a href="#" onClick="javascript: document.archive_search_form.period_to_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
+    <IMG SRC="redcross.jpg" BORDER=0></A>
     <INPUT TYPE="submit" onClick="setPeriodTimestamps();" VALUE="Refresh graphs">
    </FONT>
