
TAOKE.namespace("TAOKE.UI");

TAOKE.UI.InputInnerTip = Class.create();

TAOKE.UI.InputInnerTip.prototype = {
    initialize : function(textbox, tip, organiger) {
			this.field = $(textbox);
			this.tip = tip;
			if (organiger != 'undefined') {
				this.organiger = $(organiger);
			}
			this.tipClassName = 'input_inner_tip';
			if (!this.field) {
				return;
			}
			
			if (this.organiger) {
				this.organiger.observe("focus", this.runFocus.bindAsEventListener(this));
				this.organiger.observe("blur", this.runBlur.bindAsEventListener(this));
			} else {
				this.field.observe("focus", this.runFocus.bindAsEventListener(this));
				this.field.observe("blur", this.runBlur.bindAsEventListener(this));
			}
	 },
	 
	 runFocus : function() {
	 		if (this.field.value == this.tip) {
	 			this.field.value = '';
	 		} 
			this.field.removeClassName(this.tipClassName);
	 },
	 
	 runBlur : function() {
	 		if (this.field.value == '') {
				this.field.addClassName(this.tipClassName);
	 			this.field.value = this.tip;
	 		}
	 }
};

TAOKE.UI.SelectTip = Class.create();

TAOKE.UI.SelectTip.prototype = {
    initialize : function(textbox, compareValue) {
			this.field = $(textbox);
			this.tipClassName = 'select_tip';
			this.compareValue = compareValue;
			if (!this.field) {
				return;
			}
			if (!this.compareValue) {
				this.compareValue = '';
			}
			
			this.field.observe("focus", this.runFocus.bindAsEventListener(this));
			this.field.observe("blur", this.runBlur.bindAsEventListener(this));
	 },
	 
	 runFocus : function() {
			this.field.removeClassName(this.tipClassName);
	 },
	 
	 runBlur : function() {
	 		if (this.field.value == this.compareValue) {
				this.field.addClassName(this.tipClassName);
	 		}
	 }
};