/*
 * ToggleFormText
 *
 * Author:   Grzegorz Frydrychowicz
 * E-mail:   grzegorz.frydrychowicz@gmail.com
 * Date:     16-11-2007
*/

$(document).ready(function(){

  if (typeof disableFormText == "undefined") disableFormText = false; 
  
  if (! disableFormText) {
    $("input:text, textarea, input:password").focus(function(){
        if(this.value == this.title) {
            this.value = '';
            $(this).removeClass('input-tip')
        }
    });
    $("input:text, textarea, input:password").blur(function(){
      var v = $(this).val();
      if (!(v) || v == $(this).attr('title')) {
        $(this).val($(this).attr('title')).addClass('input-tip');
      } else {
        $(this).removeClass('input-tip');
      }
    }).blur();
    $("input:image, input:button, input:submit").click(function(){
        $(this.form.elements).each(function(){
            if(this.type =='text' || this.type =='textarea' || this.type =='password' ){
                if(this.value == this.title && this.title != ''){
                    this.value='';
                }
            }
        });
    });
  }
});
