/* ütf-8 marker */
/**
 * Input Hint
 *
 * @package     widgets
 * @author      Dieter Raber <raber@h2a.lu>
 * @author      Claudia Kosny <kosny@h2a.lu>
 * @copyright   Dieter Raber, Claudia Kosny 26.07.2007 11:09:50
 *
 * $Id: inputHint.js 9 2007-07-26 09:15:38Z dieter $
 */
function inputHint(cwp) {
  cwp = cwp || new Object();
  var wp = {
    hintColor  : cwp.hintColor  || '#787878',
    valueColor : cwp.valueColor || '#000000',
    hintClass  : cwp.hintClass  || 'hint'
  };
  function enableHintFields() {
    var allInputs = $('input.' + wp.hintClass);
    allInputs.each(function() {
      if(!this.value || this.value == this.alt) {
        this.value = this.alt;
        this.style.color = wp.hintColor;
      }
    })
    .focus(function() {
      if(this.value == this.alt) {
        this.value = '';
        this.style.color = wp.valueColor;
      }
    })
    .blur(function() {
      if(this.value == this.alt || !this.value) {
        this.value = this.alt;
        this.style.color = wp.hintColor;
      }
    })
    .parents('form').submit(function() {
      $('input.' + wp.hintClass, this).each(function() {
        if(this.value == this.alt) {
          this.value = '';
        }
      })
    });
  }
  enableHintFields();
  return true;
}
