NODE_STATE init_options(dom::element n)
    {
      //NODE_STATE n_state = NODE_MIXED;
      int n_off = 0;
      int n_on = 0;
      int n_total = 0; 
      for(int i = 0; i < int(n.children_count()); ++i)
      {
        dom::element t = n.child(i);
        NODE_STATE t_state;
        if( streq(t.get_element_type(),"options") )
          t_state = init_options(t);
        else if( streq(t.get_element_type(),"option") )
          t_state = get_state(t);
        else
          continue;
        
        set_state(t, t_state);
 
        switch( t_state )      
        {
          case NODE_OFF: ++n_off; break;
          case NODE_ON: ++n_on; break;
        }
        ++n_total; 
                 
      }
      if( n_off == n_total ) return NODE_OFF;
      if( n_on == n_total ) return NODE_ON;

      return NODE_MIXED;

    }
 /** returns current row (if any) **/
 dom::element get_current_row( dom::element& table )
 {
   for( int i = table.children_count() - 1; i >= 0 ; --i)
   {
     dom::element t = table.child((unsigned int)i);
     if( t.get_state(STATE_CURRENT))
       return t;
   }
   return dom::element(); // empty
 }