if ($member['has_voting_record']) {
	person_voting_record($member, $extra_info);
}

$member['chairmens_panel'] = false;
# Topics of interest only for current MPs at the moment
if ($member['current_member'][1]) { # in_array(1, $member['houses'])
	$member['chairmens_panel'] = person_committees_and_topics($member, $extra_info);
}

if ($member['has_recent_appearances']) {
	person_recent_appearances($member);
}

person_numerology($member, $extra_info);

if (isset($extra_info['register_member_interests_html'])) {
	person_register_interests($member, $extra_info);
}

if ($member['has_expenses']) {
	include_once INCLUDESPATH . 'easyparliament/expenses.php';
	echo '<a name="expenses"></a>';
	echo '<h2>Expenses</h2>';
	echo expenses_display_table($extra_info);
}

# Helper functions

# Gets and outputs the correct image (with special case for Lords)
# People who are or were MPs and Lords potentially have voting records, except Sinn Fein MPs
$data['has_voting_record'] = $MEMBER->house(HOUSE_TYPE_COMMONS) && $MEMBER->party() != 'SF' || $MEMBER->house(HOUSE_TYPE_LORDS);
# Everyone who is currently somewhere has email alert signup, apart from current Sinn Fein MPs who are not MLAs
$data['has_email_alerts'] = $MEMBER->current_member_anywhere() && !($MEMBER->current_member(HOUSE_TYPE_COMMONS) && $MEMBER->party() == 'SF' && !$MEMBER->current_member(HOUSE_TYPE_NI));
# XXX This is current behaviour, but should probably now just be any recent MP
$data['has_expenses'] = isset($MEMBER->extra_info['expenses2004_col1']) || isset($MEMBER->extra_info['expenses2006_col1']) || isset($MEMBER->extra_info['expenses2007_col1']) || isset($MEMBER->extra_info['expenses2008_col1']);
// Set the expenses URL if we know it
if (isset($MEMBER->extra_info['expenses_url'])) {
    $data['expenses_url_2004'] = $MEMBER->extra_info['expenses_url'];
} else {
    $data['expenses_url_2004'] = 'http://mpsallowances.parliament.uk/mpslordsandoffices/hocallowances/allowances%2Dby%2Dmp/';
}
$data['constituency_previous_mps'] = constituency_previous_mps($MEMBER);
$data['constituency_future_mps'] = constituency_future_mps($MEMBER);
$data['public_bill_committees'] = person_pbc_membership($MEMBER);
$data['numerology'] = person_numerology($MEMBER, $data['has_email_alerts']);
$data['this_page'] = $this_page;
$data['current_assembly'] = 'westminster';
if ($this_page == 'msp' || $this_page == 'yourmsp') {
    $data['current_assembly'] = 'scotland';
} else {
    if ($this_page == 'mla' || $this_page == 'yourmla') {
        $data['current_assembly'] = 'ni';
    }
}
// Do any necessary extra work based on the page type, and send for rendering.
switch ($pagetype) {
    case 'votes':
        $policiesList = new MySociety\TheyWorkForYou\Policies();
        // Generate voting segments
        $data['key_votes_segments'] = array(array('key' => 'social', 'title' => 'Social Issues', 'votes' => new MySociety\TheyWorkForYou\PolicyPositions($policiesList->limitToSet('social'), $MEMBER)), array('key' => 'foreign', 'title' => 'Foreign Policy and Defence', 'votes' => new MySociety\TheyWorkForYou\PolicyPositions($policiesList->limitToSet('foreignpolicy'), $MEMBER)), array('key' => 'welfare', 'title' => 'Welfare and Benefits', 'votes' => new MySociety\TheyWorkForYou\PolicyPositions($policiesList->limitToSet('welfare'), $MEMBER)), array('key' => 'taxation', 'title' => 'Taxation and Employment', 'votes' => new MySociety\TheyWorkForYou\PolicyPositions($policiesList->limitToSet('taxation'), $MEMBER)), array('key' => 'business', 'title' => 'Business and the Economy', 'votes' => new MySociety\TheyWorkForYou\PolicyPositions($policiesList->limitToSet('business'), $MEMBER)), array('key' => 'health', 'title' => 'Health', 'votes' => new MySociety\TheyWorkForYou\PolicyPositions($policiesList->limitToSet('health'), $MEMBER)), array('key' => 'education', 'title' => 'Education', 'votes' => new MySociety\TheyWorkForYou\PolicyPositions($policiesList->limitToSet('education'), $MEMBER)), array('key' => 'reform', 'title' => 'Constitutional Reform', 'votes' => new MySociety\TheyWorkForYou\PolicyPositions($policiesList->limitToSet('reform'), $MEMBER)), array('key' => 'home', 'title' => 'Home Affairs', 'votes' => new MySociety\TheyWorkForYou\PolicyPositions($policiesList->limitToSet('home'), $MEMBER)), array('key' => 'misc', 'title' => 'Miscellaneous Topics', 'votes' => new MySociety\TheyWorkForYou\PolicyPositions($policiesList->limitToSet('misc'), $MEMBER)));