function textbox(){

	this.dataset= new dataset()
	this._events=['click()','keyPress(e)','keyDown(e)', 'keyUp(e)','change()','blur()'];

	this._init =function(){
		this.lbl = $(this.id+'_lbl');
		this.txt = $(this.id+'_txt');
		if(this.txt)if(this.txt.options)this.options=this.txt.options
	}	
	this._init();

	this.value = function(newText){ 
		switch (this.type.toLowerCase()){
		case 'checkbox':
			if (newText==undefined) return this.txt.checked; 
			this.txt.checked= eval(newText) ;
			break;
		case 'textarea':
			if (newText==undefined) return (this.example && this.txt.value==this.example) ?'':this.txt.value; 
			this.txt.value= newText ;
			this._onblur();
			break;
		default:
			if (newText==undefined) return (this.example && this.txt.value==this.example) ?'':this.txt.value; 
			this.txt.value= newText ;
			this._onblur();
			break;
		}
		
	} ;	
	this.text= function(newText){
		if(this.type.toLowerCase()!=='select'){
			return this.value(newText);	
		}else{
			if (newText==undefined) return this.options[this.selectedIndex()].text; 			
			for (var i = 0; i < this.txt.options.length; i++){
			 if(this.txt.options[i].text==newText){this.txt.selectedIndex= i; return }
			} 
					
		}
	}
	
	this.selectedIndex= function(newIndex){
		if (newIndex==undefined) return this.txt.selectedIndex; 
		this.txt.selectedIndex= newIndex ;	
	}
	
	this.resize	  = function(){ 
		var reqOffset = this.required ? (browser.msie?9:6):0;
		var ddOffset= this.dropdown ? 14:0;
		var labelWidth=0;
		
		if(!this.captionTop) labelWidth = (this.captionWidth) ? parseInt(this.captionWidth) : this.lbl.offsetWidth 
		if(this.width())this.txt.style.width = this.width() - labelWidth- this.txt.style.marginLeft.val() -  this.elem.style.paddingLeft.val() - this.elem.style.paddingRight.val() - ddOffset - reqOffset;
		this.txt.parentNode.style.width= this.txt.style.width.val() + ddOffset+this.txt.style.marginLeft.val();
		if(this.type=='textarea')this.txt.style.height = this.height() - (this.captionTop?this.lbl.offsetHeight:0)
		
	};
	this._onblur = function(){
		if(!this.example) return
		if(this.txt.value=='')this.txt.value =this.example
	}
	this._onfocus = function(){
		if(!this.example) return
		if(this.txt.value==this.example)this.txt.value=''
	}
	this.focus= function(){
		this.txt.focus()
	}
	
	this._checkDropdown = function(thisCtl)		{
		if(thisCtl==undefined) thisCtl = this;

		if(thisCtl.dropdown){
			
			thisCtl.dd=eval(thisCtl.frameDot+thisCtl.dropdown);

			if(!thisCtl.dd) return;
			if(thisCtl.dd.edt) {
				if(thisCtl.dd.edt!==thisCtl.txt) thisCtl.dd.dropdown(false,false);
			}
			if(!thisCtl.dd.attach) thisCtl.dd.control=dropdown;thisCtl.dd.control();
			thisCtl.dd.attach(thisCtl.txt,thisCtl.dataset)
		}
	}
	this.refreshData = function(){
		
		srv = new clsAjaxCall(this.clasa+'.cls',0, 'refreshData()')	
		srv.setVar('clsName', this.clasa);
		srv.setVar('controlId', this.id);		
	
		srv.runAJAX(); 
		aData = eval(srv.response);
		
		this.txt.innerHTML = '';
		this.txt.options[0] = new Option('','');
		
		for (var i = 0; i < aData.length; i++){
		 this.txt.options[i+1] = new Option(aData[i][1],aData[i][0]);

		} 
//		this.txt.innerHTML = srv.response;
	
	}
}

function checkInputDate(input){
	if(input.value=='') return true;
	
	var d=cDate(input.value);	
	if(!d){
		alert('Invalid date!');
		setTimeout('$("'+input.id+'").focus();',10);
		return false
	}
	input.value=d;
	return true
}