
//___________________________________________  < LIB. FORM > _________________________________________________


    function inpType( inp ) { return inp.getAttribute('type') || ''; }

    function form_vars( oF, return_array )
    {                                            if( typeof(oF) == 'string' ) oF = document.forms[oF];
        var EL = oF.elements; var VARS = Array();
        var i=0; var typ, el, inpLabel;
        var ix=0;
        while( el = EL[i])
        {
                  if( el.getAttribute('notInput') || el.getAttribute('inForm') === '0' ) { i++; continue; }
                  if( typ = el.getAttribute('type') )
                  {
                      if( typ == 'button') { i++; continue; }
                      if( typ.match(/checkbox|radio/gi) && ! el.checked ) { i++; continue; }
                  }
             if( return_array )
             {
                 inpLabel = el.name;
                 if( inpLabel.match(/\[.*\]/) ) inpLabel = inpLabel.slice( inpLabel.indexOf('[')+1, inpLabel.indexOf(']') );
             } else inpLabel = ix ;
             VARS[inpLabel] = (return_array)? el : el.name +'='+ toURL(el.value) ;
             i++;  ix++;
        }

        return (return_array) ?  VARS : VARS.join('&');

    }


    function form_init( oF )
    {                            var initF = ( oF.getAttribute('noInit') !== '1' );

       var inp_txt1 = null;

       var EL = oF.elements;  var tag, typ, att, init, el;
       var i=0;


       while(el = EL[i])
       {                  tag  = el.nodeName.toUpperCase();
                          init = ( initF && el.getAttribute('noInit') !== '1' );
                          if( init ){ init = el.getAttribute(init) || '';
                                      var func_init = str2func(init);
                                      if( func_init ){ func_init(el); i++; conitnue; }
                          } else { i++; continue; }
          
          switch( tag )
          {
             case 'TEXTAREA' : { el.value = init = '';  break; }
             case 'SELECT'   : { if(init) el.value = init; else el.selectedIndex = 0;  break; }
             case 'INPUT'    :
             {                  typ = inpType(el).toLowerCase();

                  if( typ == 'button') { i++; continue; }
                  if( typ.match(/radio|checkbox/) )
                  {
                      if( el.checked == init ) { i++; continue ; } else el.checked = (init);

                      if( typ = el.onclick ){ typ = typ.toString();
                                              typ = typ.slice( typ.indexOf('{')+1, typ.lastIndexOf('}')-1 );
                                              typ = typ.slice(0,typ.indexOf('(')).replace(/^\s+|\s+$/, ''); // <=> trim
                                              eval( typ+'(el)');
                      }
                  }
                  // INPUT text
                     el.style.MozUserSelect = 'normal';
                     el.value = init;
                  break;
             }
             
          }  // fin de : switch
          i++;
       }
       return oF;
    }

    function input_1St( el, act )
    {
             var I = el.getElementsByTagName('INPUT');
             var i=0; var inp1 = null;
             while( el = I[i] )
             {                  if( el.type == 'text' ) { inp1 = el; break; }
                   i++;
             }
             if( act && inp1 ){
                 if( act === 'focus' ){ inp1.focus();  inp1.focus();  }
                 else                 {
                                        var YX = Array( document.body.scrollTop, document.body.scrollLeft );
                                        inp1.select(); inp1.select();
                                        with( document.body ) { scrollTop = YX[0]; scrollLeft = YX[1];  }
                 }

             }
             return inp1;
    }


//___________________________________________  </ LIB. FORM > _________________________________________________

