
/* This function merely allows a button to request that an encompassing form copy elements between its inputs \
   (c)2008 DRE INC 
*/

/* input : obj
   value : the calling object
   input : list
   value : [ [ 'input'  , 'other-input'  ] ,
             [ 'input2' , 'other-input2' ] ] ;
   what  : copies input to other input for each list in list
*/
function dup_form_values( o , l )
{
    /* first find the enclosing form */
    var f = o ;
    
    while( f && f.tagName != "FORM" )
        {
            f = f.parentNode ;
        }
    
    if( ! f )
        {
            return 0 ;
        }
    
    l.each( function( e )
            {
                if( "string" == typeof e[0] )
                    {
                        f[ e[1] ].value = f[ e[0] ].value ;
                    }
                else if( "object" == typeof e[0] )
                    {
                        f[ e[1] ].value = 
                            e[0]
                            .map( function( ee )
                                  {
                                      return f[ ee ].value ;
                                  } )
                            .join(' ')
                            ;
                            
                    }
            } );
    
    return 1 ;
}

