/**
 * $Id: AjaxInput.js,v 1.1.2.3 2006/10/12 10:06:59 cschmidt Exp $
 */
 
 
 function AjaxInput(objInputField) {
 		this.objInputField = objInputField;
 		
 		this.objInputField.sComponent = null;
 		this.objInputField.sCheckMethod = null;
 		
 		this.setComponent = function (sComponent) {
 			this.objInputField.sComponent = sComponent;
 		}
 		
 		this.setCheckMethod = function (sCheckMethod) {
 			this.objInputField.sCheckMethod = sCheckMethod;
 		}
 		
 		/** wrapper from ajax-from */	
 		this.checkField = function () {
	 		this.objInputField.checkField();
 		}
 		/** reading data from ajax*/
		this.objInputField.checkField = function () {
			// open a request
			var moxMessage = new MoxMessage(this.sComponent, this.sCheckMethod + "(fdID)");
			moxMessage.addData("fdID",this.value);
			var moxData = MoxServer.executeData(moxMessage);
			if(moxData!=null) {
				alert("User-ID '"+this.value+"' wurde bereits vergeben!\n\nKontakt: '"+moxData.getData("Knd_Vorname") +" " + moxData.getData("Knd_Name")+"'\nEmail: " + moxData.getData("Knd_EMail"));
				this.value="";
			}
		}
		
		/** onFocus -> save the first value */
		this.objInputField.onfocus = function () {
		   if(this.FIRST_VALUE==null)
		      this.FIRST_VALUE = this.value;
		   
		}
		
		/** onBlur -> start checkfunction */
		objInputField.onblur = function () {
		   if(this.FIRST_VALUE!=this.value)
		      this.checkField();
		}
 }
 
 
