	var youdatext = new Class({
		initialize : function(elem1, dVal) {
			this.elem1 = $(elem1);
			if ($type(this.elem1)!="element") {return;}
			this.dVal = this.elem1.value;
			if (dVal) {this.dVal = dVal}
			this.elem1.addEvent("focus", this.focused.bind(this));
			this.elem1.addEvent("blur", this.blured.bind(this));
		},
		
		focused : function() {
			if (new String(this.elem1.value).trim() == this.dVal) {
				this.elem1.value="";
			} else {
				this.elem1.select();
			}
		},
		
		blured : function() {
			if (new String(this.elem1.value).trim() == "") {
				this.elem1.value = this.dVal;
			}
		}
	});

	var youdapass = new Class({
		initialize:function(elem1) {
			this.elem1 = $(elem1);
			if ($type(this.elem1)!="element") {return;}
			this.elem2 = new Element("input", {
				"type":"password",
				"styles": {
					"display":"none"
				}
			});
			this.elem1.addEvent("focus", this.fromto.bind(this) );
			this.elem2.addEvent("blur", this.tofrom.bind(this) )
			this.elem2.addEvent("focus", this.justfoo.bindWithEvent(this) );
			
			this.elem2.injectBefore(this.elem1);
			this.elem2.setProperty("class",this.elem1.getProperty("class"));
			this.fname1 = this.elem1.getProperty("name");
			this.fname2 = "xxx_"+this.fname1;
		},
		
		fromto : function() {
				this.elem1.setStyle("display", "none");
				this.elem1.setProperty("name", this.fname2);
				this.elem2.setProperty("name", this.fname1);
				this.elem2.setStyle("display", "inline");
				this.elem2.focus();
		},
		
		tofrom : function() {
			if ( new String(this.elem2.value).trim() == "" ) {
				this.elem1.setStyle("display","inline");
				this.elem2.setStyle("display","none");
				this.elem1.setProperty("name", this.fname1);
				this.elem2.setProperty("name", this.fname2);
			}
		},
		
		justfoo : function(e) {
			this.elem2.select();
		}
	});

window.addEvent("domready", function() {
	
	$dvals = $$(".dValue");
	for (x in $dvals) {
		new youdatext($dvals[x]);
	}
	new youdapass($$(".dValuePass")[0]);
	
});
