Index: /trunk/web/addons/toga/libtoga.js
===================================================================
--- /trunk/web/addons/toga/libtoga.js	(revision 141)
+++ /trunk/web/addons/toga/libtoga.js	(revision 141)
@@ -0,0 +1,73 @@
+function setSort( sortbyval ) {
+
+	if( sortbyval != document.toga_form.sortby.value ) {
+
+		document.toga_form.sortby.value = sortbyval;
+		document.toga_form.sortorder.value = "asc";
+
+	} else {
+
+		if( document.toga_form.sortorder.value == "desc" )
+			document.toga_form.sortorder.value = "asc";
+		else if( document.toga_form.sortorder.value == "asc" )
+			document.toga_form.sortorder.value = "desc";
+	}
+
+	document.forms['toga_form'].submit();
+}
+
+function setFilter( filtername, filterval ) {
+
+	//document.toga_form.id.value = '';
+	//document.toga_form.queue.value = '';
+	//document.toga_form.state.value = '';
+	//document.toga_form.user.value = '';
+	var myfilterorder = document.toga_form.elements['filterorder'].value;
+
+	if( document.toga_form.elements[filtername] ) {
+		document.toga_form.elements[filtername].value = filterval;
+		if( myfilterorder != '')
+			myfilterorder = myfilterorder + "," + filtername;
+		else
+			myfilterorder = filtername;
+
+	}
+	document.toga_form.elements['filterorder'].value = myfilterorder;
+
+	//setTimeout( "document.forms['toga_form'].submit();", 1000 );
+
+	document.forms['toga_form'].submit();
+}
+
+//function removeFilters( filters ) {
+
+	//var myfilter_fields = filters.split( " " );
+	//for( var i=0; i<myfilter_fields.length; i++ ) {
+		//removeFilter( myfilter_fields[i] );
+		//setTimeout( "removeFilter( "+myfilter_fields[i]+" );", 50 );
+	//}
+	// delay 100 ms before submit or fields might not be set
+	//document.forms['toga_form'].submit();", 100 );
+
+	//setTimeout( "document.forms['toga_form'].submit();", 1000 );
+//}
+
+//function removeFilter( filtername ) {
+
+//      var filterorder_fields = document.toga_form.elements['filterorder'].value.split( "," );
+//      var myfilterorder = '';
+
+//      for( var i=0; i<filterorder_fields.length; i++ ) {
+//              if( filterorder_fields[i] != filtername ) {
+//                      if( myfilterorder != '') {
+//                              myfilterorder = myfilterorder + "," + filterorder_fields[i];
+//                              //alert('myfilterorder = '+myfilterorder);
+//                      } else {
+//                              myfilterorder = filterorder_fields[i];
+//                              //alert('emyfilterorder = '+myfilterorder);
+//                      }
+//              }
+//      }
+//      document.toga_form.elements[filtername].value = '';
+//      document.toga_form.elements['filterorder'].value = myfilterorder;
+//}
Index: /trunk/web/addons/toga/libtoga.php
===================================================================
--- /trunk/web/addons/toga/libtoga.php	(revision 140)
+++ /trunk/web/addons/toga/libtoga.php	(revision 141)
@@ -158,5 +158,5 @@
 		foreach( $result as $result_row ) 
 
-			$nodes[] = $this->getNodeArray( $result_row['id'] );
+			$nodes[] = $this->getNodeArray( $result_row[node_id] );
 
 		return $nodes;
@@ -171,5 +171,5 @@
 		foreach( $result as $result_row )
 
-			$jobs[] = $this->getJobArray( $result_row['id'] );
+			$jobs[] = $this->getJobArray( $result_row[job_id] );
 
 		return $jobs;
@@ -197,5 +197,9 @@
 			$map_key = explode( '_', $mykey );
 
-			$newkey = $map_key[1];
+			$rmap_key = array_reverse( $map_key );
+			array_pop( $rmap_key );
+			$map_key = array_reverse( $rmap_key );
+			
+			$newkey = implode( '_', $map_key );
 			
 			$myar[$newkey] = $result_row[$mykey];
@@ -212,4 +216,5 @@
 			$this->connect();
 
+		printf( "query = [%s]\n", $query );
 		$result = pg_query( $this->conn, $query );
 
@@ -294,4 +299,7 @@
 
 	function graph( $descr ) {
+//	monitor2:/data/toga/rrds/LISA Cluster/gb-r15n11.irc.sara.nl# rrdtool graph /var/www/ganglia/test1.png --start 1118683231 --end 1118750431 --width 300 --height 400 DEF:'1'='./1118647515/load_one.rrd':'sum':AVERAGE DEF:'2'='./1118690723/load_one.rrd':'sum':AVERAGE DEF:'3'='./1118733925/load_one.rrd':'sum':AVERAGE AREA:1#555555:"load_one" AREA:2#555555 AREA:3#555555
+//	380x461
+//	monitor2:/data/toga/rrds/LISA Cluster/gb-r15n11.irc.sara.nl#
 		//$command = $this->rrdbin . " graph - --start $start --end $end ".
 			"--width $width --height $height $upper_limit $lower_limit ".
Index: /trunk/web/addons/toga/search.php
===================================================================
--- /trunk/web/addons/toga/search.php	(revision 140)
+++ /trunk/web/addons/toga/search.php	(revision 141)
@@ -30,4 +30,106 @@
 }
 
+function makeTime( $time ) {
+
+        $days = intval( $time / 86400 );
+        $time = ($days>0) ? $time % ($days * 86400) : $time;
+
+        //printf( "time = %s, days = %s\n", $time, $days );
+
+        $date_str = '';
+        $day_str = '';
+
+        if( $days > 0 ) {
+                if( $days > 1 )
+                        $day_str .= $days . ' days';
+                else
+                        $day_str .= $days . ' day';
+        }
+
+        $hours = intval( $time / 3600 );
+        $time = $hours ? $time % ($hours * 3600) : $time;
+
+        //printf( "time = %s, days = %s, hours = %s\n", $time, $days, $hours );
+
+        if( $hours > 0 ) {
+                $date_str .= $hours . ':';
+                $date_unit = 'hours';
+        }
+
+        $minutes = intval( $time / 60 );
+        $seconds = $minutes ? $time % ($minutes * 60) : $time;
+
+        if( $minutes > 0 ) {
+
+                if( $minutes >= 10 )
+                        $date_str .= $minutes . ':';
+                else
+                        $date_str .= '0' . $minutes . ':';
+
+                $date_unit = (!isset($date_unit)) ? 'minutes' : $date_unit;
+        } else {
+                if($hours > 0 ) {
+                        $date_str .= '00:';
+                        $date_unit = (!isset($date_unit)) ? 'minutes' : $date_unit;
+                }
+        }
+
+
+        $date_unit = (!isset($date_unit)) ? 'seconds' : $date_unit;
+
+        if( $seconds > 0 ) {
+
+                if( $seconds >= 10 )
+                        $date_str .= $seconds . ' ' . $date_unit;
+                else
+                        $date_str .= '0' . $seconds . ' ' . $date_unit;
+
+        } else if ( $hours > 0 or $minutes > 0 )
+
+                $date_str .= '00 ' . $date_unit;
+
+        if( $days > 0) {
+
+                if( $hours > 0 or $minutes > 0 or $seconds > 0 )
+                        $date_str = $day_str . ' - ' . $date_str;
+                else
+                        $date_str = $day_str;
+        }
+
+        return $date_str;
+}
+
+function makeDate( $time ) {
+        return strftime( "%a %d %b %Y %H:%M:%S", $time );
+}
+
+function timeToEpoch( $time ) {
+
+        $time_fields = explode( ':', $time );
+
+        if( count($time_fields) == 3 ) {
+
+                $hours = $time_fields[0];
+                $minutes = $time_fields[1];
+                $seconds = $time_fields[2];
+
+        } else if( count($time_fields) == 2 ) {
+
+                $hours = 0;
+                $minutes = $time_fields[0];
+                $seconds = $time_fields[1];
+
+        } else if( count($time_fields) == 1 ) {
+
+                $hours = 0;
+                $minutes = 0;
+                $seconds = $time_fields[0];
+        }
+
+        $myepoch = intval( $seconds + (intval( $minutes * 60 )) + (intval( $hours * 3600 )) );
+
+        return $myepoch;
+}
+
 function makeSearchPage() {
 	global $clustername, $tpl, $id, $user, $name, $start_from_time, $start_to_time, $queue;
@@ -52,5 +154,31 @@
 		foreach( $search_ids as $foundid ) {
 
-			printf("found job %s\n", $foundid );
+			$job = $tdb->getJobArray( $foundid );
+			$nodes = $tdb->getNodesForJob( $foundid );
+
+			$tpl->newBlock( "node" );
+			$tpl->assign( "id", $job[id] );
+			$tpl->assign( "state", $job[status] );
+			$tpl->assign( "user", $job[owner] );
+			$tpl->assign( "queue", $job[queue] );
+			$tpl->assign( "name", $job[name] );
+			$tpl->assign( "req_cpu", makeTime( TimeToEpoch( $job[requested_time] ) ) );
+			$tpl->assign( "req_memory", $job[requested_memory] );
+
+			$nodes_nr = count( $nodes );
+			$domain = $job[domain];
+			$ppn = (int) $job[ppn] ? $job[ppn] : 1;
+			$cpus = $nodes_nr * $ppn;
+
+			$tpl->assign( "nodes", $nodes_nr );
+			$tpl->assign( "cpus", $cpus );
+
+			$runningtime = intval( $job[stop_timestamp] - $job[start_timestamp] );
+			$tpl->assign( "started", makeDate( $job[start_timestamp] ) );
+			$tpl->assign( "finished", makeDate( $job[stop_timestamp] ) );
+			$tpl->assign( "runningtime", makeTime( $runningtime ) );
+			
+			print_r( $job );
+			print_r( $nodes );
 			//output jobzooi
 
Index: /trunk/web/addons/toga/templates/search.tpl
===================================================================
--- /trunk/web/addons/toga/templates/search.tpl	(revision 140)
+++ /trunk/web/addons/toga/templates/search.tpl	(revision 141)
@@ -1,6 +1,7 @@
 <CENTER>
 </FORM>
+
 <SCRIPT LANGUAGE="javascript" SRC="ts_picker.js"></SCRIPT>
-<SCRIPT TYPE="text/javascript" SRC="libtoga.js"></SCRIPT>
+<SCRIPT LANGUAGE="javascript" SRC="libtoga.js"></SCRIPT>
 <SCRIPT LANGUAGE="javascript">
 
@@ -151,16 +152,9 @@
 
 </TABLE>
-</FORM>
 <BR><BR>
 <!-- START BLOCK : search_results -->
-<SCRIPT TYPE="text/javascript" SRC="libtoga.js"></SCRIPT>
 
 <INPUT TYPE="HIDDEN" NAME="sortby" VALUE="{sortby}">
 <INPUT TYPE="HIDDEN" NAME="sortorder" VALUE="{sortorder}">
-<INPUT TYPE="HIDDEN" NAME="c" VALUE="{clustername}">
-<INPUT TYPE="HIDDEN" NAME="queue" VALUE="{f_queue}">
-<INPUT TYPE="HIDDEN" NAME="state" VALUE="{f_state}">
-<INPUT TYPE="HIDDEN" NAME="user" VALUE="{f_user}">
-<INPUT TYPE="HIDDEN" NAME="id" VALUE="{f_id}">
 <INPUT TYPE="HIDDEN" NAME="filterorder" VALUE="{f_order}">
 
@@ -217,5 +211,10 @@
     <INPUT TYPE="HIDDEN" NAME="start" VALUE="{start}">
     <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"><a href="javascript:show_calendar('document.search_form.period_start_pick', document.search_form.period_start_pick.value);"><img src="cal.gif" width="16" height="16" border="0"></a> to <INPUT TYPE="text" NAME="period_stop_pick" VALUE="{stop}" SIZE=12 ALT="Stop time"><a href="javascript:show_calendar('document.toga_form.period_stop_pick', document.search_form.period_stop_pick.value);"><img src="cal.gif" width="16" height="16" border="0"></a><INPUT TYPE="submit" onClick="setPeriodTimestamps();" VALUE="Refresh graphs">
+    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>
+    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>
+    <INPUT TYPE="submit" onClick="setPeriodTimestamps();" VALUE="Refresh graphs">
    </FONT>
   </TD>
Index: /trunk/web/addons/toga/ts_picker.js
===================================================================
--- /trunk/web/addons/toga/ts_picker.js	(revision 141)
+++ /trunk/web/addons/toga/ts_picker.js	(revision 141)
@@ -0,0 +1,149 @@
+// Title: Timestamp picker
+// Description: See the demo at url
+// URL: http://us.geocities.com/tspicker/
+// Script featured on: http://javascriptkit.com/script/script2/timestamp.shtml
+// Version: 1.0
+// Date: 12-05-2001 (mm-dd-yyyy)
+// Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com>
+// Notes: Permission given to use this script in any kind of applications if
+//    header lines are left unchanged. Feel free to contact the author
+//    for feature requests and/or donations
+//
+// Additional changes for Toga by Ramon Bastiaans:
+// - Time validation
+// - Setup of str_target on load of calendar (if it's empty)
+// - Commit new time when changed (not just when date is clicked)
+
+function show_calendar(str_target, str_datetime) {
+	var arr_months = ["January", "February", "March", "April", "May", "June",
+		"July", "August", "September", "October", "November", "December"];
+	var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
+	var n_weekstart = 1; // day week starts from (normally 0 or 1)
+
+	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
+	var dt_prev_month = new Date(dt_datetime);
+	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
+	var dt_next_month = new Date(dt_datetime);
+	dt_next_month.setMonth(dt_datetime.getMonth()+1);
+	var dt_firstday = new Date(dt_datetime);
+	dt_firstday.setDate(1);
+	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
+	var dt_lastday = new Date(dt_next_month);
+	dt_lastday.setDate(0);
+	
+	// html generation (feel free to tune it for your particular application)
+	// print calendar header
+	var str_buffer = new String (
+		"<html>\n"+
+		"<head>\n"+
+		"	<title>Calendar</title>\n"+
+		"</head>\n"+
+		"<SCRIPT LANGUAGE=\"javascript\" SRC=\"ts_validatetime.js\"></SCRIPT>\n"+
+		"<body bgcolor=\"White\" onLoad=\"validateTime( '"+str_target+ "', '"+str_datetime+"' ); if( window.opener."+str_target+ ".value == '' ) window.opener."+str_target+ ".value='"+dt2dtstr( dt_datetime )+" '+document.cal.time.value;\" onUnload=\"validateTime( '"+str_target+ "', '"+str_datetime+"' ); if( window.opener."+str_target+ ".value == '' ) window.opener."+str_target+ ".value='"+dt2dtstr( dt_datetime )+"'+document.cal.time.value;\">\n"+
+		"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
+		"<tr><td bgcolor=\"#4682B4\">\n"+
+		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
+		"<tr>\n	<td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+
+		str_target+"', '"+ dt2dtstr(dt_prev_month)+"'+document.cal.time.value);\">"+
+		"<img src=\"prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
+		" alt=\"previous month\"></a></td>\n"+
+		"	<td bgcolor=\"#4682B4\" colspan=\"5\">"+
+		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
+		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
+		"	<td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
+		+str_target+"', '"+dt2dtstr(dt_next_month)+"'+document.cal.time.value);\">"+
+		"<img src=\"next.gif\" width=\"16\" height=\"16\" border=\"0\""+
+		" alt=\"next month\"></a></td>\n</tr>\n"
+	);
+
+	var dt_current_day = new Date(dt_firstday);
+	// print weekdays titles
+	str_buffer += "<tr>\n";
+	for (var n=0; n<7; n++)
+		str_buffer += "	<td bgcolor=\"#87CEFA\">"+
+		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
+		week_days[(n_weekstart+n)%7]+"</font></td>\n";
+	// print calendar table
+	str_buffer += "</tr>\n";
+	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
+		dt_current_day.getMonth() == dt_firstday.getMonth()) {
+		// print row heder
+		str_buffer += "<tr>\n";
+		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
+				if (dt_current_day.getDate() == dt_datetime.getDate() &&
+					dt_current_day.getMonth() == dt_datetime.getMonth())
+					// print current date
+					str_buffer += "	<td bgcolor=\"#FFB6C1\" align=\"right\">";
+				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
+					// weekend days
+					str_buffer += "	<td bgcolor=\"#DBEAF5\" align=\"right\">";
+				else
+					// print working days of current month
+					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";
+
+				if (dt_current_day.getMonth() == dt_datetime.getMonth())
+					// print days of current month
+					str_buffer += "<a href=\"javascript:window.opener."+str_target+
+					".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
+					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
+				else 
+					// print days of other months
+					str_buffer += "<a href=\"javascript:window.opener."+str_target+
+					".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
+					"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
+				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
+				dt_current_day.setDate(dt_current_day.getDate()+1);
+		}
+		// print row footer
+		str_buffer += "</tr>\n";
+	}
+	// print calendar footer
+	str_buffer +=
+		"<form name=\"cal\" onsubmit=\"var mf = window.opener."+str_target+".value.split( ' ' );window.opener."+str_target+".value=mf[0]+' '+document.cal.time.value; window.close();\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+
+		"<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+
+		"Time: <input type=\"text\" name=\"time\" value=\""+dt2tmstr(dt_datetime)+
+		"\" size=\"8\" maxlength=\"8\" onChange=\"validateTime('"+str_target+"', '"+str_datetime+"');\"></font></td></tr>\n</form>\n" +
+		"</table>\n" +
+		"</tr>\n</td>\n</table>\n" +
+		"</body>\n" +
+		"</html>\n";
+
+	var vWinCal = window.open("", "Calendar", 
+		"width=200,height=250,status=no,resizable=yes,top=200,left=200");
+	vWinCal.opener = self;
+	var calc_doc = vWinCal.document;
+	calc_doc.write (str_buffer);
+	calc_doc.close();
+}
+// datetime parsing and formatting routimes. modify them if you wish other datetime format
+function str2dt (str_datetime) {
+	var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/;
+	if (!re_date.exec(str_datetime))
+		return alert("Invalid Datetime format: "+ str_datetime);
+	return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
+}
+function dt2dtstr (dt_datetime) {
+	return (new String (
+			dt_datetime.getDate()+"-"+(dt_datetime.getMonth()+1)+"-"+dt_datetime.getFullYear()+" "));
+}
+function dt2tmstr (dt_datetime) {
+
+	if( dt_datetime.getHours() < 10 )
+		var hours = '0' + dt_datetime.getHours();
+	else
+		var hours = dt_datetime.getHours();
+
+	if( dt_datetime.getMinutes() < 10 )
+		var minutes = '0' + dt_datetime.getMinutes();
+	else
+		var minutes = dt_datetime.getMinutes();
+
+	if( dt_datetime.getSeconds() < 10 )
+		var seconds = '0' + dt_datetime.getSeconds();
+	else
+		var seconds = dt_datetime.getSeconds();
+		
+	return (new String (
+			hours+":"+minutes+":"+seconds));
+}
+
Index: /trunk/web/addons/toga/ts_validatetime.js
===================================================================
--- /trunk/web/addons/toga/ts_validatetime.js	(revision 141)
+++ /trunk/web/addons/toga/ts_validatetime.js	(revision 141)
@@ -0,0 +1,116 @@
+function validateTime( str_target, str_datetime ) {
+
+        var time = document.cal.time.value.split( ':' );
+        var invalid = 0;
+	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
+
+        if( time.length <= 1 && invalid == 0 ) {
+
+                document.cal.time.value = dt2tmstr( dt_datetime );
+                alert( 'Invalid time specified (needs to be HH:MM:SS), reset to current time.' );
+                invalid = 1;
+
+        } else if( time.length == 2 ) {
+
+                if( time[1] != '' ) {
+
+                        document.cal.time.value = document.cal.time.value + ':00';
+
+                } else if( invalid == 0 ) {
+
+                        document.cal.time.value = dt2tmstr( dt_datetime );
+                        alert( 'Invalid time specified (needs to be HH:MM:SS), reset to current time.' );
+                        invalid = 1;
+                }
+
+        } else if( time.length == 3 ) {
+
+                newtime = '';
+
+                for( var i=0; i<time.length; i++) {
+
+                        time_field = time[i];
+			if( i == 0 )
+				var sep = '';
+			else
+				var sep = ':';
+				
+
+                        if( time_field.length == 0 && invalid == 0 ) {
+
+                                document.cal.time.value = dt2tmstr( dt_datetime );
+                                alert( 'Invalid time specified (needs to be HH:MM:SS), reset to current time.' );
+                                invalid = 1;
+
+                        } else if( time_field.length == 1 ) {
+
+                                newtime = newtime + sep + '0' + time_field;
+                        } else {
+                                newtime = newtime + sep + time_field;
+                        }
+
+                        for( var l=0; l<time_field.length; l++ ) {
+                                var mydigit = time_field.charAt(l)
+
+                                if(( mydigit < "0" || mydigit > "9" ) && invalid == 0 ) {
+
+                                        document.cal.time.value = dt2tmstr( dt_datetime );
+                                        alert( 'Invalid time specified (needs to be HH:MM:SS), reset to current time.' );
+                                        invalid = 1;
+
+                                }
+                        }
+                }
+
+                if( invalid == 0 ) {
+
+                        document.cal.time.value = newtime;
+                }
+
+        }
+
+        if( invalid == 0 ) {
+
+		target = str_target.split('.');
+		frm = target[1];
+		elm = target[2];
+                var mf = window.opener.document.forms[frm].elements[elm].value.split( ' ' );
+
+		if( mf[0] != '' )
+			window.opener.document.forms[frm].elements[elm].value=mf[0]+' '+document.cal.time.value;
+		else
+			window.opener.document.forms[frm].elements[elm].value=dt2dtstr( new Date() ) +document.cal.time.value;
+        }
+}
+
+// datetime parsing and formatting routimes. modify them if you wish other datetime format
+function str2dt (str_datetime) {
+        var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/;
+        if (!re_date.exec(str_datetime))
+                return alert("Invalid Datetime format: "+ str_datetime);
+        return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
+}
+function dt2dtstr (dt_datetime) {
+        return (new String (
+                        dt_datetime.getDate()+"-"+(dt_datetime.getMonth()+1)+"-"+dt_datetime.getFullYear()+" "));
+}
+function dt2tmstr (dt_datetime) {
+
+        if( dt_datetime.getHours() < 10 )
+                var hours = '0' + dt_datetime.getHours();
+        else
+                var hours = dt_datetime.getHours();
+
+        if( dt_datetime.getMinutes() < 10 )
+                var minutes = '0' + dt_datetime.getMinutes();
+        else
+                var minutes = dt_datetime.getMinutes();
+
+        if( dt_datetime.getSeconds() < 10 )
+                var seconds = '0' + dt_datetime.getSeconds();
+        else
+                var seconds = dt_datetime.getSeconds();
+
+        return (new String (
+                        hours+":"+minutes+":"+seconds));
+}
