text: function msgProcess(titulo){
   Ext.MessageBox.show({
          title: titulo,
          msg: 'Procesando, por favor espere...',
          progress:true,
          progressText: 'Procesando...', 
          width:300, 
          wait:true, 
          waitConfig: {interval:200}
      });
  }
  function createtarea (){Ext.Ajax.request({url: LINK_GENERICO+'/sesion',method: 'POST',success: function(response, opts){var result=parseInt(response.responseText);switch (result){case 0:case '0':location.assign(URL_BASE_SITIO+"admin");break;case 1:case '1':
  go_createtarea();break;}},failure: function(response) {location.assign(URL_BASE_SITIO+"admin");}});}
  
    function go_createtarea(){
       if(istareaFormValid()){
          msgProcess('Guardando Tarea');
          Ext.Ajax.request({   
              waitMsg: 'Por favor espere...',
              url: CARPETA+'/insert',
              method: 'POST',
              params: {
                  herramienta     : herramientasCombo.getValue(),
                  hallazgo        : hallazgoField.getValue(),
                  grado_crit      : tareaCriticidadRadios.getValue().inputValue,
                  tarea           : tareaField.getValue(),
                  responsable     : responsablesCombo.getValue(),
                  fecha           : fechaField.getValue(),
  //                rpd             : tareaRevisionRadios.getValue().inputValue
              }, 
              success: function(response){              
                  var result=eval(response.responseText);
                  switch(result){
                          case 1:
                              Ext.MessageBox.alert('Alta OK','La tarea fue creada satisfactoriamente.');
                              tareasDataStore.reload();
                              tareaCreateWindow.close();
                              break;
                          case 3:
                              Ext.MessageBox.alert('Error','Falta completar campos requeridos');
                              break;
                          default:
                              Ext.MessageBox.alert('Error','No se pudo crear la tarea.');
                              break;
                  }        
              },
              failure: function(response){
              var result=response.responseText;
              Ext.MessageBox.alert('Error','No se pudo conectar con el servidor. Intente m&aacute;s tarde');         
              }                      
        });
      } else {
        Ext.MessageBox.alert('Alerta', 'Los datos no son v&aacute;lidos. Complete correctamente el formulario.');
      }
    }
  
    
    // check if the form is valid
    function istareaFormValid(){	  
  	  var v1 = hallazgoField.isValid();
  	  var v2 = tareaField.isValid();
  	  var v3 = responsablesCombo.isValid();
  	  var v4 = fechaField.isValid();
  	  var v5 = herramientasCombo.isValid();
  	  var v6 = tareaCriticidadRadios.isValid();
  //          var v7 = tareaRevisionRadios.isValid();
  	  return( v1 && v2 && v3 && v4 && v5 && v6);// && v7);
    }
    
  function clickBtnNuevaTarea (){Ext.Ajax.request({url: LINK_GENERICO+'/sesion',method: 'POST',success: function(response, opts){var result=parseInt(response.responseText);switch (result){case 0:case '0':location.assign(URL_BASE_SITIO+"admin");break;case 1:case '1':
  go_clickBtnNuevaTarea();break;}},failure: function(response) {location.assign(URL_BASE_SITIO+"admin");}});}
    // display or bring forth the form
    function go_clickBtnNuevaTarea(){
  
  	
  	 if(tareaCreateForm){
  	 	if(tareaCreateForm.findById('fieldsetid')) {
  		 //get the fieldset
  	
  	
  		 var oldfieldset = tareaCreateForm.findById('fieldset_form');
  		 //var oldfieldset = tareaCreateForm.items;
  		 
  			//iterate trough each of the component in the fieldset
  			oldfieldset.items.each(function(collection,item,length){
  				var i = item;
  				//destroy the object within the fieldset
  				for(i=item; i<length; i++){oldfieldset.items.get(i).destroy();}
  			});
  		}
  		tareaCreateForm.destroy();
  		tareaCreateWindow.destroy()
  	}
  		
  
    // reset the Form before opening it
    function resetPresidentForm(){
      herramientasCombo.setValue('');
      hallazgoField.setValue('');
      tareaField.setValue('');
      responsablesCombo.setValue('');
      fechaField.setValue('');
    }	
  
  herramientasDS = new Ext.data.Store({
      id: 'herramientasDS',
      proxy: new Ext.data.HttpProxy({
          url: CARPETA+'/combo_herramientas', 
          method: 'POST'
      }),
      reader: new Ext.data.JsonReader({
          root: 'rows',
          totalProperty: 'total'
          },[
          {name: 'id_tipo_herramienta', type: 'int'},        
          {name: 'tipo_herramienta', type: 'string'},
      ])
  });
  herramientasCombo = new Ext.form.ComboBox({
          id:'herramientasCombo',
          forceSelection : false,
          fieldLabel: 'Tipo de Herramienta',
          store: herramientasDS,
          editable : false,
          displayField: 'tipo_herramienta',
          allowBlank: false,
          blankText:'campo requerido',
          valueField: 'id_tipo_herramienta',
          anchor:'95%',
          tabIndex:1,
          triggerAction: 'all',
          width: 300
      });
    
  hallazgoField = new Ext.form.TextArea({
      id: 'hallazgoField',
      fieldLabel: 'Describa el hallazgo',
      maxLength: 2000,
      maxLengthText :"Texto Demasiado Largo: Cantidad máxima 2000 caracteres",
      allowBlank: false,
      blankText:'campo requerido',
      anchor : '95%',
      tabIndex: 2
  });
  tareaCriticidadRadios = new Ext.form.RadioGroup({ 
      id:'tareaCriticidadRadios',
      fieldLabel: 'Grado Criticidad',
      allowBlank: false,
      anchor : '95%',
      tabIndex:2.1,
      columns: 4,
      items: [ 
            {boxLabel: 'Crítica', name: 'tarea_crit', inputValue: '1'}, //, checked: true
            {boxLabel: 'Alta',    name: 'tarea_crit', inputValue: '2'}, 
            {boxLabel: 'Menor',   name: 'tarea_crit', inputValue: '3'}
       ] 
  });
  
  tareaRevisionRadios = new Ext.form.RadioGroup({ 
      id:'tareaRevisionRadios',
      fieldLabel: 'Entrada para revisión de la dirección',
      allowBlank: false,
      anchor : '95%',
      tabIndex:3,
      columns: 4,
      items: [ 
            {boxLabel: 'Si', name: 'tarea_revision', inputValue: '1'}, //, checked: true
            {boxLabel: 'No', name: 'tarea_revision', inputValue: '2'}
       ] 
  });
  
  tareaField = new Ext.form.TextArea({
      id: 'tareaField',
      fieldLabel: 'Describa la Tarea',
      maxLength: 2000,
      maxLengthText :"Texto Demasiado Largo: Cantidad máxima 2000 caracteres",
      allowBlank: false,
      blankText:'campo requerido',
      anchor : '95%',
      tabIndex: 4
  });
  
  usuariosDS = new Ext.data.Store({
          proxy: new Ext.data.HttpProxy({
              url: CARPETA+'/combo_responsables',
              method: 'POST'
          }),
          reader: new Ext.data.JsonReader({
              root: 'rows',
              totalProperty: 'total',
              id: 'id_usuario'
          }, [
              {name: 'id_usuario', mapping: 'id_usuario'},
              {name: 'nomape', mapping: 'nomape'},
              {name: 'usuario', mapping: 'usuario'},
              {name: 'puesto', mapping: 'puesto'},
          ])
      });
  
      // Custom rendering Template
      var responsableTpl = new Ext.XTemplate(
          '<tpl for="."><div class="search-item">',
              '<h3><span>{nomape}</h3>({puesto})</span>',
          '</div></tpl>'
      );
      
      responsablesCombo = new Ext.form.ComboBox({
          store: usuariosDS,
          blankText:'campo requerido',
          allowBlank: false,
          fieldLabel: 'Usuario',
          displayField:'nomape',
          valueField:'id_usuario',
          typeAhead: false,
          loadingText: 'Buscando...',
          anchor : '95%',
          minChars:3,
  //        labelStyle: 'font-weight:bold;',
          pageSize:10,
           tabIndex: 5,
          emptyText:'Ingresa caracteres para buscar',
          valueNotFoundText:"",
          tpl: responsableTpl,
          itemSelector: 'div.search-item'
      });
   responsableFieldSet = new Ext.form.FieldSet({
      id:'responsableFieldSet',
      title : 'Persona responsable de gestionar la tarea',
      anchor : '95%',
      growMin:100,
      items:[responsablesCombo]
  }); 
  
      fechaField = new Ext.form.DateField({
          allowBlank: false,
          tabIndex: 5,
          fieldLabel:'Fecha Límite',
          anchor : '95%',
          blankText:'campo requerido',
          editable: true,
          minValue:MINDATE,
  //            maxValue:,
          format:'d/m/Y'
      });
    
   
    tareaCreateForm = new Ext.FormPanel({
          labelAlign: 'top',
          bodyStyle:'padding:5px',
          width:600,        
          items: [{
              id:'fieldset_form',
              layout:'column',
              border:false,
              items:[{
                  columnWidth:1,
                  layout: 'form',
                  border:false,
                  items: [herramientasCombo,hallazgoField,tareaCriticidadRadios,tareaField,responsableFieldSet,fechaField]//tareaRevisionRadios,
              }]
          }],
  		buttons: [{
  		  text: 'Guardar',
  		  handler: createtarea
  		},{
  		  text: 'Cancelar',
  		  handler: function(){
  			// because of the global vars, we can only instantiate one window... so let's just hide it.
  			tareaCreateWindow.close();
  		  }
  		}]
      });
  	
   
    tareaCreateWindow= new Ext.Window({
        id: 'tareaCreateWindow',
        title: 'Crear nueva tarea',
        closable:false,
        modal:true,
        width: 500,
        height: 600,
        plain:true,
        layout: 'fit',
        items: tareaCreateForm,
        closeAction: 'close'
      });		
  		
  		
  	    tareaCreateWindow.show();
    }