/**
 * @author Administrator
 */
var Inputfocus = new Class ({	
	initialize: function(initClass) {
		this.initClass = initClass;
		$$('input.'+initClass).each( function(el) {
			el.checkInputFocus = function() {
				var text = (this.get('rel')=='')?this.get('rel'):this.get('alt');
				var value = this.get('value');
				if(value==text) {
					value = '';
				} else if(value=='') {
					value = text;
				}
				this.set('value', value);
			}
			el.checkInputSubmit = function() {
				var text = this.get('rel');
				var value = this.get('value');
				if(value==text) {
					value = '';
				}
				this.set('value', value);
			}
			el.addEvents({'focus': function() {
				this.checkInputFocus();
			}, blur: function() {
				this.checkInputFocus();
			}});
			el.checkInputFocus();
			var form = el.getParent('form');
			if(form) {
				form.addEvent('submit', function() {
					el.checkInputSubmit();
				}.bind(el));
			}
		});
	}
});
