var JadeObjects  = {
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	_default_properties: function(object){
		object.x=null;
		object.y=null;
		object.pos_method=null;
		object.width=null;
		object.height=null;
		object.parent=document.getElementById('body');
		object.lng_pos=0;
	},
	_default_functions: function(object){
		object.Position = function (x,y,method){

			if(typeof(method)=="undefined"){ method='absolute'; }
			this.pos_method=method;
			this.x=x;
			this.y=y;
			
			this.style.left = Jade.Objects._set_size(this.x);
			this.style.top = Jade.Objects._set_size(this.y);
			
			switch(this.lng_pos){
				case 1:
					this.lng_pos=2;
					break;
				case 2:
					$.Lang.Reposition(this);
					break;
			}
		}
		object.Size = function(width,height){
			this.width=width;
			this.height=height;
			if(this.width!=null) { this.style.width = Jade.Objects._set_size(this.width); }
			if(this.height!=null) { this.style.height = Jade.Objects._set_size(this.height); }
			if(typeof(this.onresize)!="undefined" && typeof(this.onresize)!="object") { this.onresize(); }
		}
		object.Location = function(x,y,width,height,method){
			this.Position(x,y,method);
			this.Size(width,height);
		}
		object.SetStyle = function(className){
			if(typeof(this._className)=="undefined") this._className = this.className;
			this.className = this._className+' '+className;
			this._subclassName = className;
		}
		object.ClearStyle=function(){
			if(typeof(this._className)!="undefined"){ this.className = this._className; }
		}
		object.SetVisible=function(value){
			if(value){ $.FX.Show(this); }
			else{ $.FX.Hide(this); }
		}		
		object.Add = function(parent){
			try{
				this.style.position=(this.pos_method==null)?'absolute':this.pos_method;
			}catch(e){}
			
			this.style.left = Jade.Objects._set_size(this.x);
			this.style.top = Jade.Objects._set_size(this.y);

			if(this.width!=null) { this.style.width = Jade.Objects._set_size(this.width); }
			if(this.height!=null) { this.style.height = Jade.Objects._set_size(this.height); }
			if(typeof(parent)!="undefined" && parent!=null) {
				this.parent = parent; 
				if(/container/.test(parent.className)) { parent.childs.push(this); }
			}
			
			this.parent.appendChild(this);
			if(typeof(this.onadd)!="undefined" && typeof(this.onadd)!="object") { this.onadd(); }
			
			$.Lang.Reposition(this);
		}
	},
	_set_size: function(value) {
		if(typeof(value) == "number" )	{ return value + 'px';	}
		else {	return value;	}
	},
	_create: function(tag){
		if(typeof(tag)=="undefined") { tag='div'; }
		var object = document.createElement(tag);
		Jade.Objects._default_properties(object);
		Jade.Objects._default_functions(object);
		return object;
	},
	_create_spare: function(parent,className){
		var object = document.createElement('div');
		object.className = className;
		//object.style.zIndex = '90';
		object.parent = parent;
		object.Size = function(width,height){
			this.style.width=Jade.Objects._set_size(width);
			this.style.height=Jade.Objects._set_size(height);
		}
		parent.appendChild(object);
		return object;
	},
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	Add:function(type, position, parent, constructor){
		var control={};
		switch(type){
			case 'container':
				control=$.Objects.Container(constructor);
				//control.SetStyle('transparent');
				break;
			case 'text': case 'label':
				control=$.Objects.Text(constructor);
				break;
			case 'link':
				control=$.Objects.Link(constructor.text);
				control.SetHref(constructor.href);
				break;
			case 'combo': case 'combobox': case 'select':
				control=$.Objects.ComboBox(constructor);
				break;
			case 'button':
				control=$.Objects.Button(constructor);
				break;
			case 'button_icon':
				control=$.Objects.ButtonIcon(constructor.text, constructor.icon);
				break;
			case 'searchemployee':
				control=$.Objects.SearchEmployee(constructor);
				break;
			case 'textbox':
				control=$.Objects.TextBox(constructor);
				break;
			case 'option':
				control=$.Objects.Option(constructor);
				break;
			case 'container':
				control=$.Objects.Container(constructor);
				break;
			case 'grid':
				var columns=$.Grids.ColumnModel(constructor);
				for(var i=0, iLen=constructor.columns.length; i<iLen; i++){
					switch(constructor.columns[i].type){
						case 'simple': 
							column=$.Grids.SimpleColumn(constructor.columns[i]);
							break;
						case 'text':
							column=$.Grids.TextColumn(constructor.columns[i]);
							break;
						case 'button':
							column=$.Grids.ButtonColumn(constructor.columns[i]);
							break;
						case 'hour':
							column=$.Grids.HourColumn(constructor.columns[i]);
							break;
						case 'combo':
							column=$.Grids.ComboColumn(constructor.columns[i]);
							break;
						case 'hide':
							column=$.Grids.HideColumn(constructor.columns[i]);
							break;
					}
					columns.Add(column);
				}
				control=$.Grids.Grid(columns);
				break;
		}
		control.Location(position[0], position[1], position[2], position[3]);
		if(parent!=null){ control.Add(parent); }
		return control;
	},
	Form: function(){
		var object = document.createElement('form');
		object.Add = function(parent) {
			if(typeof(parent)=="undefined") { parent=document.getElementById('body'); }
			this.parent=parent;
			this.parent.appendChild(this);
		}
		object.Send=function(){ this.submit(); }
		object.Clear=function(){ 
			for(var i=0,iLen=this.elements.length;i<iLen;i++){ this.elements[i].value =''; }
		}
		object.Reset=function(){ this.reset(); }
		return object;
	},
	Container:function(){
		var object = Jade.Objects._create();
		object.className='jade_container';
		object.childs=[];
		
		Jade.Objects._create_spare(object,'back');
		Jade.Objects._create_spare(object,'back_top');		
		Jade.Objects._create_spare(object,'hborder top');
		Jade.Objects._create_spare(object,'hborder bottom');
		Jade.Objects._create_spare(object,'vborder left');
		Jade.Objects._create_spare(object,'vborder right');
		Jade.Objects._create_spare(object,'corner topleft');
		Jade.Objects._create_spare(object,'corner topright');
		Jade.Objects._create_spare(object,'corner bottomleft');
		Jade.Objects._create_spare(object,'corner bottomright');
		
		//Jade.Events.NoSelect(object);
		
		object.onresize=function(){
			var width=this.width - 4;
			var height=this.height - 4;
			Jade.DOM.GetElementsByClass('back', this)[0].Size(width,height);
			Jade.DOM.GetElementsByClass('back_top', this)[0].style.width = width +'px';
			Jade.DOM.GetElementsByClass('hborder top', this)[0].style.width = width +'px';
			Jade.DOM.GetElementsByClass('hborder bottom', this)[0].style.width = width +'px';
			Jade.DOM.GetElementsByClass('vborder left', this)[0].style.height = height +'px';
			Jade.DOM.GetElementsByClass('vborder right', this)[0].style.height = height +'px';
		}
		object.Clear = function() {
			for(var i=0,iLen=this.childs.length;i<iLen;i++){ this.removeChild(this.childs[i]); }
			this.childs=[];
		}
		
		object.SetStyle('default');
		return object;
	},
	TextBox: function(type,text){
		if(typeof(type)=="undefined") { type="text"; }
		var object = Jade.Objects._create();
		object.controltype='textbox';
		if(type=='password'){ object.controltype='password'; }
		object.className='jade_textbox';
		object.errors=[];
		
		Jade.Objects._create_spare(object,'txt_left');
		Jade.Objects._create_spare(object,'txt_center');
		Jade.Objects._create_spare(object,'txt_right');

		var input = document.createElement('input');
		input.className='text-size';
		input.type=type;
		input.setAttribute('autocapitalize', 'off');
		input.setAttribute('autocorrect', 'off');
		input.setAttribute('autocomplete', 'off');
		
		input.onfocus=function(){ this.parentNode.className += ' focus';	}
		input.onblur=function(){ 
			this.parentNode.className = this.parentNode.className.replace(/ focus/,'');
			if(typeof(this.parentNode.onblur)!="undefined" && typeof(this.parentNode.onblur)!="object"){ this.parentNode.onblur(); } 
		}
		input.onkeypress = function(event){
			event = event||window.event;
			var key = event.keyCode||event.which||0;
			
			var result = true;
			switch(this.mask){
				case 'float':
					result =  key<31 || key==127 || new RegExp(/^\d*(\.\d{0,2})?$/).test(this.value+event.key);
					break;
			}
			
			return result;
		}
		input.onkeydown=function(event){
			if(typeof(this.parentNode.onkeyenter)!="undefined" && typeof(this.parentNode.onkeyenter)!="object"){	
				if(!event){ event=window.event; }
				if(event.keyCode==13){ this.parentNode.onkeyenter(); }
			}
			if($.isEvent(this.parentNode.onkeydown)){ this.parentNode.onkeydown(event); }
		}
		object.appendChild(input);
		object.input=input;
		object.onresize=function(){
			var width=this.width;
			Jade.DOM.GetElementsByClass('txt_center',this)[0].style.width=(width-15)+'px';
			if(Jade.DOM.GetElementsByClass('error',this)[0].style.display=='none'){ width -= 15; }
			else{ width -= 32; }
			this.getElementsByTagName('input')[0].style.width=width+'px';
			this.input.style.lineHeight=this.height+'px';
			this.input.style.height=(this.height-2)+'px';
		}
		
		object.SetDefaultValue = function(value) { this.input.defaultValue=value; }
		object.GetDefaultValue = function() { return this.input.defaultValue; }
		object.SetText = function(value) { this.input.value=value; }
		object.GetText = function() { return this.input.value; }
		object.SetName = function(value) { this.input.name=value; }
		object.GetName = function() { return this.input.name; }
		object.SetType = function(value) { this.input.type=value; }
		object.GetType = function() { return this.input.type; }
		object.SetMaxLength = function(value) { this.input.maxLength=value; }
		object.GetMaxLength = function() { return this.input.maxLength; }
		object.ReadOnly = function(value){ this.input.readOnly=value; }
		object.SetEnabled = function(value) {
			this.enabled=value;
			this.input.enabled=value;
			this.input.disabled=value?'':'disabled';
			this.style.cursor=value?'auto':'default';
		}
		if(typeof(text)!="undefined") { object.getElementsByTagName('input')[0].value=text; } 
		{//Error control
			var error = document.createElement('div');
			error.className = 'error';
			error.parent =object;
			Jade.FX.Hide(error);
			object.appendChild(error);
			
			error.onmouseover=function(){
				if(typeof(this.tooltip)=="undefined"){ this.tooltip = new Jade.Objects.ToolTip(); }
				Jade.FX.SetOpacity(this.tooltip,80);
				Jade.FX.Show(this.tooltip);
				
				var coords = Jade.Css.RealPosition(this);
				//var arrow = Jade.DOM.GetElementsByClass('arrow',this.tooltip)[0];
				var msg = this.parent.errors;

				this.tooltip.Position(coords[0]-200,coords[1]+error.parent.height);
				this.tooltip.Size(400,16+(10*msg.length));
				
				var strMsg ='';
				for(var i=0,iLen=msg.length;i<iLen;i++){ strMsg+=msg[i]+"<br />"; }
				this.tooltip.SetText(strMsg);
				this.tooltip.Add(document.body);
			}
			
			error.onmouseout=function(){ Jade.FX.Hide(this.tooltip); }
			
			object.AddError=function(value){ this.errors.push(value); }
			object.ShowError=function(){
				var error = Jade.DOM.GetElementsByClass('error', this)[0];
				if(this.errors.length > 0){	Jade.FX.Fade(error,0,100,1,10); }
				else{ Jade.FX.Hide(error); }
				this.onresize();
			}
			object.ClearError=function(){
				for(var i=0,iLen=this.errors.length;i<iLen; i++){
					this.errors[i]=[];
				}
			}
		}
		return object;
	},
	TimeBox: function(show_seconds, show_time) {
		if(typeof(show_seconds)=="undefined") { show_seconds=true; }
		if(typeof(show_time)=="undefined") { show_time=false; }
		
		var object = Jade.Objects._create();
		object.enabled = true;
		object.className='jade_textbox';
		object.show_seconds = show_seconds;
		object.show_time = show_time;
		Jade.Objects._create_spare(object,'txt_left');
		Jade.Objects._create_spare(object,'txt_center');
		Jade.Objects._create_spare(object,'txt_right');

		var in_hour = document.createElement('input');
		in_hour.got_focus=false;
		in_hour.type='text';
		in_hour.className = 'text-size';
		in_hour.style.position = 'absolute';
		in_hour.value=show_time?'000':'00';
		
		
		in_hour.style.top='3px';
		in_hour.style.left='2px';
		in_hour.style.width='18px';
		
		object.appendChild(in_hour);
		object.hours=in_hour;
		
		var sep1 = document.createElement('div');
		sep1.className = 'text-size';
		sep1.style.position = 'absolute';
		sep1.style.top='4px';
		if(show_time){ sep1.style.left='30px'; }
		else{ sep1.style.left='24px'; }
		sep1.innerHTML = ':';
		object.appendChild(sep1);
		
		var in_min = document.createElement('input');
		in_min.got_focus=false;
		in_min.type='text';
		in_min.className = 'text-size';
		in_min.style.position = 'absolute';
		in_min.value='00';
		in_min.style.top='3px';
		if(show_time){ in_min.style.left='32px'; }
		else{ in_min.style.left='26px'; }
		in_min.style.width='18px';
		object.appendChild(in_min);
		object.minutes=in_min;
		
		in_hour.onkeydown = function(event){
			if(!event){ event=window.event; }
			var keycode=event.keyCode||event.which||0;
			var value=$.Convert.ToInt(this.value);
			switch(keycode){
				case 13:
					if($.isEvent(object, 'onkeyenter')){ object.onkeyenter(); }
					break;
				case 27:
					if($.isEvent(object, 'onkeyescape')){ object.onkeyescape(); }
					break;
				case 38:
					if(value<23){ value=value+1; }
					break;
				case 40:
					if(value>0){ value=value-1; }
					break;
				case 39:
					in_min.focus();
					break;
				default:
					var key=(keycode>=96 && keycode<=105)?(keycode-96):(String.fromCharCode(keycode));
					if(key>=0 && key<=9){
						key=$.Convert.ToInt(key);
						if(value==1){ value=this.value+key; }
						else if(value==2 && key<=3){ value=this.value+key; }
						else{ value=key; }
					}
			}
			this.value=Jade.Strings.PadLeft(value,'0',2);
			return false;
		}
		in_hour.onkeyup = function(event){ $.DOM.SetCaretSelection(this, 0, this.value.length); }
		in_hour.onselect=function(){ $.DOM.SetCaretSelection(this, 0, this.value.length); }
		in_hour.onclick=function(){ $.DOM.SetCaretSelection(this, 0, this.value.length); }
		in_hour.onfocus=function(){ 
			this.got_focus=true;
			$.DOM.SetCaretSelection(this, 0, this.value.length); 
			this.parentNode.className += ' focus';
		}
		in_hour.onblur=function(){
			this.got_focus=false;
			object.lost_focus();
		}

		in_min.onkeydown = function(event){
			if(window.event){ event=window.event; }
			var keycode=event.keyCode||event.which||0;
			var value=$.Convert.ToInt(this.value);
			switch(keycode){
				case 13:
					if($.isEvent(object, 'onkeyenter')){ object.onkeyenter(); }
					break;
				case 27:
					if($.isEvent(object, 'onkeyescape')){ object.onkeyescape(); }
					break;
				case 38:
					if(value<59){ value=value+1; }
					break;
				case 40:
					if(value>0){ value=value-1; }
					break;
				case 37:
					in_hour.focus();
					break;
				default:
					var key=(keycode>=96 && keycode<=105)?(keycode-96):(String.fromCharCode(keycode));
					if(key>=0 && key<=9){
						key=$.Convert.ToInt(key);
						if(value<=5){ value=this.value+key; }
						else{ value=key; }
					}
			}
			this.value=Jade.Strings.PadLeft(value,'0',2);
			
			return false;
		}
		in_min.onkeyup = function(event){ $.DOM.SetCaretSelection(this, 0, this.value.length); }
		in_min.onselect=function(){ $.DOM.SetCaretSelection(this, 0, this.value.length); }
		in_min.onclick=function(){ $.DOM.SetCaretSelection(this, 0, this.value.length); }
		in_min.onfocus=function(){
			this.got_focus=true;
			console.log('Min: true');
			$.DOM.SetCaretSelection(this, 0, this.value.length);
			this.parentNode.className += ' focus';
		}
		in_min.onblur=function(){
			this.got_focus=false;
			console.log('Min: false');
			object.lost_focus();
		}
		
		if(show_seconds){
			var sep2 = document.createElement('div');
			sep2.className = 'text-size';
			sep2.style.position = 'absolute';
			sep2.style.top='4px';
			sep2.style.left='48px';
			sep2.innerHTML = ':';
			object.appendChild(sep2);
		
			var in_sec = document.createElement('input');
			in_sec.got_focus=false;
			in_sec.type='text';
			in_sec.className = 'text-size';
			in_sec.style.position = 'absolute';
			in_sec.value='00';
			in_sec.style.top='3px';
			in_sec.style.left='50px';
			in_sec.style.width='18px';
			in_sec.onkeydown = function(event){
				if(window.event){ event=window.event; }
				var keycode=event.keyCode||event.which||0;
				var value=$.Convert.ToInt(this.value);
				switch(keycode){
					case 13:
						if($.isEvent(object, 'onkeyenter')){ object.onkeyenter(); }
						break;
					case 27:
						if($.isEvent(object, 'onkeyescape')){ object.onkeyescape(); }
						break;
					case 38:
						if(value<59){ value=value+1; }
						break;
					case 40:
						if(value>0){ value=value-1; }
						break;
					case 37:
						in_hour.focus();
						break;
					default:
						var key=(keycode>=96 && keycode<=105)?(keycode-96):(String.fromCharCode(keycode));
						if(key>=0 && key<=9){
							key=$.Convert.ToInt(key);
							if(value<=5){ value=this.value+key; }
							else{ value=key; }
						}
				}
				this.value=Jade.Strings.PadLeft(value,'0',2);
				return false;
			}
			in_sec.onkeyup = function(event){ $.DOM.SetCaretSelection(this, 0, this.value.length); }
			in_sec.onselect=function(){ $.DOM.SetCaretSelection(this, 0, this.value.length); }
			in_sec.onclick=function(){ $.DOM.SetCaretSelection(this, 0, this.value.length); }			
			in_sec.onfocus=function(){
				this.got_focus=true;
				$.DOM.SetCaretSelection(this, 0, this.value.length);
				this.parentNode.className += ' focus';
			}
			in_sec.onblur=function(){
				this.parentNode.className=this.parentNode.className.replace(/ focus/,''); 
				this.got_focus=false;
				object.lost_focus();
			}
			
			object.appendChild(in_sec);
		
			object.seconds = in_sec;		
		}
		
		object.onresize=function () {
			var width=this.width;
			Jade.DOM.GetElementsByClass('txt_center',this)[0].style.width=(width-15)+'px';
			this.getElementsByTagName('input')[0].style.width=width+'px';
		}
		object.lost_focus=function(){
			console.log('Lost focus');
			setTimeout(function(){
				console.log('Min: '+in_min.got_focus+' Hour: '+(in_hour.got_focus));
				if(!in_hour.got_focus && !in_min.got_focus){
					object.className=object.className.replace(/ focus/g, ''); 
					if($.isDefined(object.onblur)){	object.onblur(); }
				}
			}, 100);
		}
		object.SetValue=function(value){
			if(!show_time){
				if(!this.show_seconds){ value=Jade.Strings.PadLeft(value,'0',4); }
				else { value = Jade.Strings.PadLeft(value,'0',6); }
				this.hours.value = value.substring(0,2);
				this.minutes.value = value.substring(2,4);
				if(this.show_seconds) { this.seconds.value = value.substring(4,6); }
			}
			else{
				this.hours.value=Jade.Strings.PadLeft(parseInt(value/60),'0',3);
				this.minutes.value=Jade.Strings.PadLeft(value%60,'0',2);
			}
		}
		object.GetValue=function(){
			if(!show_time){
				if(this.show_seconds) { return this.hours.value+this.minutes.value+this.seconds.value; }
				else { return this.hours.value+this.minutes.value; }
			}
			else{
				return (this.hour.value*60)+this.minutes.value;
			}
		}
		
		object.SetEnabled = function(value) {
			object.enabled = value;
			object.disabled = 'disabled';
			if(value){
				this.className = this.className.replace(/ disabled/,'');
				this.style.cursor = 'auto';
			}
			else{
				this.className += ' disabled';
				this.style.cursor = 'default';
				Jade.Events.NoSelect(this.hours);
				Jade.Events.NoSelect(this.minutes);
				Jade.Events.NoSelect(this.seconds);
			}
			
			this.hours.readOnly=!value;
			this.minutes.readOnly=!value;
			this.seconds.readOnly=!value;
		}
		return object;
	},
	TextArea:function(text){
		var object = Jade.Objects._create();
		object.controltype='textarea';
		object.className='jade_textarea';
		
		object.back = Jade.Objects._create_spare(object,'txa_back');
		object.top = Jade.Objects._create_spare(object,'txa_hborder txa_top');
		object.bottom = Jade.Objects._create_spare(object,'txa_hborder txa_bottom');
		object.left = Jade.Objects._create_spare(object,'txa_vborder txa_left');
		object.right = Jade.Objects._create_spare(object,'txa_vborder txa_right');
		object.topleft = Jade.Objects._create_spare(object,'txa_corner txa_topleft');
		object.topright = Jade.Objects._create_spare(object,'txa_corner txa_topright');
		object.bottomleft = Jade.Objects._create_spare(object,'txa_corner txa_bottomleft');
		object.bottomright = Jade.Objects._create_spare(object,'txa_corner txa_bottomright');		

		object.textarea = document.createElement('textarea');
		object.textarea.style.position = 'absolute';
		object.textarea.style.resize='none';
		object.textarea.className='txa_input text-size';
		object.textarea.onfocus = function() { this.parentNode.className = 'jade_textarea focus';	}
		object.textarea.onblur = function() { this.parentNode.className = 'jade_textarea'; }
		object.appendChild(object.textarea);
		object.SetText = function(value) { this.textarea.value = value; }
		object.GetText = function() { return this.textarea.value; }
		if(typeof(text)!="undefined"){ object.SetText(text); }
		
		object.onresize=function (){
			var width=Jade.Convert.ToInt(this.width);
			var height=this.height;
			
			this.textarea.style.width = (width-9)+'px';
			this.textarea.style.height = (height-6)+'px';
		}
		return object;
	},
	Text:function(text){
		var object=Jade.Objects._create();
		object.className='jade_text text-size';
		
		object.text=document.createElement('div');
		object.text.style.position='absolute';
		object.text.style.width='100%';
		object.appendChild(object.text);
		
		object.SetText=function(value){ this.text.innerHTML=value; }
		object.GetText=function(){ return this.text.innerHTML; }
		object.SetTextAlign=function(align){ this.text.style.textAlign=align; }
		object.SetBold=function(value){ this.text.style.fontWeight=value?'bold':'normal'; }
		if(typeof(text)!="undefined"){ object.SetText(text); }
		
		Jade.Events.NoSelect(object);
		
		return object;
	},
	Link: function(text) {
		var object = Jade.Objects._create();
		object.className='jade_link text-size';
		
		var href = document.createElement('a');
		href.href='';
		object.appendChild(href);
		
		object.SetText=function(value){ var element=this.getElementsByTagName('a')[0]; element.innerHTML=value; }
		object.GetText=function(){ var element=this.getElementsByTagName('a')[0]; return element.innerHTML; }
		object.SetTextAlign=function(align){ this.style.textAlign=align; }
		object.SetHref=function(value){ var element=this.getElementsByTagName('a')[0]; element.href=value; }
		object.GetHref=function(){ var element=this.getElementsByTagName('a')[0]; return element.href; }
		if(typeof(text)!="undefined"){ object.SetText(text); }
		
		Jade.Events.NoSelect(object);
		
		return object;
	},
	Button: function(text) {
		var object = Jade.Objects._create();
		object.className='jade_button';
		Jade.Objects._create_spare(object,'btn_hborder btn_top');
		Jade.Objects._create_spare(object,'btn_hborder btn_bottom');
		Jade.Objects._create_spare(object,'btn_vborder btn_left');
		Jade.Objects._create_spare(object,'btn_vborder btn_right');
		Jade.Objects._create_spare(object,'btn_corner btn_topleft');
		Jade.Objects._create_spare(object,'btn_corner btn_topright');
		Jade.Objects._create_spare(object,'btn_corner btn_bottomleft');
		Jade.Objects._create_spare(object,'btn_corner btn_bottomright');
		Jade.Objects._create_spare(object,'btn_back');
		Jade.Objects._create_spare(object,'btn_back_top');
		Jade.Objects._create_spare(object,'text-size');
		object.SetText = function(value) { this.lastChild.innerHTML = value; }
		object.GetText = function() { return this.lastChild.innerHTML; }
		object.SetStyle = function(value) { this.className += ' '+value; }
		if(typeof(text)!="undefined") { object.lastChild.innerHTML = text; }
		
		object.onresize = function () {
			var width = this.width - 4;
			var height = this.height - 4;
			Jade.DOM.GetElementsByClass('btn_back', this)[0].Size(width, height);
			Jade.DOM.GetElementsByClass('btn_back_top', this)[0].style.width = width +'px';
			if(this.height<=20) Jade.DOM.GetElementsByClass('btn_back_top', this)[0].style.height = height +'px';
			Jade.DOM.GetElementsByClass('btn_hborder btn_top', this)[0].style.width = width +'px';
			Jade.DOM.GetElementsByClass('btn_hborder btn_bottom', this)[0].style.width = width +'px';
			Jade.DOM.GetElementsByClass('btn_vborder btn_left', this)[0].style.height = height +'px';
			Jade.DOM.GetElementsByClass('btn_vborder btn_right', this)[0].style.height = height +'px';
		}

		object.onmouseover = function() { this.className += ' hover';	}
		object.onmouseout = function() { this.className = this.className.replace(/ hover/,''); }
		object.SetEnabled = function(value) { 
			this.enabled=value;
			//object.disabled = 'disabled';
			if(value) {
				if(typeof(this._onclick)!="undefined"){ this.onclick = this._onclick; }
				this.className = this.className.replace(/ disabled/g,'');
				this.style.cursor = 'pointer';
			}
			else{
				if(this.onclick!=null){
					this._onclick = this.onclick;
					this.onclick = null;
				}
				this.className = this.className.replace(/ disabled/g,'')+ ' disabled';
				this.style.cursor = 'default';
			}
		}
		Jade.Events.NoSelect(object);
		return object;
	},
	ButtonIcon: function(text,icon){
		var object = $.Objects.Button('<div class="icon '+icon+'"></div><div class="text">'+text+'</div>');
		
		/*
		var object = Jade.Objects._create();
		object.className='jade_button icon';
		Jade.Objects._create_spare(object,'btn_hborder btn_top');
		Jade.Objects._create_spare(object,'btn_hborder btn_bottom');
		Jade.Objects._create_spare(object,'btn_vborder btn_left');
		Jade.Objects._create_spare(object,'btn_vborder btn_right');
		Jade.Objects._create_spare(object,'btn_corner btn_topleft');
		Jade.Objects._create_spare(object,'btn_corner btn_topright');
		Jade.Objects._create_spare(object,'btn_corner btn_bottomleft');
		Jade.Objects._create_spare(object,'btn_corner btn_bottomright');
		Jade.Objects._create_spare(object,'btn_back');
		Jade.Objects._create_spare(object,'btn_back_top');
		Jade.Objects._create_spare(object,'container');
		
		if(typeof(text)!="undefined") { object.lastChild.innerHTML = '<div class="icon '+icon+'"></div><div class="text-size">'+text+'</div>'; }
		
		object.onresize = function () {
			var width = this.width - 4;
			var height = this.height - 4;
			Jade.DOM.GetElementsByClass('btn_back', this)[0].Size(width,height);
			Jade.DOM.GetElementsByClass('btn_back_top', this)[0].style.width = width +'px';
			if(this.height<=20) Jade.DOM.GetElementsByClass('btn_back_top', this)[0].style.height = height +'px';
			Jade.DOM.GetElementsByClass('btn_hborder btn_top', this)[0].style.width = width +'px';
			Jade.DOM.GetElementsByClass('btn_hborder btn_bottom', this)[0].style.width = width +'px';
			Jade.DOM.GetElementsByClass('btn_vborder btn_left', this)[0].style.height = height +'px';
			Jade.DOM.GetElementsByClass('btn_vborder btn_right', this)[0].style.height = height +'px';
		}
		
		object.onmouseover=function(){ this.className += ' hover';	}
		object.onmouseout=function(){ this.className = this.className.replace(/ hover/,''); }
		object.SetEnabled = function(value) { 
			//object.disabled = 'disabled';
			if(value) {
				if(typeof(this._onclick)!="undefined"){ this.onclick = this._onclick; }
				this.className = this.className.replace(/ disabled/g,'');
				this.style.cursor = 'pointer';
			}
			else{
				if(this.onclick!=null){
					this._onclick = this.onclick;
					this.onclick = null;
				}
				this.className = this.className.replace(/ disabled/g,'')+ ' disabled';
				this.style.cursor = 'default';
			}
		}
		Jade.Events.NoSelect(object);
		*/
		return object;
	},
	CheckBox: function(text) {
		var object =Jade.Objects._create();
		object.controltype='checkbox';
		object.className='jade_checkbox';
		
		object.SetDefaultValue = function(value) { this.getElementsByTagName('input')[0].defaultValue = value; }
		object.GetDefaultValue = function() { return this.getElementsByTagName('input')[0].defaultValue; }
		object.SetText = function(value) { this.lastChild.innerHTML = value; }
		object.GetText = function() { return this.lastChild.innerHTML; }
		object.SetName = function(value) { this.getElementsByTagName('input')[0].name = value; }
		object.GetName = function() { return this.getElementsByTagName('input')[0].name; }
		
		object.SetCheck = function(value){
			if(Jade.isNumber(value)){ value=value==1; }
			this.getElementsByTagName('input')[0].checked = value;
			this.className = 'jade_checkbox' + (value ? ' checked' :'') ;
			if(typeof(this.onchange)!="undefined" && typeof(this.onchange)!="object") { this.onchange(); }
		}
		object.GetCheck = function() { return this.getElementsByTagName('input')[0].checked; }
		
		var input = document.createElement('input');
		input.style.display='none';
		input.type='checkbox';
		input.onreset = object.onchange;
		object.appendChild(input);

		Jade.Objects._create_spare(object,'check');
		Jade.Objects._create_spare(object,'text-size');
		if(typeof(text)!="undefined") { object.lastChild.innerHTML = text; }
		
		object.onclick = function(){
			this.SetCheck(!this.GetCheck());
		}
		
		Jade.Events.NoSelect(object);
		return object;
	},
	Option: function(text) {
		var object=Jade.Objects._create();
		object.className = 'jade_option';
		object.checked = false;

		object.check = document.createElement('div');
		object.check.className = 'chk_check';
		object.appendChild(object.check);

		object.text = document.createElement('div');
		object.text.className = 'text-size';
		object.appendChild(object.text);
		
		object.GetCheck = function() {
			return this.checked;
		}
		
		object.SetCheck = function(value){
			if(typeof(value)=="undefined"){ value=true; }
			if(value){
				var checkedNode = Jade.DOM.GetElementsByClass('jade_option checked', this.parentNode, 'div')[0];
				if(typeof(checkedNode)!='undefined'){ checkedNode.ClearCheck(); }
			}
			this.checked=value;
			this.className = 'jade_option' + (value?' checked':'');
			if(typeof(this.onchange)!="undefined" && typeof(this.onchange)!="object") { this.onchange(); }
		}
		
		object.ClearCheck = function() {
			this.className = this.className.replace(/ checked/,'');
			this.checked=false;
			if(typeof(this.onchange)!="undefined" && typeof(this.onchange)!="object") { this.onchange(); }
		}
		
		object.SetText = function(value) { this.text.innerHTML = value; }
		object.GetText = function() { return this.text.innerHTML; }
		
		if(typeof(text)!="undefined") { object.SetText(text); }
		
		object.onmouseover = function() {
			if(!this.checked) { this.className += ' hover'; }
		}
		object.onmouseout = function() {
			if(!this.checked) { this.className = this.className.replace(/ hover/,''); }
		}
		object.onclick = function() {
			this.SetCheck();
		}
		Jade.Events.NoSelect(object);
		return object;
	},
	Validator: function() {
		var object = new Object();
		object.messages=[];
		object.objects=[];
		object.Add=function (field,validation,field_name){
			var values=validation.split('=');
			var new_message=[];
			new_message['field']=field;
			new_message['field_name']=field_name;
			new_message['type']=values[0];
			new_message['value']=values[1];
			this.messages.push(new_message);
				
			var insert=true;
			if(Jade.isArray(field)){
				for(var i in field){
					insert=true;
					for(var j=0,jLen=this.objects.length;j<jLen;j++){
						if(field[i]==this.objects[j]){ insert = false; }
					}
					if(insert){ this.objects.push(field[i]); }
				}
			}
			else{
				for(var i=0,iLen=this.objects.length;i<iLen;i++){ if(field==this.objects[i]){ insert=false; } }
				if(insert){ this.objects.push(new_message.field); }
			}
		}
		object.Validate=function(){
			var error=0;
			if(this.messages.length!=0){
				for(var i=0,iLen=this.objects.length;i<iLen; i++){
					this.objects[i].errors=[];
				}
				for(var i=0,iLen=this.messages.length;i<iLen;i++){
					var msg = this.messages[i];
					switch(msg.type){
						case 'required':
							if(msg.field.GetText()==''){
								msg.field.AddError(Jade.Strings.Format(Jade.Lang.Get('error_is_blank'),msg.field_name)); 
								++error;
							}
							break;
						case 'same':case 'equal':
							if(msg.field[0].GetText()!=msg.field[1].GetText()) {
								msg.field[0].AddError(Jade.Strings.Format(Jade.Lang.Get('error_not_same_values'),msg.field_name[0],msg.field_name[1])); 
								msg.field[1].AddError(Jade.Strings.Format(Jade.Lang.Get('error_not_same_values'),msg.field_name[0],msg.field_name[1])); 
								++error;
							}
							break;
					}
				}
				for(var i=0,iLen=this.objects.length;i<iLen; i++){
				
					this.objects[i].ShowError(); 
				}
				if(error==0){ return true; }
				else{ return false; }
			}
			else{ return true; }
		}
		return object;
	},
	ToolTip: function() {
		var object = new Jade.Objects._create();
		object.className='jade_tooltip';
		object.style.zIndex="105";
		Jade.Objects._create_spare(object,'back');
		Jade.Objects._create_spare(object,'back_top');
		Jade.Objects._create_spare(object,'hborder top');
		Jade.Objects._create_spare(object,'hborder bottom');
		Jade.Objects._create_spare(object,'vborder left');
		Jade.Objects._create_spare(object,'vborder right');
		Jade.Objects._create_spare(object,'corner topleft');
		Jade.Objects._create_spare(object,'corner topright');
		Jade.Objects._create_spare(object,'corner bottomleft');
		Jade.Objects._create_spare(object,'corner bottomright');
		Jade.Objects._create_spare(object,'text-size');
		Jade.Objects._create_spare(object,'arrow');
		
		object.SetText = function(value) { Jade.DOM.GetElementsByClass('text-size', this)[0].innerHTML = value; }
		object.GetText = function() { return Jade.DOM.GetElementsByClass('text-size', this).innerHTML; }		
		
		object.onresize = function () {
			var back_width = this.width - 4;
			var back_height = this.height - 4;
			var border_width = this.width - 10;
			var border_height = this.height - 10;
			Jade.DOM.GetElementsByClass('back', this)[0].Size(back_width,back_height);
			Jade.DOM.GetElementsByClass('back_top', this)[0].style.width = back_width +'px';			
			if(this.height<=11) Jade.DOM.GetElementsByClass('back_top', this)[0].style.height = back_height +'px';
			Jade.DOM.GetElementsByClass('hborder top', this)[0].style.width = border_width +'px';
			Jade.DOM.GetElementsByClass('hborder bottom', this)[0].style.width = border_width +'px';
			Jade.DOM.GetElementsByClass('vborder left', this)[0].style.height = border_height +'px';
			Jade.DOM.GetElementsByClass('vborder right', this)[0].style.height = border_height +'px';
		}
		return object;
	},
	ComboBox: function() {
		var object = new Jade.Objects._create();
		object.className='jade_combobox';
		object.tabIndex=0;

		object.controltype='combobox';
		object.items=[];
		object.selectedIndex=null;
		object.selectedKey=null;
		object.showitems=6;
		object.expanded=false;
		object.focused=false;
		object.enabled=true;
		object.subclassName='';
		
		Jade.Events.NoSelect(object);
		
		{//Create: Spare controls
			Jade.Objects._create_spare(object,'cb_left');
			Jade.Objects._create_spare(object,'cb_center');
			Jade.Objects._create_spare(object,'cb_right');
			
			object.texto=Jade.Objects._create_spare(object, 'cb_text text-size');
			object.texto.name='asddd';
			object.texto.tabIndex="0";
			object.texto.parent = object;
			Jade.Events.NoSelect(object);
		}
		{//Create: Container
			object.container = document.createElement('div');
			object.container.parent = object;
			object.container.className='jade_combobox_container';
			object.container.style.position = 'absolute';
			object.container.style.display = 'none';
			object.container.style.zIndex = '201';
			document.getElementById('body').appendChild(object.container);
		}
		{//Create: Text trick
			object.text_trick = document.createElement('div');
			object.text_trick.parent = object;
			object.text_trick.style.cursor = 'pointer';
			if(Jade.Browser.isIE){
				object.text_trick.style.backgroundColor = '#000000';
				Jade.FX.SetOpacity(object.text_trick, 1);
			}
			//object.text_trick.style.opacity=0.01;
			object.container.appendChild(object.text_trick);
		}
		{//Create: ItemContainer
			object.container.back = document.createElement('div');
			object.container.back.parent=object;
			object.container.back.className = 'cb_background';
			object.container.back.name='asss';
			object.container.back.tabIndex="0";
			//object.container.back.style.outline='none';
			object.container.appendChild(object.container.back);
		}
		{//Functions
			object.SetStyle = function(value) {
				this.className = 'jade_combobox '+value;
				this.subclassName = value;
				this.container.className='jade_combobox_container '+value;
			}
		
			object.SetEnabled = function(value){
				object.enabled = value;
				var subclassName = (this.subclassName!='')?' '+this.subclassName:'';
				if(value){
					this.className = 'jade_combobox'+subclassName;
					this.container.className='jade_combobox_container'+subclassName;
				}
				else
				{
					this.className = 'jade_combobox disabled'+subclassName;
					this.container.className='jade_combobox_container disabled'+subclassName;
				}
			}
			
			object.AddHideItem = function(text, key, icon){
				var item = document.createElement('div');
				item.parent = this;
				item.className = 'cb_item text-size';
				item.style.width = '100%';
				item.style.cursor = 'pointer';
				item.style.display='none';
				item.index = this.container.back.childNodes.length;
				item.key = key;
				item.icon = icon;
				item.value = text;
				if(typeof(icon)==undefined) { item.innerHTML = text; }
				else { item.innerHTML='<div class="cb_icon '+icon+'"></div>'+text; }
			
				this.container.back.appendChild(item);
				this.items.push({'text': text,'key': key,'icon':icon});
				Jade.Events.NoSelect(item);
			
				if(this.selectedIndex==null) { this.SetSelectedIndex(0); }
				item.onclick = function(){ this.parent.itemClick(this.index); }
			}

			object.AddItem = function(text, key, icon){
				var item = document.createElement('div');
				item.parent = this;
				item.className = 'cb_item text-size';
				item.style.width = '100%';
				item.style.cursor = 'pointer';
				item.index = this.container.back.childNodes.length;
				item.key = key;
				item.icon = icon;
				item.value = text;
				if(!$.isDefined(icon)) { item.innerHTML = text; }
				else { item.innerHTML='<div class="cb_icon '+icon+'"></div>'+text; }
				
				this.container.back.appendChild(item);
				this.items.push({'text': text,'key': key,'icon':icon});
				Jade.Events.NoSelect(item);
				
				if(this.selectedIndex==null) { this.SetSelectedIndex(0); }
				item.onclick = function(){ this.parent.itemClick(this.index); }
			}
			
			object.ClearItems=function(){
				this.items=[];
				var back=this.container.back;
				while(back.childNodes.length>0){ back.removeChild(back.firstChild); }
				this.selectedIndex=null;
				this.selectedKey=null;
			}
			object.Clear=object.ClearItems;
			
			object.SetSelectedIndex=function(index){
				var item=this.container.back.childNodes[index];
				if(item!=null){
					var oldIndex = this.selectedIndex;
					var oldKey = this.selectedKey;

					this.texto.innerHTML = item.innerHTML;
					this.selectedIndex = index;
					this.selectedKey = item.key;
					this.value = item.value;
			
					if(oldIndex!=index && typeof(this.onchangeindex)!="undefined" && typeof(this.onchangeindex)!="object") { this.onchangeindex(); }
					if(oldKey!=item.key && typeof(this.onchangekey)!="undefined" && typeof(this.onchangekey)!="object") { this.onchangekey(); }
					if(typeof(this.onchange)!="undefined" && typeof(this.onchange)!="object") { this.onchange(); }
				}
				this.collapse();
			}
		
			object.SetSelectedKey=function(key){
				var index=0;
				for(var i=0,iLen=this.items.length;i<iLen;i++){
					if(this.items[i].key==key){ this.SetSelectedIndex(i); }
				}
			}			
		}
		
		object.expand=function(){
			if(this.container.back.childNodes.length>0 && this.enabled){
				this.expanded=true;
				this.set_container_position();
				this.className = this.className+' focus';
				if(typeof(this.onexpand)!="undefined" && typeof(this.onexpand)!="object") { this.onexpand(); }
			}
		}
		
		object.collapse=function(){
			this.expanded=false;
			Jade.FX.Hide(this.container);
			if(typeof(this.oncollapse)!="undefined" && typeof(this.oncollapse)!="object") { this.oncollapse(); }
		}
		
		object.set_container_position=function(){
			var body_coords=Jade.Css.RealPosition(document.getElementById('body'));
			var coords=Jade.Css.RealPosition(this);
			
			this.container.style.top=((coords[1]-body_coords[1])+this.offsetHeight)+'px';
			this.container.style.left=(coords[0]-body_coords[0])+'px';
			this.container.style.width=this.offsetWidth+'px';
			this.container.style.display = 'block';
			
			this.text_trick.style.height=this.offsetHeight+'px';
			this.text_trick.style.width=this.offsetWidth+'px';
			this.text_trick.style.marginTop = '-'+this.offsetHeight+'px';
			
			this.container.back.style.overflow='auto';
			this.container.back.style.overflowX='hidden';
			if(this.container.back.childNodes.length > this.showitems){
				var child = this.container.back.childNodes;
				var itemHeight = (child[child.length-1].offsetHeight * this.showitems)+'px';
				this.container.style.height = itemHeight;
				this.container.back.style.height = itemHeight;
			}
			else{
				this.container.style.height='';
				this.container.back.style.height='';
			}
		}
		
		object.onclick = function(){ if(this.enabled){ this.onfocus(); } }
		object.onfocus = function(){
			if(this.enabled){
				this.className = this.className+' focus';
				this.expand();
				this.container.back.focus();
			}
		}
		object.texto.onfocus = function(){
			if(this.enabled){
				this.parent.className = this.parent.className+' focus'; 
				this.parent.stop_blur();
			}
		}
		object.texto.onblur = function(){
			if(!this.parent.expanded){ this.parent.className=this.parent.className.replace(/ focus/g, ''); }
		}
		
		object.text_trick.onclick = function(){ this.parent.collapse(); this.parent.texto.focus(); }
		
		object.container.back.onblur = function(){
			var _self=this.parent;
			if(_self.expanded){
				_self.blurTimer=setTimeout(function(){ _self.start_blur(); }, 300);
			}
		}
		
		object.start_blur = function(){
			if(this.expanded){ this.collapse(); }
			if(!this.expanded){ this.className=this.className.replace(/ focus/g, ''); }
		}
		object.stop_blur = function(){
			clearTimeout(this.blurTimer);
			//this.container.back.focus();
		}
		
		object.itemClick = function(index){
			if(this.selectedIndex!=index){ this.SetSelectedIndex(index); }
			else { this.collapse(); }
			this.texto.focus();
		}
		
		Jade.Events.StopPropagation(object.onfocus);
		return object;
	},
	DatePicker: function(){
		var object=Jade.Objects._create();
		object.controltype='datepicker';
		object.className='jade_datepicker';
		object.days=[];
		object.tabIndex=0;
		object.expanded=0;
		object.value='20000101';
		object.show_date=new Date(2000,1,1);
		Jade.Events.NoSelect(object);
		
		Jade.Objects._create_spare(object,'dp_left');
		Jade.Objects._create_spare(object,'dp_center');
		Jade.Objects._create_spare(object,'dp_right');
		
		object.texto=document.createElement('div');
		object.texto.className='dp_text text-size';
		object.texto.style.position='absolute';
		object.texto.style.left='0px';
		object.texto.style.top='0px';
		Jade.Events.NoSelect(object.texto);
		object.appendChild(object.texto);
		
		//-------------------------------------------------------------------------------------------------
		object.container=document.createElement('div');
		object.container.parent=object;
		object.container.className='jade_datepicker_container'
		object.container.style.position='absolute';
		object.container.style.display='none';
		object.container.style.zIndex='100';
		object.container.style.width='180px';
		object.container.style.height='195px';
		object.container.style.borderWidth='1px';
		object.container.style.borderStyle='solid';
		document.getElementById('body').appendChild(object.container);

		object.container.trick=document.createElement('div');
		object.container.trick.parent=object;
		object.container.trick.style.cursor = 'pointer';
		object.container.trick.tabIndex=0;
		
		object.container.appendChild(object.container.trick);

		object.container.back = document.createElement('div');
		object.container.back.className = 'back';
		object.container.back.style.position = 'absolute';
		object.container.back.style.top = '0px';
		object.container.back.style.left = '0px';
		object.container.back.style.width = '100%';
		object.container.appendChild(object.container.back);

		object.container.month = document.createElement('div');
		object.container.month.className='month';
		object.container.month.style.position = 'absolute';
		object.container.month.style.top = '5px';
		object.container.month.style.left = '20px';
		object.container.month.style.right = '20px';
		object.container.month.style.textAlign = 'center';
		object.container.month.style.cursor = 'default';
		object.container.appendChild(object.container.month);
		Jade.Events.NoSelect(object.container.month);

		object.container.down = document.createElement('div');
		object.container.down.className = 'down';
		object.container.down.parent=object;
		object.container.appendChild(object.container.down);
		Jade.Events.NoSelect(object.container.down);

		object.container.left = document.createElement('div');
		object.container.left.className = 'left';
		object.container.left.parent=object;
		object.container.appendChild(object.container.left);
		Jade.Events.NoSelect(object.container.left);

		object.container.right = document.createElement('div');
		object.container.right.className = 'right';
		object.container.right.parent=object;
		object.container.appendChild(object.container.right);
		Jade.Events.NoSelect(object.container.right);

		object.container.up = document.createElement('div');
		object.container.up.className = 'up';
		object.container.up.parent=object;
		object.container.appendChild(object.container.up);
		Jade.Events.NoSelect(object.container.up);

		for(var i =1;i<=7;i++){
			var weekday=document.createElement('div');
			weekday.className='weekday text-size';
			weekday.style.position='absolute';
			weekday.style.top='25px';
			weekday.style.left=(23*i-10)+'px';
			weekday.style.width='40px';
			weekday.style.cursor='default';
			weekday.innerHTML=Jade.Lang.Get('wday_'+i);
			object.container.appendChild(weekday);
			Jade.Events.NoSelect(weekday);
		}
		for(var i =1; i<=6; i++){
			for(var j=0; j<=6; j++){
				var day=document.createElement('div');
				day.className='day';
				day.style.position='absolute';
				day.style.top=(25*i+17)+'px';
				day.style.left=(25*j+2)+'px';
				day.style.width='24px';
				day.style.height='19px';
				day.style.borderWidth='1px';
				day.style.borderStyle='solid';
				day.style.padding='5px 0 0 0';
				day.style.textAlign='center';
				day.parent=object;
				object.container.appendChild(day);
				object.days.push(day);
				Jade.Events.NoSelect(day);
			}
		}
		
		object.expand=function(){
			this.className=this.className+' focus';
			this.set_container_position();
			
			if(this.value!=''){ this.show_date=Jade.DateTime.fromStoreDate(this.value); }
			else{ this.show_date=Jade.DateTime.Now(); }
			
			this.draw_month();
			//Jade.FX.Fade(this.container,1,100,5,5);
			this.expanded=1;
		}
		
		object.collapse=function(){
			this.className=this.className.replace(/ focus/,'');
			Jade.FX.Hide(this.container);
			this.expanded=0;
		}
		
		object.draw_month=function(){
			var year=this.show_date.getFullYear();
			var month=this.show_date.getMonth()+1;
			var day=this.show_date.getDate();
			
			var txt_month=Jade.Lang.Get('month_'+month)+' '+year;
			this.container.month.innerHTML=txt_month;
			//--------------------------------------------------------------------------------
			var firstday=Jade.DateTime.Firstday(month,year);
			var weekday=Jade.DateTime.Weekday(firstday);
			var i=weekday-1;
			var y=0;
			for(var x=0,xLen=this.days.length;x<xLen;x++){
				this.days[x].className='day disabled text-size';
				this.days[x].innerHTML='';
				this.days[x].style.cursor='default';
				this.days[x].onmouseover=null;
				this.days[x].onmouseout=null;
				this.days[x].onclick=null;
			}
			for(var x=i,xLen=(i+Jade.DateTime.Monthdays(month,year));x<xLen;x++){
				y++;
				this.days[x].innerHTML=y;
				this.days[x].className='day text-size';
				this.days[x].style.cursor='pointer';
				this.days[x].onmouseover=function(){ this.className='day hover text-size';	}
				this.days[x].onmouseout=function(){this.className='day text-size'; }
				this.days[x].onclick=function(){
					this.parent.SetValue(year+Jade.Strings.PadLeft(month,'0',2)+Jade.Strings.PadLeft(this.innerHTML,'0',2));
					this.parent.collapse();
				}
			}
		}
		
		object.set_container_position=function(){
			var body_coords=Jade.Css.RealPosition(document.getElementById('body'));
			var coords=Jade.Css.RealPosition(this);
			
			var top=(coords[1]-body_coords[1]-1)+this.offsetHeight;
			var left=coords[0]-body_coords[0];
			this.container.style.top=top+'px';
			this.container.style.left=left+'px';
			this.container.style.display = 'block';
			this.container.trick.style.height=this.offsetHeight+'px';
			this.container.trick.style.width=this.offsetWidth+'px';
			this.container.trick.style.marginTop = '-'+this.offsetHeight+'px';
		}
		
		object.SetValue=function(value){
			this.value=value;
			if(value!=""){ this.texto.innerHTML=Jade.DateTime.showStoreDate(this.value); }
			else{ this.texto.innerHTML=Jade.Lang.Get('undefined'); }
			if(typeof(this.onchangevalue)!="undefined" && typeof(this.onchangevalue)!="object"){ this.onchangevalue(); }
		}
		object.GetValue=function(){ return this.value; }
		object.SetStyle=function(value) { this.className = 'jade_datepicker '+value; }
		//-------------------------------------------------------------------------------------------------
		object.container.trick.onclick=function(){ this.parent.collapse(); }
		object.container.onclick=function(){ this.parent.stop_blur(); }
		object.container.down.onclick=function(){
			this.parent.stop_blur();
			this.parent.show_date=new Date(this.parent.show_date.getFullYear()-1,this.parent.show_date.getMonth(),this.parent.show_date.getDate());
			this.parent.draw_month();
		}
		object.container.left.onclick=function(){
			this.parent.stop_blur();
			this.parent.show_date=new Date(this.parent.show_date.getFullYear(),this.parent.show_date.getMonth()-1,this.parent.show_date.getDate());
			this.parent.draw_month();
		}
		object.container.right.onclick=function(){
			this.parent.stop_blur();
			this.parent.show_date=this.parent.show_date.addMonths(1);
			this.parent.draw_month();
		}
		object.container.up.onclick=function(){
			this.parent.stop_blur();
			this.parent.show_date=new Date(this.parent.show_date.getFullYear()+1,this.parent.show_date.getMonth(),this.parent.show_date.getDate());
			this.parent.draw_month();
		}		
		//-------------------------------------------------------------------------------------------------
		object.onclick=function(){ if(this.expanded==0){ this.onfocus(); } }
		object.onfocus=function(){
			if(this.expanded==0){ this.expand(); }
			this.container.trick.focus();
		}
		
		object.container.trick.onblur=function() {
			var _self=this.parent;
			if(_self.expanded==1){ _self.blur_time=setTimeout(function() { _self.start_blur(); }, 300); }
		}
		object.start_blur=function(){ this.collapse(); }
		object.stop_blur=function(){
			//this.container.trick.focus();
			clearTimeout(this.blur_time);
		}
		object.SetValue(Jade.DateTime.CurrentStoreDate());
		return object;
	},
	SimpleGrid: function(){
		var object=Jade.Objects._create('div');
		object.className = 'jade_simplegrid';
		object.numItems=0;
		object.innerHTML='<div class="head"></div><div class="body"></div>';
		object.head=Jade.DOM.GetElementsByClass('head',object)[0];
		object.body=Jade.DOM.GetElementsByClass('body',object)[0];
		object.columns = [];
		Jade.Events.NoSelect(object);

		object.AddHeader=function(text,size,className){
			var header=document.createElement('div');
			header.className='header';
			header.style.width=Jade.Objects._set_size(size);
			header.innerHTML='<p class="text-size">'+text+'</p>';
			if(typeof(className)!="undefined"){ header.childClass=className; }
			Jade.DOM.GetElementsByClass('head',this)[0].appendChild(header);
			this.columns.push({'size': size,'className': className});
		}
		
		object.AddItem=function(){
			var row=document.createElement('div');
			row.className='row';
			for(var i=0,iLen=arguments.length;i<iLen;i++){
				var cell=document.createElement('div');
				cell.className='cell';
				
				if(typeof(this.columns[i].className)!="undefined") { cell.className = cell.className+' '+this.columns[i].className; }
				cell.style.width = Jade.Objects._set_size(this.columns[i].size);
				if(i!=0){
					cell.style.borderStyle = 'solid';
					cell.style.borderWidth = '0 0 0 1px';
				}
				cell.innerHTML = '<p class="text-size">'+arguments[i]+'</p>';
				
				row.appendChild(cell);
			}
			this.body.appendChild(row);
			this.numItems++;
		}
		object.AddStyledItem = function(values,style){
			var row = document.createElement('div');
			row.className='row';
			
			for(var i=0,iLen=values.length;i<iLen;i++){
				var cell=document.createElement('div');
				var className='cell';
				if(i==0){ className+=' first'; }
				if(typeof(this.columns[i])!="undefined" && typeof(this.columns[i].className)!="undefined"){ className+=' '+this.columns[i].className; }
				className+=' '+(Jade.isArray(style)?style[i]:style);
				
				cell.className=className;
				cell.style.width = Jade.Objects._set_size(this.columns[i].size);
				cell.innerHTML='<p class="text-size">'+values[i]+'</p>';
				row.appendChild(cell);
			}
			
			this.body.appendChild(row);
			this.numItems++;			
		}
		object.Clear=function(){
			this.numItem=0;
			for(var i=0,iLen=this.body.childNodes.length;i<iLen;i++){
				this.body.removeChild(this.body.firstChild);
			}
		}
		object.onresize = function() {
			this.body.style.height = (this.height-14)+'px';
		}
		return object;
	},
	SimpleTreeGrid: function() {
		var object = new Jade.Objects._create('div');
		object.className = 'jade_simpletreegrid';
		object.numItems=0;
		object.innerHTML='<div class="head"></div><div class="body"></div>';
		object.head=Jade.DOM.GetElementsByClass('head',object)[0];
		object.body=Jade.DOM.GetElementsByClass('body',object)[0];
		
		object.AddHeader = function(text,size) {
			var header = document.createElement('div');
			header.className = 'header';
			header.style.width = Jade.Objects._set_size(size);
			header.innerHTML = '<p class="text-size">'+text+'</p>';
			Jade.DOM.GetElementsByClass('head',this)[0].appendChild(header);
		}
		object.AddItem = function(key) {
			var item = document.createElement('div');
			item.className='stg_item';
			item.key=key;
			
			for(var i=1,iLen=arguments.length;i<iLen;i++){
				var value = document.createElement('div');
				value.className = 'value';
				if(this.numItems%2!=0) { value.className='value pair'; }				
				value.style.position = 'absolute';
				if(i!=1) {
					value.innerHTML = '<p class="text-size">'+arguments[i]+'</p>';
				}
				else {
					value.innerHTML = '<div class="expand"><img class="blank"></div><p class="text-size">'+arguments[i]+'</p>';
					var expand = Jade.DOM.GetElementsByClass('expand',value)[0];
					expand.parent=item;

					expand.onclick = function() {
						var item = this.parent;
						if(typeof(item.container)!="undefined" && item.container!=null)
						{
							if(!item.expanded)
							{
								this.className='expand collapse';

								Jade.FX._create_fx(item.container);
								Jade.FX.Fade(item.container,0,100,4,1);
								if(typeof(item.container.fx.resize_max)=="undefined" || item.container.fx.resize_max<item.container.fx.resize_height)	{ item.container.fx.resize_max = item.container.offsetHeight; }
								var step=item.container.fx.resize_max/25;
								Jade.FX.Resize(item.container,item.container.offsetWidth,0,item.container.offsetWidth,item.container.fx.resize_max,step,step,1);
							}
							else
							{
								this.className='expand';
								var step=item.container.offsetHeight/25;
								Jade.FX.Fade(item.container,100,0,4,1);
								Jade.FX.Resize(item.container,item.container.offsetWidth,item.container.offsetHeight,item.container.offsetWidth,0,step,step,1);
							}
							item.expanded = !item.expanded;
						}
					}
				}
				
				var thisCol = Jade.DOM.GetElementsByClass('header',this.head)[i-1];
				value.style.left = thisCol.offsetLeft+'px';
				value.style.width = thisCol.offsetWidth+'px';
				
				
				
				item.appendChild(value);
			}
			this.body.appendChild(item);
			

			var container = document.createElement('div');
			container.className='container';
			container.style.position='relative';
			item.container = container;
			Jade.FX.Hide(container);
			Jade.DOM.InsertAfter(container,item);
			
			this.numItems++;
			return item;
		}
		object.AddSubItem = function (row,object) {
			row.container.appendChild(object);
		}
		object.onadd = function() {
			this.body.style.height = (this.offsetHeight-this.head.offsetHeight+1)+'px';
		}
		return object;
	},
	Tabs: function () {
		var object = new Jade.Objects._create('div');
		object.className = 'jade_tabs';
		
		object.back = Jade.Objects._create_spare(object,'tb_back');
		Jade.Objects._create_spare(object.back,'tb_left');
		Jade.Objects._create_spare(object.back,'tb_right');
		
		object.tabs=[];
		object.tabpages=[];
		
		object.tb_container = Jade.Objects._create_spare(object, 'tb_container');
		Jade.Objects._create_spare(object.tb_container,'tb_background');
		Jade.Objects._create_spare(object.tb_container,'tb_vborder tb_left');
		Jade.Objects._create_spare(object.tb_container,'tb_vborder tb_right');
		Jade.Objects._create_spare(object.tb_container,'tb_hborder tb_bottom');
		Jade.Objects._create_spare(object.tb_container,'tb_corner tb_bottomleft');
		Jade.Objects._create_spare(object.tb_container,'tb_corner tb_bottomright');
		
		object.AddTab=function(text) {
			var last = this.back.lastChild;
			var tab = document.createElement('div');
			tab.className='tab';
			tab.parent = this;

			var left = document.createElement('div');
			left.className = 'left';
			tab.appendChild(left);
			
			var middle = document.createElement('div');
			middle.className = 'middle text-size';
			middle.innerHTML = text;
			tab.appendChild(middle);
			Jade.Events.NoSelect(tab);
			
			var right = document.createElement('div');
			right.className = 'right';
			tab.appendChild(right);

			var tabpage = document.createElement('div');
			tabpage.className='tabpage';
			tabpage.style.position = 'absolute';
			tabpage.style.width = '100%';
			tabpage.style.height = '100%';
			tabpage.style.display = 'none';
			tabpage.style.zIndex = '100';
			this.tb_container.appendChild(tabpage);
			
			tab.onclick=function(){
				for(var i=0,iLen=this.parent.tabs.length;i<iLen;i++){
					this.parent.tabs[i].className = 'tab';
					this.parent.tabpages[i].style.display = 'none';
				}
				this.parent.tabs[this.key].className = 'tab selected';
				this.parent.tabpages[this.key].style.display = 'block';
			}
			tab.onmouseover = function() { if(this.className=='tab') { this.className='tab hover'; } }
			tab.onmouseout = function() { if(this.className=='tab hover') { this.className='tab'; } }
			tab.Visible = function(value){
				if(value){
					Jade.FX.Show(this.parent.tabpages[this.key]);
					Jade.FX.Show(this);
				}
				else{
					
					Jade.FX.Hide(this.parent.tabpages[this.key]);
					Jade.FX.Hide(this);
					if(this.className=='tab selected' && this.key < this.parent.tabs.length-1){ this.parent.tabs[this.key+1].onclick(); }
				}
			}
			tab.Hide = function(){
				Jade.FX.Hide(this.parent.tabpages[this.key]);
				Jade.FX.Hide(this);
				if(this.className=='tab selected' && this.key < this.parent.tabs.length-1){ this.parent.tabs[this.key+1].onclick(); }
			}
				
			tab.key = this.tabs.length;
			this.back.insertBefore(tab,last);
			
			this.tabs.push(tab);
			this.tabpages.push(tabpage);
		}
		object.onadd = function() {
			if(this.tabs.length>0) { this.tabs[0].onclick(); }
		}
		object.onresize = function () {
			this.tb_container.style.height = (this.height-25)+'px';
			var height = this.height - 28;
			Jade.DOM.GetElementsByClass('tb_hborder tb_bottom', this.tb_container)[0].style.width = (this.width - 4) +'px';
			Jade.DOM.GetElementsByClass('tb_vborder tb_left', this.tb_container)[0].style.height = height +'px';
			Jade.DOM.GetElementsByClass('tb_vborder tb_right', this.tb_container)[0].style.height = height +'px';
		}
		return object;
	},
	MessageBox: function(message,icon,height,width) {
		if(typeof(width)=='undefined') width=450;
		if(typeof(height)=='undefined') height=120;
		var body = document.getElementsByTagName('body')[0];
		
		var back=Jade.Objects._create('div');
		back.Location(0,0,'100%','100%');
		back.SetStyle('jade_modal_background');
		back.style.zIndex='100';
		back.id='jade_modal_background';
		Jade.FX.SetOpacity(back,'60');
		back.Add(body);

		var gpMsgBox = new Jade.Objects.Container();
		var iHeight=parseInt((Jade.DOM.Document.ClientHeight()-height)/2)+Jade.DOM.Document.ScrollY();
		var iWidth=parseInt((Jade.DOM.Document.ClientWidth()-width)/2)+Jade.DOM.Document.ScrollX();
		gpMsgBox.SetStyle('msgbox');
		gpMsgBox.Location(iWidth,iHeight,width,height);
		gpMsgBox.style.zIndex='101';
		gpMsgBox.back = back;
		gpMsgBox.Add(body);
		
		var icoMsgBox=document.createElement('div');
		icoMsgBox.className='jade_messagebox_icon '+icon;
		icoMsgBox.style.position='absolute';
		icoMsgBox.style.left='20px';
		icoMsgBox.style.top='20px';
		gpMsgBox.appendChild(icoMsgBox);

		var lblMsgBox=Jade.Objects.Text(message);
		lblMsgBox.Location(90,20,gpMsgBox.width-110,gpMsgBox.height-40);
		lblMsgBox.Add(gpMsgBox);
		
		var cmdMsgBox=Jade.Objects.Button(Jade.Lang.Get('accept'));
		cmdMsgBox.Location(10,height-30,width-20,22);
		cmdMsgBox.Add(gpMsgBox);
		cmdMsgBox.onclick=function(){ Jade.FX.Hide(gpMsgBox); Jade.FX.Hide(gpMsgBox.back); }
		
	},
	Window: function(width,height) {
		var object = new Jade.Objects.Container();
		var body = document.getElementsByTagName('body')[0];
		
		object.SetStyle('window');
		object.Size(width,height);
		object.style.zIndex='101';
		var back = document.createElement('div');
		back.id='jade_modal_background';
        back.className='jade_modal_background';
		back.style.position='absolute';
		back.style.top = '0';
		back.style.left = '0';
		back.style.height = '100%';
		back.style.width = '100%';
		back.style.zIndex= '100';
		Jade.FX.SetOpacity(back,'60');
		var documentHeight=Math.max(document.documentElement.scrollHeight,document.documentElement.clientHeight,body.scrollHeight,body.scrollHeight,body.offsetHeight);
        back.style.height=(Jade.DOM.Document.Height())+'px';
		object.back = back;
		
		object.Show = function() {
			var iHeight=Jade.Convert.ToInt((Jade.DOM.Document.ClientHeight()-this.height)/2)+Jade.DOM.Document.ScrollY();
			var iWidth=Jade.Convert.ToInt((Jade.DOM.Document.ClientWidth()-this.width)/2)+Jade.DOM.Document.ScrollX();
			this.Position(iWidth,iHeight);
			Jade.FX.Show(this);
			Jade.FX.Show(this.back);
			if($.isEvent(this, 'onshow')){ this.onshow(); }
		}
		object.Hide = function() {
			Jade.FX.Hide(this);
			Jade.FX.Hide(this.back);
		}
			
		Jade.Events.AddLoad(function(){
			body.appendChild(back);
			object.Add(body);
			Jade.FX.Hide(object);
			Jade.FX.Hide(object.back);
			});
		return object;
	},
	ContextMenu: function() {
	
		var object = new Jade.Objects._create('div');
		object.className = 'jade_contextmenu';
		object.items=[];
		object.timer={};
		Jade.Events.NoSelect(object);
		
		var verticalSep = document.createElement('div');
		verticalSep.className='vertical_sep';
		object.appendChild(verticalSep);
		object.vertical_sep = verticalSep;
		
		var inner = document.createElement('div');
		inner.className='inner';
		object.appendChild(inner);
		object.inner = inner;
		
		object.onmouseout = function() {
			this.timer=setTimeout( function() { object.Hide(); },200); 
		}
		object.onmouseover = function() { this.clearTimer(); }
		object.clearTimer = function() { 
			if(typeof(this.timer)!="undefined") { clearTimeout(this.timer); }
		}
		
		object.AddItem = function(text,key) {
			var cssItem = document.createElement('div');
			cssItem.className = 'item';
			cssItem.parent = this;
			cssItem.onmouseover = function() { this.parent.clearTimer(); this.className += ' hover'; }
			cssItem.onmouseout = function() { this.parent.clearTimer(); this.className = this.className.replace(/ hover/,''); }
			cssItem.onclick = function() {
				if(this.object.enabled) { this.object.object.Hide(); }
				if(this.object.enabled && typeof(this.object.onclick)!="undefined") { this.object.onclick(); }
			}
			
			var cssText = document.createElement('div');
			cssText.className='text-size';
			cssText.innerHTML = text;
			cssItem.appendChild(cssText);
			cssItem.cssText = cssText;
			Jade.Events.NoSelect(cssText);
			
			var cssBack = document.createElement('div');
			cssBack.className = 'back';
			cssItem.appendChild(cssBack);
			cssItem.cssBack = cssBack;
			Jade.FX.SetOpacity(cssBack,30);
			
			var cssBorder = document.createElement('div');
			cssBorder.className = 'border';
			cssItem.appendChild(cssBorder);
			
			this.inner.appendChild(cssItem);
			
			var item = {};
			item.enabled = true;
			item.cssItem = cssItem;
			item.object = this;
			cssItem.object = item;
			item.SetEnabled = function(value) {
				this.enabled = value;
				this.cssItem.className = this.cssItem.className.replace(/ disabled/,'');
				if(!value) { this.cssItem.className += ' disabled'; }
			}
			
			if(typeof("key")=="undefined") key = this.items.length;
			this.items[key] = item;
		}
	
		object.MousePop = function(ev) {
			this.Position(ev.clientX-1,ev.clientY-1);
			this.Show();
		}
		object.Pop = function(x,y) {
			this.Position(x,y);
			this.Show();
		}
		object.Show = function() {
			Jade.FX.Show(this);
		}
		object.Hide = function() {
			Jade.FX.Hide(this);
		}
		
		var body = document.getElementsByTagName('body')[0];
		try {
			object.Add(body);
			Jade.FX.Hide(object);
		}
		catch(e) { Jade.Events.AddLoad(function() { object.Add(body); Jade.FX.Hide(object); }); }
		
		return object;
		
	},
	CalendarMonth: function(size){
		var calendar=Jade.Objects._create();
		calendar.className='jade_calendar';
		calendar.allDays=[];
		calendar.days=[];
		calendar.selectedDays=[];
		Jade.Events.NoSelect(calendar);
		{//Draw weekday headers
			for(var i=0;i<=6;i++){
				var header=Jade.Objects._create();
				header.className='weekday';
				header.Location(i*(size+1),0,size,18);
				header.Add(calendar);
				var border=Jade.Objects._create();
				border.className='border';
				border.Location(0,0,size-2,16);
				border.Add(header);					
				var text=Jade.Objects._create();
				text.className='text-size';
				text.Location(1,3,size-2,16);
				text.innerHTML=Jade.Lang.Get('wday_'+(i+1));
				text.Add(header);
				Jade.Events.NoSelect(text);
			}
		}
		{//Draw days
			for(var j=0;j<6;j++){
				for(var i=0;i<7;i++){
					var cube=Jade.Objects._create();
					cube.className='day';
					cube.Location(i*(size+1),19+j*(size+1),size,size);
					cube.Add(calendar);
					cube.selected=false;
					calendar.allDays.push(cube);
					var lblDay=Jade.Objects.Text();
					lblDay.className='day_text';
					lblDay.Location(0,10,size,20);
					Jade.Events.NoSelect(lblDay);
					lblDay.Add(cube);
					var lblType=Jade.Objects.Text();
					lblType.Location(5,25,size-10,20);
					lblType.SetTextAlign('right');
					Jade.Events.NoSelect(lblType);
					lblType.Add(cube);
					var lblCode=Jade.Objects.Text();
					lblCode.Location(5,35,size-10,20);
					lblCode.SetTextAlign('right');
					Jade.Events.NoSelect(lblCode);
					lblCode.Add(cube);
					
					cube.lblDay=lblDay;
					cube.lblType=lblType;
					cube.lblCode=lblCode;

					cube.SetColor=function(id_daytype,id_variant,id_incidence){
						this.className = 'day'+ Jade.iif(this.selected,' selected','');
						if(id_incidence!=''){
							this.lblType.SetText(Jade.Lang.Get('incidence_ab'));
							this.lblCode.SetText(id_incidence);
							this.className+=' day_incidence';
						}
						else if(id_variant!=''){
							this.lblType.SetText(Jade.Lang.Get('variant_ab'));
							this.lblCode.SetText(id_variant);
							this.className+=' day_variant';
						}
						else{
							this.lblType.SetText('');
							this.lblCode.SetText('');
							this.className+=' daytype_'+id_daytype;
						}
					}
					cube.onclick=function(event){
						if(!event){ event=window.event; }
						Jade.Events.StopPropagation(event);
						
						if(this.className!='day disabled'){
							if(!event.ctrlKey){
								calendar.ClearSelected();
							}
							if(this.selected){ this.className=this.className.replace(/ selected/,''); }
							else { this.className+=' selected'; }
							this.selected=!this.selected;
							calendar.selectedDays=[];
							for(var i=0,iLen=calendar.days.length;i<iLen;i++){
								if(calendar.days[i].selected){ calendar.selectedDays.push(calendar.days[i]); }
							}
						}
						if(typeof(calendar.ondayclick)!="undefined"){ calendar.ondayclick(event,this); }
					}
				}
			}
		}
		{//Functions
			calendar.Draw=function(month,year){
				this.ClearSelected();
				month = parseInt(month);
				year = parseInt(year); 
				calendar.days=[];
				//------------------------------------------------------------------------------------------
				for(var x=0,xLen=calendar.allDays.length;x<xLen;x++){
					calendar.allDays[x].className = 'day disabled';
					calendar.allDays[x].day = '';
					calendar.allDays[x].lblDay.SetText('');
					calendar.allDays[x].lblType.SetText('');
					calendar.allDays[x].lblCode.SetText('');
				}
				//------------------------------------------------------------------------------------------
				var weekday=Jade.DateTime.Weekday(Jade.DateTime.Firstday(month,year))-1;
				if(weekday==0){ weekday=7; }
				var y=Jade.DateTime.Monthdays(month-1,year)-weekday+1;
		
				for(var x=0,xLen=weekday;x<xLen;x++,y++){
					calendar.allDays[x].lblDay.SetText(y);
				}
				//------------------------------------------------------------------------------------------
				for(var x=weekday,y=1,xLen=weekday+Jade.DateTime.Monthdays(month,year);x<xLen;x++,y++){
					calendar.allDays[x].day = y;
					calendar.allDays[x].lblDay.SetText(y);
					calendar.allDays[x].className = 'day';
					calendar.days.push(calendar.allDays[x]);
				}
				//------------------------------------------------------------------------------------------
				for(y=1;x<=41;x++,y++){
					calendar.allDays[x].lblDay.SetText(y);
				}
			}
			calendar.ClearSelected=function(){
				for(var i=0,iLen=this.selectedDays.length;i<iLen;i++){
					this.selectedDays[i].className=this.selectedDays[i].className.replace(/ selected/,'');
					this.selectedDays[i].selected=false;
				}
				calendar.selectedDays=[];
			}
		}
		return calendar;
	},
	
	SearchEmployee: function(link){
		var control=$.Objects.ButtonIcon('', 'search');
		{//Window
			if(!$.isDefined($.Objects.window_se)){
				{//Controls
					var win=$.Objects.Window(640, 400);
					$.Objects.Add('text', [10, 10, 100, 20], win, $.lng('search_by')+':');
					win.combo=$.Objects.Add('combo', [110, 10, 200, 20], win);
					win.text=$.Objects.Add('textbox', [315, 10, 315, 20], win);
					win.cancel=$.Objects.Add('button', [10, 368, 620, 22], win, $.lng('cancel'));
					win.grid=$.Objects.Add('grid', [10, 40, 620, 320], win, {columns: [
						{type: 'simple', text: $.lng('code'), width: 80},
						{type: 'simple', text: $.lng('name'), width: 200},
						{type: 'simple', text: $.lng('surnames'), width: 320}
					]});

					win.combo.AddItem($.lng('code'), 'Codigo');
					win.combo.AddItem($.lng('name'), 'Nombre');
					win.combo.AddItem($.lng('surnames'), 'Apellidos');
					win.combo.AddItem(COMPANY.department, 'IdUbicacion');
					win.combo.AddItem(COMPANY.center, 'IdCentro');			
				}
				{//Events
					win.grid.onrowclick=function(row){
						win.link.SetSelectedKey(row.key);
						win.Hide();
						control.focus();
					}
					win.text.onkeydown=function(){
						if($.isDefined(this.timer)){ clearTimeout(this.timer); }
						this.timer=setTimeout(function(){ win.search(); }, 1000);
					}
					win.combo.onchange=function(){
						win.search();
					}
					win.cancel.onclick=function(){ win.Hide(); }
				}
				win.search=function(){
					var ajax=$.AjaxDB($.Strings.Format("SELECT Codigo, Nombre, Apellidos FROM EMPLEADOS{c} WHERE {0} LIKE '%{1}%' ORDER BY Codigo", win.combo.selectedKey, win.text.GetText()), Ajax.Dontwait);
					ajax.oncomplete=function(){
						win.grid.ClearRows();
						for(var i=0, ilen=this.json.row.length; i<ilen; i++){
							var db=this.json.row[i];
							win.grid.NewRow([db.Codigo, db.Nombre, db.Apellidos], db.Codigo);
						}
					}
				}
				control.win=win;
			}
		}
		control.onclick=function(){
			win.Show();
			win.combo.SetSelectedIndex(0);
			win.text.SetText('');
			win.search();
		}
		control.set_href=function(value){ this.win.link=value; }
		
		if($.isDefined(link)){ control.set_href(link); }
		return control;
	}
}
Jade.LoadLibrary('Objects',JadeObjects);
Jade.ControlAdd=JadeObjects.Add;