/*
 * ToggleFormText
 *
 * Author:   Grzegorz Frydrychowicz
 * E-mail:   grzegorz.frydrychowicz@gmail.com
 * Date:     16-11-2007
*/

$(document).ready(function(){
    $("input.toogletext:text, textarea.toogletext, input.toogletext:password").each(function(){
        if(this.value == ""){
            this.value = this.title;
            $(this).addClass("toggleformtext");
        }
    });
    $("input.toogletext:text, textarea.toogletext, input.toogletext:password").focus(function(){
    
				var vv = new String(this.value);
				var tt = new String(this.title);

				while (vv.indexOf(String.fromCharCode(10),0) > 0){
					vv = vv.replace(String.fromCharCode(10),"")
				}
				while (vv.indexOf(String.fromCharCode(13),0) > 0){
					vv = vv.replace(String.fromCharCode(13),"")
				}
				while (tt.indexOf(String.fromCharCode(10),0) > 0){
					tt = tt.replace(String.fromCharCode(10),"")
				}
				while (tt.indexOf(String.fromCharCode(13),0) > 0){
					tt = tt.replace(String.fromCharCode(13),"")
				}

        if(vv.toString() == tt.toString()){
            this.value = "";
            this.className = "";
        }
    });
    $("input.toogletext:text, textarea.toogletext, input.toogletext:password").blur(function(){
        if(this.value == "" ){
            this.value = this.title;
            $(this).addClass("toggleformtext");
       }
    });
});