Index: /trunk/docs/revision_history.txt
===================================================================
--- /trunk/docs/revision_history.txt	(revision 234)
+++ /trunk/docs/revision_history.txt	(revision 235)
@@ -21,6 +21,6 @@
 
 remove interdependencies:
-    - App() is the only dependency for other classes. It includes Utilities.inc.php silently.
-    - Update libs requiring external files, such as html templates and email templates, classes now self-contained.
+    - App() is the primary dependency for other classes. It includes Utilities.inc.php silently.
+    - Updated classes requiring external files, such as html templates and email templates, classes now self-contained.
 
 Things with modified interfaces:
Index: /trunk/lib/ImageThumb.inc.php
===================================================================
--- /trunk/lib/ImageThumb.inc.php	(revision 234)
+++ /trunk/lib/ImageThumb.inc.php	(revision 235)
@@ -156,5 +156,7 @@
      *
      * @access  public
-     * @param   array $spec The specifications for a size of output image.
+     * @param   array   $spec   The specifications for a size of output image.
+     * @param   int     $index  The position of the specification in the spec array
+     *                          Use to overwrite existing spev array values.
      */
     function setSpec($spec, $index=null)
Index: /trunk/lib/Lock.inc.php
===================================================================
--- /trunk/lib/Lock.inc.php	(revision 234)
+++ /trunk/lib/Lock.inc.php	(revision 235)
@@ -377,5 +377,5 @@
         ?></p>
 
-        <?php if ($this->getSecondsElapsed() > $this->getParam('timeout')) { ?>
+        <?php if ($this->getSecondsElapsed() >= $this->getParam('timeout')) { ?>
         <p><?php printf(_("You can forcibly unlock the record if you believe the editing session has expired. You might want to confirm with %s before doing this."), $this->getEditor()) ?></p>
         <input type="submit" name="unlock" value="<?php echo _("Unlock"); ?>" />
@@ -416,5 +416,5 @@
     function getSecondsElapsed()
     {
-        if (isset($this->data['lock_datetime']) && $this->data['lock_datetime'] < time()) {
+        if (isset($this->data['lock_datetime']) && strtotime($this->data['lock_datetime']) < time()) {
             return time() - strtotime($this->data['lock_datetime']);
         } else {
Index: /trunk/lib/Utilities.inc.php
===================================================================
--- /trunk/lib/Utilities.inc.php	(revision 234)
+++ /trunk/lib/Utilities.inc.php	(revision 235)
@@ -150,30 +150,30 @@
 function getTextColor($text, $method=1)
 {
-    $r = substr(md5($text), 0, 1);
-    $g = substr(md5($text), 1, 1);
-    $b = substr(md5($text), 2, 1);
+    $hash = md5($text);
+    $rgb = array(
+        substr($hash, 0, 1),
+        substr($hash, 1, 1),
+        substr($hash, 2, 1),
+        substr($hash, 3, 1),
+        substr($hash, 4, 1),
+        substr($hash, 5, 1),
+    );
 
     switch ($method) {
-    case 2 :
-        if (hexdec($r) > hexdec('c')) {
-            $r = dechex(hexdec('f') - hexdec($r));
-        }
-        if (hexdec($g) > hexdec('c')) {
-            $g = dechex(hexdec('f') - hexdec($g));
-        }
-        if (hexdec($b) > hexdec('c')) {
-            $b = dechex(hexdec('f') - hexdec($b));
-        }
-        break;
-
     case 1 :
     default :
-        $r = dechex(round(hexdec($r) * .8));
-        $g = dechex(round(hexdec($g) * .8));
-        $b = dechex(round(hexdec($b) * .6));
+        // Reduce all hex values slighly to avoid all white.
+        array_walk($rgb, create_function('&$v', '$v = dechex(round(hexdec($v) * 0.87));'));
         break;
-    }
-
-    return $r . $r . $g . $g . $b . $b;
+    case 2 :
+        foreach ($rgb as $i => $v) {
+            if (hexdec($v) > hexdec('c')) {
+                $rgb[$i] = dechex(hexdec('f') - hexdec($v));
+            }
+        }
+        break;
+    }
+
+    return join('', $rgb);
 }
 
@@ -392,5 +392,6 @@
  * @return array              URL with array elements as URL key=value arguments.
  */
-function urlEncodeArray($data, $prefix='', $_return=true) {
+function urlEncodeArray($data, $prefix='', $_return=true)
+{
 
     // Data is stored in static variable.
@@ -428,5 +429,6 @@
  * @return string url         A string ready to append to a url.
  */
-function urlEncodeArrayToString($data, $prefix='') {
+function urlEncodeArrayToString($data, $prefix='')
+{
 
     $array_args = urlEncodeArray($data, $prefix);
@@ -708,5 +710,6 @@
  * will see data before the page is finished processing.
  */
-function flushBuffer() {
+function flushBuffer()
+{
     echo str_repeat('          ', 205);
     flush();
Index: /trunk/services/templates/admin_form.ihtml
===================================================================
--- /trunk/services/templates/admin_form.ihtml	(revision 234)
+++ /trunk/services/templates/admin_form.ihtml	(revision 235)
@@ -13,5 +13,5 @@
     </tr>
     <tr>
-        <td class="sc-right"><label for="username"<?php $fv->err('username', ' class="error"') ?>><?php echo _("Username"); ?></label></td>
+        <td class="sc-right"><label for="username" class="<?php $fv->err('username'); ?>"><?php echo _("Username"); ?></label></td>
         <td>
             <input type="text" class="sc-small" size="50" name="username" value="<?php echo oTxt($frm['username']); ?>" />
@@ -19,5 +19,5 @@
     </tr>
     <tr>
-        <td class="sc-right"><label for="userpass"<?php $fv->err('userpass', ' class="error"') ?>><?php echo _("Password"); ?></label></td>
+        <td class="sc-right"><label for="userpass" class="<?php $fv->err('userpass'); ?>"><?php echo _("Password"); ?></label></td>
         <td>
             <input type="password" class="sc-small" size="50" name="userpass" value="<?php echo oTxt($frm['userpass']); ?>" />
@@ -25,5 +25,5 @@
     </tr>
     <tr>
-        <td class="sc-right"><label for="first_name"<?php $fv->err('first_name', ' class="error"') ?>><?php echo _("First name"); ?></label></td>
+        <td class="sc-right"><label for="first_name" class="<?php $fv->err('first_name'); ?>"><?php echo _("First name"); ?></label></td>
         <td>
             <input type="text" class="sc-small" size="50" name="first_name" value="<?php echo oTxt($frm['first_name']); ?>" />
@@ -31,5 +31,5 @@
     </tr>
     <tr>
-        <td class="sc-right"><label for="last_name"<?php $fv->err('last_name', ' class="error"') ?>><?php echo _("Last name"); ?></label></td>
+        <td class="sc-right"><label for="last_name" class="<?php $fv->err('last_name'); ?>"><?php echo _("Last name"); ?></label></td>
         <td>
             <input type="text" class="sc-small" size="50" name="last_name" value="<?php echo oTxt($frm['last_name']); ?>" />
@@ -37,5 +37,5 @@
     </tr>
     <tr>
-        <td class="sc-right"><label for="email"<?php $fv->err('email', ' class="error"') ?>><?php echo _("Email"); ?></label></td>
+        <td class="sc-right"><label for="email" class="<?php $fv->err('email'); ?>"><?php echo _("Email"); ?></label></td>
         <td>
             <input type="text" class="sc-medium" size="50" name="email" value="<?php echo oTxt($frm['email']); ?>" />
@@ -43,5 +43,5 @@
     </tr>
     <tr>
-        <td class="sc-right"><label for="user_type"<?php $fv->err('user_type', ' class="error"') ?>><?php echo _("User type"); ?></label></td>
+        <td class="sc-right"><label for="user_type" class="<?php $fv->err('user_type'); ?>"><?php echo _("User type"); ?></label></td>
         <td>
             <select name="user_type" class="sc-small">
Index: /trunk/services/templates/password.ihtml
===================================================================
--- /trunk/services/templates/password.ihtml	(revision 234)
+++ /trunk/services/templates/password.ihtml	(revision 235)
@@ -6,5 +6,5 @@
 <table>
     <tr>
-        <td class="sc-right"><label for="oldpassword"<?php $fv->err('oldpassword', ' class="error"') ?>><?php echo _("Old password"); ?></label></td>
+        <td class="sc-right"><label for="oldpassword" class="<?php $fv->err('oldpassword'); ?>"><?php echo _("Old password"); ?></label></td>
         <td>
             <input type="password" class="sc-medium" size="50" name="oldpassword" />
@@ -12,5 +12,5 @@
     </tr>
     <tr>
-        <td class="sc-right"><label for="newpassword"<?php $fv->err('newpassword', ' class="error"') ?>><?php echo _("New password"); ?></label></td>
+        <td class="sc-right"><label for="newpassword" class="<?php $fv->err('newpassword'); ?>"><?php echo _("New password"); ?></label></td>
         <td>
             <input type="password" class="sc-medium" size="50" name="newpassword" />
@@ -18,5 +18,5 @@
     </tr>
     <tr>
-        <td class="sc-right"><label for="newpassword2"<?php $fv->err('newpassword2', ' class="error"') ?>><?php echo _("New password again"); ?></label></td>
+        <td class="sc-right"><label for="newpassword2" class="<?php $fv->err('newpassword2'); ?>"><?php echo _("New password again"); ?></label></td>
         <td>
             <input type="password" class="sc-medium" size="50" name="newpassword2" />
