}
# Last resort, use the default defined at the start of this page
#Load and create paginator object
require_once $root_path . 'include/care_api_classes/class_paginator.php';
$pagen = new Paginator($pgx, $thisfile, $_SESSION['sess_searchkey'], $root_path);
# Adjust the max nr of rows in a block
$pagen->setMaxCount($GLOBAL_CONFIG['pagin_insurance_search_max_block_rows']);
if (isset($mode) && ($mode == 'search' || $mode == 'paginate') && !empty($searchkey)) {
    # Convert wildcards
    $searchkey = strtr($searchkey, '*?', '%_');
    # Save the search keyword for eventual pagination routines
    if ($mode == 'search') {
        $_SESSION['sess_searchkey'] = $searchkey;
    }
    # Search for the firms
    $firms = $ins_obj->searchLimitActiveFirm($searchkey, $GLOBAL_CONFIG['pagin_insurance_search_max_block_rows'], $pgx, $oitem, $odir);
    //echo $ins_obj->getLastQuery();
    # Get the resulting record count
    $linecount = $ins_obj->LastRecordCount();
    $pagen->setTotalBlockCount($linecount);
    # Count total available data
    if (isset($totalcount) && $totalcount) {
        $pagen->setTotalDataCount($totalcount);
    } else {
        $totalcount = $ins_obj->searchCountActiveFirm($searchkey);
        //echo $totalcount;
        //echo $ins_obj->getLastQuery();
        $pagen->setTotalDataCount($totalcount);
    }
    $pagen->setSortItem($oitem);
    $pagen->setSortDirection($odir);