'Return the HTML representation of this rheader
@param r: the S3Request instance to render the header for
@param tabs: the tabs (overrides the original tabs definition)
@param table: override r.table
@param record: override r.record
@param as_div: True: will return the rheader_fields and the
rheader_tabs together as a DIV
False will return the rheader_fields and the
rheader_tabs as a tuple
(rheader_fields, rheader_tabs)'

def __call__(self, r, tabs=None, table=None, record=None, as_div=True):

    if (table is None):
        table = r.table
    if (record is None):
        record = r.record
    if (tabs is None):
        tabs = self.tabs
    if ((self.fields is None) and ('name' in table.fields)):
        fields = [['name']]
    else:
        fields = self.fields
    if record:
        if (tabs is not None):
            rheader_tabs = s3_rheader_tabs(r, tabs)
        else:
            rheader_tabs = ''
        trs = []
        for row in fields:
            tr = TR()
            for col in row:
                field = None
                label = ''
                value = ''
                if (isinstance(col, (tuple, list)) and (len(col) == 2)):
                    (label, f) = col
                else:
                    f = col
                if callable(f):
                    try:
                        value = f(record)
                    except:
                        pass
                elif isinstance(f, str):
                    fn = f
                    if ('.' in fn):
                        fn = f.split('.', 1)[1]
                    if ((fn not in record) or (fn not in table)):
                        continue
                    field = table[fn]
                    value = record[fn]
                    if callable(value):
                        value = value()
                elif (isinstance(f, Field) and (f.name in record)):
                    field = f
                    value = record[f.name]
                if (field is not None):
                    if (not label):
                        label = field.label
                    if (hasattr(field, 'represent') and (field.represent is not None)):
                        value = field.represent(value)
                if (label is not None):
                    tr.append(TH(('%s:    ' % label)))
                v = value
                if ((not isinstance(v, basestring)) and (not isinstance(value, DIV))):
                    try:
                        v = unicode(v)
                    except:
                        pass
                tr.append(TD(v))
            trs.append(tr)
        if as_div:
            rheader = DIV(TABLE(trs), rheader_tabs)
        else:
            rheader = (TABLE(trs), rheader_tabs)
        return rheader
    return None
