Sinfo_TextField = function Sinfo_TextField(par_pId, par_changeFunction, par_oClientObjManager,
		p_explainText)
{
   var oHtmlInput = document.getElementById(par_pId);
   
   this.extend = Sinfo_Application; 
   this.extend(oHtmlInput, par_oClientObjManager);
   delete this.extend;
   
   this.getName = function()
   {
      return oHtmlInput.getAttribute("name");
   }
   
 /**
    * This attribute return the type of the object.
    * @property 
    * @type String
    */  
   this.type = "Sinfo_TextField";
      
      
   var changeFunction = par_changeFunction;

   /**
    * Invoked on the object to trigger the change function passed as parameter
    * upon object creation (e.g. used by the date object)
    */
   this.callChangeFunction = function()
   {
	   changeFunction();
   }
   
   var pId = par_pId;

   var className;
   var classNameStyled;
   var indexStyled;
   
   // oHtmlInput.className does not contain inputStandby! 
   className = oHtmlInput.className;
   classNameStyled = className + " inputDateExplainStyle"; 
   
   var value;
   
   if (p_explainText != undefined && p_explainText != '')
   {
	   if (oHtmlInput.value == '')
	   {	   
		   oHtmlInput.value = p_explainText;
		   oHtmlInput.className = classNameStyled;
	   }
	   
	   bEvent = par_oClientObjManager.Util.addEvent(oHtmlInput, 'focus', 
			   function()
			   {
		   		   /*here we set normal style if we got a focus for typing*/
		   		   if (p_explainText != undefined && p_explainText != '' && p_explainText == oHtmlInput.value)
		   		   {
		   			  oHtmlInput.value = '';
		   			  oHtmlInput.className = className;
		   		   }
			   }
			   ,true );
	   
	   par_oClientObjManager.Util.addEvent(oHtmlInput, 'blur',
			   function () {
		   			/*the explain text may be not only '' but also undefined*/
					if (p_explainText != undefined && p_explainText != '' && oHtmlInput.value == '') 
					{
						oHtmlInput.value = p_explainText;
						oHtmlInput.className = classNameStyled;
					}
					else
					{
						oHtmlInput.className = className;
					}
				}
	   			, true );
   }		   
   
    /*
   var maxchars = 999;
  
   var checkMaxChars = function()
   {
      if (oHtmlButton.value.length > maxchars)
      {
         alert('Max ' + maxchars + ' chars');
      }
      oHtmlButton.value = oHtmlButton.value.substring(0,maxchars); 
   }
   var bEvent;
   var bEvent2;
   //bEvent = par_oClientObjManager.addEvent(oHtmlButton, 'keyup', checkMaxChars,true )
   //bEvent2 = par_oClientObjManager.addEvent(oHtmlButton, 'blur', checkMaxChars,true )

   //alert(bEvent);
   
   this.setMaxChars = function(par_maxchars)
   {
      maxchars = par_maxchars;
   }
   */

  	/**
	 * Submit on ENTER: executes the function passed with the argument par_changeFunction
	 * when the user presses ENTER while the textfield is focused.
	 * 
	 * Tested with IE6-8, FF2-3
	 * 
	 * @param event The event passed automatically by the event caller
	 * @author edandrea
	 * @author dmontesin
	 * @created may 6, 2009
	 */
	function submitOnEnterFunction(event)
	{
		if (event)
		{
			// Firefox does not access window.event
			if (13 == event.keyCode)
			{
				par_changeFunction();
			}
		} else
		{
			// IE6 does not pass the parameter
			if (13 == window.event.keycode)
			{
				par_changeFunction();
			}
		}
	}	
	par_oClientObjManager.Util.addEvent(oHtmlInput, 'keyup', submitOnEnterFunction, true);

//	onchange is disabled as it does not seem to be used and it triggers the search
//  when switching focus from the textfield	
//	var bEvent;
//	bEvent = par_oClientObjManager.Util.addEvent(oHtmlInput, 'change', changeFunction,true )

	/**
	 * Removes events upon object destruction
	 */
	this.destroy = function ()
	{
		par_oClientObjManager.Util.removeEvent(oHtmlInput, 'keyup', par_changeFunction);
		//var removeResult = par_oClientObjManager.Util.removeEvent(oHtmlInput, 'change', changeFunction);
	}

   this.getId = function()
   {
      return pId;
   }
   this.getAttrs = function()
   {
      var ret = new Array();
      //changeFunction();
      
      value = '';
      if(p_explainText == undefined || oHtmlInput.value != p_explainText)
      {
    	  value = oHtmlInput.value;
      }
      
      ret['text'] = value;
      return ret; 
   }
   this.setText = function(par_Value)
   {
      value = par_Value;
   }
   this.getHtmlObject = function()
   {
      return oHtmlInput;
   }
   
   this.getStatus = function (){return oHtmlInput.Status;}
       
}